jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1502475 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: core/AbstractTree.java core/ImmutableTree.java core/MutableTree.java security/authorization/AccessControlValidator.java
Date Fri, 12 Jul 2013 08:43:59 GMT
Author: mduerig
Date: Fri Jul 12 08:43:59 2013
New Revision: 1502475

URL: http://svn.apache.org/r1502475
Log:
OAK-798: Review / refactor TreeImpl and related classes
Always hide internal properties

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractTree.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/MutableTree.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidator.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractTree.java?rev=1502475&r1=1502474&r2=1502475&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractTree.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractTree.java
Fri Jul 12 08:43:59 2013
@@ -48,7 +48,7 @@ import org.apache.jackrabbit.oak.spi.sta
  * {@code AbstractTree} provides default implementations for most
  * read methods of {@code Tree}. Furthermore it handles the
  * {@link #setOrderableChildren(boolean) ordering} of child nodes
- * and controls visibility of internal items.
+ * and hides internal items.
  */
 public abstract class AbstractTree implements Tree {
 
@@ -61,11 +61,6 @@ public abstract class AbstractTree imple
     private static final String[] INTERNAL_NODE_NAMES = {IndexConstants.INDEX_CONTENT_NODE_NAME,
MicroKernel.CONFLICT_NAME};
 
     /**
-     * Flag to control visibility of internal properties
-     */
-    private final boolean showInternalProperties;
-
-    /**
      * Name of this tree
      */
     protected String name;
@@ -79,12 +74,10 @@ public abstract class AbstractTree imple
      * Create a new {@code AbstractTree} instance
      * @param name  name of the tree
      * @param nodeBuilder  {@code NodeBuilder} for the underlying node state
-     * @param showInternalProperties  whether to show internal properties
      */
-    protected AbstractTree(@Nonnull String name, @Nonnull NodeBuilder nodeBuilder, boolean
showInternalProperties) {
+    protected AbstractTree(@Nonnull String name, @Nonnull NodeBuilder nodeBuilder) {
         this.name = checkNotNull(name);
         this.nodeBuilder = checkNotNull(nodeBuilder);
-        this.showInternalProperties = showInternalProperties;
     }
 
     /**
@@ -192,14 +185,14 @@ public abstract class AbstractTree imple
 
     @Override
     public PropertyState getProperty(String name) {
-        return showInternalProperties || !isHidden(checkNotNull(name))
+        return !isHidden(checkNotNull(name))
             ? nodeBuilder.getProperty(name)
             : null;
     }
 
     @Override
     public boolean hasProperty(String name) {
-        return (showInternalProperties || !isHidden(checkNotNull(name))) && nodeBuilder.hasProperty(name);
+        return (!isHidden(checkNotNull(name))) && nodeBuilder.hasProperty(name);
     }
 
     @Override
@@ -213,7 +206,7 @@ public abstract class AbstractTree imple
             new Predicate<PropertyState>() {
                 @Override
                 public boolean apply(PropertyState propertyState) {
-                    return showInternalProperties || !isHidden(propertyState.getName());
+                    return !isHidden(propertyState.getName());
                 }
             });
     }

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=1502475&r1=1502474&r2=1502475&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
Fri Jul 12 08:43:59 2013
@@ -118,7 +118,7 @@ public final class ImmutableTree extends
 
     public ImmutableTree(@Nonnull ParentProvider parentProvider, @Nonnull String name,
                          @Nonnull NodeState state, @Nonnull TreeTypeProvider typeProvider)
{
-        super(name, new ReadOnlyBuilder(state), true);
+        super(name, new ReadOnlyBuilder(state));
         this.state = state;
         this.parentProvider = checkNotNull(parentProvider);
         this.typeProvider = checkNotNull(typeProvider);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java?rev=1502475&r1=1502474&r2=1502475&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
Fri Jul 12 08:43:59 2013
@@ -66,13 +66,13 @@ public class MutableTree extends Abstrac
     private Move pendingMoves;
 
     MutableTree(RootImpl root, NodeBuilder builder, Move pendingMoves) {
-        super("", builder, false);
+        super("", builder);
         this.root = checkNotNull(root);
         this.pendingMoves = checkNotNull(pendingMoves);
     }
 
     private MutableTree(RootImpl root, MutableTree parent, String name, Move pendingMoves)
{
-        super(name, parent.nodeBuilder.getChildNode(name), false);
+        super(name, parent.nodeBuilder.getChildNode(name));
         this.root = checkNotNull(root);
         this.parent = checkNotNull(parent);
         this.pendingMoves = checkNotNull(pendingMoves);

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=1502475&r1=1502474&r2=1502475&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
Fri Jul 12 08:43:59 2013
@@ -94,7 +94,7 @@ class AccessControlValidator extends Def
     public Validator childNodeAdded(String name, NodeState after) throws CommitFailedException
{
         Tree treeAfter = checkNotNull(parentAfter.getChild(name));
 
-        checkValidTree(parentAfter, treeAfter);
+        checkValidTree(parentAfter, treeAfter, after);
         return new AccessControlValidator(null, treeAfter, privileges, restrictionProvider,
ntMgr);
     }
 
@@ -103,7 +103,7 @@ class AccessControlValidator extends Def
         Tree treeBefore = checkNotNull(parentBefore.getChild(name));
         Tree treeAfter = checkNotNull(parentAfter.getChild(name));
 
-        checkValidTree(parentAfter, treeAfter);
+        checkValidTree(parentAfter, treeAfter, after);
         return new AccessControlValidator(treeBefore, treeAfter, privileges, restrictionProvider,
ntMgr);
     }
 
@@ -115,9 +115,9 @@ class AccessControlValidator extends Def
 
     //------------------------------------------------------------< private >---
 
-    private void checkValidTree(Tree parentAfter, Tree treeAfter) throws CommitFailedException
{
+    private void checkValidTree(Tree parentAfter, Tree treeAfter, NodeState nodeAfter) throws
CommitFailedException {
         if (isPolicy(treeAfter)) {
-            checkValidPolicy(parentAfter, treeAfter);
+            checkValidPolicy(parentAfter, treeAfter, nodeAfter);
         } else if (isAccessControlEntry(treeAfter)) {
             checkValidAccessControlEntry(treeAfter);
         } else if (NT_REP_RESTRICTIONS.equals(TreeUtil.getPrimaryTypeName(treeAfter))) {
@@ -141,8 +141,8 @@ class AccessControlValidator extends Def
         }
     }
 
-    private void checkValidPolicy(Tree parent, Tree policyNode) throws CommitFailedException
{
-        String mixinType = (REP_REPO_POLICY.equals(policyNode.getName())) ?
+    private void checkValidPolicy(Tree parent, Tree policyTree, NodeState policyNode) throws
CommitFailedException {
+        String mixinType = (REP_REPO_POLICY.equals(policyTree.getName())) ?
                 MIX_REP_REPO_ACCESS_CONTROLLABLE :
                 MIX_REP_ACCESS_CONTROLLABLE;
         checkValidAccessControlledNode(parent, mixinType);
@@ -150,8 +150,8 @@ class AccessControlValidator extends Def
         Collection<String> validPolicyNames = (parent.isRoot()) ?
                 POLICY_NODE_NAMES :
                 Collections.singleton(REP_POLICY);
-        if (!validPolicyNames.contains(policyNode.getName())) {
-            throw accessViolation(3, "Invalid policy name " + policyNode.getName());
+        if (!validPolicyNames.contains(policyTree.getName())) {
+            throw accessViolation(3, "Invalid policy name " + policyTree.getName());
         }
 
         if (!policyNode.hasProperty(AbstractTree.OAK_CHILD_ORDER)) {



Mime
View raw message