jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1225850 - in /jackrabbit/sandbox/jackrabbit-microkernel/src: main/java/org/apache/jackrabbit/state/ChangeTree.java test/java/org/apache/jackrabbit/state/TransientSpaceTest.java
Date Fri, 30 Dec 2011 15:42:24 GMT
Author: mduerig
Date: Fri Dec 30 15:42:24 2011
New Revision: 1225850

URL: http://svn.apache.org/viewvc?rev=1225850&view=rev
Log:
Microkernel based prototype of JCR implementation (WIP)
- moving an added node to a moved node results in the node disappearing: 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=1225850&r1=1225849&r2=1225850&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
Fri Dec 30 15:42:24 2011
@@ -517,6 +517,13 @@ public class ChangeTree {
         abstract NodeDelta remove() throws ItemNotFoundException;
         abstract void moveTo(NodeDelta parent, String name);
 
+        NodeDelta addChild(NodeDelta delta) {
+            childNodes.put(delta.name, delta);
+            delta.parent = this;
+            touch();
+            return delta;
+        }
+
         final void clear() {
             childNodes.clear();
             properties.clear();
@@ -534,12 +541,6 @@ public class ChangeTree {
             return childNodes.containsKey(name);
         }
 
-        final NodeDelta addChild(NodeDelta delta) {
-            childNodes.put(delta.name, delta);
-            touch();
-            return delta;
-        }
-
         final NodeDelta removeChild(String name) {
             NodeDelta delta = childNodes.remove(name);
             if (delta != null) {
@@ -676,7 +677,6 @@ public class ChangeTree {
 
         @Override
         void moveTo(NodeDelta parent, String name) {
-            this.parent = parent;
             this.name = name;
             parent.addChild(this);
         }
@@ -773,6 +773,11 @@ public class ChangeTree {
         }
 
         @Override
+        NodeDelta addChild(NodeDelta delta) {
+            return source.addChild(delta);
+        }
+
+        @Override
         void moveTo(NodeDelta parent, String name) {
             parent.addChild(new Moved(parent, name, source));
         }

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=1225850&r1=1225849&r2=1225850&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
Fri Dec 30 15:42:24 2011
@@ -770,6 +770,30 @@ public class TransientSpaceTest {
     }
 
     @Test
+    public void moveAddedToMove() throws RepositoryException {
+        NodeDelta root = transientSpace.getNode(ROOT);
+        root.addNode("source").addNode("node1");
+        transientSpace.save();
+
+        root.getNode("source").moveNode("node1", ROOT.concat("target"));
+        root.getNode("source").addNode("node2");
+        root.getNode("source").moveNode("node2", ROOT.concat("target/moved"));
+        dump(root);
+
+        assertNotNull(transientSpace.getNode(ROOT.concat("source")));
+        assertNull(transientSpace.getNode(ROOT.concat("source/node1")));
+        assertNull(transientSpace.getNode(ROOT.concat("source/node2")));
+        assertNotNull(transientSpace.getNode(ROOT.concat("target/moved")));
+
+        transientSpace.save();
+
+        assertNotNull(transientSpace.getNode(ROOT.concat("source")));
+        assertNull(transientSpace.getNode(ROOT.concat("source/node1")));
+        assertNull(transientSpace.getNode(ROOT.concat("source/node2")));
+        assertNotNull(transientSpace.getNode(ROOT.concat("target/moved")));
+    }
+
+    @Test
     public void setPropertyTest() throws RepositoryException {
         // Set property
         NodeDelta root = transientSpace.getNode(ROOT);



Mime
View raw message