From: Mathieu Baudier Date: Sun, 2 Jun 2013 20:40:26 +0000 (+0000) Subject: JcrUtils.updateLastModifiedAndParents() accept null X-Git-Tag: svn/tags/argeo-commons-1.2.2~4 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=e2be548db99fb67ae3cdf62cd29478f8fbf3160b;p=lgpl%2Fargeo-commons.git JcrUtils.updateLastModifiedAndParents() accept null https://www.argeo.org/bugzilla/show_bug.cgi?id=163 git-svn-id: https://svn.argeo.org/commons/branches/1.x@6322 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/JcrUtils.java b/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/JcrUtils.java index f3db14895..2176e757c 100644 --- a/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/JcrUtils.java +++ b/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/JcrUtils.java @@ -1207,14 +1207,26 @@ public class JcrUtils implements ArgeoJcrConstants { } } - /** Update lastModified recursively until this parent. */ + /** + * Update lastModified recursively until this parent. + * + * @param node + * the node + * @param untilPath + * the base path, null is equivalent to "/" + */ public static void updateLastModifiedAndParents(Node node, String untilPath) { try { - if (!node.getPath().startsWith(untilPath)) + if (untilPath != null && !node.getPath().startsWith(untilPath)) throw new ArgeoException(node + " is not under " + untilPath); updateLastModified(node); - if (!node.getPath().equals(untilPath)) - updateLastModifiedAndParents(node.getParent(), untilPath); + if (untilPath == null) { + if (!node.getPath().equals("/")) + updateLastModifiedAndParents(node.getParent(), untilPath); + } else { + if (!node.getPath().equals(untilPath)) + updateLastModifiedAndParents(node.getParent(), untilPath); + } } catch (RepositoryException e) { throw new ArgeoException("Cannot update lastModified from " + node + " until " + untilPath, e); @@ -1403,6 +1415,7 @@ public class JcrUtils implements ArgeoJcrConstants { * files * @return how many files were copied */ + @SuppressWarnings("resource") public static Long copyFiles(Node fromNode, Node toNode, Boolean recursive, ArgeoMonitor monitor) { long count = 0l;