jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1373889 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/ oak-core/src/test/java/org/apach...
Date Thu, 16 Aug 2012 15:44:00 GMT
Author: mduerig
Date: Thu Aug 16 15:43:59 2012
New Revision: 1373889

URL: http://svn.apache.org/viewvc?rev=1373889&view=rev
Log:
OAK-221: Clarify nature of 'path' parameter in oak-api
 require leading forward slash in paths for all oak-core APIs

Modified:
    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/kernel/JsopDiff.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/PathMapper.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/JsopDiffTest.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java

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=1373889&r1=1373888&r2=1373889&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 Aug 16 15:43:59 2012
@@ -396,6 +396,7 @@ public class TreeImpl implements Tree, P
      */
     @CheckForNull
     TreeImpl getTree(String path) {
+        assert path.startsWith("/");
         TreeImpl child = this;
         for (String name : elements(path)) {
             child = child.internalGetChild(name);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/JsopDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/JsopDiff.java?rev=1373889&r1=1373888&r2=1373889&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/JsopDiff.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/JsopDiff.java
Thu Aug 16 15:43:59 2012
@@ -16,8 +16,6 @@
  */
 package org.apache.jackrabbit.oak.kernel;
 
-import static org.apache.jackrabbit.oak.kernel.CoreValueMapper.TYPE2HINT;
-
 import javax.jcr.PropertyType;
 
 import org.apache.jackrabbit.mk.json.JsopBuilder;
@@ -28,6 +26,8 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
 
+import static org.apache.jackrabbit.oak.kernel.CoreValueMapper.TYPE2HINT;
+
 class JsopDiff implements NodeStateDiff {
 
     protected final JsopBuilder jsop;
@@ -40,7 +40,7 @@ class JsopDiff implements NodeStateDiff 
     }
 
     public JsopDiff() {
-        this(new JsopBuilder(), "");
+        this(new JsopBuilder(), "/");
     }
 
     public static void diffToJsop(
@@ -101,7 +101,7 @@ class JsopDiff implements NodeStateDiff 
         return PathUtils.concat(path, name);
     }
 
-    private void toJson(NodeState nodeState, JsopBuilder jsop) {
+    private static void toJson(NodeState nodeState, JsopBuilder jsop) {
         jsop.object();
         for (PropertyState property : nodeState.getProperties()) {
             jsop.key(property.getName());
@@ -114,7 +114,7 @@ class JsopDiff implements NodeStateDiff 
         jsop.endObject();
     }
 
-    private void toJson(PropertyState propertyState, JsopBuilder jsop) {
+    private static void toJson(PropertyState propertyState, JsopBuilder jsop) {
         if (propertyState.isArray()) {
             jsop.array();
             for (CoreValue value : propertyState.getValues()) {
@@ -126,7 +126,7 @@ class JsopDiff implements NodeStateDiff 
         }
     }
 
-    private void toJson(CoreValue value, JsopBuilder jsop) {
+    private static void toJson(CoreValue value, JsopBuilder jsop) {
         int type = value.getType();
         if (type == PropertyType.BOOLEAN) {
             jsop.value(value.getBoolean());

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java?rev=1373889&r1=1373888&r2=1373889&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
Thu Aug 16 15:43:59 2012
@@ -145,6 +145,7 @@ class KernelNodeStoreBranch implements N
     //------------------------------------------------------------< private >---
 
     private NodeState getNode(String path) {
+        assert path.startsWith("/");
         NodeState node = getRoot();
         for (String name : elements(path)) {
             node = node.getChildNode(name);
@@ -158,7 +159,7 @@ class KernelNodeStoreBranch implements N
 
     private void commit(String jsop) {
         MicroKernel kernel = store.getKernel();
-        branchRevision = kernel.commit("/", jsop, branchRevision, null);
+        branchRevision = kernel.commit("", jsop, branchRevision, null);
         currentRoot = new KernelNodeState(kernel, "/", branchRevision);
         committed = currentRoot;
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/PathMapper.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/PathMapper.java?rev=1373889&r1=1373888&r2=1373889&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/PathMapper.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/PathMapper.java
Thu Aug 16 15:43:59 2012
@@ -23,10 +23,9 @@ import javax.annotation.Nonnull;
  * {@code PathMapper} instances provide methods for mapping paths from their JCR
  * string representation to their Oak representation and vice versa.
  *
- * The Oak representation of a path consists of an optional forward slash followed
- * by the names of the respective items in the
- * {@link org.apache.jackrabbit.oak.api.Tree} separated by forward slashes.
- * FIXME make leading forward slash not optional. See OAK-221
+ * The Oak representation of a path consists of a forward slash followed by the
+ * names of the respective items in the {@link org.apache.jackrabbit.oak.api.Tree}
+ * separated by forward slashes.
  */
 public interface PathMapper {
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java?rev=1373889&r1=1373888&r2=1373889&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java
Thu Aug 16 15:43:59 2012
@@ -183,7 +183,7 @@ public class RootImplFuzzIT {
 
             @Override
             void apply(RootImpl root) {
-                root.move(source.substring(1), destination.substring(1));
+                root.move(source, destination);
             }
 
             @Override
@@ -203,7 +203,7 @@ public class RootImplFuzzIT {
 
             @Override
             void apply(RootImpl root) {
-                root.copy(source.substring(1), destination.substring(1));
+                root.copy(source, destination);
             }
 
             @Override

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java?rev=1373889&r1=1373888&r2=1373889&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
Thu Aug 16 15:43:59 2012
@@ -78,7 +78,7 @@ public class RootImplTest extends Abstra
         Tree y = tree.getChild("y");
 
         assertTrue(tree.hasChild("x"));
-        root.move("x", "y/xx");
+        root.move("/x", "/y/xx");
         assertFalse(tree.hasChild("x"));
         assertTrue(y.hasChild("xx"));
         
@@ -93,13 +93,13 @@ public class RootImplTest extends Abstra
     @Test
     public void move2() {
         RootImpl root = createRootImpl(null);
-        Tree r = root.getTree("");
+        Tree r = root.getTree("/");
         Tree x = r.getChild("x");
         Tree y = r.getChild("y");
 
         assertFalse(y.hasChild("x"));
         assertEquals("", x.getParent().getName());
-        root.move("x", "y/x");
+        root.move("/x", "/y/x");
         assertTrue(y.hasChild("x"));
         assertEquals("y", x.getParent().getName());
     }
@@ -110,11 +110,11 @@ public class RootImplTest extends Abstra
      */
     public void removeMoved() throws CommitFailedException {
         RootImpl root = createRootImpl(null);
-        Tree r = root.getTree("");
+        Tree r = root.getTree("/");
         r.addChild("a");
         r.addChild("b");
 
-        root.move("a", "b/c");
+        root.move("/a", "/b/c");
         assertFalse(r.hasChild("a"));
         assertTrue(r.hasChild("b"));
 
@@ -133,7 +133,7 @@ public class RootImplTest extends Abstra
         Tree tree = root.getTree("/");
 
         assertTrue(tree.hasChild("x"));
-        root.move("x", "xx");
+        root.move("/x", "/xx");
         assertFalse(tree.hasChild("x"));
         assertTrue(tree.hasChild("xx"));
         
@@ -152,7 +152,7 @@ public class RootImplTest extends Abstra
         Tree y = tree.getChild("y");
 
         assertTrue(tree.hasChild("x"));
-        root.copy("x", "y/xx");
+        root.copy("/x", "/y/xx");
         assertTrue(tree.hasChild("x"));
         assertTrue(y.hasChild("xx"));
         
@@ -171,8 +171,8 @@ public class RootImplTest extends Abstra
 
         Tree y = tree.getChild("y");
 
-        root.getTree("x").addChild("x1");
-        root.copy("x", "y/xx");
+        root.getTree("/x").addChild("x1");
+        root.copy("/x", "/y/xx");
         assertTrue(y.hasChild("xx"));
         assertTrue(y.getChild("xx").hasChild("x1"));
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/JsopDiffTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/JsopDiffTest.java?rev=1373889&r1=1373888&r2=1373889&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/JsopDiffTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/JsopDiffTest.java
Thu Aug 16 15:43:59 2012
@@ -16,15 +16,14 @@
  */
 package org.apache.jackrabbit.oak.kernel;
 
-import static junit.framework.Assert.assertEquals;
-
+import com.google.common.collect.ImmutableMap;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState;
 import org.apache.jackrabbit.oak.plugins.memory.SinglePropertyState;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.junit.Test;
 
-import com.google.common.collect.ImmutableMap;
+import static junit.framework.Assert.assertEquals;
 
 public class JsopDiffTest {
 
@@ -35,23 +34,23 @@ public class JsopDiffTest {
 
         diff = new JsopDiff();
         diff.propertyAdded(before);
-        assertEquals("^\"foo\":\"bar\"", diff.toString());
+        assertEquals("^\"/foo\":\"bar\"", diff.toString());
 
         diff = new JsopDiff();
         diff.propertyChanged(before, SinglePropertyState.create("foo", 123));
-        assertEquals("^\"foo\":123", diff.toString());
+        assertEquals("^\"/foo\":123", diff.toString());
 
         diff = new JsopDiff();
         diff.propertyChanged(before, SinglePropertyState.create("foo", 1.23));
-        assertEquals("^\"foo\":\"dou:1.23\"", diff.toString()); // TODO: 1.23?
+        assertEquals("^\"/foo\":\"dou:1.23\"", diff.toString()); // TODO: 1.23?
 
         diff = new JsopDiff();
         diff.propertyChanged(before, SinglePropertyState.create("foo", true));
-        assertEquals("^\"foo\":true", diff.toString());
+        assertEquals("^\"/foo\":true", diff.toString());
 
         diff = new JsopDiff();
         diff.propertyDeleted(before);
-        assertEquals("^\"foo\":null", diff.toString());
+        assertEquals("^\"/foo\":null", diff.toString());
     }
 
     @Test
@@ -67,15 +66,15 @@ public class JsopDiffTest {
 
         diff = new JsopDiff();
         diff.childNodeAdded("test", before);
-        assertEquals("+\"test\":{}", diff.toString());
+        assertEquals("+\"/test\":{}", diff.toString());
 
         diff = new JsopDiff();
         diff.childNodeChanged("test", before, after);
-        assertEquals("^\"test/a\":1+\"test/x\":{}", diff.toString());
+        assertEquals("^\"/test/a\":1+\"/test/x\":{}", diff.toString());
 
         diff = new JsopDiff();
         diff.childNodeDeleted("test", after);
-        assertEquals("-\"test\"", diff.toString());
+        assertEquals("-\"/test\"", diff.toString());
     }
 
 }

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=1373889&r1=1373888&r2=1373889&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
Thu Aug 16 15:43:59 2012
@@ -167,7 +167,7 @@ public class SessionDelegate {
 
     @CheckForNull
     public NodeDelegate getRoot() {
-        Tree root = getTree("");
+        Tree root = getTree("/");
         if (root == null) {
             return null;
         } else {
@@ -320,27 +320,24 @@ public class SessionDelegate {
         return contentSession.getWorkspaceName();
     }
 
-    public void copy(String srcAbsPath, String destAbsPath) throws RepositoryException {
-        String srcPath = PathUtils.relativize("/", srcAbsPath);
-        String destPath = PathUtils.relativize("/", destAbsPath);
-
+    public void copy(String srcPath, String destPath) throws RepositoryException {
         // check destination
         Tree dest = getTree(destPath);
         if (dest != null) {
-            throw new ItemExistsException(destAbsPath);
+            throw new ItemExistsException(destPath);
         }
 
         // check parent of destination
         String destParentPath = PathUtils.getParentPath(destPath);
         Tree destParent = getTree(destParentPath);
         if (destParent == null) {
-            throw new PathNotFoundException(PathUtils.getParentPath(destAbsPath));
+            throw new PathNotFoundException(PathUtils.getParentPath(destPath));
         }
 
         // check source exists
         Tree src = getTree(srcPath);
         if (src == null) {
-            throw new PathNotFoundException(srcAbsPath);
+            throw new PathNotFoundException(srcPath);
         }
 
         try {
@@ -353,30 +350,28 @@ public class SessionDelegate {
         }
     }
 
-    public void move(String srcAbsPath, String destAbsPath, boolean transientOp)
+    public void move(String srcPath, String destPath, boolean transientOp)
             throws RepositoryException {
 
-        String srcPath = PathUtils.relativize("/", srcAbsPath);
-        String destPath = PathUtils.relativize("/", destAbsPath);
         Root moveRoot = transientOp ? root : contentSession.getCurrentRoot();
 
         // check destination
         Tree dest = moveRoot.getTree(destPath);
         if (dest != null) {
-            throw new ItemExistsException(destAbsPath);
+            throw new ItemExistsException(destPath);
         }
 
         // check parent of destination
         String destParentPath = PathUtils.getParentPath(destPath);
         Tree destParent = moveRoot.getTree(destParentPath);
         if (destParent == null) {
-            throw new PathNotFoundException(PathUtils.getParentPath(destAbsPath));
+            throw new PathNotFoundException(PathUtils.getParentPath(destPath));
         }
 
         // check source exists
         Tree src = moveRoot.getTree(srcPath);
         if (src == null) {
-            throw new PathNotFoundException(srcAbsPath);
+            throw new PathNotFoundException(srcPath);
         }
 
         try {



Mime
View raw message