Skip to content
Snippets Groups Projects
Commit 3cec0ef7 authored by Nicola Fulvio Calabria's avatar Nicola Fulvio Calabria
Browse files

Bug #3612 - Fixed method getParentPath() in CreateNodeController class.

Passes testSubPath() test in CreateNodeControllerTest now.
parent 02fdc3b5
No related branches found
No related tags found
No related merge requests found
Pipeline #875 passed
...@@ -63,8 +63,8 @@ public class CreateNodeController extends BaseNodeController { ...@@ -63,8 +63,8 @@ public class CreateNodeController extends BaseNodeController {
List<String> nodeGroups List<String> nodeGroups
= Arrays.asList(groupWritePropValues.get(0).split(" ", -1)); = Arrays.asList(groupWritePropValues.get(0).split(" ", -1));
if (userGroups == null || if (userGroups == null
!nodeGroups.stream().anyMatch((i) -> userGroups.contains(i))) { || !nodeGroups.stream().anyMatch((i) -> userGroups.contains(i))) {
// If groups don't match check ownership at least // If groups don't match check ownership at least
List<String> nodeOwner List<String> nodeOwner
= getNodePropertyByURI(parentNode, "ivo://ivoa.net/vospace/core#creator"); = getNodePropertyByURI(parentNode, "ivo://ivoa.net/vospace/core#creator");
...@@ -114,13 +114,26 @@ public class CreateNodeController extends BaseNodeController { ...@@ -114,13 +114,26 @@ public class CreateNodeController extends BaseNodeController {
} }
// This method assumes that URL is in the format /node1/node2/...
// multiple slashes as a single separator are allowed
// But the output has only single slash separators
private String getParentPath(String path) { private String getParentPath(String path) {
String[] parsedPath = path.split("/");
String[] parsedPath = path.split("[/]+");
if (parsedPath.length < 2 || !parsedPath[0].isEmpty()) {
throw new IllegalArgumentException();
}
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("/");
for (int i = 0; i < parsedPath.length - 1; i++) { System.out.println(parsedPath.length);
sb.append("/").append(parsedPath[i]); for (int i = 1; i < parsedPath.length - 1; i++) {
sb.append(parsedPath[i]);
if (i < parsedPath.length - 2) {
sb.append("/");
}
} }
return sb.toString(); return sb.toString();
......
...@@ -278,7 +278,7 @@ public class CreateNodeControllerTest { ...@@ -278,7 +278,7 @@ public class CreateNodeControllerTest {
verifyArguments(); verifyArguments();
} }
//@Test @Test
public void testSubPath() throws Exception { public void testSubPath() throws Exception {
String requestBody = getResourceFileContent("create-unstructured-data-node.xml") String requestBody = getResourceFileContent("create-unstructured-data-node.xml")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment