jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1334429 - /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
Date Sat, 05 May 2012 15:22:41 GMT
Author: mduerig
Date: Sat May  5 15:22:41 2012
New Revision: 1334429

URL: http://svn.apache.org/viewvc?rev=1334429&view=rev
Log:
OAK-61: split NodeImpl into NodeImpl and NodeDelegate
addNode() should throw ItemExistsException if item exists already

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java?rev=1334429&r1=1334428&r2=1334429&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
Sat May  5 15:22:41 2012
@@ -25,6 +25,7 @@ import org.apache.jackrabbit.oak.util.Fu
 import org.apache.jackrabbit.oak.util.Iterators;
 
 import javax.jcr.InvalidItemStateException;
+import javax.jcr.ItemExistsException;
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
@@ -48,8 +49,12 @@ public class NodeDelegate extends ItemDe
         }
 
         String name = PathUtils.getName(relPath);
-        parentState.addChild(name);
-        return new NodeDelegate(sessionDelegate, parentState.getChild(name));
+        if (parentState.hasChild(name)) {
+            throw new ItemExistsException(relPath);
+        }
+
+        Tree added = parentState.addChild(name);
+        return new NodeDelegate(sessionDelegate, added);
     }
 
     Iterator<NodeDelegate> getChildren() throws RepositoryException {



Mime
View raw message