]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/JcrUtils.java
Improve tabular
[lgpl/argeo-commons.git] / server / runtime / org.argeo.server.jcr / src / main / java / org / argeo / jcr / JcrUtils.java
index 760e6600969e9e5666468e47afe1cd230be7bc1b..08f8d55c393727aecb32259c6b6f45df97db931c 100644 (file)
@@ -223,6 +223,26 @@ public class JcrUtils implements ArgeoJcrConstants {
                return path.substring(index + 1);
        }
 
+       /**
+        * Routine that get the child with this name, adding id it does not already
+        * exist
+        */
+       public static Node getOrAdd(Node parent, String childName,
+                       String childPrimaryNodeType) throws RepositoryException {
+               return parent.hasNode(childName) ? parent.getNode(childName) : parent
+                               .addNode(childName, childPrimaryNodeType);
+       }
+
+       /**
+        * Routine that get the child with this name, adding id it does not already
+        * exist
+        */
+       public static Node getOrAdd(Node parent, String childName)
+                       throws RepositoryException {
+               return parent.hasNode(childName) ? parent.getNode(childName) : parent
+                               .addNode(childName);
+       }
+
        /** Creates the nodes making path, if they don't exist. */
        public static Node mkdirs(Session session, String path) {
                return mkdirs(session, path, null, null, false);
@@ -1036,7 +1056,6 @@ public class JcrUtils implements ArgeoJcrConstants {
                        NodeIterator ni = node.getNodes();
                        while (ni.hasNext())
                                curNodeSize += getNodeApproxSize(ni.nextNode());
-                       log.debug(node + ": " + curNodeSize);
                        return curNodeSize;
                } catch (RepositoryException re) {
                        throw new ArgeoException(