jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1513063 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: ItemImpl.java NodeImpl.java PropertyImpl.java SessionContext.java WorkspaceImpl.java version/VersionManagerImpl.java xml/ImporterImpl.java
Date Mon, 12 Aug 2013 07:29:25 GMT
Author: jukka
Date: Mon Aug 12 07:29:24 2013
New Revision: 1513063

URL: http://svn.apache.org/r1513063
Log:
OAK-953: Allow sub-classing of SessionImpl

Reduce the number of extra utility methods to simplify dependency tracking

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImporterImpl.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java?rev=1513063&r1=1513062&r2=1513063&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
Mon Aug 12 07:29:24 2013
@@ -41,7 +41,6 @@ import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.ItemDefinition;
-import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.version.VersionManager;
 
 import org.apache.jackrabbit.oak.api.PropertyState;
@@ -53,8 +52,7 @@ import org.apache.jackrabbit.oak.jcr.del
 import org.apache.jackrabbit.oak.jcr.operation.ItemOperation;
 import org.apache.jackrabbit.oak.jcr.operation.SessionOperation;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryPropertyBuilder;
-import org.apache.jackrabbit.oak.plugins.nodetype.DefinitionProvider;
-import org.apache.jackrabbit.oak.plugins.nodetype.EffectiveNodeTypeProvider;
+import org.apache.jackrabbit.oak.plugins.nodetype.write.ReadWriteNodeTypeManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -149,9 +147,8 @@ abstract class ItemImpl<T extends ItemDe
         }));
     }
 
-    @Override
-    @Nonnull
-    public Session getSession() throws RepositoryException {
+    @Override @Nonnull
+    public Session getSession() {
         return sessionContext.getSession();
     }
 
@@ -301,23 +298,13 @@ abstract class ItemImpl<T extends ItemDe
     }
 
     @Nonnull
-    NodeTypeManager getNodeTypeManager() {
-        return sessionContext.getNodeTypeManager();
-    }
-
-    @Nonnull
-    DefinitionProvider getDefinitionProvider() {
-        return sessionContext.getDefinitionProvider();
-    }
-
-    @Nonnull
-    EffectiveNodeTypeProvider getEffectiveNodeTypeProvider() {
-        return sessionContext.getEffectiveNodeTypeProvider();
+    ReadWriteNodeTypeManager getNodeTypeManager() {
+        return sessionContext.getWorkspace().getNodeTypeManager();
     }
 
     @Nonnull
     VersionManager getVersionManager() throws RepositoryException {
-        return sessionContext.getVersionManager();
+        return sessionContext.getWorkspace().getVersionManager();
     }
 
     protected PropertyState createSingleState(

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1513063&r1=1513062&r2=1513063&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Mon Aug 12 07:29:24 2013
@@ -40,7 +40,6 @@ import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.Value;
-import javax.jcr.Workspace;
 import javax.jcr.lock.Lock;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NodeDefinition;
@@ -86,6 +85,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Arrays.asList;
 import static java.util.Collections.singleton;
 import static javax.jcr.Property.JCR_LOCK_IS_DEEP;
 import static javax.jcr.Property.JCR_LOCK_OWNER;
@@ -874,8 +874,7 @@ public class NodeImpl<T extends NodeDele
         return perform(new NodeOperation<Boolean>(dlg) {
             @Override
             public Boolean perform() throws RepositoryException {
-                return getEffectiveNodeTypeProvider().isNodeType(
-                        node.getTree(), oakName);
+                return getNodeTypeManager().isNodeType(node.getTree(), oakName);
             }
         });
     }
@@ -949,7 +948,7 @@ public class NodeImpl<T extends NodeDele
                 return sessionContext.getAccessManager().hasPermissions(
                     node.getTree(), prop, Permissions.NODE_TYPE_MANAGEMENT)
                         && !node.isProtected()
-                        && sessionContext.getVersionManager().isCheckedOut(toJcrPath(dlg.getPath()))
// TODO: avoid nested calls
+                        && getVersionManager().isCheckedOut(toJcrPath(dlg.getPath()))
// TODO: avoid nested calls
                         && node.canAddMixin(oakTypeName);
             }
         });
