Loading src/main/java/it/inaf/oats/vospace/UriService.java +1 −1 Original line number Diff line number Diff line Loading @@ -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 += "/"; } Loading src/main/java/it/inaf/oats/vospace/persistence/LocationDAO.java +3 −2 Original line number Diff line number Diff line Loading @@ -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 = ?"; Loading @@ -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" Loading Loading @@ -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")); Loading src/main/java/it/inaf/oats/vospace/persistence/model/Storage.java +9 −0 Original line number Diff line number Diff line Loading @@ -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() { Loading @@ -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; } Loading src/test/java/it/inaf/oats/vospace/TransferControllerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -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)); Loading src/test/java/it/inaf/oats/vospace/persistence/LocationDAOTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading Loading
src/main/java/it/inaf/oats/vospace/UriService.java +1 −1 Original line number Diff line number Diff line Loading @@ -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 += "/"; } Loading
src/main/java/it/inaf/oats/vospace/persistence/LocationDAO.java +3 −2 Original line number Diff line number Diff line Loading @@ -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 = ?"; Loading @@ -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" Loading Loading @@ -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")); Loading
src/main/java/it/inaf/oats/vospace/persistence/model/Storage.java +9 −0 Original line number Diff line number Diff line Loading @@ -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() { Loading @@ -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; } Loading
src/test/java/it/inaf/oats/vospace/TransferControllerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -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)); Loading
src/test/java/it/inaf/oats/vospace/persistence/LocationDAOTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading