jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1329152 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel: KernelBranch.java KernelContentTree.java
Date Mon, 23 Apr 2012 09:59:21 GMT
Author: mduerig
Date: Mon Apr 23 09:59:20 2012
New Revision: 1329152

URL: http://svn.apache.org/viewvc?rev=1329152&view=rev
Log:
OAK-18: Define Oak API 
return boolean for indicating success or failure in KernelContentTree.move()/.copy()

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelBranch.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelContentTree.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelBranch.java?rev=1329152&r1=1329151&r2=1329152&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelBranch.java
Mon Apr 23 09:59:20 2012
@@ -73,12 +73,8 @@ public class KernelBranch implements Bra
 
         KernelContentTree destParent = getTransientState(getParentPath(destPath));
         String destName = getName(destPath);
-        if (destParent == null || destParent.hasChild(destName)) {
-            return false;
-        }
+        return destParent != null && source.move(destParent, destName);
 
-        source.move(destParent, destName);
-        return true;
     }
 
     @Override
@@ -90,12 +86,8 @@ public class KernelBranch implements Bra
 
         KernelContentTree destParent = getTransientState(getParentPath(destPath));
         String destName = getName(destPath);
-        if (destParent == null || destParent.hasChild(destName)) {
-            return false;
-        }
+        return destParent != null && sourceNode.copy(destParent, destName);
 
-        sourceNode.copy(destParent, destName);
-        return true;
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelContentTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelContentTree.java?rev=1329152&r1=1329151&r2=1329152&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelContentTree.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelContentTree.java
Mon Apr 23 09:59:20 2012
@@ -429,8 +429,14 @@ public class KernelContentTree implement
      *
      * @param destParent  new parent for this tree
      * @param destName  new name for this tree
+     * @return  {@code true} if successful, {@code false otherwise}. I.e.
+     * when {@code destName} already exists at {@code destParent}
      */
-    public void move(KernelContentTree destParent, String destName) {
+    public boolean move(KernelContentTree destParent, String destName) {
+        if (destParent.hasChild(destName)) {
+            return false;
+        }
+
         parent.markTreeRemoved(name);
 
         KernelContentTree oldParent = parent;
@@ -442,6 +448,8 @@ public class KernelContentTree implement
         if (listener != null) {
             listener.move(oldParent, oldName, this);
         }
+
+        return true;
     }
 
     /**
@@ -449,13 +457,20 @@ public class KernelContentTree implement
      *
      * @param destParent  parent for the copied tree
      * @param destName  name for the copied tree
+     * @return  {@code true} if successful, {@code false otherwise}. I.e.
+     * when {@code destName} already exists at {@code destParent}
      */
-    public void copy(KernelContentTree destParent, String destName) {
+    public boolean copy(KernelContentTree destParent, String destName) {
+        if (destParent.hasChild(destName)) {
+            return false;
+        }
+
         KernelContentTree copy = new KernelContentTree(this, destParent, destName);
         destParent.addedTrees.put(destName, copy);
         if (listener != null) {
             listener.copy(parent, name, copy);
         }
+        return true;
     }
 
     //------------------------------------------------------------< internal >---



Mime
View raw message