jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1478209 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: api/ core/ plugins/name/ plugins/nodetype/ plugins/nodetype/write/ plugins/observation2/ security/authorization/ security/authorization/permission/ securi...
Date Wed, 01 May 2013 21:56:29 GMT
Author: mduerig
Date: Wed May  1 21:56:29 2013
New Revision: 1478209

URL: http://svn.apache.org/r1478209
Log:
OAK-798: Review / refactor TreeImpl and related classes
Replace usage of Tree.getChildOrNull with Tree.getChild

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractNodeLocation.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/EffectiveNodeType.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeTemplateImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation2/EventCollector.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation2/EventQueueReader.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlManagerImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidator.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/CompiledPermissionImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidator.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/restriction/RestrictionProviderImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeBitsProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeDefinitionReader.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserValidator.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java?rev=1478209&r1=1478208&r2=1478209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java Wed
May  1 21:56:29 2013
@@ -201,18 +201,6 @@ public interface Tree {
     Tree getChild(@Nonnull String name);
 
     /**
-     * Get a child of this {@code Tree} instance.
-     *
-     * @param name The name of the child to retrieve.
-     * @return The child with the given {@code name} or {@code null} if no such
-     *         child exists or the child is not accessible.
-     * @deprecated use {@link #getChild(String)} and {@link #exists()} instead.
-     */
-    @CheckForNull
-    @Deprecated
-    Tree getChildOrNull(@Nonnull String name);
-
-    /**
      * Determine if a child of this {@code Tree} instance exists. If no child
      * exists or an existing child isn't accessible this method returns {@code false}.
      *

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractNodeLocation.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractNodeLocation.java?rev=1478209&r1=1478208&r2=1478209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractNodeLocation.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractNodeLocation.java
Wed May  1 21:56:29 2013
@@ -19,6 +19,8 @@ package org.apache.jackrabbit.oak.core;
 import static com.google.common.base.Objects.toStringHelper;
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import javax.annotation.Nonnull;
+
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.api.TreeLocation;
@@ -40,6 +42,7 @@ abstract class AbstractNodeLocation<T ex
 
     protected abstract T getParentTree();
 
+    @Nonnull
     protected abstract T getChildTree(String name);
 
     protected abstract PropertyState getPropertyState(String name);
@@ -64,10 +67,7 @@ abstract class AbstractNodeLocation<T ex
         }
 
         T child = getChildTree(name);
-        if (child != null) {
-            return createNodeLocation(child);
-        }
-        return new NullLocation(this, name);
+        return createNodeLocation(child);
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java?rev=1478209&r1=1478208&r2=1478209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java
Wed May  1 21:56:29 2013
@@ -182,13 +182,6 @@ public final class ImmutableTree extends
         return new ImmutableTree(this, name, child);
     }
 
-    @Override
-    @Deprecated
-    public ImmutableTree getChildOrNull(@Nonnull String name) {
-        ImmutableTree child = getChild(name);
-        return child.exists() ? child : null;
-    }
-
     /**
      * This implementation does not respect ordered child nodes, but always
      * returns them in some implementation specific order.

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.java?rev=1478209&r1=1478208&r2=1478209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.java
Wed May  1 21:56:29 2013
@@ -143,13 +143,6 @@ public class ReadOnlyTree implements Tre
     }
 
     @Override
-    @Deprecated
-    public ReadOnlyTree getChildOrNull(@Nonnull String name) {
-        ReadOnlyTree child = getChild(name);
-        return child.exists() ? child : null;
-    }
-
-    @Override
     public Status getStatus() {
         return Status.EXISTING;
     }
@@ -298,7 +291,7 @@ public class ReadOnlyTree implements Tre
 
         @Override
         protected ReadOnlyTree getChildTree(String name) {
-            return tree.getChildOrNull(name);
+            return tree.getChild(name);
         }
 
         @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java?rev=1478209&r1=1478208&r2=1478209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
Wed May  1 21:56:29 2013
@@ -222,13 +222,6 @@ public class TreeImpl implements Tree {
     }
 
     @Override
-    @Deprecated
-    public TreeImpl getChildOrNull(@Nonnull String name) {
-        TreeImpl child = getChild(name);
-        return child.nodeBuilder.exists() ? child : null;
-    }
-
-    @Override
     public boolean hasChild(@Nonnull String name) {
         checkNotNull(name);
         enter();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java?rev=1478209&r1=1478208&r2=1478209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java
Wed May  1 21:56:29 2013
@@ -16,6 +16,8 @@
 */
 package org.apache.jackrabbit.oak.plugins.name;
 
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+
 import java.util.HashMap;
 import java.util.Map;
 
@@ -25,8 +27,6 @@ import org.apache.jackrabbit.JcrConstant
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
 
-import static org.apache.jackrabbit.oak.api.Type.STRING;
-
 /**
  * Internal static utility class for managing the persisted namespace registry.
  */
@@ -52,18 +52,13 @@ public class Namespaces implements Names
     public static Map<String, String> getNamespaceMap(Tree root) {
         Map<String, String> map = new HashMap<String, String>(DEFAULTS);
 
-        Tree system = root.getChildOrNull(JcrConstants.JCR_SYSTEM);
-        if (system != null) {
-            Tree namespaces = system.getChildOrNull(REP_NAMESPACES);
-            if (namespaces != null) {
-                for (PropertyState property : namespaces.getProperties()) {
-                    String prefix = property.getName();
-                    if (!property.isArray() && isValidPrefix(prefix)) {
-                        String value = property.getValue(STRING);
-                        if (STRING.equals(property.getType())) {
-                            map.put(prefix, value);
-                        }
-                    }
+        Tree namespaces = root.getChild(JcrConstants.JCR_SYSTEM).getChild(REP_NAMESPACES);
+        for (PropertyState property : namespaces.getProperties()) {
+            String prefix = property.getName();
+            if (!property.isArray() && isValidPrefix(prefix)) {
+                String value = property.getValue(STRING);
+                if (STRING.equals(property.getType())) {
+                    map.put(prefix, value);
                 }
             }
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/EffectiveNodeType.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/EffectiveNodeType.java?rev=1478209&r1=1478208&r2=1478209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/EffectiveNodeType.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/EffectiveNodeType.java
Wed May  1 21:56:29 2013
@@ -312,7 +312,7 @@ public class EffectiveNodeType {
             }
             for (NodeDefinition nd : nodeType.getChildNodeDefinitions()) {
                 String name = nd.getName();
-                if (nd.isMandatory() && !nd.isProtected() && tree.getChildOrNull(name)
== null) {
+                if (nd.isMandatory() && !nd.isProtected() && !tree.hasChild(name))
{
                     throw new ConstraintViolationException(
                             "Node '" + name + "' in '" + nodeType.getName() + "' is mandatory");
                 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeTemplateImpl.java?rev=1478209&r1=1478208&r2=1478209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeTemplateImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeTemplateImpl.java
Wed May  1 21:56:29 2013
@@ -16,8 +16,23 @@
  */
 package org.apache.jackrabbit.oak.plugins.nodetype.write;
 
+import static org.apache.jackrabbit.JcrConstants.JCR_CHILDNODEDEFINITION;
+import static org.apache.jackrabbit.JcrConstants.JCR_HASORDERABLECHILDNODES;
+import static org.apache.jackrabbit.JcrConstants.JCR_ISMIXIN;
+import static org.apache.jackrabbit.JcrConstants.JCR_NODETYPENAME;
+import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYITEMNAME;
+import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
+import static org.apache.jackrabbit.JcrConstants.JCR_PROPERTYDEFINITION;
+import static org.apache.jackrabbit.JcrConstants.JCR_SUPERTYPES;
+import static org.apache.jackrabbit.JcrConstants.NT_CHILDNODEDEFINITION;
+import static org.apache.jackrabbit.JcrConstants.NT_NODETYPE;
+import static org.apache.jackrabbit.JcrConstants.NT_PROPERTYDEFINITION;
+import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.JCR_IS_ABSTRACT;
+import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.JCR_IS_QUERYABLE;
+
 import java.util.Arrays;
 import java.util.List;
+
 import javax.annotation.Nonnull;
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.ConstraintViolationException;
@@ -34,20 +49,6 @@ import org.apache.jackrabbit.oak.api.Tre
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.namepath.NameMapper;
 
-import static org.apache.jackrabbit.JcrConstants.JCR_CHILDNODEDEFINITION;
-import static org.apache.jackrabbit.JcrConstants.JCR_HASORDERABLECHILDNODES;
-import static org.apache.jackrabbit.JcrConstants.JCR_ISMIXIN;
-import static org.apache.jackrabbit.JcrConstants.JCR_NODETYPENAME;
-import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYITEMNAME;
-import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
-import static org.apache.jackrabbit.JcrConstants.JCR_PROPERTYDEFINITION;
-import static org.apache.jackrabbit.JcrConstants.JCR_SUPERTYPES;
-import static org.apache.jackrabbit.JcrConstants.NT_CHILDNODEDEFINITION;
-import static org.apache.jackrabbit.JcrConstants.NT_NODETYPE;
-import static org.apache.jackrabbit.JcrConstants.NT_PROPERTYDEFINITION;
-import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.JCR_IS_ABSTRACT;
-import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.JCR_IS_QUERYABLE;
-
 class NodeTypeTemplateImpl extends NamedTemplate
         implements NodeTypeTemplate {
 
@@ -127,8 +128,8 @@ class NodeTypeTemplateImpl extends Named
     Tree writeTo(Tree parent, boolean allowUpdate) throws RepositoryException {
         String oakName = getOakName();
 
-        Tree type = parent.getChildOrNull(oakName);
-        if (type != null) {
+        Tree type = parent.getChild(oakName);
+        if (type.exists()) {
             if (allowUpdate) {
                 type.remove();
             } else {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation2/EventCollector.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation2/EventCollector.java?rev=1478209&r1=1478208&r2=1478209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation2/EventCollector.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation2/EventCollector.java
Wed May  1 21:56:29 2013
@@ -146,8 +146,8 @@ class EventCollector implements Runnable
     }
 
     private static Tree getOrCreate(Tree parent, String name) {
-        Tree child = parent.getChildOrNull(name);
-        if (child == null) {
+        Tree child = parent.getChild(name);
+        if (!child.exists()) {
             child = parent.addChild(name);
         }
         return child;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation2/EventQueueReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation2/EventQueueReader.java?rev=1478209&r1=1478208&r2=1478209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation2/EventQueueReader.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation2/EventQueueReader.java
Wed May  1 21:56:29 2013
@@ -76,8 +76,8 @@ public class EventQueueReader {
             bundles = root.getTree(EVENTS_PATH);
         }
 
-        Tree bundle = bundles.getChildOrNull(String.valueOf(next));
-        if (bundle != null) {
+        Tree bundle = bundles.getChild(String.valueOf(next));
+        if (bundle.exists()) {
             nextBundleId++;
             if (bundle.getChildrenCount() > 0) {
                 return Iterators.filter(bundle.getChildren().iterator(),
@@ -95,9 +95,9 @@ public class EventQueueReader {
     private Event createEvent(Tree event, String id) {
         int type = (int) getLong(event, TYPE, 0);
         String path = getJcrPath(event);
-        String userId = getString(event.getChildOrNull(id), USER_ID);
+        String userId = getString(event.getChild(id), USER_ID);
         long date = getLong(event, DATE, 0);
-        String userData = getString(event.getChildOrNull(id), USER_DATA);
+        String userData = getString(event.getChild(id), USER_DATA);
         return new EventImpl(type, path, userId, id, Collections.emptyMap(), date, userData);
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlManagerImpl.java?rev=1478209&r1=1478208&r2=1478209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlManagerImpl.java
Wed May  1 21:56:29 2013
@@ -532,8 +532,8 @@ public class AccessControlManagerImpl im
         String mixinName = getMixinName(oakPath);
 
         if (accessControlledTree.exists() && isAccessControlled(accessControlledTree,
mixinName)) {
-            Tree aclTree = accessControlledTree.getChildOrNull(aclName);
-            if (aclTree != null) {
+            Tree aclTree = accessControlledTree.getChild(aclName);
+            if (aclTree.exists()) {
                 List<JackrabbitAccessControlEntry> entries = new ArrayList<JackrabbitAccessControlEntry>();
                 for (Tree child : aclTree.getChildren()) {
                     if (isACE(child)) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidator.java?rev=1478209&r1=1478208&r2=1478209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidator.java
Wed May  1 21:56:29 2013
@@ -16,10 +16,14 @@
  */
 package org.apache.jackrabbit.oak.security.authorization;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.jackrabbit.oak.api.CommitFailedException.ACCESS;
+
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
+
 import javax.jcr.security.AccessControlException;
 import javax.jcr.security.Privilege;
 
@@ -36,9 +40,6 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.util.TreeUtil;
 import org.apache.jackrabbit.util.Text;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.apache.jackrabbit.oak.api.CommitFailedException.ACCESS;
-
 /**
  * Validation for access control information changed by regular JCR (and Jackrabbit)
  * access control management API.
@@ -90,7 +91,7 @@ class AccessControlValidator extends Def
 
     @Override
     public Validator childNodeAdded(String name, NodeState after) throws CommitFailedException
{
-        Tree treeAfter = checkNotNull(parentAfter.getChildOrNull(name));
+        Tree treeAfter = checkNotNull(parentAfter.getChild(name));
 
         checkValidTree(parentAfter, treeAfter);
         return new AccessControlValidator(null, treeAfter, privileges, restrictionProvider,
ntMgr);
@@ -98,8 +99,8 @@ class AccessControlValidator extends Def
 
     @Override
     public Validator childNodeChanged(String name, NodeState before, NodeState after) throws
CommitFailedException {
-        Tree treeBefore = checkNotNull(parentBefore.getChildOrNull(name));
-        Tree treeAfter = checkNotNull(parentAfter.getChildOrNull(name));
+        Tree treeBefore = checkNotNull(parentBefore.getChild(name));
+        Tree treeAfter = checkNotNull(parentAfter.getChild(name));
 
         checkValidTree(parentAfter, treeAfter);
         return new AccessControlValidator(treeBefore, treeAfter, privileges, restrictionProvider,
ntMgr);
@@ -173,8 +174,8 @@ class AccessControlValidator extends Def
     }
 
     private void checkValidAccessControlEntry(Tree aceNode) throws CommitFailedException
{
-        Tree parent = aceNode.getParentOrNull();
-        if (parent == null || !NT_REP_ACL.equals(TreeUtil.getPrimaryTypeName(parent))) {
+        Tree parent = aceNode.getParent();
+        if (!parent.exists() || !NT_REP_ACL.equals(TreeUtil.getPrimaryTypeName(parent)))
{
             throw accessViolation(7, "Isolated access control entry at " + aceNode.getPath());
         }
         checkValidPrincipal(TreeUtil.getString(aceNode, REP_PRINCIPAL_NAME));
@@ -208,7 +209,7 @@ class AccessControlValidator extends Def
 
     private void checkValidRestrictions(Tree aceTree) throws CommitFailedException {
         String path;
-        Tree aclTree = checkNotNull(aceTree.getParentOrNull());
+        Tree aclTree = checkNotNull(aceTree.getParent());
         String aclPath = aclTree.getPath();
         if (REP_REPO_POLICY.equals(Text.getName(aclPath))) {
             path = null;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/CompiledPermissionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/CompiledPermissionImpl.java?rev=1478209&r1=1478208&r2=1478209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/CompiledPermissionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/CompiledPermissionImpl.java
Wed May  1 21:56:29 2013
@@ -28,7 +28,6 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
-import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
@@ -92,7 +91,7 @@ class CompiledPermissionImpl implements 
         // test if a permission has been added for those principals that didn't have one
before
         if (trees.size() != principals.size()) {
             for (Principal principal : principals) {
-                if (!trees.containsKey(principal.getName()) && getPrincipalRoot(permissionsTree,
principal) != null) {
+                if (!trees.containsKey(principal.getName()) && getPrincipalRoot(permissionsTree,
principal).exists()) {
                     refresh = true;
                     break;
                 }
@@ -102,8 +101,8 @@ class CompiledPermissionImpl implements 
         if (!refresh) {
             for (Map.Entry<String, ImmutableTree> entry : trees.entrySet()) {
                 ImmutableTree t = entry.getValue();
-                ImmutableTree t2 = permissionsTree.getChildOrNull(t.getName());
-                if (t2 != null && !t.equals(t2)) {
+                ImmutableTree t2 = permissionsTree.getChild(t.getName());
+                if (t2.exists() && !t.equals(t2)) {
                     refresh = true;
                     break;
                 }
@@ -161,9 +160,9 @@ class CompiledPermissionImpl implements 
     }
 
     //------------------------------------------------------------< private >---
-    @CheckForNull
+    @Nonnull
     private static ImmutableTree getPrincipalRoot(ImmutableTree permissionsTree, Principal
principal) {
-        return permissionsTree.getChildOrNull(Text.escapeIllegalJcrChars(principal.getName()));
+        return permissionsTree.getChild(Text.escapeIllegalJcrChars(principal.getName()));
     }
 
     private void buildEntries(@Nonnull ImmutableTree permissionsTree) {
@@ -175,7 +174,7 @@ class CompiledPermissionImpl implements 
             EntriesBuilder builder = new EntriesBuilder();
             for (Principal principal : principals) {
                 ImmutableTree t = getPrincipalRoot(permissionsTree, principal);
-                if (t != null) {
+                if (t.exists()) {
                     trees.put(principal.getName(), t);
                     builder.addEntries(principal, t, restrictionProvider);
                 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidator.java?rev=1478209&r1=1478208&r2=1478209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidator.java
Wed May  1 21:56:29 2013
@@ -16,6 +16,9 @@
  */
 package org.apache.jackrabbit.oak.security.authorization.permission;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.jackrabbit.oak.api.CommitFailedException.ACCESS;
+
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -35,9 +38,6 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
 import org.apache.jackrabbit.oak.util.TreeUtil;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.apache.jackrabbit.oak.api.CommitFailedException.ACCESS;
-
 /**
  * Validator implementation that checks for sufficient permission for all
  * write operations executed by a given content session.
@@ -87,7 +87,7 @@ class PermissionValidator extends Defaul
         if (TreeImpl.OAK_CHILD_ORDER.equals(after.getName())) {
             String childName = new ChildOrderDiff(before, after).firstReordered();
             if (childName != null) {
-                Tree child = parentAfter.getChildOrNull(childName);
+                Tree child = parentAfter.getChild(childName);
                 checkPermissions(child, false, Permissions.MODIFY_CHILD_NODE_COLLECTION);
             } // else: no re-order but only internal update
         } else {
@@ -102,7 +102,7 @@ class PermissionValidator extends Defaul
 
     @Override
     public Validator childNodeAdded(String name, NodeState after) throws CommitFailedException
{
-        Tree child = checkNotNull(parentAfter.getChildOrNull(name));
+        Tree child = checkNotNull(parentAfter.getChild(name));
         if (isVersionstorageTree(child)) {
             child = getVersionHistoryTree(child);
             if (child == null) {
@@ -117,8 +117,8 @@ class PermissionValidator extends Defaul
 
     @Override
     public Validator childNodeChanged(String name, NodeState before, NodeState after) throws
CommitFailedException {
-        Tree childBefore = parentBefore.getChildOrNull(name);
-        Tree childAfter = parentAfter.getChildOrNull(name);
+        Tree childBefore = parentBefore.getChild(name);
+        Tree childAfter = parentAfter.getChild(name);
 
         // TODO
 
@@ -127,7 +127,7 @@ class PermissionValidator extends Defaul
 
     @Override
     public Validator childNodeDeleted(String name, NodeState before) throws CommitFailedException
{
-        Tree child = checkNotNull(parentBefore.getChildOrNull(name));
+        Tree child = checkNotNull(parentBefore.getChild(name));
         if (isVersionstorageTree(child)) {
             // TODO: check again
             throw new CommitFailedException(

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/restriction/RestrictionProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/restriction/RestrictionProviderImpl.java?rev=1478209&r1=1478208&r2=1478209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/restriction/RestrictionProviderImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/restriction/RestrictionProviderImpl.java
Wed May  1 21:56:29 2013
@@ -165,8 +165,8 @@ public class RestrictionProviderImpl imp
 
     @Nonnull
     private Tree getRestrictionsTree(Tree aceTree) {
-        Tree restrictions = aceTree.getChildOrNull(REP_RESTRICTIONS);
-        if (restrictions == null) {
+        Tree restrictions = aceTree.getChild(REP_RESTRICTIONS);
+        if (!restrictions.exists()) {
             // no rep:restrictions tree -> read from aceTree for backwards compatibility
             restrictions = aceTree;
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeBitsProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeBitsProvider.java?rev=1478209&r1=1478208&r2=1478209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeBitsProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeBitsProvider.java
Wed May  1 21:56:29 2013
@@ -91,8 +91,8 @@ public final class PrivilegeBitsProvider
         }
         PrivilegeBits bits = PrivilegeBits.getInstance();
         for (String privilegeName : privilegeNames) {
-            Tree defTree = privilegesTree.getChildOrNull(checkNotNull(privilegeName));
-            if (defTree != null) {
+            Tree defTree = privilegesTree.getChild(checkNotNull(privilegeName));
+            if (defTree.exists()) {
                 bits.add(PrivilegeBits.getInstance(defTree));
             }
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeDefinitionReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeDefinitionReader.java?rev=1478209&r1=1478208&r2=1478209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeDefinitionReader.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeDefinitionReader.java
Wed May  1 21:56:29 2013
@@ -70,7 +70,7 @@ class PrivilegeDefinitionReader implemen
         if (privilegesTree == null) {
             return null;
         } else {
-            Tree definitionTree = privilegesTree.getChildOrNull(privilegeName);
+            Tree definitionTree = privilegesTree.getChild(privilegeName);
             return (isPrivilegeDefinition(definitionTree)) ? readDefinition(definitionTree)
: null;
         }
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProvider.java?rev=1478209&r1=1478208&r2=1478209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProvider.java
Wed May  1 21:56:29 2013
@@ -16,10 +16,14 @@
  */
 package org.apache.jackrabbit.oak.security.user;
 
+import static org.apache.jackrabbit.oak.api.Type.STRINGS;
+import static org.apache.jackrabbit.oak.api.Type.WEAKREFERENCE;
+
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
+
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
@@ -41,9 +45,6 @@ import org.apache.jackrabbit.oak.util.Pr
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.jackrabbit.oak.api.Type.STRINGS;
-import static org.apache.jackrabbit.oak.api.Type.WEAKREFERENCE;
-
 /**
  * {@code MembershipProvider} implementation storing group membership information
  * with the {@code Tree} associated with a given {@link org.apache.jackrabbit.api.security.user.Group}.
@@ -121,8 +122,8 @@ class MembershipProvider extends Authori
     Iterator<String> getMembers(Tree groupTree, AuthorizableType authorizableType,
boolean includeInherited) {
         Iterable memberPaths = Collections.emptySet();
         if (useMemberNode(groupTree)) {
-            Tree membersTree = groupTree.getChildOrNull(REP_MEMBERS);
-            if (membersTree != null) {
+            Tree membersTree = groupTree.getChild(REP_MEMBERS);
+            if (membersTree.exists()) {
                 throw new UnsupportedOperationException("not implemented: retrieve members
from member-node hierarchy");
             }
         } else {
@@ -157,8 +158,8 @@ class MembershipProvider extends Authori
             }
         } else {
             if (useMemberNode(groupTree)) {
-                Tree membersTree = groupTree.getChildOrNull(REP_MEMBERS);
-                if (membersTree != null) {
+                Tree membersTree = groupTree.getChild(REP_MEMBERS);
+                if (membersTree.exists()) {
                     // FIXME: fix.. testing for property name in jr2 wasn't correct.
                     // TODO OAK-482: add implementation
                     throw new UnsupportedOperationException("not implemented: isMembers determined
from member-node hierarchy");
@@ -204,8 +205,8 @@ class MembershipProvider extends Authori
 
     boolean removeMember(Tree groupTree, Tree memberTree) {
         if (useMemberNode(groupTree)) {
-            Tree membersTree = groupTree.getChildOrNull(REP_MEMBERS);
-            if (membersTree != null) {
+            Tree membersTree = groupTree.getChild(REP_MEMBERS);
+            if (membersTree.exists()) {
                 // TODO OAK-482: add implementation
                 throw new UnsupportedOperationException("not implemented: remove member from
member-node hierarchy");
             }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserValidator.java?rev=1478209&r1=1478208&r2=1478209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserValidator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserValidator.java
Wed May  1 21:56:29 2013
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.oak.security.user;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
@@ -35,8 +37,6 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.util.TreeUtil;
 import org.apache.jackrabbit.util.Text;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-
 /**
  * Validator that enforces user management specific constraints. Please note that
  * is this validator is making implementation specific assumptions; if the
@@ -127,7 +127,7 @@ class UserValidator extends DefaultValid
 
     @Override
     public Validator childNodeAdded(String name, NodeState after) throws CommitFailedException
{
-        Tree tree = checkNotNull(parentAfter.getChildOrNull(name));
+        Tree tree = checkNotNull(parentAfter.getChild(name));
 
         AuthorizableType type = UserUtility.getType(tree);
         String authRoot = UserUtility.getAuthorizableRootPath(provider.getConfig(), type);
@@ -145,12 +145,12 @@ class UserValidator extends DefaultValid
     @Override
     public Validator childNodeChanged(String name, NodeState before, NodeState after) throws
CommitFailedException {
         // TODO: anything to do here?
-        return new UserValidator(parentBefore.getChildOrNull(name), parentAfter.getChildOrNull(name),
provider);
+        return new UserValidator(parentBefore.getChild(name), parentAfter.getChild(name),
provider);
     }
 
     @Override
     public Validator childNodeDeleted(String name, NodeState before) throws CommitFailedException
{
-        Tree node = parentBefore.getChildOrNull(name);
+        Tree node = parentBefore.getChild(name);
         if (isAdminUser(node)) {
             String msg = "The admin user cannot be removed.";
             throw constraintViolation(27, msg);
@@ -160,8 +160,8 @@ class UserValidator extends DefaultValid
 
     //------------------------------------------------------------< private >---
 
-    private boolean isAdminUser(@Nullable Tree userTree) {
-        if (userTree != null && isUser(userTree)) {
+    private boolean isAdminUser(@Nonnull Tree userTree) {
+        if (userTree.exists() && isUser(userTree)) {
             String id = UserProvider.getAuthorizableId(userTree);
             return UserUtility.getAdminId(provider.getConfig()).equals(id);
         } else {



Mime
View raw message