jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r985218 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ./ lock/ version/
Date Fri, 13 Aug 2010 14:48:41 GMT
Author: jukka
Date: Fri Aug 13 14:48:40 2010
New Revision: 985218

URL: http://svn.apache.org/viewvc?rev=985218&view=rev
Log:
JCR-2714: Selective disabling of checks in ItemValidator

Remove the public SessionImpl.getValidator() method to prevent client code from using the
ItemValidator.performRelaxed() method.

Renamed s/sessionContext/context/ in a few cases where there's no ambiguity

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/AddMixinOperation.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.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/PropertyImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RemoveMixinOperation.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/VersionManagerImpl.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/lock/SessionLockManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplBase.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplConfig.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplMerge.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/AddMixinOperation.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/AddMixinOperation.java?rev=985218&r1=985217&r2=985218&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/AddMixinOperation.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/AddMixinOperation.java
Fri Aug 13 14:48:40 2010
@@ -67,7 +67,7 @@ class AddMixinOperation implements Sessi
                 || MIX_SIMPLE_VERSIONABLE.equals(mixinName)) {
             permissions |= Permission.VERSION_MNGMT;
         }
-        context.getSessionImpl().getValidator().checkModify(
+        context.getItemValidator().checkModify(
                 node,
                 CHECK_LOCK | CHECK_CHECKED_OUT | CHECK_CONSTRAINTS | CHECK_HOLD,
                 permissions);

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=985218&r1=985217&r2=985218&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
Fri Aug 13 14:48:40 2010
@@ -331,7 +331,7 @@ public class BatchedItemOperations exten
     public NodeId copy(Path srcPath, Path destPath, int flag)
             throws RepositoryException {
         return copy(
-                srcPath, stateMgr, hierMgr, sessionContext.getAccessManager(),
+                srcPath, stateMgr, hierMgr, context.getAccessManager(),
                 destPath, flag);
     }
 
@@ -687,7 +687,7 @@ public class BatchedItemOperations exten
         // 3. access rights
 
         if ((options & CHECK_ACCESS) == CHECK_ACCESS) {
-            AccessManager accessMgr = sessionContext.getAccessManager();
+            AccessManager accessMgr = context.getAccessManager();
             // make sure current session is granted read access on parent node
             if (!accessMgr.isGranted(parentPath, Permission.READ)) {
                 throw new ItemNotFoundException(safeGetJCRPath(parentState.getNodeId()));
@@ -709,7 +709,7 @@ public class BatchedItemOperations exten
 
         if ((options & CHECK_CONSTRAINTS) == CHECK_CONSTRAINTS) {
             QItemDefinition parentDef =
-                sessionContext.getItemManager().getDefinition(parentState).unwrap();
+                context.getItemManager().getDefinition(parentState).unwrap();
             // make sure parent node is not protected
             if (parentDef.isProtected()) {
                 throw new ConstraintViolationException(
@@ -741,7 +741,7 @@ public class BatchedItemOperations exten
                     throw new RepositoryException(msg, ise);
                 }
                 QNodeDefinition conflictingTargetDef =
-                    sessionContext.getItemManager().getDefinition(conflictingState).unwrap();
+                    context.getItemManager().getDefinition(conflictingState).unwrap();
                 // check same-name sibling setting of both target and existing node
                 if (!conflictingTargetDef.allowsSameNameSiblings()
                         || !newNodeDef.allowsSameNameSiblings()) {
@@ -754,7 +754,7 @@ public class BatchedItemOperations exten
         }
 
         RetentionRegistry retentionReg =
-            sessionContext.getSessionImpl().getRetentionRegistry();
+            context.getSessionImpl().getRetentionRegistry();
         if ((options & CHECK_HOLD) == CHECK_HOLD) {
             if (retentionReg.hasEffectiveHold(parentPath, false)) {
                 throw new RepositoryException("Unable to add node. Parent is affected by
a hold.");
@@ -866,7 +866,7 @@ public class BatchedItemOperations exten
 
         if ((options & CHECK_ACCESS) == CHECK_ACCESS) {
             try {
-                AccessManager accessMgr = sessionContext.getAccessManager();
+                AccessManager accessMgr = context.getAccessManager();
                 // make sure current session is granted read access on parent node
                 if (!accessMgr.isGranted(targetPath, Permission.READ)) {
                     throw new PathNotFoundException(safeGetJCRPath(targetPath));
@@ -888,13 +888,13 @@ public class BatchedItemOperations exten
 
         if ((options & CHECK_CONSTRAINTS) == CHECK_CONSTRAINTS) {
             QItemDefinition parentDef =
-                sessionContext.getItemManager().getDefinition(parentState).unwrap();
+                context.getItemManager().getDefinition(parentState).unwrap();
             if (parentDef.isProtected()) {
                 throw new ConstraintViolationException(safeGetJCRPath(parentId)
                         + ": cannot remove child node of protected parent node");
             }
             QItemDefinition targetDef =
-                sessionContext.getItemManager().getDefinition(targetState).unwrap();
+                context.getItemManager().getDefinition(targetState).unwrap();
             if (targetDef.isMandatory()) {
                 throw new ConstraintViolationException(safeGetJCRPath(targetPath)
                         + ": cannot remove mandatory node");
@@ -929,7 +929,7 @@ public class BatchedItemOperations exten
         }
 
         RetentionRegistry retentionReg =
-            sessionContext.getSessionImpl().getRetentionRegistry();
+            context.getSessionImpl().getRetentionRegistry();
         if ((options & CHECK_HOLD) == CHECK_HOLD) {
             if (retentionReg.hasEffectiveHold(targetPath, true)) {
                 throw new RepositoryException("Unable to perform removal. Node is affected
by a hold.");
@@ -978,7 +978,7 @@ public class BatchedItemOperations exten
 
         // access rights
         // make sure current session is granted read access on node
-        AccessManager accessMgr = sessionContext.getAccessManager();
+        AccessManager accessMgr = context.getAccessManager();
         if (!accessMgr.isGranted(nodePath, Permission.READ)) {
             throw new PathNotFoundException(safeGetJCRPath(node.getNodeId()));
         }
@@ -998,7 +998,7 @@ public class BatchedItemOperations exten
         verifyCheckedOut(nodePath);
 
         RetentionRegistry retentionReg =
-            sessionContext.getSessionImpl().getRetentionRegistry();
+            context.getSessionImpl().getRetentionRegistry();
         if (retentionReg.hasEffectiveHold(nodePath, false)) {
             throw new RepositoryException("Unable to write. Node is affected by a hold.");
         }
@@ -1026,7 +1026,7 @@ public class BatchedItemOperations exten
             throws PathNotFoundException, RepositoryException {
         // access rights
         // make sure current session is granted read access on node
-        AccessManager accessMgr = sessionContext.getAccessManager();
+        AccessManager accessMgr = context.getAccessManager();
         if (!accessMgr.isGranted(nodePath, Permission.READ)) {
             throw new PathNotFoundException(safeGetJCRPath(nodePath));
         }
@@ -1419,7 +1419,7 @@ public class BatchedItemOperations exten
     protected void verifyUnlocked(Path nodePath)
             throws LockException, RepositoryException {
         // make sure there's no foreign lock on node at nodePath
-        sessionContext.getSessionImpl().getLockManager().checkLock(nodePath, session);
+        context.getSessionImpl().getLockManager().checkLock(nodePath, session);
     }
 
     /**
@@ -1435,7 +1435,7 @@ public class BatchedItemOperations exten
             throws PathNotFoundException, ConstraintViolationException,
             RepositoryException {
         NodeState node = getNodeState(nodePath);
-        if (sessionContext.getItemManager().getDefinition(node).isProtected()) {
+        if (context.getItemManager().getDefinition(node).isProtected()) {
             throw new ConstraintViolationException(safeGetJCRPath(nodePath)
                     + ": node is protected");
         }

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=985218&r1=985217&r2=985218&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
Fri Aug 13 14:48:40 2010
@@ -105,7 +105,7 @@ public class ItemValidator {
     /**
      * Component context of the associated session.
      */
-    protected final SessionContext sessionContext;
+    protected final SessionContext context;
 
     /**
      * node type registry
@@ -123,11 +123,11 @@ public class ItemValidator {
     /**
      * Creates a new <code>ItemValidator</code> instance.
      *
-     * @param sessionContext component context of this session
+     * @param context component context of this session
      */
-    public ItemValidator(SessionContext sessionContext) throws RepositoryException {
-        this.sessionContext = sessionContext;
-        this.ntReg = sessionContext.getRepositoryContext().getNodeTypeRegistry();
+    public ItemValidator(SessionContext context) throws RepositoryException {
+        this.context = context;
+        this.ntReg = context.getRepositoryContext().getNodeTypeRegistry();
     }
 
     /**
@@ -146,7 +146,7 @@ public class ItemValidator {
             enabledChecks &= ~checksToDisable;
             log.debug("Performing {} with checks [{}] disabled",
                     operation, Integer.toBinaryString(~enabledChecks));
-            return operation.perform(sessionContext);
+            return operation.perform(context);
         } finally {
             enabledChecks = previousChecks;
         }
@@ -176,7 +176,7 @@ public class ItemValidator {
         // effective node type (primary type incl. mixins)
         EffectiveNodeType entPrimaryAndMixins = getEffectiveNodeType(nodeState);
         QNodeDefinition def =
-            sessionContext.getItemManager().getDefinition(nodeState).unwrap();
+            context.getItemManager().getDefinition(nodeState).unwrap();
 
         // check if primary type satisfies the 'required node types' constraint
         for (Name requiredPrimaryType : def.getRequiredPrimaryTypes()) {
@@ -228,7 +228,7 @@ public class ItemValidator {
     public void validate(PropertyState propState)
             throws ConstraintViolationException, RepositoryException {
         QPropertyDefinition def =
-            sessionContext.getItemManager().getDefinition(propState).unwrap();
+            context.getItemManager().getDefinition(propState).unwrap();
         InternalValue[] values = propState.getValues();
         int type = PropertyType.UNDEFINED;
         for (InternalValue value : values) {
@@ -295,7 +295,7 @@ public class ItemValidator {
 
         if (permissions > Permission.NONE) {
             Path path = item.getPrimaryPath();
-            sessionContext.getAccessManager().checkPermission(path, permissions);
+            context.getAccessManager().checkPermission(path, permissions);
         }
         if ((options & CHECK_HOLD) == CHECK_HOLD) {
             if (hasHold(item, isRemoval)) {
@@ -346,7 +346,7 @@ public class ItemValidator {
         }
         if (permissions > Permission.NONE) {
             Path path = item.getPrimaryPath();
-            if (!sessionContext.getAccessManager().isGranted(path, permissions)) {
+            if (!context.getAccessManager().isGranted(path, permissions)) {
                 return false;
             }
         }
@@ -369,7 +369,7 @@ public class ItemValidator {
             return;
         }
         NodeImpl node = (item.isNode()) ? (NodeImpl) item : (NodeImpl) item.getParent();
-        sessionContext.getSessionImpl().getLockManager().checkLock(node);
+        context.getSessionImpl().getLockManager().checkLock(node);
     }
 
     private boolean isProtected(ItemImpl item) throws RepositoryException {
@@ -391,7 +391,7 @@ public class ItemValidator {
             path = path.getAncestor(1);
         }
         boolean checkParent = (item.isNode() && isRemoval);
-        return sessionContext.getSessionImpl().getRetentionRegistry().hasEffectiveHold(path,
checkParent);
+        return context.getSessionImpl().getRetentionRegistry().hasEffectiveHold(path, checkParent);
     }
 
     private boolean hasRetention(ItemImpl item, boolean isRemoval) throws RepositoryException
{
@@ -403,7 +403,7 @@ public class ItemValidator {
             path = path.getAncestor(1);
         }
         boolean checkParent = (item.isNode() && isRemoval);
-        return sessionContext.getSessionImpl().getRetentionRegistry().hasEffectiveRetention(path,
checkParent);
+        return context.getSessionImpl().getRetentionRegistry().hasEffectiveRetention(path,
checkParent);
     }
 
 
@@ -520,7 +520,7 @@ public class ItemValidator {
      */
     public String safeGetJCRPath(Path path) {
         try {
-            return sessionContext.getJCRPath(path);
+            return context.getJCRPath(path);
         } catch (NamespaceException e) {
             log.error("failed to convert {} to a JCR path", path);
             // return string representation of internal path as a fallback
@@ -538,7 +538,7 @@ public class ItemValidator {
     public String safeGetJCRPath(ItemId id) {
         try {
             return safeGetJCRPath(
-                    sessionContext.getHierarchyManager().getPath(id));
+                    context.getHierarchyManager().getPath(id));
         } catch (ItemNotFoundException e) {
             // return string representation of id as a fallback
             return id.toString();

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=985218&r1=985217&r2=985218&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
Fri Aug 13 14:48:40 2010
@@ -955,7 +955,7 @@ public class NodeImpl extends ItemImpl i
             throws VersionException, LockException, RepositoryException {
         // make sure this node is checked-out and is not locked
         int options = ItemValidator.CHECK_LOCK | ItemValidator.CHECK_CHECKED_OUT;
-        session.getValidator().checkModify(this, options, Permission.NONE);
+        sessionContext.getItemValidator().checkModify(this, options, Permission.NONE);
     }
 
     /**
@@ -1271,7 +1271,7 @@ public class NodeImpl extends ItemImpl i
             ItemValidator.CHECK_LOCK | ItemValidator.CHECK_CHECKED_OUT
             | ItemValidator.CHECK_CONSTRAINTS | ItemValidator.CHECK_HOLD
             | ItemValidator.CHECK_RETENTION;
-        session.getValidator().checkModify(this, options, Permission.NONE);
+        sessionContext.getItemValidator().checkModify(this, options, Permission.NONE);
 
         // now do create the child node
         return createChildNode(nodeName, nt, id);
@@ -1399,7 +1399,7 @@ public class NodeImpl extends ItemImpl i
         // make sure this node is checked-out and neither protected nor locked
         int options = ItemValidator.CHECK_LOCK | ItemValidator.CHECK_CHECKED_OUT
                 | ItemValidator.CHECK_CONSTRAINTS;
-        session.getValidator().checkModify(this, options, Permission.NONE);
+        sessionContext.getItemValidator().checkModify(this, options, Permission.NONE);
 
         /*
         make sure the session is allowed to reorder child nodes.
@@ -1584,7 +1584,7 @@ public class NodeImpl extends ItemImpl i
         // (2) check lock status
         // (3) check protected flag of parent (i.e. this) node
         int options = ItemValidator.CHECK_LOCK | ItemValidator.CHECK_CHECKED_OUT | ItemValidator.CHECK_CONSTRAINTS;
-        session.getValidator().checkModify(this, options, Permission.NONE);
+        sessionContext.getItemValidator().checkModify(this, options, Permission.NONE);
 
         // (4) check for name collisions
         NodeDefinitionImpl def;
@@ -2292,7 +2292,7 @@ public class NodeImpl extends ItemImpl i
                 || NameConstants.MIX_SIMPLE_VERSIONABLE.equals(ntName)) {
             permissions |= Permission.VERSION_MNGMT;
         }
-        if (!session.getValidator().canModify(this, options, permissions)) {
+        if (!sessionContext.getItemValidator().canModify(this, options, permissions)) {
             return false;
         }
 
@@ -3111,7 +3111,7 @@ public class NodeImpl extends ItemImpl i
         // the editing session has sufficient permission to change the primary type.
         int options = ItemValidator.CHECK_CHECKED_OUT | ItemValidator.CHECK_LOCK
                 | ItemValidator.CHECK_CONSTRAINTS | ItemValidator.CHECK_HOLD;
-        session.getValidator().checkModify(this, options, Permission.NODE_TYPE_MNGMT);
+        sessionContext.getItemValidator().checkModify(this, options, Permission.NODE_TYPE_MNGMT);
 
         final NodeState state = data.getNodeState();
         if (state.getParentId() == null) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java?rev=985218&r1=985217&r2=985218&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
Fri Aug 13 14:48:40 2010
@@ -23,6 +23,11 @@ import static javax.jcr.PropertyType.REF
 import static javax.jcr.PropertyType.STRING;
 import static javax.jcr.PropertyType.UNDEFINED;
 import static javax.jcr.PropertyType.WEAKREFERENCE;
+import static org.apache.jackrabbit.core.ItemValidator.CHECK_CHECKED_OUT;
+import static org.apache.jackrabbit.core.ItemValidator.CHECK_CONSTRAINTS;
+import static org.apache.jackrabbit.core.ItemValidator.CHECK_HOLD;
+import static org.apache.jackrabbit.core.ItemValidator.CHECK_LOCK;
+import static org.apache.jackrabbit.core.ItemValidator.CHECK_RETENTION;
 
 import java.io.InputStream;
 import java.io.IOException;
@@ -262,13 +267,14 @@ public class PropertyImpl extends ItemIm
         }
 
         // check protected flag and for retention/hold
-        int options = ItemValidator.CHECK_CONSTRAINTS;
-        session.getValidator().checkModify(this, options, Permission.NONE);
+        sessionContext.getItemValidator().checkModify(
+                this, CHECK_CONSTRAINTS, Permission.NONE);
 
         // make sure the parent is checked-out and neither locked nor under retention
-        options = ItemValidator.CHECK_CHECKED_OUT | ItemValidator.CHECK_LOCK |
-                ItemValidator.CHECK_HOLD | ItemValidator.CHECK_RETENTION;
-        session.getValidator().checkModify(parent, options, Permission.NONE);
+        sessionContext.getItemValidator().checkModify(
+                parent,
+                CHECK_CHECKED_OUT | CHECK_LOCK | CHECK_HOLD | CHECK_RETENTION,
+                Permission.NONE);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RemoveMixinOperation.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RemoveMixinOperation.java?rev=985218&r1=985217&r2=985218&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RemoveMixinOperation.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RemoveMixinOperation.java
Fri Aug 13 14:48:40 2010
@@ -76,7 +76,7 @@ class RemoveMixinOperation implements Se
         ItemManager itemMgr = context.getItemManager();
         SessionItemStateManager stateMgr = context.getItemStateManager();
 
-        session.getValidator().checkModify(
+        context.getItemValidator().checkModify(
                 node,
                 CHECK_LOCK | CHECK_CHECKED_OUT | CHECK_CONSTRAINTS | CHECK_HOLD,
                 Permission.NODE_TYPE_MNGMT);

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=985218&r1=985217&r2=985218&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
Fri Aug 13 14:48:40 2010
@@ -16,6 +16,12 @@
  */
 package org.apache.jackrabbit.core;
 
+import static org.apache.jackrabbit.core.ItemValidator.CHECK_CHECKED_OUT;
+import static org.apache.jackrabbit.core.ItemValidator.CHECK_CONSTRAINTS;
+import static org.apache.jackrabbit.core.ItemValidator.CHECK_HOLD;
+import static org.apache.jackrabbit.core.ItemValidator.CHECK_LOCK;
+import static org.apache.jackrabbit.core.ItemValidator.CHECK_RETENTION;
+
 import java.io.File;
 import java.io.PrintStream;
 import java.security.AccessControlException;
@@ -376,13 +382,6 @@ public class SessionImpl extends Abstrac
     }
 
     /**
-     * @return ItemValidator instance for this session.
-     */
-    public ItemValidator getValidator() {
-        return context.getItemValidator();
-    }
-
-    /**
      * Returns the <code>Subject</code> associated with this session.
      *
      * @return the <code>Subject</code> associated with this session
@@ -913,7 +912,7 @@ public class SessionImpl extends Abstrac
         // by either node type constraints nor by some retention or hold.
         int options = ItemValidator.CHECK_LOCK | ItemValidator.CHECK_CHECKED_OUT |
                 ItemValidator.CHECK_CONSTRAINTS | ItemValidator.CHECK_HOLD | ItemValidator.CHECK_RETENTION;
-        getValidator().checkModify(parent, options, Permission.NONE);
+        context.getItemValidator().checkModify(parent, options, Permission.NONE);
 
         SessionImporter importer = new SessionImporter(parent, this, uuidBehavior, wsp.getConfig().getImportConfig());
         return new ImportHandler(importer, this);
@@ -1227,8 +1226,10 @@ public class SessionImpl extends Abstrac
 
         // here's therefore a minimal rather than best effort implementation;
         // returning true is always fine according to the spec...
-        int options = ItemValidator.CHECK_CHECKED_OUT | ItemValidator.CHECK_LOCK |
-                ItemValidator.CHECK_CONSTRAINTS | ItemValidator.CHECK_HOLD | ItemValidator.CHECK_RETENTION;
+        ItemValidator validator = context.getItemValidator();
+        int options =
+            CHECK_CHECKED_OUT | CHECK_LOCK | CHECK_CONSTRAINTS
+            | CHECK_HOLD | CHECK_RETENTION;
         if (target instanceof Node) {
             if (methodName.equals("addNode")
                     || methodName.equals("addMixin")
@@ -1239,10 +1240,10 @@ public class SessionImpl extends Abstrac
                     || methodName.equals("setPrimaryType")
                     || methodName.equals("setProperty")
                     || methodName.equals("update")) {
-                return getValidator().canModify((ItemImpl) target, options, Permission.NONE);
+                return validator.canModify((ItemImpl) target, options, Permission.NONE);
             } else if (methodName.equals("remove")) {
                 try {
-                    getValidator().checkRemove((ItemImpl) target, options, Permission.NONE);
+                    validator.checkRemove((ItemImpl) target, options, Permission.NONE);
                 } catch (RepositoryException e) {
                     return false;
                 }
@@ -1250,10 +1251,10 @@ public class SessionImpl extends Abstrac
         } else if (target instanceof Property) {
             if (methodName.equals("setValue")
                     || methodName.equals("save")) {
-                return getValidator().canModify((ItemImpl) target, options, Permission.NONE);
+                return validator.canModify((ItemImpl) target, options, Permission.NONE);
             } else if (methodName.equals("remove")) {
                 try {
-                    getValidator().checkRemove((ItemImpl) target, options, Permission.NONE);
+                    validator.checkRemove((ItemImpl) target, options, Permission.NONE);
                 } catch (RepositoryException e) {
                     return false;
                 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/VersionManagerImpl.java?rev=985218&r1=985217&r2=985218&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/VersionManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/VersionManagerImpl.java
Fri Aug 13 14:48:40 2010
@@ -77,27 +77,21 @@ public class VersionManagerImpl extends 
     private static final Logger log = LoggerFactory.getLogger(VersionManagerImpl.class);
 
     /**
-     * Component context of the current session
-     */
-    private final SessionContext sessionContext;
-
-    /**
      * Creates a new version manager
      *
-     * @param sessionContext component context of the current session
+     * @param context component context of the current session
      * @param stateMgr the underlying state manager
      * @param hierMgr local hierarchy manager
      */
     public VersionManagerImpl(
-            SessionContext sessionContext, UpdatableItemStateManager stateMgr,
+            SessionContext context, UpdatableItemStateManager stateMgr,
             HierarchyManager hierMgr) {
-        super(sessionContext.getSessionImpl(), stateMgr, hierMgr);
-        this.sessionContext = sessionContext;
+        super(context, stateMgr, hierMgr);
     }
 
     private <T> T perform(SessionOperation<T> operation)
             throws RepositoryException {
-        return sessionContext.getSessionState().perform(operation);
+        return context.getSessionState().perform(operation);
     }
 
     /** Wrapper around {@link #checkin(String, Calendar)}. */
@@ -598,7 +592,7 @@ public class VersionManagerImpl extends 
             throws RepositoryException {
         try {
             if (options > 0 || permissions > 0) {
-                session.getValidator().checkModify(node, options, permissions);
+                context.getItemValidator().checkModify(node, options, permissions);
             }
             return new NodeStateEx(
                     stateMgr,

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=985218&r1=985217&r2=985218&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
Fri Aug 13 14:48:40 2010
@@ -257,7 +257,8 @@ public class WorkspaceImpl extends Abstr
      */
     public javax.jcr.lock.LockManager getLockManager() throws UnsupportedRepositoryOperationException,
RepositoryException {
         if (jcr283LockManager == null) {
-            jcr283LockManager = new SessionLockManager(session, session.getLockManager());
+            jcr283LockManager =
+                new SessionLockManager(sessionContext, session.getLockManager());
         }
         return jcr283LockManager;
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/SessionLockManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/SessionLockManager.java?rev=985218&r1=985217&r2=985218&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/SessionLockManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/SessionLockManager.java
Fri Aug 13 14:48:40 2010
@@ -16,23 +16,25 @@
  */
 package org.apache.jackrabbit.core.lock;
 
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.lock.Lock;
+import javax.jcr.lock.LockException;
+
+import org.apache.jackrabbit.core.ItemValidator;
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.SessionImpl;
-import org.apache.jackrabbit.core.ItemValidator;
 import org.apache.jackrabbit.core.security.authorization.Permission;
+import org.apache.jackrabbit.core.session.SessionContext;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.jcr.AccessDeniedException;
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.lock.LockException;
-import java.util.HashSet;
-import java.util.Set;
-
 /**
  * <code>SessionLockManager</code> implements the
  * {@link javax.jcr.lock.LockManager}. In contrast
@@ -47,12 +49,30 @@ public class SessionLockManager implemen
 
     private static Logger log = LoggerFactory.getLogger(SessionLockManager.class);
 
+    /**
+     * Component context of the current session
+     */
+    private final SessionContext context;
+
+    /**
+     * Current session
+     */
     private final SessionImpl session;
+
     private final LockManager systemLockMgr;
+
     private final Set<String> lockTokens = new HashSet<String>();
 
-    public SessionLockManager(SessionImpl session, LockManager systemLockMgr) throws RepositoryException
{
-        this.session = session;
+    /**
+     * Creates a lock manager.
+     *
+     * @param context component context of the current session
+     * @param systemLockMgr internal lock manager
+     */
+    public SessionLockManager(
+            SessionContext context, LockManager systemLockMgr) {
+        this.context = context;
+        this.session = context.getSessionImpl();
         this.systemLockMgr = systemLockMgr;
     }
 
@@ -153,7 +173,7 @@ public class SessionLockManager implemen
         NodeImpl node = (NodeImpl) session.getNode(absPath);
         
         int options = ItemValidator.CHECK_HOLD | ItemValidator.CHECK_PENDING_CHANGES_ON_NODE;
-        session.getValidator().checkModify(node, options, Permission.LOCK_MNGMT);
+        context.getItemValidator().checkModify(node, options, Permission.LOCK_MNGMT);
         checkLockable(node);
 
         synchronized (systemLockMgr) {
@@ -171,7 +191,7 @@ public class SessionLockManager implemen
 
         NodeImpl node = (NodeImpl) session.getNode(absPath);
         int options = ItemValidator.CHECK_HOLD | ItemValidator.CHECK_PENDING_CHANGES_ON_NODE;
-        session.getValidator().checkModify(node, options, Permission.LOCK_MNGMT);
+        context.getItemValidator().checkModify(node, options, Permission.LOCK_MNGMT);
         checkLockable(node);
 
         synchronized (systemLockMgr) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplBase.java?rev=985218&r1=985217&r2=985218&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplBase.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplBase.java
Fri Aug 13 14:48:40 2010
@@ -34,6 +34,7 @@ import org.apache.jackrabbit.core.NodeIm
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
+import org.apache.jackrabbit.core.session.SessionContext;
 import org.apache.jackrabbit.core.state.DefaultISMLocking;
 import org.apache.jackrabbit.core.state.ISMLocking;
 import org.apache.jackrabbit.core.state.ItemStateException;
@@ -60,6 +61,11 @@ abstract public class VersionManagerImpl
     private static final Logger log = LoggerFactory.getLogger(VersionManagerImplBase.class);
 
     /**
+     * Component context of the current session
+     */
+    protected final SessionContext context;
+
+    /**
      * workspace session
      */
     protected final SessionImpl session;
@@ -96,14 +102,16 @@ abstract public class VersionManagerImpl
 
     /**
      * Creates a new version manager base for the given session
-     * @param session workspace sesion
+     *
+     * @param context component context of the current session
      * @param stateMgr the underlying state manager
      * @param hierMgr local hierarchy manager
      */
-    protected VersionManagerImplBase(SessionImpl session,
-                                        UpdatableItemStateManager stateMgr,
-                                        HierarchyManager hierMgr) {
-        this.session = session;
+    protected VersionManagerImplBase(
+            SessionContext context, UpdatableItemStateManager stateMgr,
+            HierarchyManager hierMgr) {
+        this.context = context;
+        this.session = context.getSessionImpl();
         this.stateMgr = stateMgr;
         this.hierMgr = hierMgr;
         this.ntReg = session.getNodeTypeManager().getNodeTypeRegistry();
@@ -422,7 +430,7 @@ abstract public class VersionManagerImpl
             // ignore
             return;
         }
-        session.getValidator().checkModify(node, options, permissions);
+        context.getItemValidator().checkModify(node, options, permissions);
     }
 
     /**
@@ -434,7 +442,7 @@ abstract public class VersionManagerImpl
      */
     protected void checkModify(NodeImpl node, int options, int permissions)
             throws RepositoryException {
-        session.getValidator().checkModify(node, options, permissions);
+        context.getItemValidator().checkModify(node, options, permissions);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplConfig.java?rev=985218&r1=985217&r2=985218&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplConfig.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplConfig.java
Fri Aug 13 14:48:40 2010
@@ -25,8 +25,8 @@ import javax.jcr.UnsupportedRepositoryOp
 
 import org.apache.jackrabbit.core.HierarchyManager;
 import org.apache.jackrabbit.core.RepositoryImpl;
-import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.session.SessionContext;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.UpdatableItemStateManager;
 import org.apache.jackrabbit.core.value.InternalValue;
@@ -53,14 +53,15 @@ abstract public class VersionManagerImpl
 
     /**
      * Creates a new version manager for the given session
-     * @param session workspace sesion
+     *
+     * @param context component context of the current session
      * @param stateMgr the underlying state manager
      * @param hierMgr local hierarchy manager
      */
-    protected VersionManagerImplConfig(SessionImpl session,
-                                        UpdatableItemStateManager stateMgr,
-                                        HierarchyManager hierMgr) {
-        super(session, stateMgr, hierMgr);
+    protected VersionManagerImplConfig(
+            SessionContext context, UpdatableItemStateManager stateMgr,
+            HierarchyManager hierMgr) {
+        super(context, stateMgr, hierMgr);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplMerge.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplMerge.java?rev=985218&r1=985217&r2=985218&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplMerge.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplMerge.java
Fri Aug 13 14:48:40 2010
@@ -33,10 +33,10 @@ import javax.jcr.version.VersionExceptio
 
 import org.apache.jackrabbit.core.HierarchyManager;
 import org.apache.jackrabbit.core.ItemValidator;
-import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.id.ItemId;
 import org.apache.jackrabbit.core.id.NodeId;
 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.ItemStateException;
 import org.apache.jackrabbit.core.state.PropertyState;
@@ -62,14 +62,15 @@ abstract public class VersionManagerImpl
 
     /**
      * Creates a new version manager for the given session
-     * @param session workspace sesion
+     *
+     * @param context component context of the current session
      * @param stateMgr the underlying state manager
      * @param hierMgr local hierarchy manager
      */
-    protected VersionManagerImplMerge(SessionImpl session,
-                                        UpdatableItemStateManager stateMgr,
-                                        HierarchyManager hierMgr) {
-        super(session, stateMgr, hierMgr);
+    protected VersionManagerImplMerge(
+            SessionContext context, UpdatableItemStateManager stateMgr,
+            HierarchyManager hierMgr) {
+        super(context, stateMgr, hierMgr);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java?rev=985218&r1=985217&r2=985218&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java
Fri Aug 13 14:48:40 2010
@@ -32,9 +32,9 @@ import javax.jcr.version.VersionManager;
 
 import org.apache.jackrabbit.core.HierarchyManager;
 import org.apache.jackrabbit.core.ItemValidator;
-import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.id.NodeId;
 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.ItemStateException;
 import org.apache.jackrabbit.core.state.PropertyState;
@@ -48,7 +48,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * The JCR Version Manager impementation is split in several classes in order to
+ * The JCR Version Manager implementation is split in several classes in order to
  * group related methods together.
  * <p/>
  * this class provides methods for the restore operations.
@@ -65,14 +65,15 @@ abstract public class VersionManagerImpl
 
     /**
      * Creates a new version manager for the given session
-     * @param session workspace sesion
+     *
+     * @param context component context of the current session
      * @param stateMgr the underlying state manager
      * @param hierMgr local hierarchy manager
      */
-    protected VersionManagerImplRestore(SessionImpl session,
-                                        UpdatableItemStateManager stateMgr,
-                                        HierarchyManager hierMgr) {
-        super(session, stateMgr, hierMgr);
+    protected VersionManagerImplRestore(
+            SessionContext context, UpdatableItemStateManager stateMgr,
+            HierarchyManager hierMgr) {
+        super(context, stateMgr, hierMgr);
     }
 
     /**



Mime
View raw message