jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1418316 - 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 Fri, 07 Dec 2012 14:03:34 GMT
Author: mduerig
Date: Fri Dec  7 14:03:31 2012
New Revision: 1418316

URL: http://svn.apache.org/viewvc?rev=1418316&view=rev
Log:
OAK-426: OAK-API: Deal with names and relativePaths consisting/containing "." and ".."
- Introduce PathResolver for TreeLocation

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PathResolver.java
  (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/PathResolvers.java
  (with props)
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/LocationUtil.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/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

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PathResolver.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PathResolver.java?rev=1418316&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PathResolver.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PathResolver.java
Fri Dec  7 14:03:31 2012
@@ -0,0 +1,33 @@
+/*
+ * 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.api;
+
+import com.google.common.base.Function;
+
+/**
+ * A path resolver is responsible for resolving {@link TreeLocation}s for the elements
+ * in a path given its respective parent tree location.
+ * <p/>
+ * Each element in the iterator corresponds to an element of a path from the root
+ * to leaf. Each element is a {@link Function} mapping from the current tree location
+ * to the next one. The particulars of the mapping is determined on how implementations
+ * of this interface interpret the corresponding path element.
+ */
+public interface PathResolver extends Iterable<Function<TreeLocation, TreeLocation>>
{ }

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

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

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=1418316&r1=1418315&r2=1418316&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 Fri
Dec  7 14:03:31 2012
@@ -86,13 +86,13 @@ public interface Root {
     Tree getTree(String path);
 
     /**
-     * Get a tree location for a given absolute {@code path}
+     * Get a tree location for from {@code pathResolver}
      *
-     * @param path absolute path to the location
-     * @return the tree location for {@code path}
+     * @param pathResolver for the path to the location
+     * @return the tree location for {@code pathResolver}
      */
     @Nonnull
-    TreeLocation getLocation(String path);
+    TreeLocation getLocation(PathResolver pathResolver);
 
     /**
      * 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=1418316&r1=1418315&r2=1418316&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
Fri Dec  7 14:03:31 2012
@@ -53,8 +53,18 @@ public interface TreeLocation {
         /**
          * @return  {@code NULL}
          */
+        @Nonnull
         @Override
-        public TreeLocation getChild(String relPath) {
+        public TreeLocation getChild(String name) {
+            return NULL;
+        }
+
+        /**
+         * @return  {@code NULL}
+         */
+        @Nonnull
+        @Override
+        public TreeLocation getLocation(PathResolver pathResolver) {
             return NULL;
         }
 
@@ -99,13 +109,20 @@ public interface TreeLocation {
     TreeLocation getParent();
 
     /**
-     * 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
+     * Retrieve the child location with the given name.
+     * @param name  name of the child
      * @return  a {@code TreeLocation} for a child with the given {@code name}.
      */
     @Nonnull
-    TreeLocation getChild(String relPath);
+    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);
 
     /**
      * 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=1418316&r1=1418315&r2=1418316&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
Fri Dec  7 14:03:31 2012
@@ -30,6 +30,7 @@ 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;
@@ -49,7 +50,6 @@ 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,6 +128,7 @@ 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();
             }
@@ -201,10 +202,9 @@ public class RootImpl implements Root {
     }
 
     @Override
-    public TreeLocation getLocation(String path) {
+    public TreeLocation getLocation(PathResolver pathResolver) {
         checkLive();
-        checkArgument(path.startsWith("/"));
-        return rootTree.getLocation().getChild(path.substring(1));
+        return rootTree.getLocation().getLocation(pathResolver);
     }
 
     @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=1418316&r1=1418315&r2=1418316&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
Fri Dec  7 14:03:31 2012
@@ -30,6 +30,7 @@ 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;
@@ -574,7 +575,38 @@ public class TreeImpl implements Tree {
 
     //-------------------------------------------------------< TreeLocation >---
 
-    public class NodeLocation implements 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 {
         private final TreeImpl tree;
 
         private NodeLocation(TreeImpl tree) {
@@ -588,33 +620,20 @@ public class TreeImpl implements Tree {
                 : new NodeLocation(tree.parent);
         }
 
+        @Nonnull
         @Override
-        public TreeLocation getChild(String relPath) {
-            checkArgument(!relPath.startsWith("/"));
-            if (relPath.isEmpty()) {
-                return this;
+        public TreeLocation getChild(String name) {
+            TreeImpl child = tree.internalGetChild(name);
+            if (child != null) {
+                return new NodeLocation(child);
             }
 
-            TreeImpl child = tree;
-            String parentPath = PathUtils.getParentPath(relPath);
-            for (String name : PathUtils.elements(parentPath)) {
-                child = child.internalGetChild(name);
-                if (child == null) {
-                    return TreeLocation.NULL;
-                }
-            }
-
-            String name = PathUtils.getName(relPath);
-            PropertyState property = child.internalGetProperty(name);
+            PropertyState property = tree.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);
+                return new PropertyLocation(this, name);
             }
+
+            return TreeLocation.NULL;
         }
 
         @Override
@@ -628,17 +647,12 @@ public class TreeImpl implements Tree {
         }
 
         @Override
-        public PropertyState getProperty() {
-            return null;
-        }
-
-        @Override
         public Status getStatus() {
             return tree.getStatus();
         }
     }
 
-    public class PropertyLocation implements TreeLocation {
+    public class PropertyLocation extends TreeLocationBase {
         private final NodeLocation parent;
         private final String name;
 
@@ -653,21 +667,11 @@ 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)

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/PathResolvers.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/PathResolvers.java?rev=1418316&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/PathResolvers.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/PathResolvers.java
Fri Dec  7 14:03:31 2012
@@ -0,0 +1,143 @@
+/*
+ * 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.namepath;
+
+import java.util.Iterator;
+
+import javax.annotation.Nonnull;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterators;
+import org.apache.jackrabbit.oak.api.PathResolver;
+import org.apache.jackrabbit.oak.api.TreeLocation;
+import org.apache.jackrabbit.oak.commons.PathUtils;
+
+/**
+ * Static factories for {@link PathResolver} implementations.
+ */
+public class PathResolvers {
+    private PathResolvers(){}
+
+    /**
+     * Create a path resolver, which interprets name, "." and ".." elements
+     * in a path as the child of the given name of the current element, the current
+     * element and the parent of the current element, respectively.
+     * @param path  path to resolve
+     * @return  a path resolver
+     */
+    public static PathResolver dotResolver(String path) {
+        return new DotResolver(path);
+    }
+
+    /**
+     * Create a path resolver, which interprets each element in a path as the child
+     * of that name of the current element.
+     * @param path  path to resolve
+     * @return  a path resolver
+     */
+    public static PathResolver identity(String path) {
+        return new IdResolver(path);
+    }
+
+    //------------------------------------------------------------< DotResolver >---
+
+    /**
+     * A path resolver, which interprets name, "." and ".." elements
+     * in a path as the child of the given name of the current element, the current
+     * element and the parent of the current element, respectively.
+     */
+    private static class DotResolver implements PathResolver {
+        private final String path;
+
+        public DotResolver(String path) {
+            this.path = path;
+        }
+
+        @Override
+        public Iterator<Function<TreeLocation, TreeLocation>> iterator() {
+            return Iterators.transform(PathUtils.elements(path).iterator(),
+                    new Function<String, Function<TreeLocation, TreeLocation>>()
{
+                @Nonnull
+                @Override
+                public Function<TreeLocation, TreeLocation> apply(final String element)
{
+                    if (PathUtils.denotesCurrent(element)) {
+                        return new Function<TreeLocation, TreeLocation>() {
+                            @Nonnull
+                            @Override
+                            public TreeLocation apply(TreeLocation location) {
+                                return location;
+                            }
+                        };
+                    }
+                    else if (PathUtils.denotesParent(element)) {
+                        return new Function<TreeLocation, TreeLocation>() {
+                            @Nonnull
+                            @Override
+                            public TreeLocation apply(TreeLocation location) {
+                                return location.getParent();
+                            }
+                        };
+                    }
+                    else {
+                        return new Function<TreeLocation, TreeLocation>() {
+                            @Nonnull
+                            @Override
+                            public TreeLocation apply(TreeLocation location) {
+                                return location.getChild(element);
+                            }
+                        };
+                    }
+                }
+            });
+        }
+    }
+
+    //------------------------------------------------------------< IdResolver >---
+
+    /**
+     * A path resolver, which interprets each element in a path as the child
+     * of that name of the current element.
+     */
+    private static class IdResolver implements PathResolver {
+        private final String path;
+
+        public IdResolver(String path) {
+            this.path = path;
+        }
+
+        @Override
+        public Iterator<Function<TreeLocation, TreeLocation>> iterator() {
+            return Iterators.transform(PathUtils.elements(path).iterator(),
+                    new Function<String, Function<TreeLocation, TreeLocation>>()
{
+                @Nonnull
+                @Override
+                public Function<TreeLocation, TreeLocation> apply(final String element)
{
+                    return new Function<TreeLocation, TreeLocation>() {
+                        @Nonnull
+                        @Override
+                        public TreeLocation apply(TreeLocation location) {
+                            return location.getChild(element);
+                        }
+                    };
+                }
+            });
+        }
+    }
+}

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

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

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=1418316&r1=1418315&r2=1418316&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
Fri Dec  7 14:03:31 2012
@@ -20,6 +20,7 @@ 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;
@@ -38,12 +39,13 @@ import org.apache.jackrabbit.oak.plugins
 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
@@ -192,7 +194,7 @@ class OakAuthorizableProperties implemen
         checkRelativePath(relPath);
 
         Tree node = getTree();
-        TreeLocation propertyLocation = node.getLocation().getChild(relPath);
+        TreeLocation propertyLocation = node.getLocation().getLocation(dotResolver(relPath));
         PropertyState property = propertyLocation.getProperty();
         if (property != null) {
             if (isAuthorizableProperty(node, propertyLocation, true)) {
@@ -297,7 +299,7 @@ class OakAuthorizableProperties implemen
 
     @Nonnull
     private static TreeLocation getLocation(Tree tree, String relativePath) {
-        return LocationUtil.getTreeLocation(tree.getLocation(), relativePath);
+        return tree.getLocation().getLocation(dotResolver(relativePath));
     }
 
     private static void checkRelativePath(String relativePath) throws RepositoryException
{

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=1418316&r1=1418315&r2=1418316&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
Fri Dec  7 14:03:31 2012
@@ -20,6 +20,7 @@ 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;
@@ -50,6 +51,7 @@ 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.
@@ -120,7 +122,7 @@ public class NodeUtil {
     }
 
     /**
-     * FIXME: workaround for OAK-426
+     * FIXME: this might add a node at a parent where a property of the same name already
exists.
      * 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.
@@ -130,7 +132,7 @@ public class NodeUtil {
         if (relativePath.indexOf('/') == -1) {
             return getOrAddChild(relativePath, primaryTypeName);
         } else {
-            TreeLocation location = LocationUtil.getTreeLocation(tree.getLocation(), relativePath);
+            TreeLocation location = tree.getLocation().getLocation(dotResolver(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=1418316&r1=1418315&r2=1418316&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
Fri Dec  7 14:03:31 2012
@@ -59,6 +59,7 @@ 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();
@@ -78,6 +79,7 @@ public class OakAuthorizablePropertyTest
         protectedGroupProps.put(UserConstants.REP_PRINCIPAL_NAME, false);
     }
 
+    @Override
     @After
     public void after() throws Exception {
         try {
@@ -332,8 +334,8 @@ public class OakAuthorizablePropertyTest
     @Test
     public void testGetPropertyNamesByInvalidRelPath() throws Exception {
         List<String> invalidPaths = new ArrayList<String>();
-        invalidPaths.add("../");
-        invalidPaths.add("../../");
+//        invalidPaths.add("../");     // FIXME: these paths are valid on JR2
+//        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=1418316&r1=1418315&r2=1418316&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
Fri Dec  7 14:03:31 2012
@@ -36,6 +36,8 @@ 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}
@@ -247,15 +249,7 @@ public class NodeDelegate extends ItemDe
             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;
+        return getLocation().getLocation(dotResolver(relPath));
     }
 
     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=1418316&r1=1418315&r2=1418316&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
Fri Dec  7 14:03:31 2012
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.oak.jcr;
 
 import java.io.IOException;
 import java.util.concurrent.ScheduledExecutorService;
+
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.jcr.ItemExistsException;
@@ -50,12 +51,13 @@ 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.spi.security.SecurityProvider;
 import org.apache.jackrabbit.oak.plugins.value.ValueFactoryImpl;
+import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 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);
@@ -215,7 +217,7 @@ public class SessionDelegate {
      * none exists or not accessible.
      */
     public PropertyDelegate getProperty(String path) {
-        TreeLocation location = root.getLocation(path);
+        TreeLocation location = getLocation(path);
         return location.getProperty() == null
             ? null
             : new PropertyDelegate(this, location);
@@ -483,7 +485,7 @@ public class SessionDelegate {
 
     @Nonnull
     TreeLocation getLocation(String path) {
-        return root.getLocation(path);
+        return root.getLocation(dotResolver(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=1418316&r1=1418315&r2=1418316&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
Fri Dec  7 14:03:31 2012
@@ -315,8 +315,8 @@ public class AuthorizablePropertyTest ex
     @Test
     public void testGetPropertyNamesByInvalidRelPath() throws NotExecutableException, RepositoryException
{
         List<String> invalidPaths = new ArrayList<String>();
-        invalidPaths.add("../");
-        invalidPaths.add("../../");
+//        invalidPaths.add("../");  // FIXME: these paths are valid on JR2
+//        invalidPaths.add("../../");
         invalidPaths.add("../testing");
         invalidPaths.add("/testing");
         invalidPaths.add(null);



Mime
View raw message