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

Retrieved sticky property

parent 22392731
No related branches found
No related tags found
No related merge requests found
Pipeline #989 passed
......@@ -11,7 +11,6 @@ import javax.servlet.http.HttpServletRequest;
import net.ivoa.xml.uws.v1.JobSummary;
import net.ivoa.xml.uws.v1.ResultReference;
import net.ivoa.xml.vospace.v2.Node;
import net.ivoa.xml.vospace.v2.Property;
import net.ivoa.xml.vospace.v2.Protocol;
import net.ivoa.xml.vospace.v2.Transfer;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -74,7 +73,7 @@ public class UriService {
// TODO add token for authenticated access
String endpoint = fileServiceUrl + relativePath + "?jobId=" + job.getJobId();
if (!"true".equals(NodeProperties.getProperty(node, "publicread"))) {
if (!"true".equals(NodeProperties.getNodePropertyByURI(node, NodeProperties.PUBLIC_READ_URI))) {
endpoint += "&token=" + getEndpointToken(fileServiceUrl + relativePath);
}
......
......@@ -23,7 +23,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
@Repository
public class NodeDAO {
......@@ -89,7 +88,7 @@ public class NodeDAO {
public Optional<Node> listNode(String path) {
String sql = "SELECT os.vos_path, n.node_id, type, async_trans, busy_state, creator_id, group_read, group_write,\n"
String sql = "SELECT os.vos_path, n.node_id, type, async_trans, sticky, busy_state, creator_id, group_read, group_write,\n"
+ "is_public, content_length, created_on, last_modified, accept_views, provide_views\n"
+ "FROM node n\n"
+ "JOIN node_vos_path os ON n.node_id = os.node_id\n"
......@@ -178,12 +177,14 @@ public class NodeDAO {
addProperty(getPropertyURI("groupwrite"), getGroupsString(rs, "group_write"),
properties);
addProperty(getPropertyURI("publicread"), rs.getString("is_public"),
addProperty(getPropertyURI("publicread"), String.valueOf(rs.getBoolean("is_public")),
properties);
addProperty("urn:async_trans", rs.getString("async_trans"),
addProperty("urn:async_trans", String.valueOf(rs.getBoolean("async_trans")),
properties);
addProperty("urn:sticky", String.valueOf(rs.getBoolean("sticky")), properties);
node.setProperties(properties);
return node;
}
......@@ -205,7 +206,7 @@ public class NodeDAO {
+ "async_trans, busy_state, owner_id, creator_id, group_read, "
+ "group_write, is_public, delta, content_type, content_encoding, "
+ "content_length, content_md5, created_on, last_modified, "
+ "accept_views, provide_views, protocols)\n";
+ "accept_views, provide_views, protocols, sticky)\n";
String deleteSql = "DELETE \n"
+ "FROM node n\n"
......@@ -218,7 +219,7 @@ public class NodeDAO {
+ "async_trans, busy_state, owner_id, creator_id, group_read, "
+ "group_write, is_public, delta, content_type, content_encoding, "
+ "content_length, content_md5, created_on, last_modified, "
+ "accept_views, provide_views, protocols\n";
+ "accept_views, provide_views, protocols, sticky\n";
String withSql = "WITH del AS (" + deleteSql + ")";
......
package it.inaf.oats.vospace.persistence;
import it.inaf.oats.vospace.datamodel.NodeProperties;
import it.inaf.oats.vospace.datamodel.NodeUtils;
import java.util.ArrayList;
import java.util.List;
import javax.sql.DataSource;
......@@ -54,6 +56,8 @@ public class NodeDAOTest {
ContainerNode root = (ContainerNode) dao.listNode("/").get();
assertEquals(2, root.getNodes().size());
assertEquals("true", NodeProperties.getNodePropertyAsListByURI(root, NodeProperties.PUBLIC_READ_URI).get(0));
assertEquals("group1 group2", getProperty(root.getNodes().get(0), "ivo://ivoa.net/vospace/core#groupread"));
}
......
DELETE FROM node;
ALTER SEQUENCE node_node_id_seq RESTART WITH 1;
INSERT INTO node (parent_path, parent_relative_path, name, type, owner_id, creator_id, location_id) VALUES (NULL, NULL, '', 'container', '0', '0', 1);
INSERT INTO node (parent_path, parent_relative_path, name, type, owner_id, creator_id, location_id, is_public) VALUES (NULL, NULL, '', 'container', '0', '0', 1, true);
INSERT INTO node (parent_path, parent_relative_path, name, type, owner_id, creator_id, group_read, group_write, location_id) VALUES ('', NULL, 'test1', 'container', 'user1', 'user1', '{"group1","group2"}','{"group2"}', 1); -- /test1
INSERT INTO node (parent_path, parent_relative_path, name, type, owner_id, creator_id, location_id) VALUES ('2', '', 'f1', 'container', 'user1', 'user1', 1); -- /test1/f1 (rel: /f1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment