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

Added check on parent node to CreateNodeController: if it's not typed as

ContainerNode then throw ContainerNodeNotFound exception
parent 0c30dec1
Branches
Tags
No related merge requests found
Pipeline #862 passed
......@@ -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);
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment