Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vospace-rest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VOSpace INAF
vospace-rest
Commits
c61d177c
Commit
c61d177c
authored
Jan 13, 2021
by
Nicola Fulvio Calabria
Browse files
Options
Downloads
Patches
Plain Diff
Added check on parent node to CreateNodeController: if it's not typed as
ContainerNode then throw ContainerNodeNotFound exception
parent
0c30dec1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#862
passed
Jan 13, 2021
Stage: build
Stage: test
Stage: dockerize
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/it/inaf/oats/vospace/CreateNodeController.java
+24
-19
24 additions, 19 deletions
src/main/java/it/inaf/oats/vospace/CreateNodeController.java
with
24 additions
and
19 deletions
src/main/java/it/inaf/oats/vospace/CreateNodeController.java
+
24
−
19
View file @
c61d177c
...
...
@@ -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
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment