diff --git a/src/main/java/it/inaf/oats/vospace/CopyService.java b/src/main/java/it/inaf/oats/vospace/CopyService.java index e26ece064a685168fb364a78b38ed08b63722a69..38972478d61fc8d82f3a17ae232a4cc9a1cce62f 100644 --- a/src/main/java/it/inaf/oats/vospace/CopyService.java +++ b/src/main/java/it/inaf/oats/vospace/CopyService.java @@ -47,6 +47,11 @@ public class CopyService extends AbstractNodeService { if (destinationPath.startsWith(sourcePath + "/")) { throw new IllegalArgumentException("Cannot copy node to a subdirectory of its own path"); } + + // Check if destination equals parent path of source + if(NodeUtils.getParentPath(sourcePath).equals(destinationPath)){ + throw new IllegalArgumentException("Cannot duplicate node at same path without renaming it"); + } try { diff --git a/src/main/java/it/inaf/oats/vospace/MoveService.java b/src/main/java/it/inaf/oats/vospace/MoveService.java index 0a7b784be3213ef23fc193391ff4ca2e5920de63..6210c24001f80c3236fd84f3dff75cf28c016b9f 100644 --- a/src/main/java/it/inaf/oats/vospace/MoveService.java +++ b/src/main/java/it/inaf/oats/vospace/MoveService.java @@ -50,6 +50,11 @@ public class MoveService extends AbstractNodeService { // Linux-like: "cannot move to a subdirectory of itself" if(destinationPath.startsWith(sourcePath+"/")) { throw new IllegalArgumentException("Cannot move node to a subdirectory of its own path"); + } + + // Check if destination equals parent path of source + if(NodeUtils.getParentPath(sourcePath).equals(destinationPath)){ + return; } try {