X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=server%2Fruntime%2Forg.argeo.server.jcr%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fjcr%2FJcrUtils.java;h=2176e757cacac3141eb2e7c90a39302e085e0a8b;hb=ada769fe0be8288e753b3810cce0be2ebc61483c;hp=7f261b75b562a3d20ffd6445e9fc4b9d7fcf8646;hpb=cd50e3711d3b86921f11d9e021fc6a43bef0d400;p=lgpl%2Fargeo-commons.git 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 7f261b75b..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 @@ -300,8 +300,7 @@ public class JcrUtils implements ArgeoJcrConstants { throw new ArgeoException("Path " + path + " cannot end with '/'"); int index = path.lastIndexOf('/'); if (index < 0) - throw new ArgeoException("Cannot find last path element for " - + path); + return path; return path.substring(index + 1); } @@ -445,7 +444,7 @@ public class JcrUtils implements ArgeoJcrConstants { try { for (int i = 0; i < tokens.size(); i++) { String name = tokens.get(i); - if (parentNode.hasNode(name)) { + if (currParent.hasNode(name)) { currParent = currParent.getNode(name); } else { if (i != (tokens.size() - 1)) {// intermediary @@ -1208,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); @@ -1404,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;