jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meteata...@apache.org
Subject svn commit: r1419587 - in /jackrabbit/oak/trunk/oak-mongomk/src: main/java/org/apache/jackrabbit/mongomk/impl/instruction/ test/java/org/apache/jackrabbit/mongomk/impl/
Date Mon, 10 Dec 2012 17:10:33 GMT
Author: meteatamel
Date: Mon Dec 10 17:10:32 2012
New Revision: 1419587

URL: http://svn.apache.org/viewvc?rev=1419587&view=rev
Log:
Fixed a couple minor issues while testing the copy/move functionality.

Modified:
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/instruction/CommitCommandInstructionVisitor.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKCommitCopyTest.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKCommitMoveTest.java

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/instruction/CommitCommandInstructionVisitor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/instruction/CommitCommandInstructionVisitor.java?rev=1419587&r1=1419586&r2=1419587&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/instruction/CommitCommandInstructionVisitor.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/instruction/CommitCommandInstructionVisitor.java
Mon Dec 10 17:10:32 2012
@@ -145,7 +145,7 @@ public class CommitCommandInstructionVis
         String destParentPath = PathUtils.getParentPath(destPath);
         String destNodeName = PathUtils.getName(destPath);
 
-        MongoNode srcParent = getStoredNode(srcParentPath);
+        MongoNode srcParent = getStoredNode(srcParentPath, false);
         if (!srcParent.childExists(srcNodeName)) {
             throw new NotFoundException(srcPath);
         }
@@ -168,12 +168,11 @@ public class CommitCommandInstructionVis
         }
 
         // Then, copy any staged changes.
-        MongoNode srcNode = getStoredNode(srcPath);
+        MongoNode srcNode = getStoredNode(srcPath, false);
         MongoNode destNode = getStagedNode(destPath);
         copyStagedChanges(srcNode, destNode);
 
         // Finally, add to destParent.
-        pathNodeMap.put(destPath, destNode);
         destParent.addChild(destNodeName);
     }
 
@@ -216,12 +215,11 @@ public class CommitCommandInstructionVis
         }
 
         // Then, copy any staged changes.
-        MongoNode srcNode = getStoredNode(srcPath);
+        MongoNode srcNode = getStoredNode(srcPath, false);
         MongoNode destNode = getStagedNode(destPath);
         copyStagedChanges(srcNode, destNode);
 
         // Finally, add to destParent and remove from srcParent.
-        getStagedNode(destPath);
         destParent.addChild(destNodeName);
         srcParent.removeChild(srcNodeName);
     }
@@ -243,6 +241,10 @@ public class CommitCommandInstructionVis
     }
 
     private MongoNode getStoredNode(String path) {
+        return getStoredNode(path, true);
+    }
+
+    private MongoNode getStoredNode(String path, boolean addToMap) {
         MongoNode node = pathNodeMap.get(path);
         if (node != null) {
             return node;
@@ -252,7 +254,6 @@ public class CommitCommandInstructionVis
         NodeExistsCommand existCommand = new NodeExistsCommand(nodeStore,
                 path, headRevisionId);
         existCommand.setBranchId(branchId);
-        existCommand.setValidCommits(validCommits);
         boolean exists = false;
         try {
             exists = existCommand.execute();
@@ -263,7 +264,9 @@ public class CommitCommandInstructionVis
         }
         node = existCommand.getNode();
         node.removeField("_id");
-        pathNodeMap.put(path, node);
+        if (addToMap) {
+            pathNodeMap.put(path, node);
+        }
         return node;
     }
 

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKCommitCopyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKCommitCopyTest.java?rev=1419587&r1=1419586&r2=1419587&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKCommitCopyTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKCommitCopyTest.java
Mon Dec 10 17:10:32 2012
@@ -120,6 +120,16 @@ public class MongoMKCommitCopyTest exten
     }
 
     @Test
+    public void addNodeAndCopy2() {
+        mk.commit("/", "+\"a\":{}", null, null);
+        mk.commit("/", "+\"a/b\":{}", null, null);
+        mk.commit("/", "*\"a/b\":\"c\"", null, null);
+
+        assertTrue(mk.nodeExists("/a/b", null));
+        assertTrue(mk.nodeExists("/c", null));
+    }
+
+    @Test
     public void addNodeWithChildrenAndCopy() {
         mk.commit("/", "+\"a\":{}", null, null);
         mk.commit("/", "+\"a/b\":{ \"c\" : {}, \"d\" : {} }\n" +

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKCommitMoveTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKCommitMoveTest.java?rev=1419587&r1=1419586&r2=1419587&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKCommitMoveTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKCommitMoveTest.java
Mon Dec 10 17:10:32 2012
@@ -143,6 +143,17 @@ public class MongoMKCommitMoveTest exten
     }
 
     @Test
+    public void addNodeAndMove2() {
+        mk.commit("/", "+\"a\":{}", null, null);
+        mk.commit("/", "+\"a/b\": {}\n", null, null);
+        mk.commit("/", ">\"a/b\":\"c\"", null, null);
+
+        assertFalse(mk.nodeExists("/a/b", null));
+        assertTrue(mk.nodeExists("/a", null));
+        assertTrue(mk.nodeExists("/c", null));
+    }
+
+    @Test
     public void addNodeWithChildrenAndMove() {
         mk.commit("/", "+\"a\":{}", null, null);
         mk.commit("/", "+\"a/b\":{ \"c\" : {}, \"d\" : {} }\n"



Mime
View raw message