jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From un...@apache.org
Subject svn commit: r1532761 - in /jackrabbit/branches/2.6/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/state/NodeState.java test/java/org/apache/jackrabbit/core/MoveTest.java
Date Wed, 16 Oct 2013 13:43:16 GMT
Author: unico
Date: Wed Oct 16 13:43:16 2013
New Revision: 1532761

URL: http://svn.apache.org/r1532761
Log:
JCR-1880 fix problem with reordering same-name siblings

Modified:
    jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
    jackrabbit/branches/2.6/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/MoveTest.java

Modified: jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java?rev=1532761&r1=1532760&r2=1532761&view=diff
==============================================================================
--- jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
(original)
+++ jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
Wed Oct 16 13:43:16 2013
@@ -16,10 +16,6 @@
  */
 package org.apache.jackrabbit.core.state;
 
-import org.apache.jackrabbit.core.id.ItemId;
-import org.apache.jackrabbit.core.id.NodeId;
-import org.apache.jackrabbit.spi.Name;
-
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
@@ -27,6 +23,10 @@ import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.jackrabbit.core.id.ItemId;
+import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.spi.Name;
+
 /**
  * <code>NodeState</code> represents the state of a <code>Node</code>.
  */
@@ -372,8 +372,12 @@ public class NodeState extends ItemState
             }
         }
         if (oldEntry != null) {
-            notifyNodeAdded(newEntry);
-            notifyNodeRemoved(oldEntry);
+            if (oldEntry.getName().equals(newName)) {
+                notifyNodesReplaced();
+            } else {
+                notifyNodeAdded(newEntry);
+                notifyNodeRemoved(oldEntry);
+            }
             return true;
         }
         return false;

Modified: jackrabbit/branches/2.6/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/MoveTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.6/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/MoveTest.java?rev=1532761&r1=1532760&r2=1532761&view=diff
==============================================================================
--- jackrabbit/branches/2.6/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/MoveTest.java
(original)
+++ jackrabbit/branches/2.6/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/MoveTest.java
Wed Oct 16 13:43:16 2013
@@ -103,4 +103,52 @@ public class MoveTest extends AbstractJC
         assertEquals(testRootNode.getPath() + "/" + nodeName2, now);
     }
 
+    /**
+     * Test reordering same-name-siblings using move
+     */
+    public void testReorderSameNameSiblingsUsingMove() throws RepositoryException {
+        Session session = testRootNode.getSession();
+        for (NodeIterator it = testRootNode.getNodes(); it.hasNext();) {
+            it.nextNode().remove();
+            session.save();
+        }
+        Node node1 = testRootNode.addNode(nodeName1);
+        Node node2 = testRootNode.addNode(nodeName1);
+        String path = node1.getPath();
+
+        // re-order the nodes using move
+        session.move(path, path);
+
+        assertEquals(path + "[2]", node1.getPath());
+        assertEquals(path, node2.getPath());
+    }
+
+    /**
+     * Verify paths of same name siblings are correct after a (reordering) move
+     * Issue JCR-1880
+     */
+    public void testGetPathDoesNotInfluencePathsAfterMove() throws RepositoryException {
+        doTestMoveWithGetPath(false);
+        doTestMoveWithGetPath(true);
+    }
+
+    private void doTestMoveWithGetPath(boolean index) throws RepositoryException {
+        Session session = testRootNode.getSession();
+        for (NodeIterator it = testRootNode.getNodes(); it.hasNext();) {
+            it.nextNode().remove();
+            session.save();
+        }
+        String testPath = testRootNode.getPath();
+        Node a = testRootNode.addNode("a");
+        Node b = a.addNode("b");
+        session.save();
+        session.move(testPath + "/a/b", testPath + "/a");
+        if (index) {
+            b.getPath();
+        }
+        session.move(testPath + "/a", testPath + "/a");
+        assertEquals(testPath + "/a[2]", a.getPath());
+        assertEquals(testPath + "/a", b.getPath());
+    }
+
 }



Mime
View raw message