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
8bc3c0de
Commit
8bc3c0de
authored
4 years ago
by
Sara Bertocco
Browse files
Options
Downloads
Patches
Plain Diff
Some fix
parent
13ae3802
No related branches found
No related tags found
No related merge requests found
Pipeline
#1140
failed
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/SetNodeController.java
+5
-40
5 additions, 40 deletions
src/main/java/it/inaf/oats/vospace/SetNodeController.java
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java
+8
-15
8 additions, 15 deletions
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java
with
13 additions
and
55 deletions
src/main/java/it/inaf/oats/vospace/SetNodeController.java
+
5
−
40
View file @
8bc3c0de
...
...
@@ -14,6 +14,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
...
@@ -60,46 +61,10 @@ public class SetNodeController extends BaseNodeController {
LOG
.
debug
(
"setNode trying to modify type. Stored "
,
storedNodeType
+
", requested "
+
newNodeType
);
throw
new
PermissionDeniedException
(
path
);
}
// This method cannot be used to modify the accepts or provides list of Views for the Node.
// For this case, throws exception in NodeDAO
// This method cannot be used to create children of a container Node. (Non capisco, Sara)
// If a parent node in the URI path does not exist then the service SHALL throw a
// HTTP 404 status code including a ContainerNotFound fault in the entity-body
// For example, given the URI path /a/b/c, the service must throw a HTTP 404 status
// code including a ContainerNotFound fault in the entity-body if either /a or /a/b
// do not exist.
List
<
String
>
pathComponents
=
NodeUtils
.
subPathComponents
(
path
);
if
(
pathComponents
.
size
()
==
0
)
{
// Manage root node
throw
new
PermissionDeniedException
(
"root"
);
}
else
{
// Manage all precursors in full path
for
(
int
i
=
0
;
i
<
pathComponents
.
size
();
i
++)
{
String
tmpPath
=
pathComponents
.
get
(
i
);
Node
mynode
=
nodeDao
.
listNode
(
tmpPath
)
.
orElseThrow
(()
->
new
NodeNotFoundException
(
tmpPath
));
if
(
mynode
.
getType
().
equals
(
"vos:LinkNode"
)
&&
i
<
pathComponents
.
size
()-
1
)
// a LinkNode leaf can be deleted
throw
new
LinkFoundException
(
tmpPath
);
}
}
//The service SHOULD throw a HTTP 500 status code including an InternalFault fault
// in the entity-body if the operation fails
// Done in NodeDAO
// to be fixed
// A HTTP 200 status code and a Node representation in the entity-body The full
// expanded record for the node SHALL be returned, including any xsi:type
// specific extensions.
return
ResponseEntity
.
ok
(
nodeDao
.
setNode
(
node
));
Node
result
=
nodeDao
.
setNode
(
node
).
orElseThrow
(()
->
new
PermissionDeniedException
(
""
));
return
ResponseEntity
.
ok
(
result
);
}
}
This diff is collapsed.
Click to expand it.
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java
+
8
−
15
View file @
8bc3c0de
...
...
@@ -124,18 +124,11 @@ public class NodeDAO {
}
public
Node
setNode
(
Node
newNode
)
{
public
Optional
<
Node
>
setNode
(
Node
newNode
)
{
// Verify that the node is in the database
String
nodeURI
=
newNode
.
getUri
();
List
<
NodePaths
>
paths
=
getNodePathsFromDB
(
nodeURI
);
if
(
paths
.
isEmpty
())
{
throw
new
IllegalStateException
(
"Unable to find node during node update"
);
}
if
(
paths
.
size
()
>
1
)
{
throw
new
IllegalStateException
(
"Multiple ltree parent paths during node update"
);
}
String
vosPath
=
NodeUtils
.
getVosPath
(
newNode
);
// List<NodePaths> paths = getNodePathsFromDB(nodeURI);
// This method cannot be used to modify the accepts or provides list of Views for the Node.
// Only DataNodes has Views (see VOSpace Data Model
...
...
@@ -143,10 +136,10 @@ public class NodeDAO {
if
(
newNode
instanceof
DataNode
)
{
DataNode
dataNode
=
(
DataNode
)
newNode
;
List
<
View
>
requestedAcceptedViews
=
dataNode
.
getAccepts
();
List
<
View
>
savedAcceptedViews
=
getAcceptedViewsFromDB
(
paths
.
get
(
0
).
get
Path
()
);
List
<
View
>
savedAcceptedViews
=
getAcceptedViewsFromDB
(
vos
Path
);
// Get the Views of the saved node
List
<
View
>
requestedProvidedViews
=
dataNode
.
getProvides
();
List
<
View
>
savedProvidedViews
=
getProvidedViewsFromDB
(
paths
.
get
(
0
).
get
Path
()
);
List
<
View
>
savedProvidedViews
=
getProvidedViewsFromDB
(
vos
Path
);
if
(!
requestedAcceptedViews
.
isEmpty
())
{
//se sono non nulle, devo fare i controlli, altrimenti di sicuro l'utente non sta chiedendo di cambiarle
...
...
@@ -180,11 +173,11 @@ public class NodeDAO {
ps
.
setArray
(++
i
,
fromPropertyToArray
(
ps
,
NodeProperties
.
getNodePropertyByURI
(
newNode
,
NodeProperties
.
GROUP_READ_URI
)));
ps
.
setArray
(++
i
,
fromPropertyToArray
(
ps
,
NodeProperties
.
getNodePropertyByURI
(
newNode
,
NodeProperties
.
GROUP_WRITE_URI
)));
ps
.
setBoolean
(++
i
,
Boolean
.
valueOf
(
NodeProperties
.
getNodePropertyByURI
(
newNode
,
NodeProperties
.
PUBLIC_READ_URI
)));
ps
.
setString
(++
i
,
paths
.
get
(
0
).
get
Path
()
);
ps
.
setString
(++
i
,
vos
Path
);
return
ps
;
});
return
newNode
;
return
Optional
.
of
(
newNode
)
;
}
...
...
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