diff --git a/src/main/java/it/inaf/oats/vospace/UriService.java b/src/main/java/it/inaf/oats/vospace/UriService.java index 405f97413781dfd4e5ffabcc147ff825ff9d77ad..b7d132a51de8ad17f869bc532fb79eedb1056347 100644 --- a/src/main/java/it/inaf/oats/vospace/UriService.java +++ b/src/main/java/it/inaf/oats/vospace/UriService.java @@ -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 += "/"; } diff --git a/src/main/java/it/inaf/oats/vospace/persistence/LocationDAO.java b/src/main/java/it/inaf/oats/vospace/persistence/LocationDAO.java index ef8618c646bfc08b45de78ea5bdc50d3294a5202..b6bb2f419920491cb71b709737ba669d0d679599 100644 --- a/src/main/java/it/inaf/oats/vospace/persistence/LocationDAO.java +++ b/src/main/java/it/inaf/oats/vospace/persistence/LocationDAO.java @@ -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")); diff --git a/src/main/java/it/inaf/oats/vospace/persistence/model/Storage.java b/src/main/java/it/inaf/oats/vospace/persistence/model/Storage.java index f936ac95aca3fc447c8dbfaa46afceeb42968696..3611d3cc8b72d9cd13529db881f5dee371dc18b0 100644 --- a/src/main/java/it/inaf/oats/vospace/persistence/model/Storage.java +++ b/src/main/java/it/inaf/oats/vospace/persistence/model/Storage.java @@ -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; } diff --git a/src/test/java/it/inaf/oats/vospace/TransferControllerTest.java b/src/test/java/it/inaf/oats/vospace/TransferControllerTest.java index a15c8811ff056214080ff00c05bec9218db79539..a35dc3d1518891da05a03df3fe4e8f4a65659a22 100644 --- a/src/test/java/it/inaf/oats/vospace/TransferControllerTest.java +++ b/src/test/java/it/inaf/oats/vospace/TransferControllerTest.java @@ -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)); diff --git a/src/test/java/it/inaf/oats/vospace/persistence/LocationDAOTest.java b/src/test/java/it/inaf/oats/vospace/persistence/LocationDAOTest.java index 067c2e6ba429437f370e9feffb4a5b33613ffe87..26037b5a9dfe68f9b535c20130afbbdb3d3e25c2 100644 --- a/src/test/java/it/inaf/oats/vospace/persistence/LocationDAOTest.java +++ b/src/test/java/it/inaf/oats/vospace/persistence/LocationDAOTest.java @@ -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