jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r957229 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ./ session/ xml/
Date Wed, 23 Jun 2010 14:49:05 GMT
Author: jukka
Date: Wed Jun 23 14:49:04 2010
New Revision: 957229

URL: http://svn.apache.org/viewvc?rev=957229&view=rev
Log:
JCR-890: concurrent read-only access to a session

Leverage SessionContext in more places.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemSaveOperation.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemValidator.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java?rev=957229&r1=957228&r2=957229&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java
Wed Jun 23 14:49:04 2010
@@ -37,12 +37,11 @@ import javax.jcr.version.VersionExceptio
 import org.apache.jackrabbit.core.id.ItemId;
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.id.PropertyId;
-import org.apache.jackrabbit.core.lock.LockManager;
 import org.apache.jackrabbit.core.nodetype.EffectiveNodeType;
 import org.apache.jackrabbit.core.nodetype.NodeTypeConflictException;
-import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.security.AccessManager;
 import org.apache.jackrabbit.core.security.authorization.Permission;
+import org.apache.jackrabbit.core.session.SessionContext;
 import org.apache.jackrabbit.core.state.ChildNodeEntry;
 import org.apache.jackrabbit.core.state.ItemState;
 import org.apache.jackrabbit.core.state.ItemStateException;
@@ -100,15 +99,12 @@ public class BatchedItemOperations exten
      * @param hierMgr    hierarchy manager
      * @throws RepositoryException
      */
