Loading src/main/java/it/inaf/oats/vospace/SetNodeController.java +5 −40 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); } } src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java +8 −15 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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).getPath()); List<View> savedAcceptedViews = getAcceptedViewsFromDB(vosPath); // Get the Views of the saved node List<View> requestedProvidedViews = dataNode.getProvides(); List<View> savedProvidedViews = getProvidedViewsFromDB(paths.get(0).getPath()); List<View> savedProvidedViews = getProvidedViewsFromDB(vosPath); if (!requestedAcceptedViews.isEmpty()) { //se sono non nulle, devo fare i controlli, altrimenti di sicuro l'utente non sta chiedendo di cambiarle Loading Loading @@ -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).getPath()); ps.setString(++i, vosPath); return ps; }); return newNode; return Optional.of(newNode); } Loading Loading
src/main/java/it/inaf/oats/vospace/SetNodeController.java +5 −40 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); } }
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java +8 −15 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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).getPath()); List<View> savedAcceptedViews = getAcceptedViewsFromDB(vosPath); // Get the Views of the saved node List<View> requestedProvidedViews = dataNode.getProvides(); List<View> savedProvidedViews = getProvidedViewsFromDB(paths.get(0).getPath()); List<View> savedProvidedViews = getProvidedViewsFromDB(vosPath); if (!requestedAcceptedViews.isEmpty()) { //se sono non nulle, devo fare i controlli, altrimenti di sicuro l'utente non sta chiedendo di cambiarle Loading Loading @@ -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).getPath()); ps.setString(++i, vosPath); return ps; }); return newNode; return Optional.of(newNode); } Loading