Commit a626fb14 authored by Nicola Fulvio Calabria's avatar Nicola Fulvio Calabria
Browse files

Commented out or deleted code about portal locations

parent e73e7332
......@@ -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) {
......
......@@ -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();
......
......@@ -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"
......
......@@ -99,8 +99,7 @@ public class TransferControllerTest {
portalStorage.setHostname("archive.lbto.org");
portalStorage.setBaseUrl("/files");
portalLocation.setSource(portalStorage);
when(locationDao.getNodeLocation(eq("/portalnode"))).thenReturn(Optional.of(portalLocation));
when(locationDao.findPortalLocation(any())).thenReturn(Optional.of(portalLocation));
when(locationDao.getNodeLocation(eq("/portalnode"))).thenReturn(Optional.of(portalLocation));
}
@Test
......
......@@ -399,22 +399,6 @@ public class UriServiceTest {
uriService.getNegotiatedTransfer(job, tr);
});
}
@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() {
......
......@@ -34,26 +34,6 @@ public class LocationDAOTest {
dao = new LocationDAO(dataSource);
}
@Test
public void testGetPortalLocation() {
String hostname = "archive.lbto.org";
Optional<Location> optLocation = dao.findPortalLocation(hostname);
assertTrue(optLocation.isPresent());
Location location = optLocation.get();
assertEquals(hostname, location.getSource().getHostname());
assertNotNull(location.getSource().getBaseUrl());
assertNull(location.getSource().getBasePath());
}
@Test
public void testInexistentLocation() {
assertTrue(dao.findPortalLocation("foo").isEmpty());
}
@Test
public void testGetRootLocation() {
dao.getNodeLocation("/");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment