Commit 3e0c800b authored by Nicola Fulvio Calabria's avatar Nicola Fulvio Calabria
Browse files

Cleaned commented parts

parent a626fb14
Loading
Loading
Loading
Loading
+2 −25
Original line number Original line Diff line number Diff line
@@ -22,11 +22,6 @@ import it.inaf.oats.vospace.exception.NodeBusyException;
import it.inaf.oats.vospace.parent.persistence.LinkedServiceDAO;
import it.inaf.oats.vospace.parent.persistence.LinkedServiceDAO;
import it.inaf.oats.vospace.persistence.LocationDAO;
import it.inaf.oats.vospace.persistence.LocationDAO;
import it.inaf.oats.vospace.persistence.NodeDAO;
import it.inaf.oats.vospace.persistence.NodeDAO;
import it.inaf.oats.vospace.persistence.model.Location;
import it.inaf.oats.vospace.persistence.model.LocationType;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.List;
import java.util.List;
import java.util.Objects;
import java.util.Objects;
@@ -42,7 +37,6 @@ import net.ivoa.xml.vospace.v2.Transfer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;


@Service
@Service
public class UriService {
public class UriService {
@@ -59,9 +53,6 @@ public class UriService {
    @Autowired
    @Autowired
    private LinkService linkService;
    private LinkService linkService;


    @Autowired
    private LocationDAO locationDAO;

    @Autowired
    @Autowired
    private LinkedServiceDAO linkedServiceDAO;
    private LinkedServiceDAO linkedServiceDAO;


@@ -232,21 +223,7 @@ public class UriService {
            }
            }
        } else {
        } else {


            /*
            Location location = locationDAO.getNodeLocation(relativePath).orElse(null);

            
            if (location != null && location.getType() == LocationType.PORTAL) {
                String fileName = nodeDao.getNodeOsName(relativePath);
                endpoint = "http://" + location.getSource().getHostname() + location.getSource().getBaseUrl();
                if (!endpoint.endsWith("/")) {
                    endpoint += "/";
                }
                endpoint += fileName;
            } else {*/
            endpoint = fileServiceUrl + urlEncodePath(relativePath);
            endpoint = fileServiceUrl + urlEncodePath(relativePath);
            //}

            endpoint += "?jobId=" + job.getJobId();
            endpoint += "?jobId=" + job.getJobId();


            if (!"true".equals(NodeProperties.getNodePropertyByURI(node, NodeProperties.PUBLIC_READ_URI))) {
            if (!"true".equals(NodeProperties.getNodePropertyByURI(node, NodeProperties.PUBLIC_READ_URI))) {
+0 −13
Original line number Original line Diff line number Diff line
@@ -523,19 +523,6 @@ public class NodeDAO {
        return jdbcTemplate.queryForObject(sql, args, types, Integer.class);
        return jdbcTemplate.queryForObject(sql, args, types, Integer.class);
    }
    }


    /*
    public String getNodeOsName(String vosPath) {
        String sql = "SELECT \n"
                + "COALESCE(os_name, name) AS os_name\n"
                + "FROM node n\n"
                + "WHERE node_id = id_from_vos_path(?)";

        Object[] args = {vosPath};
        int[] types = {Types.VARCHAR};

        return jdbcTemplate.queryForObject(sql, args, types, String.class);
    }*/

    public void setNodeLocation(String vosPath, int locationId) {
    public void setNodeLocation(String vosPath, int locationId) {


        String sql = "UPDATE node SET location_id = ? WHERE node_id = id_from_vos_path(?)";
        String sql = "UPDATE node SET location_id = ? WHERE node_id = id_from_vos_path(?)";
+0 −1
Original line number Original line Diff line number Diff line
@@ -8,7 +8,6 @@ package it.inaf.oats.vospace.persistence.model;
public enum LocationType {
public enum LocationType {


    ASYNC("async"),
    ASYNC("async"),
    PORTAL("portal"),
    USER("user");
    USER("user");


    private final String name;
    private final String name;
+1 −2
Original line number Original line Diff line number Diff line
@@ -9,8 +9,7 @@ public enum StorageType {


    COLD("cold"),
    COLD("cold"),
    HOT("hot"),
    HOT("hot"),
    LOCAL("local"),
    LOCAL("local");
    PORTAL("portal");


    private final String name;
    private final String name;


+3 −26
Original line number Original line Diff line number Diff line
@@ -91,15 +91,6 @@ public class TransferControllerTest {
        asyncLocation.setType(LocationType.ASYNC);
        asyncLocation.setType(LocationType.ASYNC);
        asyncLocation.setId(1);
        asyncLocation.setId(1);
        when(locationDao.getNodeLocation(eq("/mynode"))).thenReturn(Optional.of(asyncLocation));
        when(locationDao.getNodeLocation(eq("/mynode"))).thenReturn(Optional.of(asyncLocation));

        Location portalLocation = new Location();
        portalLocation.setType(LocationType.PORTAL);
        portalLocation.setId(2);
        Storage portalStorage = new Storage();
        portalStorage.setHostname("archive.lbto.org");
        portalStorage.setBaseUrl("/files");
        portalLocation.setSource(portalStorage);
        when(locationDao.getNodeLocation(eq("/portalnode"))).thenReturn(Optional.of(portalLocation));        
    }
    }


    @Test
    @Test
@@ -145,20 +136,6 @@ public class TransferControllerTest {
        verify(jobDao, times(2)).updateJob(argThat(j -> ExecutionPhase.QUEUED == j.getPhase()), any());
        verify(jobDao, times(2)).updateJob(argThat(j -> ExecutionPhase.QUEUED == j.getPhase()), any());
    }
    }


    /*
    @Test
    public void testPullToVoSpacePortal() throws Exception {

        when(nodeDao.getNodeOsName(eq("/portalnode"))).thenReturn("file.fits");

        String endpoint = testAsyncTransferNegotiation("/portalnode",
                getResourceFileContent("pullToVoSpace-portal.xml"), ExecutionPhase.COMPLETED);

        assertTrue(endpoint.startsWith("http://archive.lbto.org"));

        verify(nodeDao, times(1)).setNodeLocation(eq("/portalnode"), eq(2), eq("lbcr.20130512.060722.fits.gz"));
    }*/

    @Test
    @Test
    public void testPushToVoSpace() throws Exception {
    public void testPushToVoSpace() throws Exception {
        // job completion will be set by file service
        // job completion will be set by file service
Loading