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

Cleanup for merge

parent ebe67cc6
Loading
Loading
Loading
Loading
+0 −6
Original line number Original line Diff line number Diff line
@@ -6,20 +6,14 @@
package it.inaf.oats.vospace;
package it.inaf.oats.vospace;


import it.inaf.ia2.aa.data.User;
import it.inaf.ia2.aa.data.User;
import it.inaf.oats.vospace.datamodel.NodeProperties;
import it.inaf.oats.vospace.datamodel.NodeUtils;
import net.ivoa.xml.vospace.v2.Node;
import net.ivoa.xml.vospace.v2.Node;
import org.springframework.http.MediaType;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import it.inaf.oats.vospace.persistence.NodeDAO;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PutMapping;
import it.inaf.oats.vospace.exception.*;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
import net.ivoa.xml.vospace.v2.Property;


@RestController
@RestController
public class CreateNodeController extends BaseNodeController {
public class CreateNodeController extends BaseNodeController {
+2 −21
Original line number Original line Diff line number Diff line
@@ -8,7 +8,6 @@ package it.inaf.oats.vospace;
import it.inaf.ia2.aa.data.User;
import it.inaf.ia2.aa.data.User;
import it.inaf.oats.vospace.datamodel.NodeUtils;
import it.inaf.oats.vospace.datamodel.NodeUtils;
import it.inaf.oats.vospace.exception.InternalFaultException;
import it.inaf.oats.vospace.exception.InternalFaultException;
import it.inaf.oats.vospace.exception.InvalidURIException;
import it.inaf.oats.vospace.exception.NodeBusyException;
import it.inaf.oats.vospace.exception.NodeBusyException;
import it.inaf.oats.vospace.exception.NodeNotFoundException;
import it.inaf.oats.vospace.exception.NodeNotFoundException;
import it.inaf.oats.vospace.exception.PermissionDeniedException;
import it.inaf.oats.vospace.exception.PermissionDeniedException;
@@ -101,7 +100,7 @@ public class MoveService {
                } else {
                } else {
                    throw new UnsupportedOperationException("Creation of destination upon move not supported");
                    throw new UnsupportedOperationException("Creation of destination upon move not supported");
                    // TODO (if we want this): modify the return type of createDestination to obtain an ltree path
                    // TODO (if we want this): modify the return type of createDestination to obtain an ltree path
                    //parentDestLtree = this.createDestination(NodeUtils.getParentPath(destinationPath), user);
                    // parentDestLtree = this.createDestination(NodeUtils.getParentPath(destinationPath), user);
                }
                }
            }
            }


@@ -120,24 +119,6 @@ public class MoveService {
        if (path.equals("/")) {            
        if (path.equals("/")) {            
            throw new IllegalArgumentException("Cannot move root node or to root node");
            throw new IllegalArgumentException("Cannot move root node or to root node");
        }
        }
    }
    }  
    
    /*
    // Returns node id of created destination
    private Long createDestination(String path, User user) {
        List<String> components = NodeUtils.subPathComponents(path);

        for (int i = 0; i < components.size(); i++) {
            if (!this.checkNodeExistence(components.get(i))) {
                ContainerNode node = new ContainerNode();
                node.setUri("vos://" + this.authority + components.get(i));
                createNodeController.createNode(node, user);                
            }
        }
        
        return nodeDao.getNodeId(path).orElseThrow(()-> 
                new InternalFaultException("Unable to create destination at path: "+path));
            
    }*/


}
}
+0 −1
Original line number Original line Diff line number Diff line
@@ -5,7 +5,6 @@
 */
 */
package it.inaf.oats.vospace;
package it.inaf.oats.vospace;


