Commit af9345e9 authored by Sara Bertocco's avatar Sara Bertocco
Browse files

Working on task #3635 - Refactoring: create NodeUtils class

parent 5c4d42c2
Pipeline #959 passed with stages
in 32 seconds
...@@ -8,6 +8,7 @@ package it.inaf.oats.vospace.datamodel; ...@@ -8,6 +8,7 @@ package it.inaf.oats.vospace.datamodel;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import net.ivoa.xml.vospace.v2.Node; import net.ivoa.xml.vospace.v2.Node;
import net.ivoa.xml.vospace.v2.Property;
/** /**
* *
...@@ -44,6 +45,18 @@ public class NodeProperties { ...@@ -44,6 +45,18 @@ public class NodeProperties {
public static final String TYPE_URI = "ivo://ivoa.net/vospace/core#type"; // the nature or genre of the resource public static final String TYPE_URI = "ivo://ivoa.net/vospace/core#type"; // the nature or genre of the resource
public static 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;
}
// Returns all properties stored inside the node under the requested // Returns all properties stored inside the node under the requested
// property URI. // property URI.
public static List<String> getNodePropertyByURI(Node node, String propertyURI) { public static List<String> getNodePropertyByURI(Node node, String propertyURI) {
......
...@@ -87,11 +87,10 @@ public class NodeUtils { ...@@ -87,11 +87,10 @@ public class NodeUtils {
public static boolean checkIfWritable(Node myNode, String userName, List<String> userGroups) { public static boolean checkIfWritable(Node myNode, String userName, List<String> userGroups) {
// First check if parent node creator is == userid
List<String> nodeOwner List<String> nodeOwner
= NodeProperties.getNodePropertyByURI(myNode, NodeProperties.CREATOR_URI); = NodeProperties.getNodePropertyByURI(myNode, NodeProperties.CREATOR_URI);
//= getNodePropertyByURI(
// toBeDeletedNode, "ivo://ivoa.net/vospace/core#creator");
if (nodeOwner == null if (nodeOwner == null
|| nodeOwner.isEmpty() || nodeOwner.isEmpty()
...@@ -125,7 +124,6 @@ public class NodeUtils { ...@@ -125,7 +124,6 @@ public class NodeUtils {
} }
// DUPLICATED code from CreateNodeController - END
return true; return true;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment