diff --git a/src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java b/src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java index 72bd712ab9707f33a6a219549e6c15da0d453e93..e871bd45b491dbf9359fff006937af10df63b53a 100644 --- a/src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java +++ b/src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java @@ -10,7 +10,6 @@ import it.inaf.oats.vospace.URIUtils; import it.inaf.oats.vospace.datamodel.NodeProperties; import it.inaf.oats.vospace.datamodel.NodeUtils; import it.inaf.oats.vospace.exception.InternalFaultException; -import java.net.URISyntaxException; import java.sql.Array; import net.ivoa.xml.vospace.v2.Node; import java.sql.PreparedStatement; @@ -82,10 +81,10 @@ public class NodeDAO { } else { ps.setString(++i, jobId); } - ps.setString(++i, NodeProperties.getStandardNodePropertyByName(myNode, "creator")); - ps.setArray(++i, fromPropertyToArray(ps, NodeProperties.getStandardNodePropertyByName(myNode, "groupread"))); - ps.setArray(++i, fromPropertyToArray(ps, NodeProperties.getStandardNodePropertyByName(myNode, "groupwrite"))); - ps.setBoolean(++i, Boolean.valueOf(NodeProperties.getStandardNodePropertyByName(myNode, "publicread"))); + ps.setString(++i, NodeProperties.getNodePropertyByURI(myNode, NodeProperties.CREATOR_URI)); + ps.setArray(++i, fromPropertyToArray(ps, NodeProperties.getNodePropertyByURI(myNode, NodeProperties.GROUP_READ_URI))); + ps.setArray(++i, fromPropertyToArray(ps, NodeProperties.getNodePropertyByURI(myNode, NodeProperties.GROUP_WRITE_URI))); + ps.setBoolean(++i, Boolean.valueOf(NodeProperties.getNodePropertyByURI(myNode, NodeProperties.PUBLIC_READ_URI))); ps.setObject(++i, paths.get(0).getPath(), Types.OTHER); ps.setObject(++i, paths.get(0).getRelativePath(), Types.OTHER); ps.setObject(++i, NodeUtils.getDbNodeType(myNode), Types.OTHER); @@ -99,7 +98,7 @@ public class NodeDAO { String sql = "SELECT (CASE WHEN c.path = n.path THEN ? ELSE (? || ? || c.name) END) AS vos_path, c.node_id, c.name,\n" + "c.type, c.async_trans, c.sticky, c.job_id IS NOT NULL AS busy_state, c.creator_id, c.group_read, c.group_write,\n" - + "c.is_public, c.content_length, c.created_on, c.last_modified, c.accept_views, c.provide_views, c.quota\n" + + "c.is_public, c.content_length, c.created_on, c.last_modified, c.accept_views, c.provide_views, c.quota, c.content_md5\n" + "FROM node n\n" + "JOIN node c ON c.path ~ (n.path::varchar || ? || '*{1}')::lquery OR c.path = n.path\n" + "WHERE n.node_id = id_from_vos_path(?)\n" @@ -213,6 +212,9 @@ public class NodeDAO { addProperty(NodeProperties.QUOTA_URI, String.valueOf(rs.getString("quota")), properties); + addProperty(NodeProperties.MD5_URI, String.valueOf(rs.getString("content_md5")), + properties); + addProperty("urn:async_trans", String.valueOf(rs.getBoolean("async_trans")), properties); diff --git a/src/test/java/it/inaf/oats/vospace/persistence/NodeDAOTest.java b/src/test/java/it/inaf/oats/vospace/persistence/NodeDAOTest.java index cbef81635960fbbbb4be53f25ee8ddd4ce52efba..62c064ca1f3c52419ac44e9269c8947d32a07bf5 100644 --- a/src/test/java/it/inaf/oats/vospace/persistence/NodeDAOTest.java +++ b/src/test/java/it/inaf/oats/vospace/persistence/NodeDAOTest.java @@ -81,6 +81,16 @@ public class NodeDAOTest { assertEquals(bTime, NodeProperties.getNodePropertyByURI(root.getNodes().get(0), NodeProperties.DATE_URI)); } + @Test + public void testGetQuotaAndMD5() { + + ContainerNode node = (ContainerNode) dao.listNode("/test1/f1/f2_renamed").get(); + assertEquals("50000", NodeProperties.getNodePropertyByURI(node, NodeProperties.QUOTA_URI)); + DataNode child = (DataNode) node.getNodes().get(0); + assertEquals("4000", NodeProperties.getNodePropertyByURI(child, NodeProperties.LENGTH_URI)); + assertEquals("<md5sum>", NodeProperties.getNodePropertyByURI(child, NodeProperties.MD5_URI)); + } + @Test public void testGetNodeId() { Optional<Long> id1 = dao.getNodeId("/test1"); diff --git a/src/test/resources/test-data.sql b/src/test/resources/test-data.sql index 3872174c43e0b3270918bd90c8a849657ed0e9da..4d3234f2076c4a371b38df11e4657a771a4b6c0c 100644 --- a/src/test/resources/test-data.sql +++ b/src/test/resources/test-data.sql @@ -16,8 +16,8 @@ INSERT INTO node (parent_path, parent_relative_path, name, type, creator_id, loc INSERT INTO node (parent_path, parent_relative_path, name, type, creator_id, group_read, group_write, location_id) VALUES ('', NULL, 'test1', 'container', 'user1', '{"group1","group2"}','{"group2"}', 1); -- /test1 INSERT INTO node (parent_path, parent_relative_path, name, type, creator_id, location_id) VALUES ('2', '', 'f1', 'container', 'user1', 1); -- /test1/f1 (rel: /f1) -INSERT INTO node (parent_path, parent_relative_path, name, os_name, type, creator_id, location_id) VALUES ('2.3', '3', 'f2_renamed', 'f2', 'container', 'user1', 1); -- /test1/f1/f2_renamed (rel: /f1/f2) -INSERT INTO node (parent_path, parent_relative_path, name, type, creator_id, location_id) VALUES ('2.3.4', '3.4', 'f3', 'data', 'user1', 1); -- /test1/f1/f2_renamed/f3 (rel: /f1/f2/f3) +INSERT INTO node (parent_path, parent_relative_path, name, os_name, type, creator_id, location_id, quota) VALUES ('2.3', '3', 'f2_renamed', 'f2', 'container', 'user1', 1, 50000); -- /test1/f1/f2_renamed (rel: /f1/f2) +INSERT INTO node (parent_path, parent_relative_path, name, type, creator_id, location_id, content_md5, content_length) VALUES ('2.3.4', '3.4', 'f3', 'data', 'user1', 1, '<md5sum>', 4000); -- /test1/f1/f2_renamed/f3 (rel: /f1/f2/f3) INSERT INTO node (parent_path, parent_relative_path, name, type, creator_id, is_public, location_id) VALUES ('', NULL, 'test2', 'container', 'user2', true, 1); -- /test2 INSERT INTO node (parent_path, parent_relative_path, name, type, creator_id, is_public, location_id) VALUES ('6', '', 'f4', 'container', 'user2', true, 1); -- /test2/f4 (rel: /f4)