jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1565319 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/core/ main/java/org/apache/jackrabbit/oak/plugins/tree/ test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/
Date Thu, 06 Feb 2014 16:12:06 GMT
Author: angela
Date: Thu Feb  6 16:12:05 2014
New Revision: 1565319

URL: http://svn.apache.org/r1565319
Log:
OAK-842 : Incorrect interaction of orderable child nodes with permission evaluation

Modified:
    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/plugins/tree/AbstractTree.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/TreeTest.java

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=1565319&r1=1565318&r2=1565319&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
Thu Feb  6 16:12:05 2014
@@ -44,7 +44,6 @@ import static com.google.common.collect.
 import static org.apache.jackrabbit.oak.api.Type.NAME;
 import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
 import static org.apache.jackrabbit.oak.commons.PathUtils.isAbsolute;
-import static org.apache.jackrabbit.oak.spi.state.NodeStateUtils.isHidden;
 
 class MutableTree extends AbstractTree {
 
@@ -104,7 +103,7 @@ class MutableTree extends AbstractTree {
     @Override
     public boolean exists() {
         beforeRead();
-        return isVisible();
+        return internalExists();
     }
 
     @Override
@@ -174,7 +173,6 @@ class MutableTree extends AbstractTree {
         if (parent != null && parent.hasChild(name)) {
             nodeBuilder.remove();
             if (parent.hasOrderableChildren()) {
-                // FIXME (OAK-842) child order not updated when parent is not accessible
                 parent.nodeBuilder.setProperty(
                         PropertyBuilder.copy(NAME, parent.nodeBuilder.getProperty(TreeConstants.OAK_CHILD_ORDER))
                                 .removeValue(name)
@@ -425,21 +423,11 @@ class MutableTree extends AbstractTree {
      */
     private void beforeWrite() throws IllegalStateException {
         beforeRead();
-        if (!isVisible()) {
+        if (!internalExists()) {
             throw new IllegalStateException("This tree does not exist");
         }
     }
 
-    /**
-     * Internal method for checking whether this node exists and is visible
-     * (i.e. not hidden).
-     *
-     * @return {@code true} if the node is visible, {@code false} if not
-     */
-    private boolean isVisible() {
-        return !isHidden(name) && nodeBuilder.exists();
-    }
-
     private boolean applyPendingMoves() {
         boolean movesApplied = false;
         if (parent != null) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/tree/AbstractTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/tree/AbstractTree.java?rev=1565319&r1=1565318&r2=1565319&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/tree/AbstractTree.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/tree/AbstractTree.java
Thu Feb  6 16:12:05 2014
@@ -153,6 +153,10 @@ public abstract class AbstractTree imple
         }
     }
 
+    protected boolean internalExists() {
+        return !isHidden(name) && nodeBuilder.exists();
+    }
+
     //---------------------------------------------------------------< Tree >---
 
     @Override
@@ -196,7 +200,7 @@ public abstract class AbstractTree imple
 
     @Override
     public boolean exists() {
-        return !isHidden(name) && nodeBuilder.exists();
+        return internalExists();
     }
 
     @Override
@@ -270,18 +274,18 @@ public abstract class AbstractTree imple
 
     @Override
     public Iterable<Tree> getChildren() {
-        return transform(
-                filter(getChildNames(), new Predicate<String>() {
-                    @Override
-                    public boolean apply(String name) {
-                        return !isHidden(name);
-                    }
-                }),
+        Iterable<Tree> children = transform(getChildNames(),
                 new Function<String, Tree>() {
                     @Override
                     public Tree apply(String name) {
                         return createChild(name);
                     }
                 });
+        return filter(children, new Predicate<Tree>() {
+            @Override
+            public boolean apply(Tree child) {
+                return ((AbstractTree) child).internalExists();
+            }
+        });
     }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/TreeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/TreeTest.java?rev=1565319&r1=1565318&r2=1565319&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/TreeTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/TreeTest.java
Thu Feb  6 16:12:05 2014
@@ -32,6 +32,7 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 public class TreeTest extends AbstractOakCoreTest {
 
@@ -110,6 +111,31 @@ public class TreeTest extends AbstractOa
     }
 
     @Test
+    public void testGetChildren() throws Exception {
+        for (Tree t : testRoot.getTree("/a").getChildren()) {
+            if (!"b".equals(t.getName())) {
+                fail("Child " + t.getName() + " should not be accessible.");
+            }
+        }
+    }
+
+    /**
+     * @see <a href="https://issues.apache.org/jira/browse/OAK-842">OAK-842</a>
+     */
+    @Test
+    public void testOrderableChildren() throws Exception {
+        Tree a = root.getTree("/a");
+        a.setOrderableChildren(true);
+
+        testRoot.refresh();
+        for (Tree t : testRoot.getTree("/a").getChildren()) {
+            if (!"b".equals(t.getName())) {
+                fail("Child " + t.getName() + " should not be accessible.");
+            }
+        }
+    }
+
+    @Test
     public void testHasProperty() throws Exception {
         // TODO
     }



Mime
View raw message