-    public BatchedItemOperations(UpdatableItemStateManager stateMgr,
-                                 NodeTypeRegistry ntReg,
-                                 LockManager lockMgr,
-                                 SessionImpl session,
-                                 HierarchyManager hierMgr) throws RepositoryException {
-        super(ntReg, hierMgr, session, lockMgr, session.getAccessManager(),
-                session.getRetentionRegistry(), session.getItemManager());
+    public BatchedItemOperations(
+            UpdatableItemStateManager stateMgr, SessionContext sessionContext)
+            throws RepositoryException {
+        super(sessionContext);
         this.stateMgr = stateMgr;
-        this.session = session;
+        this.session = sessionContext.getSessionImpl();
     }
 
     //-----------------------------------------< controlling batch operations >
@@ -326,19 +322,13 @@ public class BatchedItemOperations exten
      *                 <li><code>CLONE_REMOVE_EXISTING</code></li>
      *                 </ul>
      * @return the id of the node at its new position
-     * @throws ConstraintViolationException
-     * @throws AccessDeniedException
-     * @throws VersionException
-     * @throws PathNotFoundException
-     * @throws ItemExistsException
-     * @throws LockException
-     * @throws RepositoryException
+     * @throws RepositoryException if the copy operation fails
      */
     public NodeId copy(Path srcPath, Path destPath, int flag)
-            throws ConstraintViolationException, AccessDeniedException,
-            VersionException, PathNotFoundException, ItemExistsException,
-            LockException, RepositoryException {
-        return copy(srcPath, stateMgr, hierMgr, session.getAccessManager(), destPath, flag);
+            throws RepositoryException {
+        return copy(
+                srcPath, stateMgr, hierMgr, sessionContext.getAccessManager(),
+                destPath, flag);
     }
 
     /**
@@ -693,6 +683,7 @@ public class BatchedItemOperations exten
         // 3. access rights
 
         if ((options & CHECK_ACCESS) == CHECK_ACCESS) {
+            AccessManager accessMgr = sessionContext.getAccessManager();
             // make sure current session is granted read access on parent node
             if (!accessMgr.isGranted(parentPath, Permission.READ)) {
                 throw new ItemNotFoundException(safeGetJCRPath(parentState.getNodeId()));
@@ -713,7 +704,8 @@ public class BatchedItemOperations exten
         // 4. node type constraints
 
         if ((options & CHECK_CONSTRAINTS) == CHECK_CONSTRAINTS) {
-            QItemDefinition parentDef = itemMgr.getDefinition(parentState).unwrap();
+            QItemDefinition parentDef =
+                sessionContext.getItemManager().getDefinition(parentState).unwrap();
             // make sure parent node is not protected
             if (parentDef.isProtected()) {
                 throw new ConstraintViolationException(
@@ -744,7 +736,8 @@ public class BatchedItemOperations exten
                     log.debug(msg);
                     throw new RepositoryException(msg, ise);
                 }
-                QNodeDefinition conflictingTargetDef = itemMgr.getDefinition(conflictingState).unwrap();
+                QNodeDefinition conflictingTargetDef =
+                    sessionContext.getItemManager().getDefinition(conflictingState).unwrap();
                 // check same-name sibling setting of both target and existing node
                 if (!conflictingTargetDef.allowsSameNameSiblings()
                         || !newNodeDef.allowsSameNameSiblings()) {
@@ -867,6 +860,7 @@ public class BatchedItemOperations exten
 
         if ((options & CHECK_ACCESS) == CHECK_ACCESS) {
             try {
+                AccessManager accessMgr = sessionContext.getAccessManager();
                 // make sure current session is granted read access on parent node
                 if (!accessMgr.isGranted(targetPath, Permission.READ)) {
                     throw new PathNotFoundException(safeGetJCRPath(targetPath));
@@ -887,12 +881,14 @@ public class BatchedItemOperations exten
         // 4. node type constraints
 
         if ((options & CHECK_CONSTRAINTS) == CHECK_CONSTRAINTS) {
-            QItemDefinition parentDef = itemMgr.getDefinition(parentState).unwrap();
+            QItemDefinition parentDef =
+                sessionContext.getItemManager().getDefinition(parentState).unwrap();
             if (parentDef.isProtected()) {
                 throw new ConstraintViolationException(safeGetJCRPath(parentId)
                         + ": cannot remove child node of protected parent node");
             }
-            QItemDefinition targetDef = itemMgr.getDefinition(targetState).unwrap();
+            QItemDefinition targetDef =
+                sessionContext.getItemManager().getDefinition(targetState).unwrap();
             if (targetDef.isMandatory()) {
                 throw new ConstraintViolationException(safeGetJCRPath(targetPath)
                         + ": cannot remove mandatory node");
@@ -974,6 +970,7 @@ public class BatchedItemOperations exten
 
         // access rights
         // make sure current session is granted read access on node
+        AccessManager accessMgr = sessionContext.getAccessManager();
         if (!accessMgr.isGranted(nodePath, Permission.READ)) {
             throw new PathNotFoundException(safeGetJCRPath(node.getNodeId()));
         }
@@ -1019,6 +1016,7 @@ public class BatchedItemOperations exten
             throws PathNotFoundException, RepositoryException {
         // access rights
         // make sure current session is granted read access on node
+        AccessManager accessMgr = sessionContext.getAccessManager();
         if (!accessMgr.isGranted(nodePath, Permission.READ)) {
             throw new PathNotFoundException(safeGetJCRPath(nodePath));
         }
@@ -1427,7 +1425,7 @@ public class BatchedItemOperations exten
             throws PathNotFoundException, ConstraintViolationException,
             RepositoryException {
         NodeState node = getNodeState(nodePath);
-        if (itemMgr.getDefinition(node).isProtected()) {
+        if (sessionContext.getItemManager().getDefinition(node).isProtected()) {
             throw new ConstraintViolationException(safeGetJCRPath(nodePath)
                     + ": node is protected");
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java?rev=957229&r1=957228&r2=957229&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
Wed Jun 23 14:49:04 2010
@@ -181,7 +181,7 @@ public abstract class ItemImpl implement
      * @return the primary path to this <code>Item</code>
      */
     public Path getPrimaryPath() throws RepositoryException {
-        return session.getHierarchyManager().getPath(id);
+        return sessionContext.getHierarchyManager().getPath(id);
     }
 
     /**
@@ -383,7 +383,7 @@ public abstract class ItemImpl implement
             // shortcut
             return 0;
         }
-        return session.getHierarchyManager().getDepth(id);
+        return sessionContext.getHierarchyManager().getDepth(id);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java?rev=957229&r1=957228&r2=957229&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
Wed Jun 23 14:49:04 2010
@@ -414,12 +414,12 @@ public class ItemManager implements Dump
                 need use the path to evaluate the effective permissions.
                 */
                 return (path == null) ?
-                        session.getAccessManager().isGranted(data.getId(), AccessManager.READ)
:
-                        session.getAccessManager().isGranted(path, Permission.READ);
+                        sessionContext.getAccessManager().isGranted(data.getId(), AccessManager.READ)
:
+                        sessionContext.getAccessManager().isGranted(path, Permission.READ);
             }
         } else {
             /* item is not NEW -> save to call acMgr.canRead(Path,ItemId) */
-            return session.getAccessManager().canRead(path, data.getId());
+            return sessionContext.getAccessManager().canRead(path, data.getId());
         }
     }
 
