jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1477955 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission...
Date Wed, 01 May 2013 11:40:22 GMT
Author: mduerig
Date: Wed May  1 11:40:22 2013
New Revision: 1477955

URL: http://svn.apache.org/r1477955
Log:
OAK-798: Review / refactor TreeImpl and related classes
reduce usage of deprecated API: replace getLocation with getTree and exists

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/IdentifierManager.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadOnlyVersionManager.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionProviderImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/ReadWriteVersionManager.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/IdentifierManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/IdentifierManager.java?rev=1477955&r1=1477954&r2=1477955&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/IdentifierManager.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/IdentifierManager.java
Wed May  1 11:40:22 2013
@@ -16,6 +16,9 @@
  */
 package org.apache.jackrabbit.oak.core;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+
 import java.text.ParseException;
 import java.util.Collections;
 import java.util.Map;
@@ -49,9 +52,6 @@ import org.apache.jackrabbit.oak.spi.que
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static com.google.common.base.Preconditions.checkArgument;
-import static org.apache.jackrabbit.oak.api.Type.STRING;
-
 /**
  * TODO document
  */
@@ -245,9 +245,7 @@ public class IdentifierManager {
     }
 
     private String findProperty(String path, final String uuid) {
-        TreeLocation loc = root.getLocation(path);
-        Tree tree = loc.getTree();
-        assert tree != null;
+        Tree tree = root.getTree(path);
         final PropertyState refProp = Iterables.find(tree.getProperties(), new Predicate<PropertyState>()
{
             @Override
             public boolean apply(PropertyState pState) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadOnlyVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadOnlyVersionManager.java?rev=1477955&r1=1477954&r2=1477955&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadOnlyVersionManager.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadOnlyVersionManager.java
Wed May  1 11:40:22 2013
@@ -70,7 +70,23 @@ public abstract class ReadOnlyVersionMan
      * @return whether the tree is checked out or not.
      */
     public boolean isCheckedOut(@Nonnull Tree tree) {
-        return isCheckedOut(checkNotNull(tree).getLocation());
+        if (checkNotNull(tree).exists()) {
+            PropertyState p = tree.getProperty(VersionConstants.JCR_ISCHECKEDOUT);
+            if (p != null) {
+                return p.getValue(Type.BOOLEAN);
+            } else if (tree.isRoot()) {
+                return true;
+            }
+        } else {
+            // FIXME: this actually means access to the tree is restricted
+            // and may result in wrong isCheckedOut value. This should never
+            // be the case in a commit hook because it operates on non-access-
+            // controlled NodeStates. This means consistency is not at risk
+            // but it may mean oak-jcr sees a node as checked out even though
+            // it is in fact read-only because of a checked-in ancestor.
+        }
+        // otherwise return checkedOut status of parent
+        return isCheckedOut(tree.getParent());
     }
 
     /**
@@ -78,10 +94,10 @@ public abstract class ReadOnlyVersionMan
      * checked out; otherwise {@code false}.
      *
      * @param absOakPath an absolute path.
-     * @return whether the tree at the given location is checked out or not.
+     * @return whether the tree at the given path is checked out or not.
      */
     public boolean isCheckedOut(@Nonnull String absOakPath) {
-        return isCheckedOut(getWorkspaceRoot().getLocation(checkNotNull(absOakPath)));
+        return isCheckedOut(getWorkspaceRoot().getTree(checkNotNull(absOakPath)));
     }
 
     /**
@@ -170,27 +186,6 @@ public abstract class ReadOnlyVersionMan
         return new IdentifierManager(getWorkspaceRoot());
     }
 
-    protected static boolean isCheckedOut(@Nonnull TreeLocation location) {
-        Tree t = checkNotNull(location).getTree();
-        if (t != null) {
-            PropertyState p = t.getProperty(VersionConstants.JCR_ISCHECKEDOUT);
-            if (p != null) {
-                return p.getValue(Type.BOOLEAN);
-            } else if (t.isRoot()) {
-                return true;
-            }
-        } else {
-            // FIXME: this actually means access to the tree is restricted
-            // and may result in wrong isCheckedOut value. This should never
-            // be the case in a commit hook because it operates on non-access-
-            // controlled NodeStates. This means consistency is not at risk
-            // but it may mean oak-jcr sees a node as checked out even though
-            // it is in fact read-only because of a checked-in ancestor.
-        }
-        // otherwise return checkedOut status of parent
-        return isCheckedOut(location.getParent());
-    }
-
     /**
      * Checks if the given {@code tree} is versionable and throws a {@link
      * UnsupportedRepositoryOperationException} if it is not.

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionProviderImpl.java?rev=1477955&r1=1477954&r2=1477955&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionProviderImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionProviderImpl.java
Wed May  1 11:40:22 2013
@@ -16,8 +16,11 @@
  */
 package org.apache.jackrabbit.oak.security.authorization.permission;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 import java.security.Principal;
 import java.util.Set;
+
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -48,8 +51,6 @@ import org.apache.jackrabbit.oak.util.Tr
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-
 /**
  * PermissionProviderImpl... TODO
  * <p/>
@@ -78,7 +79,7 @@ public class PermissionProviderImpl impl
             compiledPermissions = AllPermissions.getInstance();
         } else {
             ImmutableTree permissionsTree = getPermissionsRoot();
-            if (permissionsTree == null || principals.isEmpty()) {
+            if (!permissionsTree.exists() || principals.isEmpty()) {
                 compiledPermissions = NoPermissions.getInstance();
             } else {
                 compiledPermissions = new CompiledPermissionImpl(principals,
@@ -192,11 +193,9 @@ public class PermissionProviderImpl impl
         }
     }
 
-    @CheckForNull
+    @Nonnull
     private ImmutableTree getPermissionsRoot() {
-        String path = PERMISSIONS_STORE_PATH + '/' + workspaceName;
-        Tree tree = getImmutableRoot().getLocation(path).getTree();
-        return (tree == null) ? null : (ImmutableTree) tree;
+        return getImmutableRoot().getTree(PERMISSIONS_STORE_PATH + '/' + workspaceName);
     }
 
     @Nonnull

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/ReadWriteVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/ReadWriteVersionManager.java?rev=1477955&r1=1477954&r2=1477955&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/ReadWriteVersionManager.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/ReadWriteVersionManager.java
Wed May  1 11:40:22 2013
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.oak.jcr.version;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 import javax.annotation.Nonnull;
 import javax.jcr.InvalidItemStateException;
 import javax.jcr.RepositoryException;
@@ -31,8 +33,6 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.version.ReadOnlyVersionManager;
 import org.apache.jackrabbit.oak.plugins.version.VersionConstants;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-
 /**
  * {@code ReadWriteVersionManager}...
  */
@@ -104,8 +104,7 @@ public class ReadWriteVersionManager ext
             throw new UnsupportedRepositoryOperationException(
                     versionable.getPath() + " is not versionable");
         }
-        TreeLocation location = versionable.getLocation();
-        if (isCheckedOut(location)) {
+        if (isCheckedOut(versionable)) {
             versionable.setProperty(VersionConstants.JCR_ISCHECKEDOUT,
                     Boolean.FALSE, Type.BOOLEAN);
             try {
@@ -116,7 +115,7 @@ public class ReadWriteVersionManager ext
                 throw new RepositoryException(e);
             }
         }
-        return getBaseVersion(getWorkspaceRoot().getTreeOrNull(location.getPath()));
+        return getBaseVersion(getWorkspaceRoot().getTreeOrNull(versionable.getPath()));
     }
 
     /**
@@ -142,8 +141,7 @@ public class ReadWriteVersionManager ext
             throw new UnsupportedRepositoryOperationException(
                     versionable.getPath() + " is not versionable");
         }
-        TreeLocation location = versionable.getLocation();
-        if (!isCheckedOut(location)) {
+        if (!isCheckedOut(versionable)) {
             versionable.setProperty(VersionConstants.JCR_ISCHECKEDOUT,
                     Boolean.TRUE, Type.BOOLEAN);
             try {



Mime
View raw message