jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1420143 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/api/ oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/ oak-core/src/main/java/org/apache/j...
Date Tue, 11 Dec 2012 13:23:09 GMT
Author: mduerig
Date: Tue Dec 11 13:23:04 2012
New Revision: 1420143

URL: http://svn.apache.org/viewvc?rev=1420143&view=rev
Log:
OAK-426: OAK-API: Deal with names and relativePaths consisting/containing "." and ".."
Reverting changes from revision 1418316 and 1418552 as per Angela's request

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/LocationUtil.java
  (with props)
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PathResolver.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/PathResolvers.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/TreeLocation.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.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/identifier/IdentifierManager.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/OakAuthorizableProperties.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/OakAuthorizablePropertyTest.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizablePropertyTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java?rev=1420143&r1=1420142&r2=1420143&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java Tue
Dec 11 13:23:04 2012
@@ -86,13 +86,13 @@ public interface Root {
     Tree getTree(String path);
 
     /**
-     * Get a tree location for from {@code pathResolver}
+     * Get a tree location for a given absolute {@code path}
      *
-     * @param pathResolver for the path to the location
-     * @return the tree location for {@code pathResolver}
+     * @param path absolute path to the location
+     * @return the tree location for {@code path}
      */
     @Nonnull
-    TreeLocation getLocation(PathResolver pathResolver);
+    TreeLocation getLocation(String path);
 
     /**
      * Rebase this root instance to the latest revision. After a call to this method,

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/TreeLocation.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/TreeLocation.java?rev=1420143&r1=1420142&r2=1420143&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/TreeLocation.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/TreeLocation.java
Tue Dec 11 13:23:04 2012
@@ -53,18 +53,8 @@ public interface TreeLocation {
         /**
          * @return  {@code NULL}
          */
-        @Nonnull
         @Override
-        public TreeLocation getChild(String name) {
-            return NULL;
-        }
-
-        /**
-         * @return  {@code NULL}
-         */
-        @Nonnull
-        @Override
-        public TreeLocation getLocation(PathResolver pathResolver) {
+        public TreeLocation getChild(String relPath) {
             return NULL;
         }
 
@@ -109,20 +99,13 @@ public interface TreeLocation {
     TreeLocation getParent();
 
     /**
-     * Retrieve the child location with the given name.
-     * @param name  name of the child
+     * Navigate to a child through a relative path. A relative path consists of a
+     * possibly empty lists of names separated by forward slashes.
+     * @param relPath  relative path to the child
      * @return  a {@code TreeLocation} for a child with the given {@code name}.
      */
     @Nonnull
-    TreeLocation getChild(String name);
-
-    /**
-     * Navigate to a child through a {@code pathResolver}.
-     * @param pathResolver for the path to the location
-     * @return the tree location for {@code pathResolver}
-     */
-    @Nonnull
-    TreeLocation getLocation(PathResolver pathResolver);
+    TreeLocation getChild(String relPath);
 
     /**
      * Get the underlying {@link org.apache.jackrabbit.oak.api.Tree} for this {@code TreeLocation}.

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java?rev=1420143&r1=1420142&r2=1420143&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
Tue Dec 11 13:23:04 2012
@@ -30,7 +30,6 @@ import javax.security.auth.Subject;
 import org.apache.jackrabbit.oak.api.Blob;
 import org.apache.jackrabbit.oak.api.BlobFactory;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
-import org.apache.jackrabbit.oak.api.PathResolver;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.SessionQueryEngine;
 import org.apache.jackrabbit.oak.api.TreeLocation;
@@ -50,6 +49,7 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static org.apache.jackrabbit.oak.commons.PathUtils.getName;
 import static org.apache.jackrabbit.oak.commons.PathUtils.getParentPath;
@@ -128,7 +128,6 @@ public class RootImpl implements Root {
     public Root getLatest() {
         checkLive();
         RootImpl root = new RootImpl(store, null, subject, accConfiguration, indexProvider)
{
-            @Override
             protected void checkLive() {
                 RootImpl.this.checkLive();
             }
@@ -202,9 +201,10 @@ public class RootImpl implements Root {
     }
 
     @Override
-    public TreeLocation getLocation(PathResolver pathResolver) {
+    public TreeLocation getLocation(String path) {
         checkLive();
-        return rootTree.getLocation().getLocation(pathResolver);
+        checkArgument(path.startsWith("/"));
+        return rootTree.getLocation().getChild(path.substring(1));
     }
 
     @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=1420143&r1=1420142&r2=1420143&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
Tue Dec 11 13:23:04 2012
@@ -30,7 +30,6 @@ import com.google.common.base.Function;
 import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Sets;
-import org.apache.jackrabbit.oak.api.PathResolver;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.api.TreeLocation;
@@ -575,38 +574,7 @@ public class TreeImpl implements Tree {
 
     //-------------------------------------------------------< TreeLocation >---
 
-    private abstract static class TreeLocationBase implements TreeLocation {
-
-        @Nonnull
-        @Override
-        public TreeLocation getChild(String name) {
-            return TreeLocation.NULL;
-        }
-
-        @Nonnull
-        @Override
-        public TreeLocation getLocation(PathResolver pathResolver) {
-            TreeLocation cur = this;
-            for (Function<TreeLocation, TreeLocation> element : pathResolver) {
-                cur = element.apply(cur);
-            }
-
-            assert cur != null;
-            return cur;
-        }
-
-        @Override
-        public Tree getTree() {
-            return null;
-        }
-
-        @Override
-        public PropertyState getProperty() {
-            return null;
-        }
-    }
-
-    public class NodeLocation extends TreeLocationBase {
+    public class NodeLocation implements TreeLocation {
         private final TreeImpl tree;
 
         private NodeLocation(TreeImpl tree) {
@@ -620,20 +588,33 @@ public class TreeImpl implements Tree {
                 : new NodeLocation(tree.parent);
         }
 
-        @Nonnull
         @Override
-        public TreeLocation getChild(String name) {
-            TreeImpl child = tree.internalGetChild(name);
-            if (child != null) {
-                return new NodeLocation(child);
+        public TreeLocation getChild(String relPath) {
+            checkArgument(!relPath.startsWith("/"));
+            if (relPath.isEmpty()) {
+                return this;
             }
 
-            PropertyState property = tree.internalGetProperty(name);
-            if (property != null) {
-                return new PropertyLocation(this, name);
+            TreeImpl child = tree;
+            String parentPath = PathUtils.getParentPath(relPath);
+            for (String name : PathUtils.elements(parentPath)) {
+                child = child.internalGetChild(name);
+                if (child == null) {
+                    return TreeLocation.NULL;
+                }
             }
 
-            return TreeLocation.NULL;
+            String name = PathUtils.getName(relPath);
+            PropertyState property = child.internalGetProperty(name);
+            if (property != null) {
+                return new PropertyLocation(new NodeLocation(child), name);
+            }
+            else {
+                child = child.internalGetChild(name);
+                return child == null
+                    ? TreeLocation.NULL
+                    : new NodeLocation(child);
+            }
         }
 
         @Override
@@ -647,12 +628,17 @@ public class TreeImpl implements Tree {
         }
 
         @Override
+        public PropertyState getProperty() {
+            return null;
+        }
+
+        @Override
         public Status getStatus() {
             return tree.getStatus();
         }
     }
 
-    public class PropertyLocation extends TreeLocationBase {
+    public class PropertyLocation implements TreeLocation {
         private final NodeLocation parent;
         private final String name;
 
@@ -667,11 +653,21 @@ public class TreeImpl implements Tree {
         }
 
         @Override
+        public TreeLocation getChild(String relPath) {
+            return TreeLocation.NULL;
+        }
+
+        @Override
         public String getPath() {
             return PathUtils.concat(parent.getPath(), name);
         }
 
         @Override
+        public Tree getTree() {
+            return null;
+        }
+
+        @Override
         public PropertyState getProperty() {
             PropertyState property = parent.tree.internalGetProperty(name);
             return canRead(property)

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java?rev=1420143&r1=1420142&r2=1420143&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java
Tue Dec 11 13:23:04 2012
@@ -51,7 +51,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static org.apache.jackrabbit.oak.api.Type.STRING;
-import static org.apache.jackrabbit.oak.namepath.PathResolvers.identity;
 
 /**
  * IdentifierManager...
@@ -237,7 +236,7 @@ public class IdentifierManager {
     }
 
     private String findProperty(String path, final String uuid) {
-        TreeLocation loc = root.getLocation(identity(path));
+        TreeLocation loc = root.getLocation(path);
         Tree tree = loc.getTree();
         assert tree != null;
         final PropertyState refProp = Iterables.find(tree.getProperties(), new Predicate<PropertyState>()
{

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/OakAuthorizableProperties.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/OakAuthorizableProperties.java?rev=1420143&r1=1420142&r2=1420143&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/OakAuthorizableProperties.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/OakAuthorizableProperties.java
Tue Dec 11 13:23:04 2012
@@ -20,7 +20,6 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
-
 import javax.annotation.Nonnull;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
@@ -34,19 +33,17 @@ import org.apache.jackrabbit.oak.api.Pro
 import org.apache.jackrabbit.oak.api.Root;
 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.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 import org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager;
 import org.apache.jackrabbit.oak.plugins.value.ValueFactoryImpl;
 import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
+import org.apache.jackrabbit.oak.util.LocationUtil;
 import org.apache.jackrabbit.oak.util.NodeUtil;
 import org.apache.jackrabbit.util.Text;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.jackrabbit.oak.namepath.PathResolvers.dotResolver;
-
 /**
  * Oak level implementation of the internal {@code AuthorizableProperties} that
  * is used in those cases where no {@code Session} is associated with the
@@ -195,7 +192,7 @@ class OakAuthorizableProperties implemen
         checkRelativePath(relPath);
 
         Tree node = getTree();
-        TreeLocation propertyLocation = node.getLocation().getLocation(dotResolver(relPath));
+        TreeLocation propertyLocation = node.getLocation().getChild(relPath);
         PropertyState property = propertyLocation.getProperty();
         if (property != null) {
             if (isAuthorizableProperty(node, propertyLocation, true)) {
@@ -300,14 +297,14 @@ class OakAuthorizableProperties implemen
 
     @Nonnull
     private static TreeLocation getLocation(Tree tree, String relativePath) {
-        return tree.getLocation().getLocation(dotResolver(relativePath));
+        return LocationUtil.getTreeLocation(tree.getLocation(), relativePath);
     }
 
     private static void checkRelativePath(String relativePath) throws RepositoryException
{
         if (relativePath == null) {
             throw new RepositoryException("Relative path expected. Found null.");
         }
-        if (PathUtils.isAbsolute(relativePath)) {
+        if ('/' == relativePath.charAt(0)) {
             throw new RepositoryException("Relative path expected. Found " + relativePath);
         }
     }

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/LocationUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/LocationUtil.java?rev=1420143&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/LocationUtil.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/LocationUtil.java
Tue Dec 11 13:23:04 2012
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.util;
+
+import javax.annotation.Nonnull;
+
+import org.apache.jackrabbit.oak.api.TreeLocation;
+import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.util.Text;
+
+/**
+ * LocationUtil... FIXME: workaround for OAK-426
+ */
+public class LocationUtil {
+
+    @Nonnull
+    public static TreeLocation getTreeLocation(TreeLocation parentLocation, String relativePath)
{
+        TreeLocation targetLocation = parentLocation;
+        String[] segments = Text.explode(relativePath, '/', false);
+        for (int i = 0; i < segments.length && targetLocation != TreeLocation.NULL;
i++) {
+            String segment = segments[i];
+            if (PathUtils.denotesCurrent(segment)) {
+                continue;
+            } else if (PathUtils.denotesParent(segment)) {
+                targetLocation = targetLocation.getParent();
+            } else {
+                targetLocation = targetLocation.getChild(segment);
+            }
+        }
+        return targetLocation;
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/LocationUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/LocationUtil.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java?rev=1420143&r1=1420142&r2=1420143&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java
Tue Dec 11 13:23:04 2012
@@ -20,7 +20,6 @@ import java.util.Arrays;
 import java.util.Calendar;
 import java.util.GregorianCalendar;
 import java.util.List;
-
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.jcr.RepositoryException;
@@ -51,7 +50,6 @@ import static org.apache.jackrabbit.oak.
 import static org.apache.jackrabbit.oak.api.Type.NAMES;
 import static org.apache.jackrabbit.oak.api.Type.STRING;
 import static org.apache.jackrabbit.oak.api.Type.STRINGS;
-import static org.apache.jackrabbit.oak.namepath.PathResolvers.dotResolver;
 
 /**
  * Utility class for accessing and writing typed content of a tree.
@@ -122,7 +120,7 @@ public class NodeUtil {
     }
 
     /**
-     * FIXME: this might add a node at a parent where a property of the same name already
exists.
+     * FIXME: workaround for OAK-426
      * FIXME: does probably no work as intended
      * rootNode.getOrAddTree("a/b/../../c/d/../../e/f", "");
      * adds the three sub trees /a/b, /c/d and /e/f.
@@ -132,7 +130,7 @@ public class NodeUtil {
         if (relativePath.indexOf('/') == -1) {
             return getOrAddChild(relativePath, primaryTypeName);
         } else {
-            TreeLocation location = tree.getLocation().getLocation(dotResolver(relativePath));
+            TreeLocation location = LocationUtil.getTreeLocation(tree.getLocation(), relativePath);
             if (location.getTree() == null) {
                 NodeUtil target = this;
                 for (String segment : Text.explode(relativePath, '/')) {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/OakAuthorizablePropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/OakAuthorizablePropertyTest.java?rev=1420143&r1=1420142&r2=1420143&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/OakAuthorizablePropertyTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/OakAuthorizablePropertyTest.java
Tue Dec 11 13:23:04 2012
@@ -59,7 +59,6 @@ public class OakAuthorizablePropertyTest
     private Map<String, Boolean> protectedUserProps = new HashMap<String, Boolean>();
     private Map<String, Boolean> protectedGroupProps = new HashMap<String, Boolean>();
     
-    @Override
     @Before
     public void before() throws Exception {
         super.before();
@@ -79,7 +78,6 @@ public class OakAuthorizablePropertyTest
         protectedGroupProps.put(UserConstants.REP_PRINCIPAL_NAME, false);
     }
 
-    @Override
     @After
     public void after() throws Exception {
         try {
@@ -334,8 +332,8 @@ public class OakAuthorizablePropertyTest
     @Test
     public void testGetPropertyNamesByInvalidRelPath() throws Exception {
         List<String> invalidPaths = new ArrayList<String>();
-//        invalidPaths.add("../");     // FIXME: these paths are valid on JR2
-//        invalidPaths.add("../../");
+        invalidPaths.add("../");
+        invalidPaths.add("../../");
         invalidPaths.add("../testing");
         invalidPaths.add("/testing");
         invalidPaths.add(null);

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=1420143&r1=1420142&r2=1420143&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 Dec 11 13:23:04 2012
@@ -36,8 +36,6 @@ import org.apache.jackrabbit.oak.api.Tre
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 
-import static org.apache.jackrabbit.oak.namepath.PathResolvers.dotResolver;
-
 /**
  * {@code NodeDelegate} serve as internal representations of {@code Node}s.
  * Most methods of this class throw an {@code InvalidItemStateException}
@@ -249,7 +247,15 @@ public class NodeDelegate extends ItemDe
             throw new RepositoryException("Not a relative path: " + relPath);
         }
 
-        return getLocation().getLocation(dotResolver(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/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java?rev=1420143&r1=1420142&r2=1420143&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
Tue Dec 11 13:23:04 2012
@@ -19,7 +19,6 @@ package org.apache.jackrabbit.oak.jcr;
 import java.io.IOException;
 import java.util.Map;
 import java.util.concurrent.ScheduledExecutorService;
-
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.jcr.ItemExistsException;
@@ -55,15 +54,14 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.nodetype.DefinitionProvider;
 import org.apache.jackrabbit.oak.plugins.nodetype.EffectiveNodeTypeProvider;
 import org.apache.jackrabbit.oak.plugins.observation.ObservationManagerImpl;
-import org.apache.jackrabbit.oak.plugins.value.ValueFactoryImpl;
 import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
+import org.apache.jackrabbit.oak.plugins.value.ValueFactoryImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.Maps;
 
 import static com.google.common.base.Preconditions.checkNotNull;
-import static org.apache.jackrabbit.oak.namepath.PathResolvers.dotResolver;
 
 public class SessionDelegate {
     static final Logger log = LoggerFactory.getLogger(SessionDelegate.class);
@@ -231,7 +229,7 @@ public class SessionDelegate {
      * none exists or not accessible.
      */
     public PropertyDelegate getProperty(String path) {
-        TreeLocation location = getLocation(path);
+        TreeLocation location = root.getLocation(path);
         return location.getProperty() == null
             ? null
             : new PropertyDelegate(this, location);
@@ -499,7 +497,7 @@ public class SessionDelegate {
 
     @Nonnull
     TreeLocation getLocation(String path) {
-        return root.getLocation(dotResolver(path));
+        return root.getLocation(path);
     }
 
     @Nonnull

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizablePropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizablePropertyTest.java?rev=1420143&r1=1420142&r2=1420143&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizablePropertyTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizablePropertyTest.java
Tue Dec 11 13:23:04 2012
@@ -315,8 +315,8 @@ public class AuthorizablePropertyTest ex
     @Test
     public void testGetPropertyNamesByInvalidRelPath() throws NotExecutableException, RepositoryException
{
         List<String> invalidPaths = new ArrayList<String>();
-//        invalidPaths.add("../");  // FIXME: these paths are valid on JR2
-//        invalidPaths.add("../../");
+        invalidPaths.add("../");
+        invalidPaths.add("../../");
         invalidPaths.add("../testing");
         invalidPaths.add("/testing");
         invalidPaths.add(null);



Mime
View raw message