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
47342b33
Commit
47342b33
authored
4 years ago
by
Sara Bertocco
Browse files
Options
Downloads
Patches
Plain Diff
Working on task #3635 - Refactoring: create NodeUtils class
parent
731bc2a7
No related branches found
No related tags found
No related merge requests found
Pipeline
#958
passed
4 years ago
Stage: build
Stage: test
Stage: dockerize
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/it/inaf/oats/vospace/CreateNodeController.java
+5
-39
5 additions, 39 deletions
src/main/java/it/inaf/oats/vospace/CreateNodeController.java
src/main/java/it/inaf/oats/vospace/UriService.java
+2
-11
2 additions, 11 deletions
src/main/java/it/inaf/oats/vospace/UriService.java
with
7 additions
and
50 deletions
src/main/java/it/inaf/oats/vospace/CreateNodeController.java
+
5
−
39
View file @
47342b33
...
...
@@ -2,6 +2,7 @@ package it.inaf.oats.vospace;
import
it.inaf.ia2.aa.data.User
;
import
it.inaf.oats.vospace.datamodel.NodeProperties
;
import
it.inaf.oats.vospace.datamodel.NodeUtils
;
import
net.ivoa.xml.vospace.v2.Node
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
...
@@ -60,45 +61,10 @@ public class CreateNodeController extends BaseNodeController {
}
}
// First check if parent node creator is == userid
List
<
String
>
nodeOwner
=
NodeProperties
.
getNodePropertyByURI
(
parentNode
,
NodeProperties
.
CREATOR_URI
);
if
(
nodeOwner
==
null
||
nodeOwner
.
isEmpty
()
||
!
nodeOwner
.
get
(
0
).
equals
(
principal
.
getName
()))
{
// Node owner check has failed: let's check if user can write
// due to group privileges
List
<
String
>
userGroups
=
principal
.
getGroups
();
// If the user doesn't belong to any groups throw exception
if
(
userGroups
==
null
||
userGroups
.
isEmpty
())
{
throw
new
PermissionDeniedException
(
path
);
}
List
<
String
>
groupWritePropValues
=
NodeProperties
.
getNodePropertyByURI
(
parentNode
,
"ivo://ivoa.net/vospace/core#groupwrite"
);
// If groupwrite property is absent in Parent Node throw exception
if
(
groupWritePropValues
==
null
||
groupWritePropValues
.
isEmpty
())
{
if
(!
NodeUtils
.
checkIfWritable
(
parentNode
,
principal
.
getName
(),
principal
.
getGroups
()))
{
throw
new
PermissionDeniedException
(
path
);
}
List
<
String
>
nodeGroups
=
NodeProperties
.
parsePropertyStringToList
(
groupWritePropValues
.
get
(
0
));
if
(
nodeGroups
.
isEmpty
()
||
!
nodeGroups
.
stream
()
.
anyMatch
((
i
)
->
userGroups
.
contains
(
i
)))
{
throw
new
PermissionDeniedException
(
path
);
}
}
nodeDao
.
createNode
(
node
);
return
node
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/it/inaf/oats/vospace/UriService.java
+
2
−
11
View file @
47342b33
...
...
@@ -3,6 +3,7 @@ package it.inaf.oats.vospace;
import
it.inaf.ia2.aa.ServletRapClient
;
import
it.inaf.ia2.aa.data.User
;
import
it.inaf.ia2.rap.client.call.TokenExchangeRequest
;
import
it.inaf.oats.vospace.datamodel.NodeProperties
;
import
it.inaf.oats.vospace.persistence.NodeDAO
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -73,7 +74,7 @@ public class UriService {
// TODO add token for authenticated access
String
endpoint
=
fileServiceUrl
+
relativePath
+
"?jobId="
+
job
.
getJobId
();
if
(!
"true"
.
equals
(
getProperty
(
node
,
"publicread"
)))
{
if
(!
"true"
.
equals
(
NodeProperties
.
getProperty
(
node
,
"publicread"
)))
{
endpoint
+=
"&token="
+
getEndpointToken
(
fileServiceUrl
+
relativePath
);
}
...
...
@@ -97,16 +98,6 @@ public class UriService {
return
rapClient
.
exchangeToken
(
exchangeRequest
,
servletRequest
);
}
private
String
getProperty
(
Node
node
,
String
propertyName
)
{
for
(
Property
property
:
node
.
getProperties
())
{
if
(
property
.
getUri
().
equals
(
"ivo://ivoa.net/vospace/core#"
.
concat
(
propertyName
)))
{
return
property
.
getValue
();
}
}
return
null
;
}
private
Transfer
getTransfer
(
JobSummary
job
)
{
// TODO add checks on data type
return
(
Transfer
)
job
.
getJobInfo
().
getAny
().
get
(
0
);
...
...
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