jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1411900 - in /jackrabbit/oak/trunk/oak-jcr: pom.xml src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Date Tue, 20 Nov 2012 21:55:18 GMT
Author: mduerig
Date: Tue Nov 20 21:55:17 2012
New Revision: 1411900

URL: http://svn.apache.org/viewvc?rev=1411900&view=rev
Log:
OAK-369: missing support for relative path consisting of parent-element

Modified:
    jackrabbit/oak/trunk/oak-jcr/pom.xml
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1411900&r1=1411899&r2=1411900&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Tue Nov 20 21:55:17 2012
@@ -258,7 +258,7 @@
       org.apache.jackrabbit.oak.jcr.security.user.GroupTest#testInheritedMembers        
                <!-- OAK-343 -->
       org.apache.jackrabbit.oak.jcr.security.user.GroupTest#testCyclicGroups            
                <!-- OAK-343 -->
       org.apache.jackrabbit.oak.jcr.security.user.AuthorizableTest#testRemoveListedAuthorizable
         <!-- OAK-343 -->
-      org.apache.jackrabbit.oak.jcr.security.user.AuthorizablePropertyTest#testSetPropertyInvalidRelativePath
   <!-- OAK-369 -->
+      org.apache.jackrabbit.oak.jcr.security.user.AuthorizablePropertyTest#testSetPropertyInvalidRelativePath
       org.apache.jackrabbit.oak.jcr.security.principal.PrincipalManagerTest#testGetPrincipals
           <!-- principal search missing -->
       org.apache.jackrabbit.oak.jcr.security.principal.PrincipalManagerTest#testGetGroupPrincipals
      <!-- principal search missing -->
       org.apache.jackrabbit.oak.jcr.security.principal.PrincipalManagerTest#testGetAllPrincipals
        <!-- principal search missing -->

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java?rev=1411900&r1=1411899&r2=1411900&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
Tue Nov 20 21:55:17 2012
@@ -33,6 +33,7 @@ import com.google.common.collect.Iterato
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.api.TreeLocation;
+import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 
 /**
@@ -93,7 +94,7 @@ public class NodeDelegate extends ItemDe
      * no such property exists
      */
     @CheckForNull
-    public PropertyDelegate getProperty(String relPath) throws InvalidItemStateException
{
+    public PropertyDelegate getProperty(String relPath) throws RepositoryException {
         TreeLocation propertyLocation = getChildLocation(relPath);
         PropertyState propertyState = propertyLocation.getProperty();
         return propertyState == null
@@ -126,7 +127,7 @@ public class NodeDelegate extends ItemDe
      * no such node exists
      */
     @CheckForNull
-    public NodeDelegate getChild(String relPath) throws InvalidItemStateException {
+    public NodeDelegate getChild(String relPath) throws RepositoryException {
         return create(sessionDelegate, getChildLocation(relPath));
     }
 
@@ -241,8 +242,20 @@ public class NodeDelegate extends ItemDe
 
     // -----------------------------------------------------------< private >---
 
-    private TreeLocation getChildLocation(String relPath) throws InvalidItemStateException
{
-        return getLocation().getChild(relPath);
+    private TreeLocation getChildLocation(String relPath) throws RepositoryException {
+        if (PathUtils.isAbsolute(relPath)) {
+            throw new RepositoryException("Not a relative path: " + relPath);
+        }
+
+        TreeLocation loc = getLocation();
+        for (String element : PathUtils.elements(relPath)) {
+            if (PathUtils.denotesParent(element)) {
+                loc = loc.getParent();
+            } else if (!PathUtils.denotesCurrent(element)) {
+                loc = loc.getChild(element);
+            }  // else . -> skip to next element
+        }
+        return loc;
     }
 
     private Iterator<NodeDelegate> nodeDelegateIterator(

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java?rev=1411900&r1=1411899&r2=1411900&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Tue Nov 20 21:55:17 2012
@@ -185,12 +185,16 @@ public class RepositoryTest extends Abst
 
     @Test
     public void hasPropertyDot() throws RepositoryException {
+        Node root = getNode("/");
+        assertFalse((root.hasProperty(".")));
         Node node = getNode("/foo");
         assertFalse((node.hasProperty(".")));
     }
 
     @Test
     public void hasPropertyDotDot() throws RepositoryException {
+        Node root = getNode("/");
+        assertFalse((root.hasProperty("..")));
         Node node = getNode("/foo");
         assertFalse((node.hasProperty("..")));
     }
@@ -204,7 +208,6 @@ public class RepositoryTest extends Abst
         assertTrue(same.isSame(node));
     }
 
-    @Ignore("OAK-369") // FIXME: OAK-369
     @Test
     public void getNodeDotDot() throws RepositoryException {
         Node node = getNode("/foo");
@@ -214,6 +217,13 @@ public class RepositoryTest extends Abst
         assertTrue(root.isSame(node.getParent()));
     }
 
+    @Test(expected = PathNotFoundException.class)
+    public void getRootGetDotDot() throws RepositoryException {
+        Node root = getNode("/");
+        assertNotNull(root);
+        root.getNode("..");
+    }
+
     @Test
     public void hasNodeDot() throws RepositoryException {
         Node root = getNode("/");
@@ -222,16 +232,14 @@ public class RepositoryTest extends Abst
         assertTrue(node.hasNode("."));
     }
 
-    @Ignore("OAK-369")
     @Test
     public void hasNodeDotDot() throws RepositoryException {
         Node root = getNode("/");
         assertFalse(root.hasNode(".."));
         Node node = getNode("/foo");
-        assertTrue(node.hasNode(".."));  // FIXME OAK-369
+        assertTrue(node.hasNode(".."));
     }
 
-    @Ignore("OAK-369") // FIXME: OAK-369
     @Test(expected = ItemExistsException.class)
     public void testAddNodeDot() throws RepositoryException {
         Node node = getNode("/foo");
@@ -253,6 +261,12 @@ public class RepositoryTest extends Abst
         assertEquals("/foo", node.getPath());
     }
 
+    @Test(expected = RepositoryException.class)
+    public void getNodeAbsolutePath() throws RepositoryException {
+        Node root = getNode("/");
+        root.getNode("/foo");
+    }
+
     @Test
     public void getNodeByIdentifier() throws RepositoryException {
         Node node = getNode("/foo");



Mime
View raw message