jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1475819 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/core/ test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/
Date Thu, 25 Apr 2013 15:12:58 GMT
Author: mduerig
Date: Thu Apr 25 15:12:57 2013
New Revision: 1475819

URL: http://svn.apache.org/r1475819
Log:
OAK-766: TreeImpl#*Location: unable retrieve child location if access to parent is denied
tentative fix

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

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=1475819&r1=1475818&r2=1475819&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
Thu Apr 25 15:12:57 2013
@@ -57,15 +57,15 @@ abstract class AbstractNodeLocation<T ex
 
     @Override
     public TreeLocation getChild(String name) {
-        T child = getChildTree(name);
-        if (child != null) {
-            return createNodeLocation(child);
-        }
-
         PropertyState prop = getPropertyState(name);
         if (prop != null) {
             return createPropertyLocation(this, name);
         }
+
+        T child = getChildTree(name);
+        if (child != null) {
+            return createNodeLocation(child);
+        }
         return new NullLocation(this, name);
     }
 

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=1475819&r1=1475818&r2=1475819&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
Thu Apr 25 15:12:57 2013
@@ -91,7 +91,7 @@ public class TreeImpl implements Tree {
         this.root = checkNotNull(root);
         this.parent = checkNotNull(parent);
         this.name = checkNotNull(name);
-        this.nodeBuilder = parent.nodeBuilder.child(name);
+        this.nodeBuilder = parent.nodeBuilder.getChildNode(name);
         this.pendingMoves = checkNotNull(pendingMoves);
     }
 
@@ -187,11 +187,7 @@ public class TreeImpl implements Tree {
         checkNotNull(name);
         enter();
         TreeImpl child = internalGetChild(name);
-        if (child != null && canRead(child)) {
-            return child;
-        } else {
-            return null;
-        }
+        return canRead(child) ? child : null;
     }
 
     @Override
@@ -438,11 +434,8 @@ public class TreeImpl implements Tree {
         TreeImpl child = this;
         for (String name : elements(path)) {
             child = child.internalGetChild(name);
-            if (child == null) {
-                return null;
-            }
         }
-        return (canRead(child)) ? child : null;
+        return canRead(child) ? child : null;
     }
 
     /**
@@ -526,9 +519,7 @@ public class TreeImpl implements Tree {
     }
 
     private TreeImpl internalGetChild(String childName) {
-        return nodeBuilder.hasChildNode(childName)
-            ? new TreeImpl(root, this, childName, pendingMoves)
-            : null;
+        return new TreeImpl(root, this, childName, pendingMoves);
     }
 
     private PropertyState internalGetProperty(String propertyName) {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/RootTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/RootTest.java?rev=1475819&r1=1475818&r2=1475819&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/RootTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/RootTest.java
Thu Apr 25 15:12:57 2013
@@ -16,6 +16,9 @@
  */
 package org.apache.jackrabbit.oak.security.authorization.evaluation;
 
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
 import java.util.List;
 
 import com.google.common.collect.ImmutableList;
@@ -24,12 +27,8 @@ import org.apache.jackrabbit.oak.api.Roo
 import org.apache.jackrabbit.oak.api.TreeLocation;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConstants;
-import org.junit.Ignore;
 import org.junit.Test;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
 /**
  * Testing {@link Root} with access control restrictions in place.
  */
@@ -53,7 +52,6 @@ public class RootTest extends AbstractOa
         assertNull(testRoot.getTree("/a/bb"));
     }
 
-    @Ignore("OAK-766") // FIXME
     @Test
     public void testGetTree2() throws Exception {
         setupPermission("/a", testPrincipal, true, PrivilegeConstants.JCR_READ);
@@ -93,7 +91,6 @@ public class RootTest extends AbstractOa
         assertNull(location.getTree());
     }
 
-    @Ignore("OAK-766") // FIXME
     @Test
     public void testGetNodeLocation2() throws Exception {
         setupPermission("/a", testPrincipal, true, PrivilegeConstants.REP_READ_NODES);
@@ -154,7 +151,6 @@ public class RootTest extends AbstractOa
         }
     }
 
-    @Ignore("OAK-766") // FIXME
     @Test
     public void testGetPropertyLocation2() throws Exception {
         setupPermission("/", testPrincipal, true, PrivilegeConstants.REP_READ_PROPERTIES);
@@ -177,7 +173,6 @@ public class RootTest extends AbstractOa
         }
     }
 
-    @Ignore("OAK-766") // FIXME
     @Test
     public void testGetPropertyLocation3() throws Exception {
         setupPermission("/a", testPrincipal, true, PrivilegeConstants.REP_READ_PROPERTIES);



Mime
View raw message