jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1127541 - /jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoBuilder.java
Date Wed, 25 May 2011 14:22:27 GMT
Author: mduerig
Date: Wed May 25 14:22:27 2011
New Revision: 1127541

URL: http://svn.apache.org/viewvc?rev=1127541&view=rev
Log:
JCR-2976: Allow parent path to be set explicitly in NodeInfoBuilder

Modified:
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoBuilder.java

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoBuilder.java?rev=1127541&r1=1127540&r2=1127541&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoBuilder.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoBuilder.java
Wed May 25 14:22:27 2011
@@ -149,6 +149,7 @@ public final class ItemInfoBuilder {
         private final NodeInfoBuilder parent;
         private final Listener listener;
 
+        private Path parentPath;
         private String name;
         private int index = Path.INDEX_DEFAULT;
         private String namespace;
@@ -254,6 +255,17 @@ public final class ItemInfoBuilder {
         }
 
         /**
+         * Set the parent's path of the node
+         * 
+         * @param parentPath
+         * @return
+         */
+        public NodeInfoBuilder setParentPath(Path parentPath) {
+            this.parentPath = parentPath;
+            return this;
+        }
+
+        /**
          * Set the name of the primary type.
          * @param name
          * @see NodeInfo#getNodetype()
@@ -369,13 +381,14 @@ public final class ItemInfoBuilder {
                 throw new IllegalStateException("Name not set");
             }
             
-            if (parent == null) {
+            if (parent == null && parentPath == null) {
                 return PathFactoryImpl.getInstance().getRootPath();
             }
             else {
+                Path path = parentPath == null ? parent.getPath() : parentPath;
                 String namespace = this.namespace == null ? Name.NS_DEFAULT_URI : this.namespace;
                 Name name = NameFactoryImpl.getInstance().create(namespace, this.name);
-                return PathFactoryImpl.getInstance().create(parent.getPath(), name, true);
+                return PathFactoryImpl.getInstance().create(path, name, true);
             }
         }
 



Mime
View raw message