import it.inaf.oats.vospace.exception.InvalidArgumentException;
import it.inaf.oats.vospace.exception.InvalidURIException;
import it.inaf.oats.vospace.exception.InvalidURIException;
import java.net.URI;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URISyntaxException;
+0 −56
Original line number Original line Diff line number Diff line
@@ -243,44 +243,6 @@ public class MoveServiceTest {
        
        
    }
    }
    
    
    /*
    @Test
    @Order(10)
    public void testMoveToUnexistingParent() {
        User user = mock(User.class);        
        when(user.getName()).thenReturn("user3");
        when(servletRequest.getUserPrincipal()).thenReturn(user);
        
        Optional<Long> sourceId = nodeDao.getNodeId("/test3/m1");
        assertTrue(sourceId.isPresent());
        Optional<Long> childId = nodeDao.getNodeId("/test3/m1/m2");
        assertTrue(childId.isPresent());
        
        Optional<Long> destParentId = nodeDao.getNodeId("/test4");
        assertTrue(destParentId.isPresent());
        
        Optional<Long> destCreatemeId = nodeDao.getNodeId("/test4/createme");
        assertTrue(destCreatemeId.isEmpty());
        
        // Rename
        moveService.processMoveJob(getTransfer("/test3/m1", "/test4/createme/dest1"));
        
        Optional<Long> checkSourceId = nodeDao.getNodeId("/test3/m1");
        assertTrue(checkSourceId.isEmpty());
        
        Optional<Long> newCreatemeId = nodeDao.getNodeId("/test4/createme");
        assertTrue(newCreatemeId.isPresent());        
        
        Optional<Long> newSourceId = nodeDao.getNodeId("/test4/createme/dest1");
        assertTrue(newSourceId.isPresent());
        assertEquals(sourceId.get(), newSourceId.get());

        Optional<Long> newChildId = nodeDao.getNodeId("/test4/createme/dest1/m2");
        assertTrue(newChildId.isPresent());
        assertEquals(childId.get(), newChildId.get());        
        
    }    */ 

    private Transfer getTransfer(String vosTarget, String vosDestination) {
    private Transfer getTransfer(String vosTarget, String vosDestination) {
        Transfer transfer = new Transfer();
        Transfer transfer = new Transfer();
        transfer.setTarget("vos://" + this.authority + vosTarget);
        transfer.setTarget("vos://" + this.authority + vosTarget);
@@ -288,22 +250,4 @@ public class MoveServiceTest {
        return transfer;
        return transfer;
    }
    }
    
    
    private ContainerNode getContainerNode(String vosPath, String owner, String writeGroups)
    {
        ContainerNode node = new ContainerNode();
        node.setUri("vos://"+this.authority+vosPath);
        Property ownerProp = new Property();
        ownerProp.setUri(NodeProperties.CREATOR_URI);
        ownerProp.setValue(owner);
        
        Property writeGroupsProp = new Property();
        writeGroupsProp.setUri(NodeProperties.GROUP_WRITE_URI);
        writeGroupsProp.setValue(writeGroups);
        
        node.getProperties().add(ownerProp);
        node.getProperties().add(writeGroupsProp);
        
        return node;
    }

}
}
+0 −71
Original line number Original line Diff line number Diff line
@@ -93,77 +93,6 @@ public class NodeDAOTest {
        assertTrue(id3.isEmpty());
        assertTrue(id3.isEmpty());
    }
    }
    
    
    /*
    @Test
    public void testGetNodeById() {
        Optional<Long> id1 = dao.getNodeId("/test1/f1");
        assertTrue(id1.isPresent());
        
        assertThrows(InternalFaultException.class,
                () -> {
                    dao.getNodeById(id1.get(), true);
                });
        
        Optional<Node> opt1 = dao.getNodeById(id1.get(), false);
        
        assertTrue(opt1.isPresent());
        assertTrue(NodeUtils.getVosPath(opt1.get()).equals("/test1/f1"));
    }*/    

    /*
    @Test
    public void testListNodesInBranch() {
        Optional<Long> id1 = dao.getNodeId("/test1/f1");
        assertTrue(id1.isPresent());
        
        List<Node> result = dao.listNodesInBranch(id1.get(), false);
        assertEquals(3, result.size());
        // Check if list has root node at index 0
        Node root = result.get(0);
        assertEquals("/test1/f1", NodeUtils.getVosPath(root));

        assertThrows(InternalFaultException.class,
                () -> {
                    dao.listNodesInBranch(id1.get(), true);
                });

    }*/

    /*
    @Test
    public void testSetBranchBusy() {
        Optional<Long> rootId = dao.getNodeId("/test1/f1");
        assertTrue(rootId.isPresent());
        
        dao.setBranchBusy(rootId.get(), true);
        List<Node> busyList = dao.listNodesInBranch(rootId.get(), false);
        boolean busyTrue = busyList.stream().allMatch((n) -> {
            if (n instanceof DataNode) {
                return ((DataNode) n).isBusy();
            } else {
                return true;
            }
        }
        );

        assertTrue(busyTrue);

        dao.setBranchBusy(rootId.get(), false);

        busyList = dao.listNodesInBranch(rootId.get(), false);

        boolean busyFalse = busyList.stream().allMatch((n) -> {
            if (n instanceof DataNode) {
                return !((DataNode) n).isBusy();
            } else {
                return true;
            }
        }
        );

        assertTrue(busyFalse);
    } */
    
    @Test
    @Test
    public void testGetShortNodeDescriptor(){
    public void testGetShortNodeDescriptor(){
        String userName = "user3";
        String userName = "user3";