jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1353450 - /jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JcrUtils.java
Date Mon, 25 Jun 2012 10:09:10 GMT
Author: jukka
Date: Mon Jun 25 10:09:09 2012
New Revision: 1353450

URL: http://svn.apache.org/viewvc?rev=1353450&view=rev
Log:
JCR-3358: Allow null type in JcrUtils.getOrAddNode(parent, name, type)

Modified:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JcrUtils.java

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JcrUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JcrUtils.java?rev=1353450&r1=1353449&r2=1353450&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JcrUtils.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JcrUtils.java
Mon Jun 25 10:09:09 2012
@@ -488,11 +488,7 @@ public class JcrUtils {
      */
     public static Node getOrAddNode(Node parent, String name)
             throws RepositoryException {
-        if (parent.hasNode(name)) {
-            return parent.getNode(name);
-        } else {
-            return parent.addNode(name);
-        }
+        return getOrAddNode(parent, name, null);
     }
 
     /**
@@ -506,7 +502,8 @@ public class JcrUtils {
      * @see Node#isNodeType(String)
      * @param parent parent node
      * @param name name of the child node
-     * @param type type of the child node, ignored if the child already exists
+     * @param type type of the child node or {@code null},
+     *             ignored if the child already exists
      * @return the child node
      * @throws RepositoryException if the child node can not be accessed
      *                             or created
@@ -515,8 +512,10 @@ public class JcrUtils {
             throws RepositoryException {
         if (parent.hasNode(name)) {
             return parent.getNode(name);
-        } else {
+        } else if (type != null) {
             return parent.addNode(name, type);
+        } else {
+            return parent.addNode(name);
         }
     }
 



Mime
View raw message