jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1226281 - in /jackrabbit/sandbox/jackrabbit-microkernel/src: main/java/org/apache/jackrabbit/state/ChangeTree.java test/java/org/apache/jackrabbit/state/TransientSpaceTest.java
Date Sun, 01 Jan 2012 18:28:08 GMT
Author: mduerig
Date: Sun Jan  1 18:28:08 2012
New Revision: 1226281

URL: http://svn.apache.org/viewvc?rev=1226281&view=rev
Log:
Microkernel based prototype of JCR implementation (WIP)
- moving a node to an added node results in wrong order of jsop statements: fixed

Modified:
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/TransientSpaceTest.java

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java?rev=1226281&r1=1226280&r2=1226281&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
Sun Jan  1 18:28:08 2012
@@ -29,9 +29,11 @@ import org.apache.jackrabbit.utils.Predi
 import javax.jcr.ItemExistsException;
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.PathNotFoundException;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
@@ -274,7 +276,18 @@ public class ChangeTree {
         }
 
         private void visitNodes(NodeDelta delta) {
+            List<NodeDelta> moved = new ArrayList<NodeDelta>();
+            // visit move operations after add and remove operations in order to make
+            // sure transiently added move targets are in place
             for (NodeDelta node : delta.childNodes()) {
+                if (node.isMoved()) {
+                    moved.add(node);
+                }
+                else {
+                    node.accept(this);
+                }
+            }
+            for (NodeDelta node : moved) {
                 node.accept(this);
             }
         }
@@ -856,7 +869,12 @@ public class ChangeTree {
 
         @Override
         public String toString() {
-            return "Removed[" + getPath() + ']';
+            if (isMoved()) {
+                return "MovedTo[" + movedTo + ']';
+            }
+            else {
+                return "Removed[" + getPath() + ']';
+            }
         }
 
     }

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/TransientSpaceTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/TransientSpaceTest.java?rev=1226281&r1=1226280&r2=1226281&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/TransientSpaceTest.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/TransientSpaceTest.java
Sun Jan  1 18:28:08 2012
@@ -844,6 +844,24 @@ public class TransientSpaceTest {
     }
 
     @Test
+    public void moveToAdded() throws RepositoryException {
+        NodeDelta root = transientSpace.getNode(ROOT);
+        root.addNode("node");
+        transientSpace.save();
+        
+        root.addNode("target");
+        root.moveNode("node", ROOT.concat("target/node-moved"));
+        
+        assertNull(transientSpace.getNode(ROOT.concat("node")));
+        assertNotNull(transientSpace.getNode(ROOT.concat("target/node-moved")));
+
+        transientSpace.save();
+
+        assertNull(transientSpace.getNode(ROOT.concat("node")));
+        assertNotNull(transientSpace.getNode(ROOT.concat("target/node-moved")));
+    }
+
+    @Test
     public void setPropertyTest() throws RepositoryException {
         // Set property
         NodeDelta root = transientSpace.getNode(ROOT);



Mime
View raw message