Loading src/main/java/it/inaf/oats/vospace/JobService.java +2 −18 Original line number Diff line number Diff line Loading @@ -151,26 +151,10 @@ public class JobService { if (isAsyncRecall(transfer)) { asyncTransfService.startJob(job); return transfer; } else { throw new InvalidArgumentException("Unsupported pullToVoSpace transfer"); } for (Protocol protocol : transfer.getProtocols()) { switch (protocol.getUri()) { case "ivo://ivoa.net/vospace/core#httpget": String nodeUri = transfer.getTarget(); String contentUri = protocol.getEndpoint(); uriService.setNodeRemoteLocation(nodeUri, contentUri); Transfer negotiatedTransfer = uriService.getNegotiatedTransfer(job, transfer); setJobResults(job, transfer); // Special case: import of a node from a portal file server // doesn't imply file transfer, so it can be set to completed job.setPhase(ExecutionPhase.COMPLETED); return negotiatedTransfer; default: throw new InvalidArgumentException("Unsupported pullToVoSpace protocol: " + protocol.getUri()); } } throw new InvalidArgumentException("Transfer contains no protocols"); } private boolean isAsyncRecall(Transfer transfer) { Loading src/main/java/it/inaf/oats/vospace/UriService.java +0 −19 Original line number Diff line number Diff line Loading @@ -282,25 +282,6 @@ public class UriService { return rapClient.exchangeToken(exchangeRequest, servletRequest); } public void setNodeRemoteLocation(String nodeUri, String contentUri) { URL url; try { url = new URL(contentUri); } catch (MalformedURLException ex) { throw new InternalFaultException(ex); } Location location = locationDAO.findPortalLocation(url.getHost()).orElseThrow(() -> new InternalFaultException("No registered location found for host " + url.getHost())); String vosPath = URIUtils.returnVosPathFromNodeURI(nodeUri, authority); // String fileName = url.getPath().substring(url.getPath().lastIndexOf("/") + 1); nodeDao.setNodeLocation(vosPath, location.getId()); } public Transfer getTransfer(JobSummary job) { List<Object> jobPayload = job.getJobInfo().getAny(); Loading src/main/java/it/inaf/oats/vospace/persistence/LocationDAO.java +0 −15 Original line number Diff line number Diff line Loading @@ -32,21 +32,6 @@ public class LocationDAO { jdbcTemplate = new JdbcTemplate(dataSource); } 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, 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 = ?"; return jdbcTemplate.query(sql, ps -> { ps.setString(1, host); }, rs -> { return getLocation(rs, () -> new IllegalStateException("Found multiple locations for the same hostname")); }); } public Optional<Location> getNodeLocation(String vosPath) { String sql = "SELECT l.location_id, location_type, storage_src_id, storage_dest_id,\n" Loading src/test/java/it/inaf/oats/vospace/TransferControllerTest.java +1 −2 Original line number Diff line number Diff line Loading @@ -100,7 +100,6 @@ public class TransferControllerTest { portalStorage.setBaseUrl("/files"); portalLocation.setSource(portalStorage); when(locationDao.getNodeLocation(eq("/portalnode"))).thenReturn(Optional.of(portalLocation)); when(locationDao.findPortalLocation(any())).thenReturn(Optional.of(portalLocation)); } @Test Loading src/test/java/it/inaf/oats/vospace/UriServiceTest.java +0 −16 Original line number Diff line number Diff line Loading @@ -400,22 +400,6 @@ public class UriServiceTest { }); } @Test public void setNodeRemoteLocationTest() { String nodeUri = "vos://example.com!vospace/test/f1/lbtfile.fits"; String contentUri = "http://archive.lbto.org/files/lbtfile.fits"; Location location = new Location(); location.setId(5); when(locationDAO.findPortalLocation(eq("archive.lbto.org"))).thenReturn(Optional.of(location)); uriService.setNodeRemoteLocation(nodeUri, contentUri); verify(nodeDAO).setNodeLocation(eq("/test/f1/lbtfile.fits"), eq(5)); } @Test public void testSetSyncTransferEndpointsPullFromVoSpace() { Loading Loading
src/main/java/it/inaf/oats/vospace/JobService.java +2 −18 Original line number Diff line number Diff line Loading @@ -151,26 +151,10 @@ public class JobService { if (isAsyncRecall(transfer)) { asyncTransfService.startJob(job); return transfer; } else { throw new InvalidArgumentException("Unsupported pullToVoSpace transfer"); } for (Protocol protocol : transfer.getProtocols()) { switch (protocol.getUri()) { case "ivo://ivoa.net/vospace/core#httpget": String nodeUri = transfer.getTarget(); String contentUri = protocol.getEndpoint(); uriService.setNodeRemoteLocation(nodeUri, contentUri); Transfer negotiatedTransfer = uriService.getNegotiatedTransfer(job, transfer); setJobResults(job, transfer); // Special case: import of a node from a portal file server // doesn't imply file transfer, so it can be set to completed job.setPhase(ExecutionPhase.COMPLETED); return negotiatedTransfer; default: throw new InvalidArgumentException("Unsupported pullToVoSpace protocol: " + protocol.getUri()); } } throw new InvalidArgumentException("Transfer contains no protocols"); } private boolean isAsyncRecall(Transfer transfer) { Loading
src/main/java/it/inaf/oats/vospace/UriService.java +0 −19 Original line number Diff line number Diff line Loading @@ -282,25 +282,6 @@ public class UriService { return rapClient.exchangeToken(exchangeRequest, servletRequest); } public void setNodeRemoteLocation(String nodeUri, String contentUri) { URL url; try { url = new URL(contentUri); } catch (MalformedURLException ex) { throw new InternalFaultException(ex); } Location location = locationDAO.findPortalLocation(url.getHost()).orElseThrow(() -> new InternalFaultException("No registered location found for host " + url.getHost())); String vosPath = URIUtils.returnVosPathFromNodeURI(nodeUri, authority); // String fileName = url.getPath().substring(url.getPath().lastIndexOf("/") + 1); nodeDao.setNodeLocation(vosPath, location.getId()); } public Transfer getTransfer(JobSummary job) { List<Object> jobPayload = job.getJobInfo().getAny(); Loading
src/main/java/it/inaf/oats/vospace/persistence/LocationDAO.java +0 −15 Original line number Diff line number Diff line Loading @@ -32,21 +32,6 @@ public class LocationDAO { jdbcTemplate = new JdbcTemplate(dataSource); } 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, 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 = ?"; return jdbcTemplate.query(sql, ps -> { ps.setString(1, host); }, rs -> { return getLocation(rs, () -> new IllegalStateException("Found multiple locations for the same hostname")); }); } public Optional<Location> getNodeLocation(String vosPath) { String sql = "SELECT l.location_id, location_type, storage_src_id, storage_dest_id,\n" Loading
src/test/java/it/inaf/oats/vospace/TransferControllerTest.java +1 −2 Original line number Diff line number Diff line Loading @@ -100,7 +100,6 @@ public class TransferControllerTest { portalStorage.setBaseUrl("/files"); portalLocation.setSource(portalStorage); when(locationDao.getNodeLocation(eq("/portalnode"))).thenReturn(Optional.of(portalLocation)); when(locationDao.findPortalLocation(any())).thenReturn(Optional.of(portalLocation)); } @Test Loading
src/test/java/it/inaf/oats/vospace/UriServiceTest.java +0 −16 Original line number Diff line number Diff line Loading @@ -400,22 +400,6 @@ public class UriServiceTest { }); } @Test public void setNodeRemoteLocationTest() { String nodeUri = "vos://example.com!vospace/test/f1/lbtfile.fits"; String contentUri = "http://archive.lbto.org/files/lbtfile.fits"; Location location = new Location(); location.setId(5); when(locationDAO.findPortalLocation(eq("archive.lbto.org"))).thenReturn(Optional.of(location)); uriService.setNodeRemoteLocation(nodeUri, contentUri); verify(nodeDAO).setNodeLocation(eq("/test/f1/lbtfile.fits"), eq(5)); } @Test public void testSetSyncTransferEndpointsPullFromVoSpace() { Loading