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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VOSpace INAF
vospace-rest
Commits
da45c497
Commit
da45c497
authored
4 years ago
by
Sara Bertocco
Browse files
Options
Downloads
Patches
Plain Diff
Working on redmine task #3635src/main/java/it/inaf/oats/vospace/BaseNodeController.java
parent
ecc7ab5f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/it/inaf/oats/vospace/CreateNodeController.java
+6
-54
6 additions, 54 deletions
src/main/java/it/inaf/oats/vospace/CreateNodeController.java
with
6 additions
and
54 deletions
src/main/java/it/inaf/oats/vospace/CreateNodeController.java
+
6
−
54
View file @
da45c497
package
it.inaf.oats.vospace
;
package
it.inaf.oats.vospace
;
import
it.inaf.ia2.aa.data.User
;
import
it.inaf.ia2.aa.data.User
;
import
it.inaf.oats.vospace.datamodel.NodeProperties
;
import
net.ivoa.xml.vospace.v2.Node
;
import
net.ivoa.xml.vospace.v2.Node
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
@@ -61,8 +62,8 @@ public class CreateNodeController extends BaseNodeController {
...
@@ -61,8 +62,8 @@ public class CreateNodeController extends BaseNodeController {
// First check if parent node creator is == userid
// First check if parent node creator is == userid
List
<
String
>
nodeOwner
List
<
String
>
nodeOwner
=
getNodePropertyByURI
(
=
NodeProperties
.
getNodePropertyByURI
(
parentNode
,
"ivo://ivoa.net/vospace/core#creator"
);
parentNode
,
NodeProperties
.
CREATOR_URI
);
if
(
nodeOwner
==
null
if
(
nodeOwner
==
null
||
nodeOwner
.
isEmpty
()
||
nodeOwner
.
isEmpty
()
...
@@ -78,7 +79,7 @@ public class CreateNodeController extends BaseNodeController {
...
@@ -78,7 +79,7 @@ public class CreateNodeController extends BaseNodeController {
}
}
List
<
String
>
groupWritePropValues
List
<
String
>
groupWritePropValues
=
getNodePropertyByURI
(
parentNode
,
=
NodeProperties
.
getNodePropertyByURI
(
parentNode
,
"ivo://ivoa.net/vospace/core#groupwrite"
);
"ivo://ivoa.net/vospace/core#groupwrite"
);
// If groupwrite property is absent in Parent Node throw exception
// If groupwrite property is absent in Parent Node throw exception
...
@@ -88,7 +89,7 @@ public class CreateNodeController extends BaseNodeController {
...
@@ -88,7 +89,7 @@ public class CreateNodeController extends BaseNodeController {
}
}
List
<
String
>
nodeGroups
List
<
String
>
nodeGroups
=
parsePropertyStringToList
(
groupWritePropValues
.
get
(
0
));
=
NodeProperties
.
parsePropertyStringToList
(
groupWritePropValues
.
get
(
0
));
if
(
nodeGroups
.
isEmpty
()
if
(
nodeGroups
.
isEmpty
()
||
!
nodeGroups
.
stream
()
||
!
nodeGroups
.
stream
()
...
@@ -129,55 +130,6 @@ public class CreateNodeController extends BaseNodeController {
...
@@ -129,55 +130,6 @@ 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
)
{
String
[]
parsedPath
=
path
.
split
(
"[/]+"
);
if
(
parsedPath
.
length
<
2
||
!
parsedPath
[
0
].
isEmpty
())
{
throw
new
IllegalArgumentException
();
}
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"/"
);
for
(
int
i
=
1
;
i
<
parsedPath
.
length
-
1
;
i
++)
{
sb
.
append
(
parsedPath
[
i
]);
if
(
i
<
parsedPath
.
length
-
2
)
{
sb
.
append
(
"/"
);
}
}
return
sb
.
toString
();
}
// Returns all properties stored inside the node under the requested
// property URI.
private
List
<
String
>
getNodePropertyByURI
(
Node
node
,
String
propertyURI
)
{
List
<
String
>
propertyList
=
node
.
getProperties
().
stream
()
.
filter
((
i
)
->
i
.
getUri
()
.
equals
(
propertyURI
))
.
map
((
i
)
->
i
.
getValue
())
.
collect
(
Collectors
.
toList
());
return
propertyList
;
}
private
List
<
String
>
parsePropertyStringToList
(
String
property
)
{
// If separator changes, this method should remain consistent
// For now it assumes that " " is the separator
String
separator
=
" "
;
String
trimmedProperty
=
property
.
trim
();
if
(
trimmedProperty
.
isEmpty
())
{
return
List
.
of
();
}
return
List
.
of
(
trimmedProperty
.
split
(
separator
));
}
}
}
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