@@ -432,16 +432,12 @@ public class ItemManager implements Dump
      */
     private boolean canRead(ItemData parent, ItemId childId) throws RepositoryException {
         if (parent.getStatus() == ItemState.STATUS_EXISTING) {
-            /*
-             child item is for sure not NEW (because then the parent was modified).
-             safe to use AccessManager#canRead(Path, ItemId).
-             */
-            return session.getAccessManager().canRead(null, childId);
+            // child item is for sure not NEW (because then the parent was modified).
+            // safe to use AccessManager#canRead(Path, ItemId).
+            return sessionContext.getAccessManager().canRead(null, childId);
         } else {
-            /*
-             child could be NEW -> don't use AccessManager#canRead(Path, ItemId)
-             */
-            return session.getAccessManager().isGranted(childId, AccessManager.READ);
+            // child could be NEW -> don't use AccessManager#canRead(Path, ItemId)
+            return sessionContext.getAccessManager().isGranted(childId, AccessManager.READ);
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemSaveOperation.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemSaveOperation.java?rev=957229&r1=957228&r2=957229&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemSaveOperation.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemSaveOperation.java
Wed Jun 23 14:49:04 2010
@@ -442,7 +442,7 @@ class ItemSaveOperation extends SessionO
         ItemManager itemMgr = context.getItemManager();
         SessionItemStateManager stateMgr = context.getItemStateManager();
 
-        AccessManager accessMgr = session.getAccessManager();
+        AccessManager accessMgr = context.getAccessManager();
         NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
         // walk through list of dirty transient items and validate each
         for (ItemState itemState : dirty) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemValidator.java?rev=957229&r1=957228&r2=957229&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemValidator.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemValidator.java
Wed Jun 23 14:49:04 2010
@@ -34,8 +34,8 @@ import org.apache.jackrabbit.core.nodety
 import org.apache.jackrabbit.core.nodetype.NodeTypeConflictException;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.retention.RetentionRegistry;
-import org.apache.jackrabbit.core.security.AccessManager;
 import org.apache.jackrabbit.core.security.authorization.Permission;
+import org.apache.jackrabbit.core.session.SessionContext;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.value.InternalValue;
@@ -105,6 +105,11 @@ public class ItemValidator {
     private static Logger log = LoggerFactory.getLogger(ItemValidator.class);
 
     /**
+     * Component context of the associated session.
+     */
+    protected final SessionContext sessionContext;
+
+    /**
      * node type registry
      */
     protected final NodeTypeRegistry ntReg;
@@ -127,52 +132,20 @@ public class ItemValidator {
      */
     protected final LockManager lockMgr;
 
-    protected final AccessManager accessMgr;
-
     protected final RetentionRegistry retentionReg;
 
-    protected final ItemManager itemMgr;
-
     /**
      * Creates a new <code>ItemValidator</code> instance.
      *
-     * @param ntReg      node type registry
-     * @param hierMgr    hierarchy manager
-     * @param session    session
-     */
-    public ItemValidator(NodeTypeRegistry ntReg,
-                         HierarchyManager hierMgr,
-                         SessionImpl session) throws RepositoryException {
-        this(ntReg, hierMgr, session, session.getLockManager(),
-                session.getAccessManager(), session.getRetentionRegistry(),
-                session.getItemManager());
-    }
-
-    /**
-     * Creates a new <code>ItemValidator</code> instance.
-     *
-     * @param ntReg      node type registry
-     * @param hierMgr    hierarchy manager
-     * @param resolver   resolver
-     * @param lockMgr    lockMgr
-     * @param accessMgr  accessMgr
-     * @param retentionReg
-     * @param itemMgr    the item manager
-     */
-    public ItemValidator(NodeTypeRegistry ntReg,
-                         HierarchyManager hierMgr,
-                         PathResolver resolver,
-                         LockManager lockMgr,
-                         AccessManager accessMgr,
-                         RetentionRegistry retentionReg,
-                         ItemManager itemMgr) {
-        this.ntReg = ntReg;
-        this.hierMgr = hierMgr;
-        this.resolver = resolver;
-        this.lockMgr = lockMgr;
-        this.accessMgr = accessMgr;
-        this.retentionReg = retentionReg;
-        this.itemMgr = itemMgr;
+     * @param sessionContext component context of this session
+     */
+    public ItemValidator(SessionContext sessionContext) throws RepositoryException {
+        this.sessionContext = sessionContext;
+        this.ntReg = sessionContext.getRepositoryContext().getNodeTypeRegistry();
+        this.hierMgr = sessionContext.getHierarchyManager();
+        this.resolver = sessionContext.getSessionImpl();
+        this.lockMgr = sessionContext.getSessionImpl().getLockManager();
+        this.retentionReg = sessionContext.getSessionImpl().getRetentionRegistry();
     }
 
     /**
@@ -198,7 +171,8 @@ public class ItemValidator {
                 ntReg.getEffectiveNodeType(nodeState.getNodeTypeName());
         // effective node type (primary type incl. mixins)
         EffectiveNodeType entPrimaryAndMixins = getEffectiveNodeType(nodeState);
-        QNodeDefinition def = itemMgr.getDefinition(nodeState).unwrap();
+        QNodeDefinition def =
+            sessionContext.getItemManager().getDefinition(nodeState).unwrap();
 
         // check if primary type satisfies the 'required node types' constraint
         for (Name requiredPrimaryType : def.getRequiredPrimaryTypes()) {
@@ -249,7 +223,8 @@ public class ItemValidator {
      */
     public void validate(PropertyState propState)
             throws ConstraintViolationException, RepositoryException {
-        QPropertyDefinition def = itemMgr.getDefinition(propState).unwrap();
+        QPropertyDefinition def =
+            sessionContext.getItemManager().getDefinition(propState).unwrap();
         InternalValue[] values = propState.getValues();
         int type = PropertyType.UNDEFINED;
         for (InternalValue value : values) {
@@ -312,7 +287,7 @@ public class ItemValidator {
 
         if (permissions > Permission.NONE) {
             Path path = item.getPrimaryPath();
-            accessMgr.checkPermission(path, permissions);
+            sessionContext.getAccessManager().checkPermission(path, permissions);
         }
         if ((options & CHECK_HOLD) == CHECK_HOLD) {
             if (hasHold(item, isRemoval)) {
@@ -361,7 +336,7 @@ public class ItemValidator {
         }
         if (permissions > Permission.NONE) {
             Path path = item.getPrimaryPath();
-            if (!accessMgr.isGranted(path, permissions)) {
+            if (!sessionContext.getAccessManager().isGranted(path, permissions)) {
                 return false;
             }
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=957229&r1=957228&r2=957229&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
Wed Jun 23 14:49:04 2010
@@ -207,7 +207,7 @@ public class NodeImpl extends ItemImpl i
              */
             Path p = PathFactoryImpl.getInstance().create(
                     getPrimaryPath(), session.getQPath(relPath), true);
-            return session.getHierarchyManager().resolvePropertyPath(p);
+            return sessionContext.getHierarchyManager().resolvePropertyPath(p);
         } catch (NameException e) {
             String msg = "failed to resolve path " + relPath + " relative to " + this;
             log.debug(msg);
@@ -289,7 +289,7 @@ public class NodeImpl extends ItemImpl i
          * build and resolve absolute path
          */
         p = PathFactoryImpl.getInstance().create(getPrimaryPath(), p, true);
-        return session.getHierarchyManager().resolveNodePath(p);
+        return sessionContext.getHierarchyManager().resolveNodePath(p);
     }
 
     /**
@@ -1495,7 +1495,7 @@ public class NodeImpl extends ItemImpl i
             } else {
                 // adding a node with explicit specifying the node type name
                 // requires the editing session to have nt_management privilege.
-                session.getAccessManager().checkPermission(
+                sessionContext.getAccessManager().checkPermission(
                         nodePath, Permission.NODE_TYPE_MNGMT);
             }
         }
@@ -1622,7 +1622,7 @@ public class NodeImpl extends ItemImpl i
      * @see ItemImpl#getQName()
      */
     public Name getQName() throws RepositoryException {
-        HierarchyManager hierMgr = session.getHierarchyManager();
+        HierarchyManager hierMgr = sessionContext.getHierarchyManager();
         Name name;
 
         if (!isShareable()) {
@@ -1717,7 +1717,7 @@ public class NodeImpl extends ItemImpl i
         i.e. treating reorder similar to a move.
         TODO: properly deal with sns in which case the index would change upon reorder.
         */
-        AccessManager acMgr = session.getAccessManager();
+        AccessManager acMgr = sessionContext.getAccessManager();
         PathBuilder pb = new PathBuilder(getPrimaryPath());
         pb.addLast(srcName.getName(), srcName.getIndex());
         Path childPath = pb.getPath();
@@ -1953,9 +1953,8 @@ public class NodeImpl extends ItemImpl i
             return "";
         }
 
-        HierarchyManager hierMgr = session.getHierarchyManager();
         Name name;
-
+        HierarchyManager hierMgr = sessionContext.getHierarchyManager();
         if (!isShareable()) {
             name = hierMgr.getName(id);
         } else {
@@ -3059,7 +3058,7 @@ public class NodeImpl extends ItemImpl i
 
         // detect share cycle
         NodeId srcId = getNodeId();
-        HierarchyManager hierMgr = session.getHierarchyManager();
+        HierarchyManager hierMgr = sessionContext.getHierarchyManager();
         if (parentId.equals(srcId) || hierMgr.isAncestor(srcId, parentId)) {
             String msg = "This would create a share cycle.";
             log.debug(msg);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java?rev=957229&r1=957228&r2=957229&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
Wed Jun 23 14:49:04 2010
@@ -161,11 +161,6 @@ public class SessionImpl extends Abstrac
     protected final NodeTypeManagerImpl ntMgr;
 
     /**
-     * the AccessManager associated with this session
-     */
-    protected AccessManager accessMgr;
-
-    /**
      * the Workspace associated with this session
      */
     protected final WorkspaceImpl wsp;
@@ -270,7 +265,7 @@ public class SessionImpl extends Abstrac
         wsp = createWorkspaceInstance(wspConfig);
         context.setItemStateManager(createSessionItemStateManager());
         context.setItemManager(createItemManager());
-        accessMgr = createAccessManager(subject);
+        context.setAccessManager(createAccessManager(subject));
         versionMgr = createVersionManager();
         ntInstanceHandler = new NodeTypeInstanceHandler(userId);
     }
@@ -309,7 +304,7 @@ public class SessionImpl extends Abstrac
      */
     protected WorkspaceImpl createWorkspaceInstance(WorkspaceConfig wspConfig)
             throws RepositoryException {
-        return new WorkspaceImpl(wspConfig, repositoryContext, this);
+        return new WorkspaceImpl(wspConfig, context);
     }
 
     /**
@@ -378,9 +373,7 @@ public class SessionImpl extends Abstrac
      */
     public synchronized ItemValidator getValidator() throws RepositoryException {
         if (validator == null) {
-            validator = new ItemValidator(
-                    repositoryContext.getNodeTypeRegistry(),
-                    getHierarchyManager(), this);
+            validator = new ItemValidator(context);
         }
         return validator;
     }
@@ -427,7 +420,7 @@ public class SessionImpl extends Abstrac
      * @return the <code>AccessManager</code> associated with this session
      */
     public AccessManager getAccessManager() {
-        return accessMgr;
+        return context.getAccessManager();
     }
 
     /**
@@ -535,7 +528,7 @@ public class SessionImpl extends Abstrac
         List<String> names = new ArrayList<String>();
         for (String name : repositoryContext.getWorkspaceManager().getWorkspaceNames()) {
             try {
-                if (getAccessManager().canAccess(name)) {
+                if (context.getAccessManager().canAccess(name)) {
                     names.add(name);
                 }
             } catch (NoSuchWorkspaceException e) {
@@ -698,7 +691,7 @@ public class SessionImpl extends Abstrac
      */
     public Path getPath(String identifier) throws MalformedPathException {
         try {
-            return getHierarchyManager().getPath(NodeId.valueOf(identifier));
+            return context.getHierarchyManager().getPath(NodeId.valueOf(identifier));
         } catch (RepositoryException e) {
             throw new MalformedPathException("Identifier '" + identifier + "' cannot be resolved.");
         }
@@ -1031,7 +1024,7 @@ public class SessionImpl extends Abstrac
         }
 
         // check permissions
-        AccessManager acMgr = getAccessManager();
+        AccessManager acMgr = context.getAccessManager();
         if (!(acMgr.isGranted(srcPath, Permission.REMOVE_NODE) &&
                 acMgr.isGranted(destPath, Permission.ADD_NODE | Permission.NODE_TYPE_MNGMT)))
{
             String msg = "Not allowed to move node " + srcAbsPath + " to " + destAbsPath;
@@ -1179,7 +1172,7 @@ public class SessionImpl extends Abstrac
         }
 
         try {
-            accessMgr.close();
+            context.getAccessManager().close();
         } catch (Exception e) {
             log.warn("error while closing AccessManager", e);
         }
@@ -1479,7 +1472,7 @@ public class SessionImpl extends Abstrac
             throw new IllegalArgumentException("Unknown actions: " + s);
         }
         try {
-            return getAccessManager().isGranted(path, permissions);
+            return context.getAccessManager().isGranted(path, permissions);
         } catch (AccessDeniedException e) {
             return false;
         }
@@ -1557,10 +1550,12 @@ public class SessionImpl extends Abstrac
      */
     public AccessControlManager getAccessControlManager()
             throws UnsupportedRepositoryOperationException, RepositoryException {
+        AccessManager accessMgr = context.getAccessManager();
         if (accessMgr instanceof AccessControlManager) {
             return (AccessControlManager) accessMgr;
         } else {
-            throw new UnsupportedRepositoryOperationException("Access control discovery is
not supported.");
+            throw new UnsupportedRepositoryOperationException(
+                    "Access control discovery is not supported.");
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java?rev=957229&r1=957228&r2=957229&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
Wed Jun 23 14:49:04 2010
@@ -48,6 +48,7 @@ import org.apache.jackrabbit.core.observ
 import org.apache.jackrabbit.core.observation.ObservationManagerImpl;
 import org.apache.jackrabbit.core.query.QueryManagerImpl;
 import org.apache.jackrabbit.core.retention.RetentionRegistry;
+import org.apache.jackrabbit.core.session.SessionContext;
 import org.apache.jackrabbit.core.state.LocalItemStateManager;
 import org.apache.jackrabbit.core.state.SharedItemStateManager;
 import org.apache.jackrabbit.core.xml.ImportHandler;
@@ -80,6 +81,11 @@ public class WorkspaceImpl extends Abstr
     protected final RepositoryContext repositoryContext;
 
     /**
+     * The component context of this session.
+     */
+    protected final SessionContext sessionContext;
+
+    /**
      * The persistent state mgr associated with the workspace represented by <i>this</i>
      * <code>Workspace</code> instance.
      */
@@ -133,20 +139,19 @@ public class WorkspaceImpl extends Abstr
      * Protected constructor.
      *
      * @param wspConfig The workspace configuration
-     * @param stateMgr  The shared item state manager
-     * @param rep       The repository
-     * @param session   The session
+     * @param sessionContext component context of this session
      */
     protected WorkspaceImpl(
-            WorkspaceConfig wspConfig, RepositoryContext repositoryContext,
-            SessionImpl session) throws RepositoryException {
+            WorkspaceConfig wspConfig, SessionContext sessionContext)
+            throws RepositoryException {
         this.wspConfig = wspConfig;
-        this.repositoryContext = repositoryContext;
+        this.sessionContext = sessionContext;
+        this.repositoryContext = sessionContext.getRepositoryContext();
         this.stateMgr = createItemStateManager();
         this.hierMgr = new CachingHierarchyManager(
                 repositoryContext.getRootNodeId(), this.stateMgr);
         this.stateMgr.addListener(hierMgr);
-        this.session = session;
+        this.session = sessionContext.getSessionImpl();
     }
 
     /**
@@ -390,9 +395,8 @@ public class WorkspaceImpl extends Abstr
             throw new RepositoryException("not an absolute path: " + destAbsPath);
         }
 
-        BatchedItemOperations ops = new BatchedItemOperations(
-                stateMgr, repositoryContext.getNodeTypeRegistry(),
-                session.getLockManager(), session, hierMgr);
+        BatchedItemOperations ops =
+            new BatchedItemOperations(stateMgr, sessionContext);
 
         try {
             ops.edit();
@@ -407,7 +411,7 @@ public class WorkspaceImpl extends Abstr
         try {
             NodeId id = ops.copy(srcPath, srcWsp.getItemStateManager(),
                     srcWsp.getHierarchyManager(),
-                    ((SessionImpl) srcWsp.getSession()).getAccessManager(),
+                    srcWsp.sessionContext.getAccessManager(),
                     destPath, flag);
             ops.update();
             succeeded = true;
@@ -466,9 +470,8 @@ public class WorkspaceImpl extends Abstr
             throw new RepositoryException("not an absolute path: " + destAbsPath);
         }
 
-        BatchedItemOperations ops = new BatchedItemOperations(
-                stateMgr, repositoryContext.getNodeTypeRegistry(),
-                session.getLockManager(), session, hierMgr);
+        BatchedItemOperations ops =
+            new BatchedItemOperations(stateMgr, sessionContext);
 
         try {
             ops.edit();
@@ -590,7 +593,7 @@ public class WorkspaceImpl extends Abstr
         }
 
         // check authorization for specified workspace
-        if (!session.getAccessManager().canAccess(srcWorkspace)) {
+        if (!sessionContext.getAccessManager().canAccess(srcWorkspace)) {
             throw new AccessDeniedException("not authorized to access " + srcWorkspace);
         }
 
@@ -652,7 +655,7 @@ public class WorkspaceImpl extends Abstr
         }
 
         // check authorization for specified workspace
-        if (!session.getAccessManager().canAccess(srcWorkspace)) {
+        if (!sessionContext.getAccessManager().canAccess(srcWorkspace)) {
             throw new AccessDeniedException("not authorized to access " + srcWorkspace);
         }
 
@@ -713,9 +716,8 @@ public class WorkspaceImpl extends Abstr
             throw new RepositoryException("not an absolute path: " + destAbsPath);
         }
 
-        BatchedItemOperations ops = new BatchedItemOperations(
-                stateMgr, repositoryContext.getNodeTypeRegistry(),
-                session.getLockManager(), session, hierMgr);
+        BatchedItemOperations ops =
+            new BatchedItemOperations(stateMgr, sessionContext);
 
         try {
             ops.edit();
@@ -843,8 +845,7 @@ public class WorkspaceImpl extends Abstr
         }
 
         Importer importer = new WorkspaceImporter(
-                parentPath, this,
-                repositoryContext.getNodeTypeRegistry(),
+                parentPath, this, sessionContext,
                 uuidBehavior, wspConfig.getImportConfig());
         return new ImportHandler(importer, session);
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java?rev=957229&r1=957228&r2=957229&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
Wed Jun 23 14:49:04 2010
@@ -160,7 +160,7 @@ public class XASessionImpl extends Sessi
     @Override
     protected WorkspaceImpl createWorkspaceInstance(WorkspaceConfig wspConfig)
             throws RepositoryException {
-        return new XAWorkspace(wspConfig, repositoryContext, this);
+        return new XAWorkspace(wspConfig, context);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java?rev=957229&r1=957228&r2=957229&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java
Wed Jun 23 14:49:04 2010
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.core;
 import javax.jcr.RepositoryException;
 
 import org.apache.jackrabbit.core.config.WorkspaceConfig;
+import org.apache.jackrabbit.core.session.SessionContext;
 import org.apache.jackrabbit.core.state.LocalItemStateManager;
 import org.apache.jackrabbit.core.state.XAItemStateManager;
 
@@ -31,13 +32,12 @@ public class XAWorkspace extends Workspa
      * Protected constructor.
      *
      * @param wspConfig The workspace configuration
-     * @param repositoryContext repository context
-     * @param session   The session
+     * @param sessionContext component context of this session
      */
     protected XAWorkspace(
-            WorkspaceConfig wspConfig, RepositoryContext repositoryContext,
-            SessionImpl session) throws RepositoryException {
-        super(wspConfig, repositoryContext, session);
+            WorkspaceConfig wspConfig, SessionContext sessionContext)
+            throws RepositoryException {
+        super(wspConfig, sessionContext);
     }
 
     @Override

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java?rev=957229&r1=957228&r2=957229&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java
Wed Jun 23 14:49:04 2010
@@ -22,6 +22,7 @@ import org.apache.jackrabbit.core.Reposi
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.security.AccessManager;
 import org.apache.jackrabbit.core.state.SessionItemStateManager;
 
 public class SessionContext {
@@ -33,15 +34,19 @@ public class SessionContext {
     private volatile SessionState state;
 
     /**
-     * The item state manager associated with this session
+     * The item state manager of this session
      */
     private volatile SessionItemStateManager itemStateManager;
 
     /**
-     * The item manager associated with this session
+     * The item manager of this session
      */
     private volatile ItemManager itemManager;
 
+    /**
+     * The access manager of this session
+     */
+    private volatile AccessManager accessManager;
 
     public SessionContext(
             RepositoryContext repositoryContext, SessionImpl session) {
@@ -111,4 +116,14 @@ public class SessionContext {
         this.itemManager = itemManager;
     }
 
+    public AccessManager getAccessManager() {
+        assert accessManager != null;
+        return accessManager;
+    }
+
+    public void setAccessManager(AccessManager accessManager) {
+        assert accessManager != null;
+        this.accessManager = accessManager;
+    }
+
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java?rev=957229&r1=957228&r2=957229&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
Wed Jun 23 14:49:04 2010
@@ -39,7 +39,7 @@ import org.apache.jackrabbit.core.config
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.nodetype.EffectiveNodeType;
-import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
+import org.apache.jackrabbit.core.session.SessionContext;
 import org.apache.jackrabbit.core.state.ChildNodeEntry;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
@@ -103,11 +103,11 @@ public class WorkspaceImporter implement
      */
     public WorkspaceImporter(Path parentPath,
                              WorkspaceImpl wsp,
-                             NodeTypeRegistry ntReg,
+                             SessionContext sessionContext,
                              int uuidBehavior)
             throws PathNotFoundException, ConstraintViolationException,
             VersionException, LockException, RepositoryException {
-        this(parentPath, wsp, ntReg, uuidBehavior, null);
+        this(parentPath, wsp, sessionContext, uuidBehavior, null);
     }
 
     /**
@@ -131,21 +131,18 @@ public class WorkspaceImporter implement
      *                                      the subtree
      * @throws RepositoryException          if another error occurs
      */
-    public WorkspaceImporter(Path parentPath,
-                             WorkspaceImpl wsp,
-                             NodeTypeRegistry ntReg,
-                             int uuidBehavior,
-                             ImportConfig config)
+    public WorkspaceImporter(
+            Path parentPath, WorkspaceImpl wsp, SessionContext sessionContext,
+            int uuidBehavior, ImportConfig config)
             throws PathNotFoundException, ConstraintViolationException,
             VersionException, LockException, RepositoryException {
         this.wsp = wsp;
-        this.session = (SessionImpl) wsp.getSession();
+        this.session = sessionContext.getSessionImpl();
         this.versionManager = session.getInternalVersionManager();
         this.uuidBehavior = uuidBehavior;
 
         itemOps = new BatchedItemOperations(
-                wsp.getItemStateManager(), ntReg, session.getLockManager(),
-                session, wsp.getHierarchyManager());
+                wsp.getItemStateManager(), sessionContext);
         hierMgr = wsp.getHierarchyManager();
 
         // perform preliminary checks



Mime
View raw message