Skip to content
Snippets Groups Projects
Commit 484cbe1b authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Retrieved MD5 of nodes

parent 32847848
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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");
......
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment