diff --git a/src/main/java/it/inaf/oats/vospace/UriService.java b/src/main/java/it/inaf/oats/vospace/UriService.java index 1dad3e5a4e662a18d05a49766ac17faecb569505..3ee470495c6654c1942c6f5319bcf71bf08861d8 100644 --- a/src/main/java/it/inaf/oats/vospace/UriService.java +++ b/src/main/java/it/inaf/oats/vospace/UriService.java @@ -22,11 +22,6 @@ import it.inaf.oats.vospace.exception.NodeBusyException; import it.inaf.oats.vospace.parent.persistence.LinkedServiceDAO; import it.inaf.oats.vospace.persistence.LocationDAO; 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.List; 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.Value; import org.springframework.stereotype.Service; -import org.springframework.util.StringUtils; @Service public class UriService { @@ -55,12 +49,9 @@ public class UriService { @Autowired private NodeDAO nodeDao; - - @Autowired - private LinkService linkService; @Autowired - private LocationDAO locationDAO; + private LinkService linkService; @Autowired private LinkedServiceDAO linkedServiceDAO; @@ -232,21 +223,7 @@ public class UriService { } } 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(); if (!"true".equals(NodeProperties.getNodePropertyByURI(node, NodeProperties.PUBLIC_READ_URI))) { diff --git a/src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java b/src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java index 658b86dd712e070ae9084ce5a5b4276c6216f78f..f07c4ce5be9a0ef976531dc6daf128d84db754d9 100644 --- a/src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java +++ b/src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java @@ -523,19 +523,6 @@ public class NodeDAO { 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) { String sql = "UPDATE node SET location_id = ? WHERE node_id = id_from_vos_path(?)"; diff --git a/src/main/java/it/inaf/oats/vospace/persistence/model/LocationType.java b/src/main/java/it/inaf/oats/vospace/persistence/model/LocationType.java index 99a208c9cc3ce80185057058b1127cdd8b5d53bc..a52c36c619b78a4e307f1ecc40afbff8173713c9 100644 --- a/src/main/java/it/inaf/oats/vospace/persistence/model/LocationType.java +++ b/src/main/java/it/inaf/oats/vospace/persistence/model/LocationType.java @@ -8,7 +8,6 @@ package it.inaf.oats.vospace.persistence.model; public enum LocationType { ASYNC("async"), - PORTAL("portal"), USER("user"); private final String name; diff --git a/src/main/java/it/inaf/oats/vospace/persistence/model/StorageType.java b/src/main/java/it/inaf/oats/vospace/persistence/model/StorageType.java index efff80e7f191b87ef873a9163661330c532171b5..0830a4b8b2084bc679b15d8540a884055e9cfcba 100644 --- a/src/main/java/it/inaf/oats/vospace/persistence/model/StorageType.java +++ b/src/main/java/it/inaf/oats/vospace/persistence/model/StorageType.java @@ -9,8 +9,7 @@ public enum StorageType { COLD("cold"), HOT("hot"), - LOCAL("local"), - PORTAL("portal"); + LOCAL("local"); private final String name; diff --git a/src/test/java/it/inaf/oats/vospace/TransferControllerTest.java b/src/test/java/it/inaf/oats/vospace/TransferControllerTest.java index d2dc0862b243e0a060687816173adc1c4e248248..df1d12a2dc39df864928f5692aafa934651708b2 100644 --- a/src/test/java/it/inaf/oats/vospace/TransferControllerTest.java +++ b/src/test/java/it/inaf/oats/vospace/TransferControllerTest.java @@ -91,15 +91,6 @@ public class TransferControllerTest { asyncLocation.setType(LocationType.ASYNC); asyncLocation.setId(1); 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 @@ -145,20 +136,6 @@ public class TransferControllerTest { 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 public void testPushToVoSpace() throws Exception { // job completion will be set by file service @@ -243,7 +220,7 @@ public class TransferControllerTest { JobSummary job = getFakePendingJob(); when(jobDao.getJob(eq("123"))).thenReturn(Optional.of(job)); - + when(jobDao.getTransferDetails(eq("123"))).thenReturn(new Transfer()); mockMvc.perform(get("/transfers/123/results/transferDetails") @@ -442,7 +419,7 @@ public class TransferControllerTest { assertTrue(ex instanceof ProtocolNotSupportedException); } - + private Jobs getFakeJobs() { Jobs jobs = new Jobs(); jobs.setVersion("1.1"); @@ -486,7 +463,7 @@ public class TransferControllerTest { } protected static String getResourceFileContent(String fileName) throws Exception { - try ( InputStream in = TransferControllerTest.class.getClassLoader().getResourceAsStream(fileName)) { + try (InputStream in = TransferControllerTest.class.getClassLoader().getResourceAsStream(fileName)) { return new String(in.readAllBytes(), StandardCharsets.UTF_8); } } diff --git a/src/test/resources/pullToVoSpace-portal.xml b/src/test/resources/pullToVoSpace-portal.xml deleted file mode 100644 index f83a08136da420a523657939a102367828f95718..0000000000000000000000000000000000000000 --- a/src/test/resources/pullToVoSpace-portal.xml +++ /dev/null @@ -1,7 +0,0 @@ -<vos:transfer xmlns:vos="http://www.ivoa.net/xml/VOSpace/v2.0" version="2.1"> - <vos:target>vos://example.com!vospace/portalnode</vos:target> - <vos:direction>pullToVoSpace</vos:direction> - <vos:protocol uri="ivo://ivoa.net/vospace/core#httpget"> - <vos:endpoint>http://archive.lbto.org/files/lbcr.20130512.060722.fits.gz</vos:endpoint> - </vos:protocol> -</vos:transfer> \ No newline at end of file diff --git a/src/test/resources/test-data.sql b/src/test/resources/test-data.sql index b9e8f6d18bb59a785e9e6dd52c923bfda64f70e2..03124d36099e28148378aaa913b0251cf73d69d5 100644 --- a/src/test/resources/test-data.sql +++ b/src/test/resources/test-data.sql @@ -4,12 +4,10 @@ INSERT INTO storage (storage_type, base_path, base_url, hostname) VALUES ('cold' INSERT INTO storage (storage_type, base_path, base_url, hostname) VALUES ('hot', '/mnt/hot_storage/users', NULL, 'server'); INSERT INTO storage (storage_type, base_path, base_url, hostname) VALUES ('local', '/home', NULL, 'localhost'); INSERT INTO storage (storage_type, base_path, base_url, hostname) VALUES ('local', '/home/vospace/upload', NULL, 'localhost'); -INSERT INTO storage (storage_type, base_path, base_url, hostname) VALUES ('portal', NULL, '/files/lbt', 'archive.lbto.org'); INSERT INTO location (location_type, storage_src_id, storage_dest_id) VALUES ('async', 1, 3); INSERT INTO location (location_type, storage_src_id, storage_dest_id) VALUES ('async', 2, 3); INSERT INTO location (location_type, storage_src_id, storage_dest_id) VALUES ('user', 4, 4); -INSERT INTO location (location_type, storage_src_id, storage_dest_id) VALUES ('portal', 5, 5); DELETE FROM node; ALTER SEQUENCE node_node_id_seq RESTART WITH 1;