git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/data-transfer-library@128875 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7eff5dec47
commit
7f8b2880fd
|
@ -1,16 +1,23 @@
|
||||||
package org.gcube.data.transfer.library.transferers;
|
package org.gcube.data.transfer.library.transferers;
|
||||||
|
|
||||||
|
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
||||||
|
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import org.gcube.common.resources.gcore.HostingNode;
|
||||||
import org.gcube.data.transfer.library.caches.CapabilitiesCache;
|
import org.gcube.data.transfer.library.caches.CapabilitiesCache;
|
||||||
import org.gcube.data.transfer.library.client.Client;
|
import org.gcube.data.transfer.library.client.Client;
|
||||||
import org.gcube.data.transfer.library.faults.HostingNodeNotFoundException;
|
import org.gcube.data.transfer.library.faults.HostingNodeNotFoundException;
|
||||||
import org.gcube.data.transfer.library.faults.ServiceNotFoundException;
|
import org.gcube.data.transfer.library.faults.ServiceNotFoundException;
|
||||||
import org.gcube.data.transfer.library.faults.UnreachableNodeException;
|
import org.gcube.data.transfer.library.faults.UnreachableNodeException;
|
||||||
import org.gcube.data.transfer.model.TransferCapabilities;
|
import org.gcube.data.transfer.model.TransferCapabilities;
|
||||||
|
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||||
|
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class TransfererBuilder {
|
public class TransfererBuilder {
|
||||||
|
|
||||||
|
@ -53,7 +60,15 @@ public class TransfererBuilder {
|
||||||
|
|
||||||
|
|
||||||
private static String retrieveHostnameByNodeId(String nodeId)throws HostingNodeNotFoundException{
|
private static String retrieveHostnameByNodeId(String nodeId)throws HostingNodeNotFoundException{
|
||||||
//TODO implement endpoint retrieval
|
SimpleQuery query = queryFor(HostingNode.class);
|
||||||
return null;
|
|
||||||
|
query.addCondition("$resource/ID/text() eq '"+nodeId+"'");
|
||||||
|
|
||||||
|
|
||||||
|
List<HostingNode> found= clientFor(HostingNode.class).submit(query);
|
||||||
|
|
||||||
|
if(found.isEmpty()) throw new HostingNodeNotFoundException("No Hosting node with the id "+nodeId);
|
||||||
|
|
||||||
|
return "http://"+found.get(0).profile().description().name();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.net.MalformedURLException;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
import org.gcube.data.transfer.library.faults.FailedTransferException;
|
import org.gcube.data.transfer.library.faults.FailedTransferException;
|
||||||
|
import org.gcube.data.transfer.library.faults.HostingNodeNotFoundException;
|
||||||
import org.gcube.data.transfer.library.faults.InitializationException;
|
import org.gcube.data.transfer.library.faults.InitializationException;
|
||||||
import org.gcube.data.transfer.library.faults.InvalidSourceException;
|
import org.gcube.data.transfer.library.faults.InvalidSourceException;
|
||||||
import org.gcube.data.transfer.library.faults.ServiceNotFoundException;
|
import org.gcube.data.transfer.library.faults.ServiceNotFoundException;
|
||||||
|
@ -19,14 +20,16 @@ import org.junit.Test;
|
||||||
public class TransfererTest {
|
public class TransfererTest {
|
||||||
|
|
||||||
static String hostname="http://pc-fabio.isti.cnr.it:8080/data-transfer-service/gcube/service";
|
static String hostname="http://pc-fabio.isti.cnr.it:8080/data-transfer-service/gcube/service";
|
||||||
|
static String nodeId="462b68c5-463f-4295-86da-37d6c0abc7ea";
|
||||||
static String scope="/gcube/devNext";
|
static String scope="/gcube/devNext";
|
||||||
|
|
||||||
static DataTransferClient client;
|
static DataTransferClient client;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void init() throws UnreachableNodeException, ServiceNotFoundException{
|
public static void init() throws UnreachableNodeException, ServiceNotFoundException, HostingNodeNotFoundException{
|
||||||
ScopeProvider.instance.set(scope);
|
ScopeProvider.instance.set(scope);
|
||||||
client=DataTransferClient.getInstanceByEndpoint(hostname);
|
// client=DataTransferClient.getInstanceByEndpoint(hostname);
|
||||||
|
client=DataTransferClient.getInstanceByNodeId(nodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue