Loading src/main/java/it/inaf/oats/vospace/CreateNodeController.java +24 −19 Original line number Diff line number Diff line Loading @@ -32,8 +32,9 @@ public class CreateNodeController extends BaseNodeController { List<String> userGroups = principal.getGroups(); if (!isValidURI(node.getUri())) if (!isValidURI(node.getUri())) { throw new InvalidURIException(node.getUri()); } if (!isUrlConsistentWithPayloadURI(node.getUri(), path)) { throw new InvalidURIException(node.getUri(), path); Loading Loading @@ -65,30 +66,34 @@ public class CreateNodeController extends BaseNodeController { throw new PermissionDeniedException(path); } // Check if parent node is a LinkNode and if so throw exception // Check if parent node is not a Container node and in case throw // appropriate exception if (!parentNode.getType().equals("vos:ContainerNode")) { if (parentNode.getType().equals("vos:LinkNode")) { throw new LinkFoundException(getParentPath(path)); } else { throw new ContainerNotFoundException(getParentPath(path)); } } nodeDao.createNode(node); return node; } // Assuming that this service implementation uses only ! as a separator // in the authority part of the URI private boolean isValidURI(String nodeURI) { private boolean isValidURI(String nodeURI) { String parsedAuthority; if(!nodeURI.startsWith("vos://")) { if (!nodeURI.startsWith("vos://")) { return false; } else { parsedAuthority = nodeURI.replaceAll("vos://", "").split("/", -1)[0]; } if(parsedAuthority.isEmpty() || !parsedAuthority.replace("~","!").equals(authority)) if (parsedAuthority.isEmpty() || !parsedAuthority.replace("~", "!").equals(authority)) { return false; } return true; } Loading Loading
src/main/java/it/inaf/oats/vospace/CreateNodeController.java +24 −19 Original line number Diff line number Diff line Loading @@ -32,8 +32,9 @@ public class CreateNodeController extends BaseNodeController { List<String> userGroups = principal.getGroups(); if (!isValidURI(node.getUri())) if (!isValidURI(node.getUri())) { throw new InvalidURIException(node.getUri()); } if (!isUrlConsistentWithPayloadURI(node.getUri(), path)) { throw new InvalidURIException(node.getUri(), path); Loading Loading @@ -65,30 +66,34 @@ public class CreateNodeController extends BaseNodeController { throw new PermissionDeniedException(path); } // Check if parent node is a LinkNode and if so throw exception // Check if parent node is not a Container node and in case throw // appropriate exception if (!parentNode.getType().equals("vos:ContainerNode")) { if (parentNode.getType().equals("vos:LinkNode")) { throw new LinkFoundException(getParentPath(path)); } else { throw new ContainerNotFoundException(getParentPath(path)); } } nodeDao.createNode(node); return node; } // Assuming that this service implementation uses only ! as a separator // in the authority part of the URI private boolean isValidURI(String nodeURI) { private boolean isValidURI(String nodeURI) { String parsedAuthority; if(!nodeURI.startsWith("vos://")) { if (!nodeURI.startsWith("vos://")) { return false; } else { parsedAuthority = nodeURI.replaceAll("vos://", "").split("/", -1)[0]; } if(parsedAuthority.isEmpty() || !parsedAuthority.replace("~","!").equals(authority)) if (parsedAuthority.isEmpty() || !parsedAuthority.replace("~", "!").equals(authority)) { return false; } return true; } Loading