git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/data-transfer-library@134272 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
92465d24a4
commit
6ec148dcff
16
pom.xml
16
pom.xml
|
@ -10,7 +10,19 @@
|
|||
<artifactId>data-transfer-library</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<name>DataTransfer-library</name>
|
||||
|
||||
<description>Data Transfer Service client library</description>
|
||||
|
||||
<properties>
|
||||
<distroDirectory>${project.basedir}/distro</distroDirectory>
|
||||
<svnBaseUrl>http://svn.research-infrastructures.eu/d4science/gcube/trunk/data-transfer/${project.artifactId}</svnBaseUrl>
|
||||
</properties>
|
||||
|
||||
|
||||
<scm>
|
||||
<connection>scm:svn:${svnBaseUrl}/${project.artifactId}</connection>
|
||||
<developerConnection>scm:svn:${svnBaseUrl}/${project.artifactId}</developerConnection>
|
||||
<url>${svnBaseUrl}/${project.artifactId}</url>
|
||||
</scm>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
@ -62,7 +74,7 @@
|
|||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>0.11.6</version>
|
||||
<version>1.14.8</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JERSEY -->
|
||||
|
|
|
@ -7,7 +7,6 @@ import javax.ws.rs.client.ClientBuilder;
|
|||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.data.transfer.library.client.AuthorizationFilter;
|
||||
import org.gcube.data.transfer.library.client.Client;
|
||||
import org.gcube.data.transfer.library.faults.CommunicationException;
|
||||
|
@ -37,7 +36,7 @@ public class TestClientCalls {
|
|||
|
||||
@BeforeClass
|
||||
public static void init() throws ServiceNotFoundException{
|
||||
ScopeProvider.instance.set(scope);
|
||||
TokenSetter.set(scope);
|
||||
client=new Client(hostname);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,10 @@ import java.util.Properties;
|
|||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class TokenSetter {
|
||||
|
||||
|
||||
|
@ -20,12 +24,18 @@ public class TokenSetter {
|
|||
}
|
||||
|
||||
|
||||
public static void set(String scope){
|
||||
if(!props.containsKey(scope)) throw new RuntimeException("No token found for scope : "+scope);
|
||||
SecurityTokenProvider.instance.set(props.getProperty(scope));
|
||||
public static void set(String scope){
|
||||
try{
|
||||
if(!props.containsKey(scope)) throw new RuntimeException("No token found for scope : "+scope);
|
||||
SecurityTokenProvider.instance.set(props.getProperty(scope));
|
||||
}catch(Throwable e){
|
||||
log.warn("Unable to set token for scope "+scope,e);
|
||||
}
|
||||
ScopeProvider.instance.set(scope);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,8 +3,9 @@ package org.gcube.data.transfer.library;
|
|||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
import org.gcube.data.transfer.library.faults.DestinationNotSetException;
|
||||
import org.gcube.data.transfer.library.faults.FailedTransferException;
|
||||
|
@ -18,6 +19,7 @@ import org.gcube.data.transfer.library.faults.UnreachableNodeException;
|
|||
import org.gcube.data.transfer.library.utils.StorageUtils;
|
||||
import org.gcube.data.transfer.model.Destination;
|
||||
import org.gcube.data.transfer.model.DestinationClashPolicy;
|
||||
import org.gcube.data.transfer.model.PluginInvocation;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -25,14 +27,14 @@ import org.junit.Test;
|
|||
public class TransfererTest {
|
||||
|
||||
static String hostname="http://node3-d-d4s.d4science.org:80";
|
||||
static String nodeId="462b68c5-463f-4295-86da-37d6c0abc7ea";
|
||||
static String scope="/gcube/devsec";
|
||||
// static String nodeId="462b68c5-463f-4295-86da-37d6c0abc7ea";
|
||||
static String scope="/gcube/devNext";
|
||||
|
||||
static DataTransferClient client;
|
||||
|
||||
@BeforeClass
|
||||
public static void init() throws UnreachableNodeException, ServiceNotFoundException, HostingNodeNotFoundException{
|
||||
ScopeProvider.instance.set(scope);
|
||||
TokenSetter.set(scope);
|
||||
client=DataTransferClient.getInstanceByEndpoint(hostname);
|
||||
// client=DataTransferClient.getInstanceByNodeId(nodeId);
|
||||
}
|
||||
|
@ -61,7 +63,7 @@ public class TransfererTest {
|
|||
|
||||
@Test
|
||||
public void storage() throws InvalidSourceException, SourceNotSetException, FailedTransferException, InitializationException, RemoteBackendException, FileNotFoundException, InvalidDestinationException, DestinationNotSetException{
|
||||
ScopeProvider.instance.set(scope);
|
||||
TokenSetter.set(scope);
|
||||
String toUpload="/home/fabio/Documents/Personal/DND/Incantesimi 3.5 - Mago e Stregone.pdf";
|
||||
String id=StorageUtils.putOntoStorage(new File(toUpload));
|
||||
Destination dest=new Destination("some/where","My Pdf.pdf");
|
||||
|
@ -86,4 +88,13 @@ public class TransfererTest {
|
|||
String link="https://www.some.where.com/over/theRainbow.txt";
|
||||
System.out.println(client.httpSource(link,new Destination("oz")));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void decompressPlugin() throws InvalidSourceException, SourceNotSetException, FailedTransferException, InitializationException, InvalidDestinationException, DestinationNotSetException{
|
||||
HashMap<String,String> invocationParams=new HashMap<String,String>();
|
||||
invocationParams.put("SOURCE_ARCHIVE", PluginInvocation.DESTINATION_FILE_PATH);
|
||||
client.localFile(new File("/home/fabio/workspaces/home-library-jcr-PRE-PROD.jar"), new Destination("MyJar"),Collections.singleton(new PluginInvocation("DECOMPRESS", invocationParams)));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue