jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1310044 - /jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
Date Thu, 05 Apr 2012 20:11:58 GMT
Author: stefan
Date: Thu Apr  5 20:11:58 2012
New Revision: 1310044

URL: http://svn.apache.org/viewvc?rev=1310044&view=rev
Log:
OAK-47: NPE with nested add&copy operation

Modified:
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java?rev=1310044&r1=1310043&r2=1310044&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
Thu Apr  5 20:11:58 2012
@@ -141,6 +141,13 @@ public class CommitBuilder {
         MutableNode destParent = getOrCreateStagedNode(destParentPath);
         destParent.add(new ChildNode(destNodeName, srcCNE.getId()));
 
+        if (srcCNE.getId() == null) {
+            // a 'new' node is being copied
+
+            // update staging area
+            copyStagedNodes(srcPath, destPath);
+        }
+
         // update change log
         changeLog.add(new CopyNode(srcPath, destPath));
     }
@@ -269,6 +276,17 @@ public class CommitBuilder {
         }
     }
 
+    void copyStagedNodes(String srcPath, String destPath) throws Exception {
+        MutableNode node = staged.get(srcPath);
+        if (node != null) {
+            staged.put(destPath, new MutableNode(node, store, destPath));
+            for (Iterator<String> it = node.getChildNodeNames(0, -1); it.hasNext();
) {
+                String childName = it.next();
+                copyStagedNodes(PathUtils.concat(srcPath, childName), PathUtils.concat(destPath,
childName));
+            }
+        }
+    }
+
     void removeStagedNodes(String nodePath) throws Exception {
         MutableNode node = staged.get(nodePath);
         if (node != null) {



Mime
View raw message