Commit d2500f43 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Changes after split base_path and base_url in storage table

parent 732a7ded
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ public class UriService {

        if (location != null && location.getType() == LocationType.PORTAL) {
            String fileName = nodeDao.getNodeOsName(relativePath);
            endpoint = "http://" + location.getSource().getHostname() + location.getSource().getBasePath();
            endpoint = "http://" + location.getSource().getHostname() + location.getSource().getBaseUrl();
            if (!endpoint.endsWith("/")) {
                endpoint += "/";
            }
+3 −2
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ public class LocationDAO {
    public Optional<Location> findPortalLocation(String host) {

        String sql = "SELECT location_id, location_type, storage_src_id, storage_dest_id,\n"
                + "storage_id, storage_type, base_path, hostname\n"
                + "storage_id, storage_type, base_path, base_url, hostname\n"
                + "FROM location l\n"
                + "JOIN storage s ON l.storage_src_id = s.storage_id OR l.storage_dest_id = s.storage_id\n"
                + "WHERE hostname = ?";
@@ -45,7 +45,7 @@ public class LocationDAO {
    public Optional<Location> getNodeLocation(String vosPath) {

        String sql = "SELECT location_id, location_type, storage_src_id, storage_dest_id,\n"
                + "storage_id, storage_type, base_path, hostname\n"
                + "storage_id, storage_type, base_path, base_url, hostname\n"
                + "FROM location l\n"
                + "JOIN storage s ON l.storage_src_id = s.storage_id OR l.storage_dest_id = s.storage_id\n"
                + "WHERE location_id = (\n"
@@ -96,6 +96,7 @@ public class LocationDAO {

            storage.setType(StorageType.parse(rs.getString("storage_type")));
            storage.setBasePath(rs.getString("base_path"));
            storage.setBaseUrl(rs.getString("base_url"));
            storage.setHostname(rs.getString("hostname"));

            Storage storageSrc = storagesMap.get(rs.getInt("storage_src_id"));
+9 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ public class Storage {
    private int id;
    private StorageType type;
    private String basePath;
    private String baseUrl;
    private String hostname;

    public int getId() {
@@ -31,6 +32,14 @@ public class Storage {
        this.basePath = basePath;
    }

    public String getBaseUrl() {
        return baseUrl;
    }

    public void setBaseUrl(String baseUrl) {
        this.baseUrl = baseUrl;
    }

    public String getHostname() {
        return hostname;
    }
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ public class TransferControllerTest {
        portalLocation.setId(2);
        Storage portalStorage = new Storage();
        portalStorage.setHostname("archive.lbto.org");
        portalStorage.setBasePath("/files");
        portalStorage.setBaseUrl("/files");
        portalLocation.setSource(portalStorage);
        when(locationDao.getNodeLocation(eq("/portalnode"))).thenReturn(Optional.of(portalLocation));
        when(locationDao.findPortalLocation(any())).thenReturn(Optional.of(portalLocation));
+4 −0
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@ import it.inaf.oats.vospace.persistence.model.Location;
import java.util.Optional;
import javax.sql.DataSource;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -38,6 +40,8 @@ public class LocationDAOTest {
        Location location = optLocation.get();

        assertEquals(hostname, location.getSource().getHostname());
        assertNotNull(location.getSource().getBaseUrl());
        assertNull(location.getSource().getBasePath());
    }

    @Test