@@ -963,9 +962,9 @@ public class NodeImpl<T extends NodeDele
             public NodeDefinition perform() throws RepositoryException {
                 NodeDelegate parent = node.getParent();
                 if (parent == null) {
-                    return getDefinitionProvider().getRootDefinition();
+                    return getNodeTypeManager().getRootDefinition();
                 } else {
-                    return getDefinitionProvider().getDefinition(
+                    return getNodeTypeManager().getDefinition(
                             parent.getTree(), node.getTree());
                 }
             }
@@ -1261,7 +1260,7 @@ public class NodeImpl<T extends NodeDele
     //------------------------------------------------------------< internal >---
 
     private EffectiveNodeType getEffectiveNodeType() throws RepositoryException {
-        return getEffectiveNodeTypeProvider().getEffectiveNodeType(dlg.getTree());
+        return getNodeTypeManager().getEffectiveNodeType(dlg.getTree());
     }
 
     private Iterator<Node> nodeIterator(Iterator<NodeDelegate> childNodes) {
@@ -1286,14 +1285,14 @@ public class NodeImpl<T extends NodeDele
                 });
     }
 
-    private void checkValidWorkspace(String workspaceName) throws RepositoryException {
-        Workspace workspace = sessionContext.getWorkspace();
-        for (String wn : workspace.getAccessibleWorkspaceNames()) {
-            if (wn.equals(workspaceName)) {
-                return;
-            }
+    private void checkValidWorkspace(String workspaceName)
+            throws RepositoryException {
+        String[] workspaceNames =
+                getSession().getWorkspace().getAccessibleWorkspaceNames();
+        if (!asList(workspaceNames).contains(workspaceName)) {
+            throw new NoSuchWorkspaceException(
+                    "Workspace " + workspaceName + " does not exist");
         }
-        throw new NoSuchWorkspaceException(workspaceName + " does not exist.");
     }
 
     private void internalSetPrimaryType(final String nodeTypeName) throws RepositoryException
{

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java?rev=1513063&r1=1513062&r2=1513063&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
Mon Aug 12 07:29:24 2013
@@ -386,7 +386,7 @@ public class PropertyImpl extends ItemIm
         return perform(new PropertyOperation<PropertyDefinition>(dlg) {
             @Override
             public PropertyDefinition perform() throws RepositoryException {
-                return getDefinitionProvider().getDefinition(
+                return getNodeTypeManager().getDefinition(
                         property.getParent().getTree(),
                         property.getPropertyState(), true);
             }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java?rev=1513063&r1=1513062&r2=1513063&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
Mon Aug 12 07:29:24 2013
@@ -33,11 +33,8 @@ import javax.jcr.Session;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.ValueFactory;
 import javax.jcr.Workspace;
-import javax.jcr.lock.LockManager;
-import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.observation.ObservationManager;
 import javax.jcr.security.AccessControlManager;
-import javax.jcr.version.VersionManager;
 
 import org.apache.jackrabbit.api.security.authorization.PrivilegeManager;
 import org.apache.jackrabbit.api.security.principal.PrincipalManager;
@@ -56,8 +53,6 @@ import org.apache.jackrabbit.oak.namepat
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.namepath.NamePathMapperImpl;
 import org.apache.jackrabbit.oak.plugins.name.Namespaces;
-import org.apache.jackrabbit.oak.plugins.nodetype.DefinitionProvider;
-import org.apache.jackrabbit.oak.plugins.nodetype.EffectiveNodeTypeProvider;
 import org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager;
 import org.apache.jackrabbit.oak.plugins.observation.Observable;
 import org.apache.jackrabbit.oak.plugins.value.ValueFactoryImpl;
@@ -164,26 +159,6 @@ public class SessionContext implements N
         return new WorkspaceImpl(this);
     }
 
-    public LockManager getLockManager() {
-        return getWorkspace().getLockManager();
-    }
-
-    public NodeTypeManager getNodeTypeManager() {
-        return getWorkspace().getNodeTypeManager();
-    }
-
-    public VersionManager getVersionManager() throws RepositoryException {
-        return getWorkspace().getVersionManager();
-    }
-
-    public EffectiveNodeTypeProvider getEffectiveNodeTypeProvider() {
-        return getWorkspace().getReadWriteNodeTypeManager();
-    }
-
-    public DefinitionProvider getDefinitionProvider() {
-        return getWorkspace().getReadWriteNodeTypeManager();
-    }
-
     @Nonnull
     public Repository getRepository() {
         return repository;

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java?rev=1513063&r1=1513062&r2=1513063&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
Mon Aug 12 07:29:24 2013
@@ -27,7 +27,6 @@ import javax.jcr.Session;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.ValueFactory;
 import javax.jcr.lock.LockManager;
-import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.observation.ObservationManager;
 import javax.jcr.query.QueryManager;
 import javax.jcr.version.Version;
@@ -214,7 +213,7 @@ public class WorkspaceImpl implements Ja
     }
 
     @Override
-    public NodeTypeManager getNodeTypeManager() {
+    public ReadWriteNodeTypeManager getNodeTypeManager() {
         return nodeTypeManager;
     }
 
@@ -317,12 +316,6 @@ public class WorkspaceImpl implements Ja
         return sessionContext.getPrivilegeManager();
     }
 
-    //-----------------------------------------------------------< internal >---
-
-    ReadWriteNodeTypeManager getReadWriteNodeTypeManager() {
-        return nodeTypeManager;
-    }
-
     //------------------------------------------------------------< private >---
 
     private void ensureIsAlive() throws RepositoryException {

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java?rev=1513063&r1=1513062&r2=1513063&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java
Mon Aug 12 07:29:24 2013
@@ -31,7 +31,6 @@ import javax.jcr.Property;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.lock.LockException;
-import javax.jcr.lock.LockManager;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.util.TraversingItemVisitor;
 import javax.jcr.version.Version;
@@ -324,11 +323,6 @@ public class VersionManagerImpl implemen
         return v;
     }
 
-    @Nonnull
-    private LockManager getLockManager() {
-        return sessionContext.getLockManager();
-    }
-
     @Override
     public void checkout(final String absPath) throws RepositoryException {
         final SessionDelegate sessionDelegate = sessionContext.getSessionDelegate();
@@ -381,7 +375,8 @@ public class VersionManagerImpl implemen
     }
 
     private void checkNotLocked(String absPath) throws RepositoryException {
-        if (getLockManager().isLocked(absPath)) {
+        // TODO: avoid nested calls
+        if (sessionContext.getWorkspace().getLockManager().isLocked(absPath)) {
             throw new LockException("Node at " + absPath + " is locked");
         }
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImporterImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImporterImpl.java?rev=1513063&r1=1513062&r2=1513063&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImporterImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImporterImpl.java
Mon Aug 12 07:29:24 2013
@@ -130,18 +130,18 @@ public class ImporterImpl implements Imp
         }
 
         // TODO: review usage of write-root and object obtained from session-context (OAK-931)
-        VersionManager vMgr = sessionContext.getVersionManager();
+        VersionManager vMgr = sessionContext.getWorkspace().getVersionManager();
         if (!vMgr.isCheckedOut(absPath)) {
             throw new VersionException("Target node is checked in.");
         }
-        if (sessionContext.getLockManager().isLocked(absPath)) {
+        if (sessionContext.getWorkspace().getLockManager().isLocked(absPath)) {
             throw new LockException("Target node is locked.");
         }
         ntTypesRoot = root.getTree(NODE_TYPES_PATH);
         accessManager = sessionContext.getAccessManager();
         idManager = new IdentifierManager(root);
-        effectiveNodeTypeProvider = sessionContext.getEffectiveNodeTypeProvider();
-        definitionProvider = sessionContext.getDefinitionProvider();
+        effectiveNodeTypeProvider = sessionContext.getWorkspace().getNodeTypeManager();
+        definitionProvider = sessionContext.getWorkspace().getNodeTypeManager();
         // TODO: end
 
         refTracker = new ReferenceChangeTracker();



Mime
View raw message