Commit bc52987f authored by Nicola Fulvio Calabria's avatar Nicola Fulvio Calabria
Browse files

bugfix allow destination of move to be sticky

parent 0dc0489f
Loading
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -246,7 +246,8 @@ public class NodeDAO {
            String userId, List<String> userGroups) {

        String sql = "SELECT path,\n"
                + "NOT (n.async_trans OR n.sticky OR COALESCE(location_type = 'async', FALSE)) AS is_writable,\n"
                + "NOT (n.async_trans OR COALESCE(location_type = 'async', FALSE)) AS is_writable,\n"
                + "n.sticky AS is_sticky,\n"
                + "((SELECT COUNT(*) FROM (SELECT UNNEST(?) INTERSECT SELECT UNNEST(n.group_write)) AS allowed_groups ) = 0 AND\n"
                + "n.creator_id <> ?) AS is_permission_denied,\n"
                + "n.type = 'container' AS is_container,\n"
@@ -280,8 +281,9 @@ public class NodeDAO {
            Boolean isWritable = rs.getBoolean("is_writable");
            Boolean isBusy = rs.getBoolean("busy_state");
            Boolean isPermissionDenied = rs.getBoolean("is_permission_denied");
            Boolean isSticky = rs.getBoolean("is_sticky");

            ShortNodeDescriptor result = new ShortNodeDescriptor(nodePath, isContainer, isWritable, isBusy, isPermissionDenied);
            ShortNodeDescriptor result = new ShortNodeDescriptor(nodePath, isContainer, isWritable, isBusy, isPermissionDenied, isSticky);

            return Optional.of(result);
        });
@@ -610,13 +612,15 @@ public class NodeDAO {
        private final boolean writable;
        private final boolean busy;
        private final boolean permissionDenied;
        private final boolean sticky;

        public ShortNodeDescriptor(String nodeLtreePath, boolean container, boolean writable, boolean busy, boolean permissionDenied) {
        public ShortNodeDescriptor(String nodeLtreePath, boolean container, boolean writable, boolean busy, boolean permissionDenied, boolean sticky) {
            this.nodeLtreePath = nodeLtreePath;
            this.container = container;
            this.writable = writable;
            this.busy = busy;
            this.permissionDenied = permissionDenied;
            this.sticky = sticky;
        }

        public String getDestinationNodeLtreePath() {
@@ -639,6 +643,10 @@ public class NodeDAO {
            return permissionDenied;
        }
        
        public boolean isSticky() {
            return sticky;
        }

    }

    private class NodePaths {
+3 −2
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@ package it.inaf.oats.vospace.persistence;
import it.inaf.oats.vospace.datamodel.NodeProperties;
import it.inaf.oats.vospace.exception.InternalFaultException;
import it.inaf.oats.vospace.persistence.NodeDAO.ShortNodeDescriptor;
import java.lang.reflect.Field;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
@@ -108,8 +107,9 @@ public class NodeDAOTest {
        ShortNodeDescriptor snd1 = snd1Opt.get();
        assertTrue(snd1.isContainer());
        assertFalse(snd1.isPermissionDenied());
        assertFalse(snd1.isWritable());
        assertTrue(snd1.isWritable());
        assertFalse(snd1.isBusy());
        assertTrue(snd1.isSticky());

        assertEquals("9.13", snd1.getDestinationNodeLtreePath());

@@ -120,6 +120,7 @@ public class NodeDAOTest {
        assertTrue(snd1.isWritable());
        assertFalse(snd1.isPermissionDenied());
        assertTrue(snd1.isBusy());
        assertFalse(snd1.isSticky());

        snd1Opt
                = dao.getShortNodeDescriptor("/test3/masynctrans", userName, userGroups);