Compare commits
No commits in common. "master" and "v2.6.1" have entirely different histories.
|
@ -1,7 +0,0 @@
|
|||
/target/
|
||||
/.classpath
|
||||
/*.project
|
||||
/.settings
|
||||
/.idea/target/
|
||||
/src/test/resources/
|
||||
/.idea/
|
17
CHANGELOG.md
17
CHANGELOG.md
|
@ -1,27 +1,12 @@
|
|||
# Changelog for storage-manager-wrapper
|
||||
|
||||
## [v4.0.0]
|
||||
* removed slf4j implementations, added slf4j-simple;
|
||||
* Discovering serviceEndpoint with category Storage
|
||||
* moved version from 3.1.0-SNAPSHOT to 4.0.0-SNAPSHOT
|
||||
* upgrade to gcube-bom 3 and ScopeProvider removed
|
||||
* removed environment variable scope
|
||||
* passed to jdk11 and gcube-bom 4.0
|
||||
|
||||
## [v3.0.1-SNAPSHOT]
|
||||
* removed http protocol;
|
||||
* deprecated old smp classes
|
||||
* fix JUnitTests
|
||||
* upgrade JUnit to 4.12
|
||||
|
||||
## [v3.0.0] 2021-09-10
|
||||
## [v2.6.1] 2021-09-10
|
||||
* bug fix #20505
|
||||
* update gcub-bom version
|
||||
* Change serviceEndpoint Category from DataStorage to Storage
|
||||
* bugfix #20505
|
||||
* adding new constructor with the backendType as input parameter
|
||||
* retrieving specific backend credentials if a specific backend si specified as input parameter
|
||||
* moved from 2.6.1 to 3.0.0-SNAPSHOT
|
||||
|
||||
## [v2.5.3] 2019-03-20
|
||||
* Added wrapper for HomeLibrary configuration related to the new preproduction infrastructure
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
v 2.2.0 (21-04-2015)
|
||||
* change smp protocol
|
||||
v 2.1.0 (01-04-2014)
|
||||
* support MongoDB backend with authentication
|
||||
v 2.0.1 (29-05-2013)
|
||||
* bug fix incident: connection pending #606
|
||||
v 2.0.0 (19-05-2013)
|
||||
* added move, copy and link operations
|
||||
*FWS integration
|
||||
v 1.0.2 (15-01-2013)
|
||||
* Integration with new gCube release 2.12.0 version system
|
||||
v 1.0.1 (11-10-2012)
|
||||
* added VOLATILE area
|
||||
v. 1.0.0 (04-05-2012)
|
||||
* First release
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
${gcube.license}
|
||||
|
|
@ -0,0 +1 @@
|
|||
* Roberto Cirillo (roberto.cirillo@isti.cnr.it), CNR Pisa, Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo"
|
Binary file not shown.
|
@ -0,0 +1,55 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.content-management.storage-manager-wrapper.2-5-1" date="2019-03-20">
|
||||
<Change>Added HomeLibrary wrapper configuration for the new preproduction infrastructure</Change>
|
||||
<Change>Added new Costants class for Junit package</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.content-management.storage-manager-wrapper.2-5-1" date="2018-10-11">
|
||||
<Change>Constants definition moved on storage-manager-core Castants class</Change>
|
||||
<Change>Added new Costants class for Junit package</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.content-management.storage-manager-wrapper.2-5-0" date="2017-10-15">
|
||||
<Change>Added new JUnit Test classes</Change>
|
||||
<Change>update JUnit Test Classes</Change>
|
||||
<Change>delete old method for retrieving remote phrase used by old smp protocol classes</Change>
|
||||
<Change></Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.content-management.storage-manager-wrapper.2-3-1" date="2016-01-14">
|
||||
<Change>dinamically load "write concern"" and ""read preference" options</Change>
|
||||
<Change>add method for decrypt an id</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.content-management.storage-manager-wrapper.2-3-0" date="2016-01-14">
|
||||
<Change>dinamically load smpConnection handler</Change>
|
||||
<Change>add method for decrypt an id</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.content-management.storage-manager-wrapper.2-2-1" date="2015-07-01">
|
||||
<Change>update JUnit test for smp uri without payload</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.content-management.storage-manager-wrapper.2-2-0" date="2015-04-21">
|
||||
<Change>change smp protocol</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.content-management.storage-manager-wrapper.2-1-0" date="2014-04-01">
|
||||
<Change>support MongoDB backend with authentication</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.content-management.storage-manager-wrapper.2-0-3" date="2014-02-12">
|
||||
<Change>Integration with new gCube release 3.0.0 version system</Change>
|
||||
<Change>Java7 refactoring</Change>
|
||||
</Changeset>
|
||||
<Changeset component="${build.finalName}" date="2013-05-29">
|
||||
<Change>Integration with new gCube release 2.15.0 version system</Change>
|
||||
<Change>bugfix on pending connections</Change>
|
||||
</Changeset>
|
||||
<Changeset component="${build.finalName}" date="2013-04-29">
|
||||
<Change>Integration with new gCube release 2.14.0 version system</Change>
|
||||
<Change>FWS integration</Change>
|
||||
<Change>added move, copy and link operations</Change>
|
||||
</Changeset>
|
||||
<Changeset component="${build.finalName}" date="2013-01-15">
|
||||
<Change>Integration with new gCube release 2.12.0 version system</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.content-management.storage-manager-wrapper.1-0-1" date="2012-10-11">
|
||||
<Change>Added VOLATILE area</Change>
|
||||
</Changeset>
|
||||
<Changeset component="${build.finalName}" date="2012-05-04">
|
||||
<Change>First Release</Change>
|
||||
</Changeset>
|
||||
</ReleaseNotes>
|
|
@ -0,0 +1,32 @@
|
|||
<assembly
|
||||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
|
||||
<id>servicearchive</id>
|
||||
<formats>
|
||||
<format>tar.gz</format>
|
||||
</formats>
|
||||
<baseDirectory>/</baseDirectory>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>${distroDirectory}</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<useDefaultExcludes>true</useDefaultExcludes>
|
||||
<includes>
|
||||
<include>README</include>
|
||||
<include>LICENSE</include>
|
||||
<include>changelog.xml</include>
|
||||
<include>profile.xml</include>
|
||||
</includes>
|
||||
<fileMode>755</fileMode>
|
||||
<filtered>true</filtered>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
<files>
|
||||
<file>
|
||||
<source>target/${build.finalName}.${project.packaging}</source>
|
||||
<outputDirectory>/${artifactId}</outputDirectory>
|
||||
</file>
|
||||
|
||||
</files>
|
||||
</assembly>
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<ID />
|
||||
<Type>Service</Type>
|
||||
<Profile>
|
||||
<Description>${description}</Description>
|
||||
<Class>ContentManagement</Class>
|
||||
<Name>${artifactId}</Name>
|
||||
<Version>1.0.0</Version>
|
||||
<Packages>
|
||||
<Software>
|
||||
<Name>${artifactId}</Name>
|
||||
<Version>${version}</Version>
|
||||
<MavenCoordinates>
|
||||
<groupId>${groupId}</groupId>
|
||||
<artifactId>${artifactId}</artifactId>
|
||||
<version>${version}</version>
|
||||
</MavenCoordinates>
|
||||
<Files>
|
||||
<File>${build.finalName}.jar</File>
|
||||
</Files>
|
||||
</Software>
|
||||
</Packages>
|
||||
</Profile>
|
||||
</Resource>
|
|
@ -0,0 +1 @@
|
|||
${scm.url}
|
78
pom.xml
78
pom.xml
|
@ -3,28 +3,26 @@
|
|||
<parent>
|
||||
<artifactId>maven-parent</artifactId>
|
||||
<groupId>org.gcube.tools</groupId>
|
||||
<version>1.2.0</version>
|
||||
<version>1.1.0</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-wrapper</artifactId>
|
||||
<version>4.0.0</version>
|
||||
<version>2.6.1</version>
|
||||
<scm>
|
||||
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection>
|
||||
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</developerConnection>
|
||||
<url>https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</url>
|
||||
</scm>
|
||||
<properties>
|
||||
<distroDirectory>${project.basedir}/distro</distroDirectory>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<distroDirectory>${project.basedir}/distro</distroDirectory>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>gcube-bom</artifactId>
|
||||
<version>4.0.0</version>
|
||||
<version>2.0.1</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
@ -34,7 +32,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-core</artifactId>
|
||||
<version>[4.0.0-SNAPSHOT, 5.0.0-SNAPSHOT)</version>
|
||||
<version>[2.13.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -61,29 +59,71 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>4.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.7.32</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.7.30</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>common-security</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-profile</id>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>target</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${distroDirectory}</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>profile.xml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- <plugin> -->
|
||||
<!-- <groupId>org.apache.maven.plugins</groupId> -->
|
||||
<!-- <artifactId>maven-assembly-plugin</artifactId> -->
|
||||
<!-- <configuration> -->
|
||||
<!-- <descriptors> -->
|
||||
<!-- <descriptor>${distroDirectory}/descriptor.xml</descriptor> -->
|
||||
<!-- </descriptors> -->
|
||||
<!-- </configuration> -->
|
||||
<!-- <executions> -->
|
||||
<!-- <execution> -->
|
||||
<!-- <id>servicearchive</id> -->
|
||||
<!-- <phase>install</phase> -->
|
||||
<!-- <goals> -->
|
||||
<!-- <goal>single</goal> -->
|
||||
<!-- </goals> -->
|
||||
<!-- </execution> -->
|
||||
<!-- </executions> -->
|
||||
<!-- </plugin> -->
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -2,15 +2,35 @@ package org.gcube.common.scope.impl;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
||||
/**
|
||||
* Utility class
|
||||
* Check the validity of a given scope
|
||||
* @author Roberto Cirillo (ISTI-CNR)
|
||||
*
|
||||
*/
|
||||
public class ServiceMapScannerMediator {
|
||||
|
||||
/**
|
||||
* The validation has been removed
|
||||
* @param scope
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isValid(String scope){
|
||||
// log.debug("validating scope "+scope);
|
||||
String currentScope=ScopeProvider.instance.get();
|
||||
ScopeProvider.instance.set(scope);
|
||||
try{
|
||||
new ScopedServiceMap().scope();
|
||||
|
||||
}catch(Exception e){
|
||||
return false;
|
||||
}finally{
|
||||
ScopeProvider.instance.set(currentScope);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static Set<String> getScopeKeySet(){
|
||||
|
|
|
@ -0,0 +1,155 @@
|
|||
package org.gcube.contentmanager.storageclient.model.protocol;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
//import org.gcube.common.core.scope.GCUBEScope;
|
||||
//import org.gcube.common.core.scope.GCUBEScopeManager;
|
||||
import org.gcube.contentmanager.storageclient.model.protocol.smp.Handler;
|
||||
|
||||
/**
|
||||
* Utility methods for content URI creation and manipulation.
|
||||
* @author Fabio Simeoni (University of Strathclyde)
|
||||
* @author Roberto Cirillo (ISTI-CNR)
|
||||
*
|
||||
*/
|
||||
public class URIs {
|
||||
|
||||
static {
|
||||
Handler.activateProtocol();
|
||||
}
|
||||
|
||||
/**Scheme of cms URIs.*/
|
||||
public static final String PROTOCOL="smp";
|
||||
|
||||
/**
|
||||
* Indicates whether a URI is a valid content URI.
|
||||
* @param uri the URI.
|
||||
* @throws URISyntaxException if the URI fails validation.
|
||||
*/
|
||||
public static void validate(URI uri) throws URISyntaxException {
|
||||
if (!PROTOCOL.equals(uri.getScheme()) ||
|
||||
uri.getAuthority()==null ||
|
||||
uri.getPath()==null ||
|
||||
uri.getPath().length()<2)
|
||||
throw new IllegalArgumentException(new URISyntaxException(uri.toString(),"uri is not a well-formed content URI"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a content URI from a collection identifiers and one or more node identifiers.
|
||||
* @param collectionID the collection identifier.
|
||||
* @param identifiers the node identifiers.
|
||||
* @return the URI.
|
||||
* @throws IllegalArgumentException if the input is <code>null</code> or empty.
|
||||
*/
|
||||
public static URI make(String collectionID, String ... identifiers) throws IllegalArgumentException {
|
||||
|
||||
if (collectionID==null || identifiers==null || identifiers.length==0)
|
||||
throw new IllegalArgumentException("null or empty input");
|
||||
|
||||
StringBuilder path = new StringBuilder();
|
||||
for (Object id : identifiers)
|
||||
path.append("/"+id.toString());
|
||||
|
||||
URI uri = null;
|
||||
try {
|
||||
uri = new URI(PROTOCOL,collectionID,path.toString(),null);
|
||||
}
|
||||
catch(URISyntaxException e) {
|
||||
throw new RuntimeException("error in generation uri with "+PROTOCOL+","+collectionID+","+path,e);
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the collection identifier in a <code>sm</code> URI.
|
||||
* @param uri the URI.
|
||||
* @return the identifier.
|
||||
* @throws URISyntaxException if the URI is not a content URI.
|
||||
*/
|
||||
public static String collectionID(URI uri) throws URISyntaxException {
|
||||
validate(uri);
|
||||
return uri.getAuthority();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the document identifier in a content URI.
|
||||
* @param uri the URI.
|
||||
* @return the identifier.
|
||||
* @throws URISyntaxException if the URI is not a content URI.
|
||||
*/
|
||||
public static String documentID(URI uri) throws URISyntaxException {
|
||||
validate(uri);
|
||||
String p = uri.getPath().substring(1);
|
||||
if (p.endsWith("/"))
|
||||
p = p.substring(0,p.length()-1);
|
||||
int index = p.indexOf("/");
|
||||
return p.substring(0,index>0?index:p.length());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the identifier of the node identified by a content URI.
|
||||
* @param uri the URI.
|
||||
* @return the identifier.
|
||||
* @throws URISyntaxException if the URI is not a content URI.
|
||||
*/
|
||||
public static String nodeID(URI uri) throws URISyntaxException {
|
||||
validate(uri);
|
||||
return uri.getPath().substring(uri.getPath().lastIndexOf("/")+1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the identifiers in a content URI.
|
||||
* @param uri the URI.
|
||||
* @return the identifiers.
|
||||
* @throws URISyntaxException if the URI is not a content URI.
|
||||
*/
|
||||
public static String[] nodeIDs(URI uri) throws URISyntaxException {
|
||||
validate(uri);
|
||||
List<String> ids = new ArrayList<String>();
|
||||
for (String s : uri.getPath().substring(1).split("/")) //will be validated here
|
||||
ids.add(s);
|
||||
return ids.toArray(new String[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a content URI for the parent of the node identified by another content URI.
|
||||
* @param uri the input URI.
|
||||
* @return the parent URI.
|
||||
* @throws URISyntaxException if the input URI is not a content URL.
|
||||
*/
|
||||
public static URI parentURI(URI uri) throws URISyntaxException {
|
||||
validate(uri);
|
||||
String u = uri.getPath();
|
||||
return make(uri.getAuthority(),u.substring(1,u.lastIndexOf("/")).split("/"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a content URI for the document of the node identified by another content URI.
|
||||
* @param uri the input URI.
|
||||
* @return the document URI.
|
||||
* @throws URISyntaxException if the input URI is not a content URI.
|
||||
*/
|
||||
public static URI documentURI(URI uri) throws URISyntaxException {
|
||||
validate(uri);
|
||||
return make(uri.getAuthority(),documentID(uri));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a URL connection in a given scope.
|
||||
* @param uri a content URI.
|
||||
* @param scope the scope.
|
||||
* @return the connection.
|
||||
* @throws IOException if the connections could not be established.
|
||||
* @throws URISyntaxException if the URI is not a content URI or if the protocol handler for the <code>smp</code> scheme is not active.
|
||||
* @deprecated since 2.3.1. Use {@link URLConnection} normally in current scope.
|
||||
*/
|
||||
public static URLConnection connection(URI uri, String scope) throws IOException, URISyntaxException {
|
||||
validate(uri);
|
||||
URLConnection connection = uri.toURL().openConnection();
|
||||
return connection;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package org.gcube.contentmanager.storageclient.model.protocol.smp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLStreamHandler;
|
||||
|
||||
/**
|
||||
* A handler for the <code>smp</code> protocol.
|
||||
* @author Fabio Simeoni (University of Strathclyde)
|
||||
* @author Roberto Cirillo (ISTI-CNR)
|
||||
*
|
||||
*/
|
||||
public class Handler extends URLStreamHandler {
|
||||
|
||||
/**{@inheritDoc}*/
|
||||
@Override
|
||||
protected URLConnection openConnection(URL u) throws IOException {
|
||||
return SMPURLConnectionFactory.getSmp(u);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the protocol with the JVM.
|
||||
*/
|
||||
public static void activateProtocol() {
|
||||
|
||||
String pkgs_name="java.protocol.handler.pkgs";
|
||||
String pkgs = System.getProperty(pkgs_name);
|
||||
String pkg = "org.gcube.contentmanager.storageclient.model.protocol";
|
||||
if (pkgs==null)
|
||||
pkgs = pkg ;
|
||||
else if (!pkgs.contains(pkg))
|
||||
pkgs = pkgs+"|"+pkg;
|
||||
System.setProperty(pkgs_name, pkgs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package org.gcube.contentmanager.storageclient.model.protocol.smp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.ISClientConnector;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* An extension of URLConnection used for smp url
|
||||
* @author Roberto Cirillo (ISTI-CNR)
|
||||
*
|
||||
*/
|
||||
public abstract class SMPConnection extends URLConnection {
|
||||
|
||||
Logger logger= LoggerFactory.getLogger(SMPURLConnection.class);
|
||||
|
||||
public SMPConnection(URL url) {
|
||||
super(url);
|
||||
}
|
||||
|
||||
public abstract URLConnection init(URL url);
|
||||
|
||||
/**{@inheritDoc}*/
|
||||
@Override
|
||||
public synchronized void connect() throws IOException {
|
||||
connected=true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract InputStream getInputStream() throws IOException;
|
||||
|
||||
|
||||
protected abstract InputStream storageClient(String url) throws Exception;
|
||||
|
||||
/**
|
||||
* This method has been moved in Configuration class
|
||||
* @param rootScope
|
||||
* @return
|
||||
* @throws Exception
|
||||
* @see org.gcube.contentmanager.storageclient.wrapper.Configuration
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
protected String retrieveEncryptionPhrase() throws Exception {
|
||||
String currentScope=ScopeProvider.instance.get();
|
||||
logger.debug("retrieve encryption prhase on scope: "+currentScope);
|
||||
String encryptedKey=null;
|
||||
ISClientConnector isclient=new ISClientConnector();
|
||||
encryptedKey=isclient.retrievePropertyValue("PassPhrase", currentScope);
|
||||
String decryptString=org.gcube.common.encryption.StringEncrypter.getEncrypter().decrypt(encryptedKey);
|
||||
return decryptString;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package org.gcube.contentmanager.storageclient.model.protocol.smp;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* This is invoked by the platform with a URL of the right protocol.
|
||||
* @author Fabio Simeoni (University of Strathclyde), @author Roberto Cirillo (ISTI-CNR)
|
||||
* @deprecated this class will be deleted and will be changed with the factory class invocation: SMPURLConnectionFactory
|
||||
* @see SMPURLConnectionFactory
|
||||
*/
|
||||
@Deprecated
|
||||
public class SMPURLConnection extends URLConnection {
|
||||
|
||||
SMPConnection smp;
|
||||
Logger logger= LoggerFactory.getLogger(SMPURLConnection.class);
|
||||
/**
|
||||
* Constructs a new instance for a given <code>sm</code> URL.
|
||||
* @deprecated reason this method is deprecated </br>
|
||||
* {will be removed in next version} </br>
|
||||
* use {@link #SMPURLConnectionFactory.getSmp(url)}
|
||||
* @param url the URL.
|
||||
*/
|
||||
@Deprecated
|
||||
public SMPURLConnection(URL url) {
|
||||
super(url);
|
||||
this.smp=SMPURLConnectionFactory.getSmp(url);
|
||||
}
|
||||
|
||||
/**{@inheritDoc}*/
|
||||
@Override
|
||||
public synchronized void connect() throws IOException {
|
||||
connected=true;
|
||||
}
|
||||
|
||||
/**{@inheritDoc}*/
|
||||
@Override
|
||||
public synchronized InputStream getInputStream() throws IOException {
|
||||
return smp.getInputStream();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package org.gcube.contentmanager.storageclient.model.protocol.smp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.service.operation.GetHttpUrl;
|
||||
import org.gcube.contentmanagement.blobstorage.service.operation.GetUrl;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* This is invoked by the platform with a URL of the smp protocol with new format (>= 2.2.0 version) .
|
||||
* @author Roberto Cirillo (ISTI-CNR)
|
||||
*
|
||||
* Example: smp://data.gcube.org?uhdnfounhcfnshfnrhbvyaeegytf6dfawiuawgcyg
|
||||
*/
|
||||
public class SMPURLConnectionById extends SMPConnection {
|
||||
|
||||
private Logger logger= LoggerFactory.getLogger(SMPURLConnectionOld.class);
|
||||
private String serviceClass="Storage-manager";
|
||||
private String serviceName="resolver-uri";
|
||||
private String owner="storage-manager";
|
||||
|
||||
/**
|
||||
* Constructs a new instance for a given <code>sm</code> URL.
|
||||
* @param url the URL.
|
||||
*/
|
||||
public SMPURLConnectionById(URL url) {
|
||||
super(url);
|
||||
}
|
||||
|
||||
public SMPConnection init(URL url){
|
||||
return new SMPURLConnectionById(url);
|
||||
}
|
||||
|
||||
/**{@inheritDoc}
|
||||
* internal handler implementation
|
||||
* */
|
||||
@Override
|
||||
public synchronized InputStream getInputStream() throws IOException {
|
||||
if (!connected)
|
||||
this.connect();
|
||||
try {
|
||||
return storageClient(this.url.toString());
|
||||
}
|
||||
catch(Exception e) {
|
||||
IOException ioe = new IOException();
|
||||
ioe.initCause(e);
|
||||
throw ioe;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a StorageManager instance from url
|
||||
*/
|
||||
|
||||
protected InputStream storageClient(String url) throws Exception {
|
||||
logger.info("url :" + url);
|
||||
String [] urlParam=url.split(Costants.URL_SEPARATOR);
|
||||
String protocol=urlParam[0];
|
||||
protocol=protocol.substring(0, protocol.length()-1);
|
||||
logger.debug("protocol is "+protocol);
|
||||
if(ScopeProvider.instance.get() == null){
|
||||
throw new RuntimeException("Scope not set");
|
||||
}
|
||||
String encrypted=retrieveStringEncrypted(urlParam);
|
||||
MemoryType memory=null;
|
||||
if(encrypted.contains(Costants.VOLATILE_URL_IDENTIFICATOR)){
|
||||
memory=MemoryType.VOLATILE;
|
||||
encrypted=encrypted.replace(Costants.VOLATILE_URL_IDENTIFICATOR, "");
|
||||
}
|
||||
logger.debug("String encrypted "+encrypted);
|
||||
String phrase=retrieveEncryptionPhrase();
|
||||
String location=null;
|
||||
if(Base64.isBase64(encrypted) && (protocol.equalsIgnoreCase("http"))){
|
||||
byte[] valueDecoded= Base64.decodeBase64(encrypted);
|
||||
String encryptedID = new String(valueDecoded);
|
||||
location=new StringDecrypter("DES", phrase).decrypt(encryptedID);
|
||||
}else{
|
||||
location=new StringDecrypter("DES", phrase).decrypt(encrypted);
|
||||
}
|
||||
IClient client=null;
|
||||
if(memory!=null)
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, memory).getClient();
|
||||
else
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED).getClient();
|
||||
InputStream is=null;
|
||||
is=client.get().RFileAsInputStream(location);
|
||||
return is;
|
||||
}
|
||||
|
||||
private String retrieveStringEncrypted(String[] urlParam) {
|
||||
String encrypted=urlParam[3];
|
||||
int i=4;
|
||||
while(i < urlParam.length){
|
||||
encrypted=encrypted+Costants.URL_SEPARATOR+urlParam[i];
|
||||
i++;
|
||||
}
|
||||
return encrypted;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
package org.gcube.contentmanager.storageclient.model.protocol.smp;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.common.scope.impl.ScopeBean.Type;
|
||||
import org.gcube.contentmanagement.blobstorage.service.operation.GetUrl;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;
|
||||
import org.gcube.contentmanager.storageclient.protocol.utils.Utils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Factory class used to determine the right smp url protocol: old format(<2.2.0 version), new format (>= 2.2.0-SNAPSHOT)
|
||||
* @author Roberto Cirillo (ISTI-CNR)
|
||||
*
|
||||
*/
|
||||
public class SMPURLConnectionFactory {
|
||||
|
||||
static Logger logger=LoggerFactory.getLogger(SMPURLConnectionFactory.class);
|
||||
|
||||
public static SMPConnection getSmp(URL url) {
|
||||
String urlString=url.toString();
|
||||
Utils.checkScopeProvider();
|
||||
if(isNewSmpFormat(urlString)|| isIntermediateType(urlString)){
|
||||
logger.info("detected new smp format "+url);
|
||||
SMPConnection connection=load(url);
|
||||
if (connection!= null)
|
||||
return connection;
|
||||
return new SMPURLConnectionById(url);
|
||||
}else{
|
||||
logger.info("detected old smp format "+url);
|
||||
return new SMPURLConnectionOld(url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* patch method for a particular smp uri: smp://data.gcube.org/8TFLhJ991DF1M/Ae8rGamC3CgCjAXlnVGmbP5+HKCzc=
|
||||
* @param urlString
|
||||
* @return
|
||||
*/
|
||||
private static boolean isIntermediateType(String urlString) {
|
||||
String [] urlParam=urlString.split(Costants.URL_SEPARATOR);
|
||||
String infraHost=urlParam[2];
|
||||
if(Utils.isScopeProviderMatch(infraHost))
|
||||
return true;
|
||||
String infra=Utils.getInfraFromResolverHost(infraHost);
|
||||
String rootScope="/"+infra;
|
||||
ScopeBean scope=new ScopeBean(rootScope);
|
||||
if(scope.is(Type.INFRASTRUCTURE)){
|
||||
return Utils.validationScope2(rootScope);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isNewSmpFormat(String urlString) {
|
||||
logger.debug("check format: "+urlString);
|
||||
String httpString=urlString;
|
||||
httpString=httpString.replace("smp://", "http://");
|
||||
logger.debug("httpUrl conversion: "+httpString);
|
||||
URL httpUrl=null;
|
||||
try {
|
||||
httpUrl=new URL(httpString);
|
||||
} catch (MalformedURLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
List<ServiceEndpoint> services=Utils.queryServiceEndpoint(Utils.URI_RESOLVER_RESOURCE_CATEGORY, Utils.URI_RESOLVER_RESOURCE_NAME);
|
||||
String host=null;
|
||||
if(services != null && services.size()>0){
|
||||
host=Utils.getResolverHost(services.get(0));
|
||||
}
|
||||
logger.debug("uri-resolver host: "+host+" in scope: "+ScopeProvider.instance.get());
|
||||
if((host!=null) && (host.equals(httpUrl.getHost()))){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load a backend driver from classpath
|
||||
* @param url
|
||||
* @return
|
||||
*/
|
||||
private static SMPConnection load(URL url){
|
||||
ServiceLoader<SMPConnection> loader = ServiceLoader.load(SMPConnection.class);
|
||||
Iterator<SMPConnection> iterator = loader.iterator();
|
||||
List<SMPConnection> impls = new ArrayList<SMPConnection>();
|
||||
while(iterator.hasNext())
|
||||
impls.add(iterator.next());
|
||||
int implementationCounted=impls.size();
|
||||
// System.out.println("size: "+implementationCounted);
|
||||
if(implementationCounted==0){
|
||||
logger.info(" 0 implementation found. Load default implementation of SMPConnection");
|
||||
return null;
|
||||
}else if(implementationCounted>0){
|
||||
SMPConnection connection = impls.get(0);
|
||||
logger.info("1 implementation of TransportManager found. ");
|
||||
connection.init(url);
|
||||
return connection;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
package org.gcube.contentmanager.storageclient.model.protocol.smp;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* This is invoked by the platform with a URL of the right protocol.
|
||||
* @author Fabio Simeoni (University of Strathclyde), @author Roberto Cirillo (ISTI-CNR)
|
||||
*
|
||||
*/
|
||||
public class SMPURLConnectionOld extends SMPConnection{
|
||||
|
||||
|
||||
Logger logger= LoggerFactory.getLogger(SMPURLConnectionOld.class);
|
||||
/**
|
||||
* Constructs a new instance for a given <code>sm</code> URL.
|
||||
* @param url the URL.
|
||||
*/
|
||||
public SMPURLConnectionOld(URL url) {
|
||||
super(url);
|
||||
}
|
||||
|
||||
public SMPConnection init(URL url){
|
||||
return new SMPURLConnectionOld(url);
|
||||
}
|
||||
|
||||
/**{@inheritDoc}*/
|
||||
@Override
|
||||
public synchronized InputStream getInputStream() throws IOException {
|
||||
if (!connected)
|
||||
this.connect();
|
||||
try {
|
||||
return storageClient(this.url.toString());
|
||||
}
|
||||
catch(Exception e) {
|
||||
IOException ioe = new IOException();
|
||||
ioe.initCause(e);
|
||||
throw ioe;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected InputStream storageClient(String url) throws Exception {
|
||||
logger.info("url :" + url);
|
||||
String [] urlParam=url.split("\\?");
|
||||
logger.info("String encrypted "+urlParam[1]);
|
||||
String param=new StringDecrypter("DES", retrieveEncryptionPhrase()).decrypt(urlParam[1]);
|
||||
logger.info("String decrypted: "+param);
|
||||
String [] getParam=param.split("\\&");
|
||||
String serviceClass=null;
|
||||
String serviceName=null;
|
||||
String owner=null;
|
||||
String accessType=null;
|
||||
String memoryType=null;
|
||||
String scopeType=null;
|
||||
AccessType type = null;
|
||||
MemoryType mType = null;
|
||||
String server= null;
|
||||
String [] par1;
|
||||
for(String par : getParam){
|
||||
if(par.contains("ServiceClass")){
|
||||
par1=par.split("=");
|
||||
serviceClass=par1[1];
|
||||
}else if(par.contains("ServiceName")){
|
||||
par1=par.split("=");
|
||||
serviceName=par1[1];
|
||||
}else if(par.contains("owner")){
|
||||
par1=par.split("=");
|
||||
owner=par1[1];
|
||||
}else if(par.contains("scope")){
|
||||
par1=par.split("=");
|
||||
scopeType=par1[1];
|
||||
}else if(par.contains("server")){
|
||||
par1=par.split("=");
|
||||
server=par1[1];
|
||||
}else if(par.contains("AccessType")){
|
||||
par1=par.split("=");
|
||||
accessType=par1[1];
|
||||
if(accessType.equalsIgnoreCase("public")){
|
||||
type=AccessType.PUBLIC;
|
||||
}else if(accessType.equalsIgnoreCase("shared")){
|
||||
type=AccessType.SHARED;
|
||||
}
|
||||
}else if(par.contains("MemoryType")){
|
||||
par1=par.split("=");
|
||||
memoryType=par1[1];
|
||||
if(memoryType.equalsIgnoreCase("VOLATILE")){
|
||||
mType=MemoryType.VOLATILE;
|
||||
}else{
|
||||
mType=MemoryType.PERSISTENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
// throw an exception if one or more uri parameters are invalid
|
||||
if((serviceName==null) || (serviceClass==null) || (owner == null) || (scopeType==null) || (type == null)){
|
||||
logger.error("Bad Parameter in URI");
|
||||
if (type == null){
|
||||
logger.error("URI generated from a private file");
|
||||
throw new MalformedURLException("The uri is generated from a private file. It cannot be accessed");
|
||||
}
|
||||
if (serviceName==null) throw new MalformedURLException("The uri generated has an invalid serviceName");
|
||||
if (serviceClass==null) throw new MalformedURLException("The uri generated has an invalid serviceClass");
|
||||
if (owner==null) throw new MalformedURLException("The uri generated has an invalid owner");
|
||||
if (scopeType==null) throw new MalformedURLException("The uri is generated has an invalid scopeType.");
|
||||
}
|
||||
String location=extractLocation(urlParam[0]);
|
||||
logger.info("Parameters from URI "+serviceClass+" "+serviceName+" "+owner+" "+type+" "+mType +" location: "+urlParam[0]+" scope: "+scopeType);
|
||||
IClient client=null;
|
||||
String currentScope=ScopeProvider.instance.get();
|
||||
logger.info("current scope used: "+currentScope+". scope found on url is: "+ scopeType);
|
||||
// ScopeProvider.instance.set(scopeType);
|
||||
if(mType != null){
|
||||
if(server!=null)
|
||||
client=new StorageClient(serviceClass, serviceName, owner, type, mType, server).getClient();
|
||||
else
|
||||
client=new StorageClient(serviceClass, serviceName, owner, type, mType).getClient();
|
||||
}else{
|
||||
if (server != null)
|
||||
client=new StorageClient(serviceClass, serviceName, owner, server, type ).getClient();
|
||||
else
|
||||
client=new StorageClient(serviceClass, serviceName, owner, type).getClient();
|
||||
}
|
||||
InputStream is=null;
|
||||
is=client.get().RFileAsInputStream(location);
|
||||
// ScopeProvider.instance.set(currentScope);
|
||||
return is;
|
||||
}
|
||||
|
||||
private String extractLocation(String url) {
|
||||
String [] loc=url.split("//");
|
||||
logger.info("url extracted: "+loc[1]);
|
||||
return loc[1];
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
package org.gcube.contentmanager.storageclient.model.protocol.smp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URLConnection;
|
||||
import org.gcube.contentmanager.storageclient.model.protocol.smp.SMPURLConnectionFactory;
|
||||
|
||||
/**
|
||||
* Allow to the end user to manage a smp url as an url with a configured stream handler
|
||||
* @author Roberto Cirillo (ISTI-CNR)
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class SMPUrl extends java.net.URLStreamHandler{
|
||||
|
||||
private java.net.URL url;
|
||||
|
||||
/**
|
||||
* map a url string as a normal url
|
||||
* @param u url string
|
||||
* @throws MalformedURLException
|
||||
*/
|
||||
public SMPUrl(String u) throws MalformedURLException{
|
||||
this.url=new java.net.URL(null, u, this);
|
||||
}
|
||||
|
||||
public URLConnection openConnection() throws IOException{
|
||||
return this.openConnection(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected URLConnection openConnection(java.net.URL u) throws IOException {
|
||||
if(u.getProtocol().equalsIgnoreCase("smp")){
|
||||
return SMPURLConnectionFactory.getSmp(u);
|
||||
}else{
|
||||
return new java.net.URL(null, u.toString()).openConnection();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getHost(){
|
||||
return this.url.getHost();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the path part of this <code>URL</code>.
|
||||
*
|
||||
* @return the path part of this <code>URL</code>, or an
|
||||
* empty string if one does not exist
|
||||
* @since 1.3
|
||||
*/
|
||||
public String getPath() {
|
||||
return url.getPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the userInfo part of this <code>URL</code>.
|
||||
*
|
||||
* @return the userInfo part of this <code>URL</code>, or
|
||||
* <CODE>null</CODE> if one does not exist
|
||||
* @since 1.3
|
||||
*/
|
||||
public String getUserInfo() {
|
||||
return url.getUserInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the authority part of this <code>URL</code>.
|
||||
*
|
||||
* @return the authority part of this <code>URL</code>
|
||||
* @since 1.3
|
||||
*/
|
||||
public String getAuthority() {
|
||||
return url.getAuthority();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the port number of this <code>URL</code>.
|
||||
*
|
||||
* @return the port number, or -1 if the port is not set
|
||||
*/
|
||||
public int getPort() {
|
||||
return url.getPort();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default port number of the protocol associated
|
||||
* with this <code>URL</code>. If the URL scheme or the URLStreamHandler
|
||||
* for the URL do not define a default port number,
|
||||
* then -1 is returned.
|
||||
*
|
||||
* @return the port number
|
||||
* @since 1.4
|
||||
*/
|
||||
public int getDefaultPort() {
|
||||
return url.getDefaultPort();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the protocol name of this <code>URL</code>.
|
||||
*
|
||||
* @return the protocol of this <code>URL</code>.
|
||||
*/
|
||||
public String getProtocol() {
|
||||
return url.getProtocol();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the file name of this <code>URL</code>.
|
||||
* The returned file portion will be
|
||||
* the same as <CODE>getPath()</CODE>, plus the concatenation of
|
||||
* the value of <CODE>getQuery()</CODE>, if any. If there is
|
||||
* no query portion, this method and <CODE>getPath()</CODE> will
|
||||
* return identical results.
|
||||
*
|
||||
* @return the file name of this <code>URL</code>,
|
||||
* or an empty string if one does not exist
|
||||
*/
|
||||
public String getFile() {
|
||||
return url.getFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the anchor (also known as the "reference") of this
|
||||
* <code>URL</code>.
|
||||
*
|
||||
* @return the anchor (also known as the "reference") of this
|
||||
* <code>URL</code>, or <CODE>null</CODE> if one does not exist
|
||||
*/
|
||||
public String getRef() {
|
||||
return url.getRef();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -97,7 +97,7 @@ public class StringDecrypter {
|
|||
{
|
||||
SecretKey key = keyFactory.generateSecret( keySpec );
|
||||
cipher.init( Cipher.DECRYPT_MODE, key );
|
||||
return org.gcube.common.encryption.encrypter.StringEncrypter.getEncrypter().decrypt(encryptedString, key);
|
||||
return org.gcube.common.encryption.StringEncrypter.getEncrypter().decrypt(encryptedString, key);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
@ -98,7 +98,7 @@ public class StringEncrypter {
|
|||
{
|
||||
SecretKey key = keyFactory.generateSecret( keySpec );
|
||||
cipher.init( Cipher.ENCRYPT_MODE, key );
|
||||
return org.gcube.common.encryption.encrypter.StringEncrypter.getEncrypter().encrypt(unencryptedString, key);
|
||||
return org.gcube.common.encryption.StringEncrypter.getEncrypter().encrypt(unencryptedString, key);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
@ -9,8 +9,10 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.common.scope.impl.ScopeBean.Type;
|
||||
import org.gcube.common.scope.impl.ServiceMapScannerMediator;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -34,9 +36,47 @@ public class Utils {
|
|||
public static final String URI_RESOLVER_RESOURCE_NAME="HTTP-URI-Resolver";
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Utils.class);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static boolean validationScope2(String scope){
|
||||
ScopeBean scopeBean=new ScopeBean(scope);
|
||||
if((scopeBean.is(Type.VRE)))
|
||||
scope=scopeBean.enclosingScope().toString();
|
||||
return ServiceMapScannerMediator.isValid(scope);
|
||||
}
|
||||
|
||||
public static ArrayList<String> getVOScopes(String scope){
|
||||
ArrayList<String> vos=new ArrayList<String>();
|
||||
ScopeBean scopeBean=new ScopeBean(scope);
|
||||
//retrieve INFRA scope
|
||||
while(!scopeBean.is(Type.INFRASTRUCTURE)){
|
||||
logger.debug("the scope "+scope+" is not an INFRA scope ");
|
||||
scopeBean=new ScopeBean(scopeBean.enclosingScope().toString());
|
||||
}
|
||||
scope=scopeBean.toString();
|
||||
if(scopeBean.is(Type.INFRASTRUCTURE)){
|
||||
Set<String> scopeSet=ServiceMapScannerMediator.getScopeKeySet();
|
||||
for(String scopeItem : scopeSet){
|
||||
//retrieve all Vo scopes
|
||||
logger.debug("scope scanned: "+scopeItem);
|
||||
if(scopeItem.contains(scope) && (new ScopeBean(scopeItem).is(Type.VO))){
|
||||
logger.debug("found vo scope: "+scopeItem);
|
||||
vos.add(scopeItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
return vos;
|
||||
}
|
||||
|
||||
public static String extractInfrastructureNewVersion(String urlParam){
|
||||
logger.debug("urlParam: "+urlParam);
|
||||
String infra= checkVarEnv(INFRASTRUCTURE_ENV_VARIABLE_NAME);
|
||||
if (infra != null)
|
||||
return infra;
|
||||
else
|
||||
//only for test return the infra from the uri. In prod will be throws a runtime exception
|
||||
return getInfraFromResolverHost(urlParam);
|
||||
}
|
||||
|
||||
public static String getInfraFromResolverHost(String resolverHost) {
|
||||
if(resolverHost.equals(GCUBE_RESOLVER_HOST)){
|
||||
|
@ -46,6 +86,48 @@ public class Utils {
|
|||
}else return resolverHost;
|
||||
}
|
||||
|
||||
public static String checkVarEnv(String name){
|
||||
Map<String, String> env = System.getenv();
|
||||
TreeSet<String> keys = new TreeSet<String>(env.keySet());
|
||||
Iterator<String> iter = keys.iterator();
|
||||
String value=null;
|
||||
while(iter.hasNext())
|
||||
{
|
||||
String key = iter.next();
|
||||
if(key.equalsIgnoreCase(name)){
|
||||
value=env.get(key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static boolean isScopeProviderMatch(String infraHost) {
|
||||
String currentScope=ScopeProvider.instance.get();
|
||||
if(currentScope != null){
|
||||
//get vo scope
|
||||
String voScope=Utils.getVOScope(currentScope);
|
||||
// get the uri resolver host
|
||||
List<ServiceEndpoint> services=queryServiceEndpoint(URI_RESOLVER_RESOURCE_CATEGORY, URI_RESOLVER_RESOURCE_NAME);
|
||||
String host=null;
|
||||
if(services != null && services.size()>0){
|
||||
host=getResolverHost(services.get(0));
|
||||
if(host!=null){
|
||||
if(infraHost.equalsIgnoreCase(host)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String getVOScope(String currentScope) {
|
||||
ScopeBean scopeBean=new ScopeBean(currentScope);
|
||||
if((scopeBean.is(Type.VRE)))
|
||||
currentScope=scopeBean.enclosingScope().toString();
|
||||
return currentScope;
|
||||
}
|
||||
|
||||
public static List<ServiceEndpoint> queryServiceEndpoint(String category, String name){
|
||||
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||||
|
@ -54,6 +136,25 @@ public class Utils {
|
|||
List<ServiceEndpoint> resources = client.submit(query);
|
||||
return resources;
|
||||
}
|
||||
|
||||
/**
|
||||
* if the scope provider is not set then check if the env variable: SCOPE is set and set the scopeProvider
|
||||
*/
|
||||
public static void checkScopeProvider(){
|
||||
String scopeProvided=ScopeProvider.instance.get();
|
||||
logger.info("check scope: scope found "+scopeProvided);
|
||||
if ((scopeProvided==null) || (scopeProvided.isEmpty())){
|
||||
logger.debug("scope not correctly set on ScopeProvider");
|
||||
logger.info("scope: check variable");
|
||||
scopeProvided=Utils.checkVarEnv("SCOPE");
|
||||
if (scopeProvided != null){
|
||||
ScopeProvider.instance.set(scopeProvided);
|
||||
}else{
|
||||
throw new RuntimeException("Scope not set ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String getResolverHost(ServiceEndpoint serviceEndpoint) {
|
||||
return serviceEndpoint.profile().runtime().hostedOn();
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
package org.gcube.contentmanager.storageclient.wrapper;
|
||||
|
||||
public enum BackendType {
|
||||
MongoDB, S3;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
switch(this) {
|
||||
case MongoDB: return "MongoDB";
|
||||
case S3: return "S3";
|
||||
default: throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
MongoDB, S3
|
||||
}
|
||||
|
|
|
@ -3,11 +3,12 @@ package org.gcube.contentmanager.storageclient.wrapper;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.common.scope.impl.ScopeBean.Type;
|
||||
import org.gcube.contentmanagement.blobstorage.service.impl.ServiceEngine;
|
||||
import org.gcube.contentmanager.storageclient.protocol.utils.Utils;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -27,7 +28,6 @@ public class Configuration {
|
|||
private String sn;
|
||||
private String user;
|
||||
private String password;
|
||||
// if the backend is mongodb, this field is used for crypt/decrypt. If the backend is S3, this field is a token.
|
||||
private String passPhrase;
|
||||
private ISClientConnector isclient;
|
||||
// the scope used for discovering the runtimeResource
|
||||
|
@ -36,17 +36,12 @@ public class Configuration {
|
|||
private String[] volatileHost;
|
||||
private String[] persistentHosts;
|
||||
private String resolverHost;
|
||||
private String region;
|
||||
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Configuration.class);
|
||||
protected static final String DEFAULT_BACKEND_TYPE="MongoDB";
|
||||
private static final String DEFAULT_BACKEND_TYPE="MongoDB";
|
||||
private static final String WRITE_CONCERN_PROPERTY_NAME="write_concern";
|
||||
private static final String READ_PREFERENCE_PROPERTY_NAME="read_preference";
|
||||
private static final String DB_PROPERTY_NAME="collection";
|
||||
private static final String DB_STRING_SEPARATOR=";";
|
||||
private static final String PASS_PHRASE_FIELD="PassPhrase";
|
||||
private static final String TOKEN_FIELD="token";
|
||||
/**
|
||||
* home library need a special configuration
|
||||
*/
|
||||
|
@ -90,7 +85,7 @@ public class Configuration {
|
|||
* @param memory indicates the type of memory used by the storage: Persistent or Volatile
|
||||
*
|
||||
*/
|
||||
public Configuration(String sc, String sn, String scopeString, String owner, String clientID, String accessType, String memory, String backend){
|
||||
public Configuration(String sc, String sn, String scopeString, String owner, String clientID, String accessType, String memory, BackendType backend){
|
||||
this.sc=sc;
|
||||
this.sn=sn;
|
||||
this.owner=owner;
|
||||
|
@ -98,7 +93,7 @@ public class Configuration {
|
|||
this.typeAccess=accessType;
|
||||
this.memoryType=memory;
|
||||
setScopeString(scopeString);
|
||||
setBackendType(backend);
|
||||
setBackendType(backend.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,19 +101,29 @@ public class Configuration {
|
|||
*/
|
||||
public void getConfiguration(){
|
||||
String[] newServer=null;
|
||||
String currentScope;
|
||||
currentScope = SecretManagerProvider.get().getContext();
|
||||
// ISClientConnector isclient=getISClient();
|
||||
String currentScope=ScopeProvider.instance.get();
|
||||
logger.debug("Scope found on ScopeProvider instance is "+currentScope);
|
||||
logger.debug("Manually scope was set to"+RRScope+" it doesn't take effect");
|
||||
//if a specific backend is not passed as input param then take the default one
|
||||
if (Objects.isNull(getBackendType()))
|
||||
setBackendType(DEFAULT_BACKEND_TYPE);
|
||||
ServiceEndpoint resource=getISClient(getBackendType()).getStorageEndpoint();
|
||||
|
||||
/*COMMENTED THE FOLLOWING LINES 20181214*/
|
||||
|
||||
if(RRScope == null){
|
||||
// if(new ScopeBean(currentScope).is(Type.VRE)){
|
||||
// logger.debug("If ScopeProvider scope is VRE scope RR scope became VO scope");
|
||||
// RRScope=new ScopeBean(currentScope).enclosingScope().toString();
|
||||
// }else{
|
||||
// logger.debug("If ScopeProvider scope is not a VRE scope RR scope is ScopeProvider scope");
|
||||
RRScope=currentScope;
|
||||
// }
|
||||
}
|
||||
/*END*/
|
||||
logger.debug("RuntimeResource scope "+RRScope);
|
||||
ServiceEndpoint resource=getISClient().getStorageEndpoint(RRScope);
|
||||
if(resource ==null )
|
||||
throw new IllegalStateException("the storage resource is not present on IS in scope: "+RRScope);
|
||||
List<ServiceEndpoint> resolverResource =getISClient(getBackendType()).getServiceEndpoint(Utils.URI_RESOLVER_RESOURCE_CATEGORY, Utils.URI_RESOLVER_RESOURCE_NAME);
|
||||
List<ServiceEndpoint> resolverResource =getISClient().getServiceEndpoint(Utils.URI_RESOLVER_RESOURCE_CATEGORY, Utils.URI_RESOLVER_RESOURCE_NAME);
|
||||
if(resolverResource !=null && resolverResource.size()> 0)
|
||||
setResolverHost(getISClient(getBackendType()).getResolverHost(resolverResource.get(0)));
|
||||
setResolverHost(getISClient().getResolverHost(resolverResource.get(0)));
|
||||
else
|
||||
throw new IllegalStateException("the uri resolver resource is not present on IS in scope: "+currentScope);
|
||||
// old method for retrieve hostedOn field in storage ServiceEndpoint resource
|
||||
|
@ -126,17 +131,13 @@ public class Configuration {
|
|||
logger.debug("server not set. Try to query IS in scope: "+scopeString);
|
||||
String[] serverFound=checkVarEnvMongo();
|
||||
if(serverFound==null){
|
||||
serverFound=getISClient(getBackendType()).retrieveConnectionInfo(resource);
|
||||
setUser(getISClient(getBackendType()).getUsername());
|
||||
setPassword(getISClient(getBackendType()).password);
|
||||
setRegion(getISClient(getBackendType()).getRegion());
|
||||
if (Objects.isNull(getBackendType()))
|
||||
setBackendType(getISClient(getBackendType()).getBackendType(resource));
|
||||
serverFound=getISClient().retrieveConnectionInfo(resource);
|
||||
setUser(getISClient().getUsername());
|
||||
setPassword(getISClient().password);
|
||||
setBackendType(getISClient().getBackendType(resource));
|
||||
}else{
|
||||
if (!Objects.isNull(getBackendType()))
|
||||
setBackendType(checkVarEnvBackendType());
|
||||
else
|
||||
setBackendType(DEFAULT_BACKEND_TYPE);
|
||||
setBackendType(checkVarEnvBackendType());
|
||||
if(getBackendType() == null) setBackendType(DEFAULT_BACKEND_TYPE);
|
||||
setUser(checkVarEnvUser());
|
||||
setPassword(checkVarEnvPassword());
|
||||
}
|
||||
|
@ -150,33 +151,16 @@ public class Configuration {
|
|||
if(newServer==null){
|
||||
throw new IllegalStateException("Resource not found on Information System");
|
||||
}else{
|
||||
setEnvironment(setAreaStorage(getSc(), getSn()));
|
||||
// if the backend is mongodb we should set a separated server for volatile area
|
||||
if(getBackendType().equals("MongoDB")) {
|
||||
setServerHosts(newServer, isclient, resource);
|
||||
try {
|
||||
setPassPhrase(retrieveEncryptionField(PASS_PHRASE_FIELD));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else {
|
||||
// if the backend isn't mongodb, the passPhrase field will be filled with a token if it is present on ServiceEndpoint
|
||||
try {
|
||||
setPassPhrase(retrieveEncryptionField(TOKEN_FIELD));
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
setPersistentHosts(newServer);
|
||||
|
||||
setEnvironment(setAreaStorage(getSc(), getSn()));
|
||||
setServerHosts(newServer, isclient, resource);
|
||||
try {
|
||||
setPassPhrase(retrieveEncryptionPhrase());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
logger.debug("Configuration parameters retrieved: host: "+getPersistentHosts()+" user: "+getUser());
|
||||
}
|
||||
|
||||
|
||||
private void setServerHosts(String[] newServer, ISClientConnector isclient, ServiceEndpoint resource) {
|
||||
if((getMemoryType() != null) && ((getMemoryType().equals(MemoryType.VOLATILE.toString()) || (getMemoryType().equals(MemoryType.BOTH.toString()))))){
|
||||
setVolatileHost(isclient.getVolatileHost(resource));
|
||||
|
@ -206,7 +190,7 @@ public class Configuration {
|
|||
|
||||
private String getHomeLibraryContext(){
|
||||
String area=null;
|
||||
String scope= SecretManagerProvider.get().getContext();
|
||||
String scope=ScopeProvider.instance.get();
|
||||
String context=null;
|
||||
if (scope.startsWith("/gcube"))
|
||||
context= HL_CONTEXT_DEV;
|
||||
|
@ -224,18 +208,18 @@ public class Configuration {
|
|||
}
|
||||
|
||||
|
||||
protected void getOptionalPropertiesFromRR( ServiceEngine engine) {
|
||||
protected void getOptionalPropertiesFromRR( String currentScope, ServiceEngine engine) {
|
||||
String write=null;
|
||||
String read=null;
|
||||
String [] dbNames=null;
|
||||
String dbString=null;
|
||||
// check optional properties only if it is not a volatile storage instance
|
||||
if((getMemoryType() != null) && (!(getMemoryType().equals(MemoryType.VOLATILE.toString())))){
|
||||
write=getISClient(getBackendType()).retrievePropertyValue(WRITE_CONCERN_PROPERTY_NAME);
|
||||
write=getISClient().retrievePropertyValue(WRITE_CONCERN_PROPERTY_NAME, currentScope);
|
||||
logger.debug("read preference: read from service endpoint");
|
||||
read=getISClient(getBackendType()).retrievePropertyValue(READ_PREFERENCE_PROPERTY_NAME);
|
||||
read=getISClient().retrievePropertyValue(READ_PREFERENCE_PROPERTY_NAME, currentScope);
|
||||
logger.debug(" write preference: read from service endpoint");
|
||||
dbString=getISClient(getBackendType()).retrievePropertyValue(DB_PROPERTY_NAME);
|
||||
dbString=getISClient().retrievePropertyValue(DB_PROPERTY_NAME, currentScope);
|
||||
if((write!=null) && (read!=null)){
|
||||
engine.setWriteConcern(write);
|
||||
engine.setReadConcern(read);
|
||||
|
@ -249,12 +233,11 @@ public class Configuration {
|
|||
}
|
||||
if (dbNames.length > 1)
|
||||
logger.debug("multiple collection discovered");
|
||||
if (Objects.isNull(engine.getDbNames()))
|
||||
engine.setDbNames(dbNames);
|
||||
engine.setDbNames(dbNames);
|
||||
}
|
||||
// added db check also on volatile are
|
||||
}else if((getMemoryType().equals(MemoryType.VOLATILE.toString()))){
|
||||
dbString=getISClient(getBackendType()).retrievePropertyValue(DB_PROPERTY_NAME);
|
||||
dbString=getISClient().retrievePropertyValue(DB_PROPERTY_NAME, currentScope);
|
||||
if(dbString!=null){
|
||||
if (dbString.contains(DB_STRING_SEPARATOR)){
|
||||
logger.debug("more than one collection read from ServiceEnpoint");
|
||||
|
@ -366,28 +349,16 @@ public class Configuration {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
||||
public String retrieveEncryptionPhrase() throws Exception {
|
||||
String currentScope=SecretManagerProvider.get().getContext();
|
||||
String currentScope=ScopeProvider.instance.get();
|
||||
logger.debug("retrieve encryption prhase on scope: "+currentScope);
|
||||
String encryptedKey=null;
|
||||
// ISClientConnector isclient=getISClient();
|
||||
logger.info("retrieve encryption phrase from scope "+currentScope);
|
||||
encryptedKey=getISClient(getBackendType()).retrievePropertyValue("PassPhrase");
|
||||
encryptedKey=getISClient().retrievePropertyValue("PassPhrase", currentScope);
|
||||
logger.info("encrypted prhase is "+encryptedKey);
|
||||
String decryptString=org.gcube.common.encryption.encrypter.StringEncrypter.getEncrypter().decrypt(encryptedKey);
|
||||
return decryptString;
|
||||
}
|
||||
|
||||
public String retrieveEncryptionField(String fieldName) throws Exception {
|
||||
String currentScope=SecretManagerProvider.get().getContext();
|
||||
logger.debug("retrieve encryption prhase on scope: "+currentScope);
|
||||
String encryptedKey=null;
|
||||
// ISClientConnector isclient=getISClient();
|
||||
logger.info("retrieve encryption phrase from scope "+currentScope);
|
||||
encryptedKey=getISClient(getBackendType()).retrievePropertyValue(fieldName);
|
||||
logger.info("encrypted prhase is "+encryptedKey);
|
||||
String decryptString=(!Objects.isNull(encryptedKey))?org.gcube.common.encryption.encrypter.StringEncrypter.getEncrypter().decrypt(encryptedKey):null;
|
||||
String decryptString=org.gcube.common.encryption.StringEncrypter.getEncrypter().decrypt(encryptedKey);
|
||||
return decryptString;
|
||||
}
|
||||
|
||||
|
@ -512,14 +483,10 @@ public class Configuration {
|
|||
this.resolverHost = resolverHost;
|
||||
}
|
||||
|
||||
private ISClientConnector getISClient(String backendType){
|
||||
// if ((isclient == null) || (isclient.getBackendType().equals(backendType)))
|
||||
// isclient=new ISClientConnector(backendType);
|
||||
//
|
||||
// return isclient;
|
||||
|
||||
return isclient=((isclient == null) || (!isclient.getBackendType().equals(backendType)))?new ISClientConnector(backendType):isclient;
|
||||
|
||||
public ISClientConnector getISClient(){
|
||||
if (isclient == null)
|
||||
isclient=new ISClientConnector();
|
||||
return isclient;
|
||||
}
|
||||
|
||||
public String getSc() {
|
||||
|
@ -537,13 +504,5 @@ public class Configuration {
|
|||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(String region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,15 +8,11 @@ import java.util.HashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.gcube.common.encryption.encrypter.StringEncrypter;
|
||||
import org.gcube.common.encryption.StringEncrypter;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.BackendType;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.Property;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -38,20 +34,7 @@ public class ISClientConnector {
|
|||
protected String username;
|
||||
protected String password;
|
||||
protected ServiceEndpoint storageResource;
|
||||
public String region;
|
||||
private static HashMap<String, Object> isCache;
|
||||
/**
|
||||
* identify the ServiceEndpoint Category of the storage-manager backend
|
||||
*/
|
||||
public final String CATEGORY="Storage";
|
||||
/**
|
||||
* identify the ServiceEndpoint name of the storage-manager backend
|
||||
*/
|
||||
public final String NAME="StorageManager";
|
||||
|
||||
public ISClientConnector(String backendType){
|
||||
setBackendType(backendType);
|
||||
}
|
||||
|
||||
public ISClientConnector(){
|
||||
}
|
||||
|
@ -68,21 +51,31 @@ public class ISClientConnector {
|
|||
return resources;
|
||||
}
|
||||
|
||||
public ServiceEndpoint getStorageEndpoint() {
|
||||
public ServiceEndpoint getStorageEndpoint(String scope) {
|
||||
//if the serviceEndpoint has been already discovered and selected, I'm going to use that
|
||||
// otherwise I'm going to discovered it from IS
|
||||
if(getStorageResource() == null){
|
||||
logger.debug("discovering service endpoint");
|
||||
String savedScope=null;
|
||||
if(scope!=null){
|
||||
savedScope=ScopeProvider.instance.get();
|
||||
logger.debug("set scopeProvider to scope "+scope+" scope provider scope is "+savedScope);
|
||||
ScopeProvider.instance.set(scope);
|
||||
}
|
||||
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||||
query.addCondition("$resource/Profile/Category/text() eq '"+CATEGORY+"' and $resource/Profile/Name eq '"+NAME+"' ");
|
||||
query.addCondition("$resource/Profile/Category/text() eq '"+Configuration.STORAGE_SERVICEENDPOINT_CATEGORY+"' and $resource/Profile/Name eq '"+Configuration.STORAGE_SERVICEENDPOINT_NAME+"' ");
|
||||
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
|
||||
List<ServiceEndpoint> resources = client.submit(query);
|
||||
if(scope!=null){
|
||||
logger.debug("reset scopeProvider to scope "+scope);
|
||||
ScopeProvider.instance.set(savedScope);
|
||||
}
|
||||
if (resources.size()>0){
|
||||
ServiceEndpoint storageResource = getPriorityResource(resources);
|
||||
setStorageResource(storageResource);
|
||||
return storageResource;
|
||||
}else
|
||||
throw new RuntimeException("Storage ServiceEndpoint not found under scope: "+SecretManagerProvider.get().getContext());
|
||||
throw new RuntimeException("Storage ServiceEndpoint not found under scope: "+scope);
|
||||
}else{
|
||||
logger.debug("service endpoint already discovered");
|
||||
return getStorageResource();
|
||||
|
@ -91,82 +84,43 @@ public class ISClientConnector {
|
|||
|
||||
|
||||
private String[] fillConnectionFields(ServiceEndpoint resource) {
|
||||
logger.debug("fillConnectionsFields method ");
|
||||
if(resource!=null){
|
||||
logger.debug("checking resource "+resource.id());
|
||||
ArrayList<String> server=new ArrayList<String> ();//new String[resource.profile().accessPoints().size()];
|
||||
if(!(getBackendType(resource).equals(BackendType.MongoDB.name()))) {
|
||||
logger.info("searching backend: "+getBackendType());
|
||||
for (AccessPoint ap:resource.profile().accessPoints()) {
|
||||
if( (ap.name().equals(getBackendType()))){
|
||||
//in v1.6.0 we are considering only one accessPoint for a backend except for mongodb.
|
||||
server.add( ap.address());
|
||||
// if presents, try to get user and password
|
||||
setUsername(ap.username());
|
||||
decryptPwd(ap);
|
||||
setRegion(retrievePropertyValue(ap, "region"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
int i=0;
|
||||
|
||||
for (AccessPoint ap:resource.profile().accessPoints()) {
|
||||
if (ap.name().equals("server"+(i+1))) {
|
||||
|
||||
server.add(ap.address());
|
||||
setUsername(ap.username());
|
||||
setPassword("");
|
||||
if(getUsername() != null && getUsername().length() > 0){
|
||||
try {
|
||||
setPassword(StringEncrypter.getEncrypter().decrypt(ap.password()));
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
ArrayList<String> srvs=new ArrayList <String>();
|
||||
// String [] server=new String[resource.profile().accessPoints().size()];
|
||||
int i=0;
|
||||
for (AccessPoint ap:resource.profile().accessPoints()) {
|
||||
if (ap.name().equals("server"+(i+1))) {
|
||||
// server[i] = ap.address();
|
||||
srvs.add(ap.address());
|
||||
// if presents, try to get user and password
|
||||
setUsername(ap.username());
|
||||
// set password default value to empty string
|
||||
setPassword("");
|
||||
if(getUsername() != null && getUsername().length() > 0){
|
||||
try {
|
||||
setPassword(StringEncrypter.getEncrypter().decrypt(ap.password()));
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
logger.info("credentials Mongodb: "+getUsername()+" "+getPassword());
|
||||
// setBackendType(retrievePropertyValue(resource, "type"));
|
||||
}
|
||||
//<<<<<<< HEAD
|
||||
//
|
||||
//=======
|
||||
// String [] server=new String[srvs.size()];
|
||||
// server = srvs.toArray(server);
|
||||
// setBackendType(retrievePropertyValue(resource, "type"));
|
||||
//>>>>>>> master
|
||||
String [] server=new String[srvs.size()];
|
||||
server = srvs.toArray(server);
|
||||
setBackendType(retrievePropertyValue(resource, "type"));
|
||||
String [] volatileHost= new String [1];
|
||||
volatileHost[0]=retrievePropertyValue(resource, "volatile");
|
||||
setVolatileHost(volatileHost);
|
||||
logger.info("Type of backend found in RR is "+backendType);
|
||||
String [] servers= new String[server.size()];
|
||||
servers=server.toArray(servers);
|
||||
return servers;
|
||||
return server;
|
||||
|
||||
}else{
|
||||
throw new IllegalStateException("Runtime Resource found are more than 1 but all without default priority setted");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void decryptPwd(AccessPoint ap) {
|
||||
// set password default value to empty string
|
||||
setPassword("");
|
||||
if(getUsername() != null && getUsername().length() > 0){
|
||||
try {
|
||||
setPassword(StringEncrypter.getEncrypter().decrypt(ap.password()));
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ServiceEndpoint getPriorityResource(List<ServiceEndpoint> resources) {
|
||||
ServiceEndpoint defaultResource=null;
|
||||
logger.info("search RR with priority ");
|
||||
|
@ -198,8 +152,8 @@ public class ISClientConnector {
|
|||
}
|
||||
|
||||
|
||||
public String retrievePropertyValue(String name) {
|
||||
ServiceEndpoint res = getStorageEndpoint();
|
||||
public String retrievePropertyValue(String name, String scope) {
|
||||
ServiceEndpoint res = getStorageEndpoint(scope);
|
||||
Iterator<AccessPoint> it= res.profile().accessPoints().iterator();
|
||||
String value=null;
|
||||
while(it.hasNext()){
|
||||
|
@ -214,17 +168,6 @@ public class ISClientConnector {
|
|||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public String retrievePropertyValue(AccessPoint ap, String name) {
|
||||
String value=null;
|
||||
Map<String, Property>map= ap.propertyMap();
|
||||
Property type=map.get(name);
|
||||
if(type!=null){
|
||||
value=type.value();
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private String retrievePropertyValue(ServiceEndpoint res, String name) {
|
||||
Iterator<AccessPoint> it= res.profile().accessPoints().iterator();
|
||||
|
@ -254,7 +197,7 @@ public class ISClientConnector {
|
|||
return backendType;
|
||||
}
|
||||
|
||||
private void setBackendType(String backendType) {
|
||||
public void setBackendType(String backendType) {
|
||||
this.backendType = backendType;
|
||||
}
|
||||
|
||||
|
@ -290,14 +233,6 @@ public class ISClientConnector {
|
|||
this.storageResource = storageResource;
|
||||
}
|
||||
|
||||
private void setRegion(String region) {
|
||||
this.region=region;
|
||||
|
||||
}
|
||||
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -1,12 +1,10 @@
|
|||
package org.gcube.contentmanager.storageclient.wrapper;
|
||||
package org.gcube.contentmanager.storageclient.wrapper;
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.BackendType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
//import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.service.impl.ServiceEngine;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;
|
||||
|
@ -40,20 +38,53 @@ public class StorageClient {
|
|||
private static final String DEFAULT_SERVICE_NAME="Default";
|
||||
private static final MemoryType DEFAULT_MEMORY_TYPE=MemoryType.PERSISTENT;
|
||||
|
||||
/**
|
||||
* Constructor without optional argument created for gcube infrastructure internal use
|
||||
* @param ServiceClass
|
||||
* @param ServiceName
|
||||
* @param owner
|
||||
* @param typeAccess
|
||||
* @param scope scope identifier
|
||||
* @param forceScope if true the scope used is the scope specified in scope parameter, else the scope specified in the parameter scope is used only for discovering the RuntimeResource
|
||||
*/
|
||||
@Deprecated
|
||||
public StorageClient(String serviceClass, String serviceName, String owner, AccessType accessType, String scope, boolean forceScope){
|
||||
checkScopeProvider();
|
||||
if(forceScope){
|
||||
this.currentScope=ScopeProvider.instance.get();
|
||||
ScopeProvider.instance.set(scope);
|
||||
this.scopeString=ScopeProvider.instance.get();
|
||||
}else{
|
||||
this.RRScope=scope;
|
||||
this.scopeString=ScopeProvider.instance.get();
|
||||
}
|
||||
String id=owner;
|
||||
this.owner=owner;
|
||||
if(accessType!=null)
|
||||
this.typeAccess=accessType;
|
||||
else throw new RuntimeException("AccessType parameter must be not null");
|
||||
this.memoryType=MemoryType.BOTH;
|
||||
this.serviceClass=serviceClass;
|
||||
this.serviceName=serviceName;
|
||||
setClientId(serviceClass, serviceName, id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor without optional argument created for gcube infrastructure internal use
|
||||
* @param serviceClass
|
||||
* @param serviceName
|
||||
* @param ServiceClass
|
||||
* @param ServiceName
|
||||
* @param owner
|
||||
* @param accessType
|
||||
* @param typeAccess
|
||||
* @param scope
|
||||
*/
|
||||
public StorageClient(String serviceClass, String serviceName, String owner, AccessType accessType){
|
||||
checkScopeProvider();
|
||||
String id=owner;
|
||||
this.owner=owner;
|
||||
this.scopeString=SecretManagerProvider.get().getContext();
|
||||
this.scopeString=ScopeProvider.instance.get();
|
||||
if(accessType!=null)
|
||||
this.typeAccess=accessType;
|
||||
else throw new RuntimeException("AccessType parameter must be not null");
|
||||
|
@ -69,15 +100,17 @@ public class StorageClient {
|
|||
* New constructor with another optional argument created for gcube infrastructure internal use.
|
||||
* Available in v1.6.0
|
||||
* It's possible to specify a specific backend.
|
||||
* @param serviceClass
|
||||
* @param serviceName
|
||||
* @param ServiceClass
|
||||
* @param ServiceName
|
||||
* @param owner
|
||||
* @param accessType
|
||||
* @param typeAccess
|
||||
* @param scope
|
||||
*/
|
||||
public StorageClient(String serviceClass, String serviceName, String owner, AccessType accessType, BackendType backend){;
|
||||
public StorageClient(String serviceClass, String serviceName, String owner, AccessType accessType, BackendType backend){
|
||||
checkScopeProvider();
|
||||
String id=owner;
|
||||
this.owner=owner;
|
||||
this.scopeString=SecretManagerProvider.get().getContext();
|
||||
this.scopeString=ScopeProvider.instance.get();
|
||||
if(accessType!=null)
|
||||
this.typeAccess=accessType;
|
||||
else throw new RuntimeException("AccessType parameter must be not null");
|
||||
|
@ -94,13 +127,15 @@ public class StorageClient {
|
|||
/**
|
||||
* Constructor created for external use
|
||||
* @param owner
|
||||
* @param accessType
|
||||
* @param typeAccess
|
||||
* @param memory defines the kind of memory: VOLATILE or PERSISTENT
|
||||
* @param scope
|
||||
*/
|
||||
public StorageClient(String owner, AccessType accessType, MemoryType memory){
|
||||
checkScopeProvider();
|
||||
String id=owner;
|
||||
this.owner=owner;
|
||||
this.scopeString=SecretManagerProvider.get().getContext();
|
||||
this.scopeString=ScopeProvider.instance.get();
|
||||
if(accessType!=null)
|
||||
this.typeAccess=accessType;
|
||||
else throw new RuntimeException("AccessType parameter must be not null");
|
||||
|
@ -115,16 +150,18 @@ public class StorageClient {
|
|||
|
||||
/**
|
||||
* Constructor with optional argument server
|
||||
* @param serviceClass
|
||||
* @param serviceName
|
||||
* @param ServiceClass
|
||||
* @param ServiceName
|
||||
* @param owner
|
||||
* @param accessType
|
||||
* @param typeAccess
|
||||
* @param scope
|
||||
* @param server: define the mongoDBserver
|
||||
*/
|
||||
public StorageClient(String serviceClass, String serviceName, String owner, String server, AccessType accessType){
|
||||
checkScopeProvider();
|
||||
String id=owner;
|
||||
this.owner=owner;
|
||||
this.scopeString=SecretManagerProvider.get().getContext();
|
||||
this.scopeString=ScopeProvider.instance.get();
|
||||
if(accessType!=null)
|
||||
this.typeAccess=accessType;
|
||||
else throw new RuntimeException("AccessType parameter must be not null");
|
||||
|
@ -139,16 +176,18 @@ public class StorageClient {
|
|||
|
||||
/**
|
||||
* Constructor with optional argument memoryType
|
||||
* @param serviceClass
|
||||
* @param serviceName
|
||||
* @param ServiceClass
|
||||
* @param ServiceName
|
||||
* @param owner
|
||||
* @param accessType
|
||||
* @param typeAccess
|
||||
* @param memory defines the kind of memory: VOLATILE or PERSISTENT
|
||||
* @param scope
|
||||
*/
|
||||
public StorageClient(String serviceClass, String serviceName, String owner, AccessType accessType, MemoryType memory){
|
||||
checkScopeProvider();
|
||||
String id=owner;
|
||||
this.owner=owner;
|
||||
this.scopeString=SecretManagerProvider.get().getContext();
|
||||
this.scopeString=ScopeProvider.instance.get();
|
||||
if(accessType!=null)
|
||||
this.typeAccess=accessType;
|
||||
else throw new RuntimeException("AccessType parameter must be not null");
|
||||
|
@ -164,17 +203,19 @@ public class StorageClient {
|
|||
/**
|
||||
* Available in v1.6.0
|
||||
* It's possible to specify a specific backend.
|
||||
* @param serviceClass
|
||||
* @param serviceName
|
||||
* @param ServiceClass
|
||||
* @param ServiceName
|
||||
* @param owner
|
||||
* @param accessType
|
||||
* @param typeAccess
|
||||
* @param backend: specify mongodb (default) or s3
|
||||
* @param memory defines the kind of memory: VOLATILE or PERSISTENT
|
||||
* @param scope
|
||||
*/
|
||||
public StorageClient(String serviceClass, String serviceName, String owner, AccessType accessType, MemoryType memory, BackendType backend){
|
||||
checkScopeProvider();
|
||||
String id=owner;
|
||||
this.owner=owner;
|
||||
this.scopeString=SecretManagerProvider.get().getContext();
|
||||
this.scopeString=ScopeProvider.instance.get();
|
||||
if(accessType!=null)
|
||||
this.typeAccess=accessType;
|
||||
else throw new RuntimeException("AccessType parameter must be not null");
|
||||
|
@ -191,17 +232,19 @@ public class StorageClient {
|
|||
|
||||
/**
|
||||
* Constructor with optional arguments server and memory
|
||||
* @param serviceClass
|
||||
* @param serviceName
|
||||
* @param ServiceClass
|
||||
* @param ServiceName
|
||||
* @param owner
|
||||
* @param accessType
|
||||
* @param typeAccess
|
||||
* @param memory defines the kind of memory: VOLATILE or PERSISTENT
|
||||
* @param server: define the mongoDBserver
|
||||
* @param scope
|
||||
*/
|
||||
public StorageClient(String serviceClass, String serviceName, String owner, AccessType accessType, MemoryType memory, String server){
|
||||
checkScopeProvider();
|
||||
String id=owner;
|
||||
this.owner=owner;
|
||||
this.scopeString=SecretManagerProvider.get().getContext();
|
||||
this.scopeString=ScopeProvider.instance.get();
|
||||
if(accessType!=null)
|
||||
this.typeAccess=accessType;
|
||||
else throw new RuntimeException("AccessType parameter must be not null");
|
||||
|
@ -221,11 +264,7 @@ public class StorageClient {
|
|||
* @throws IllegalStateException if the resource is not found on the IS
|
||||
*/
|
||||
public IClient getClient(){
|
||||
Configuration cfg=null;
|
||||
if(Objects.isNull(getBackendType()))
|
||||
cfg= new Configuration(serviceClass, serviceName, scopeString, owner, clientID, typeAccess.toString(), memoryType.toString());
|
||||
else
|
||||
cfg= new Configuration(serviceClass, serviceName, scopeString, owner, clientID, typeAccess.toString(), memoryType.toString(), getBackendType());
|
||||
Configuration cfg= new Configuration(serviceClass, serviceName, scopeString, owner, clientID, typeAccess.toString(), memoryType.toString());
|
||||
cfg.getConfiguration();
|
||||
ServiceEngine engine= new ServiceEngine(cfg.getPersistentHosts(), cfg.getVolatileHost(), cfg.getEnvironment(), cfg.getTypeAccess(), cfg.getOwner(), cfg.getMemoryType());
|
||||
// set additional fields for the new engine object
|
||||
|
@ -236,20 +275,15 @@ public class StorageClient {
|
|||
engine.setBackendUser(cfg.getUser());
|
||||
engine.setBackendPassword(cfg.getPassword());
|
||||
engine.setResolverHost(cfg.getResolverHost());
|
||||
engine.setRegion(cfg.getRegion());
|
||||
if(cfg.getPassPhrase()!=null) {
|
||||
if(cfg.getPassPhrase()!=null)
|
||||
engine.setPassPhrase(cfg.getPassPhrase());
|
||||
engine.setToken(cfg.getPassPhrase());
|
||||
}
|
||||
if(getMemoryType() !=null)
|
||||
engine.setGcubeMemoryType(getMemoryType().toString());
|
||||
engine.setGcubeScope(SecretManagerProvider.get().getContext());
|
||||
engine.setGcubeScope(ScopeProvider.instance.get());
|
||||
engine.setOwnerGcube(owner);
|
||||
cfg.getOptionalPropertiesFromRR(engine);
|
||||
if(getCurrentScope()!=null){
|
||||
if(!getCurrentScope().equals(SecretManagerProvider.get().getContext()))
|
||||
logger.warn("scope force to "+getCurrentScope()+"doesn't take effect. The current scope is set to"+SecretManagerProvider.get().getContext());
|
||||
}
|
||||
cfg.getOptionalPropertiesFromRR( getCurrentScope(), engine);
|
||||
if(getCurrentScope()!=null)
|
||||
ScopeProvider.instance.set(getCurrentScope());
|
||||
return engine;
|
||||
}
|
||||
|
||||
|
@ -266,6 +300,23 @@ public class StorageClient {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* if the scope provider is not set then check if the env variable: SCOPE is set and set the scopeProvider
|
||||
*/
|
||||
private void checkScopeProvider(){
|
||||
String scopeProvided=ScopeProvider.instance.get();
|
||||
if (scopeProvided==null){
|
||||
scopeProvided=Utils.checkVarEnv("SCOPE");
|
||||
if (scopeProvided != null){
|
||||
ScopeProvider.instance.set(scopeProvided);
|
||||
}else{
|
||||
throw new RuntimeException("Scope not set ");
|
||||
}
|
||||
}else setCurrentScope(scopeProvided);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getClientID() {
|
||||
return clientID;
|
||||
|
@ -376,8 +427,6 @@ public class StorageClient {
|
|||
|
||||
|
||||
public String getBackendType() {
|
||||
if(Objects.isNull(backendType))
|
||||
backendType=Configuration.DEFAULT_BACKEND_TYPE;
|
||||
logger.debug("backend type returned is "+backendType);
|
||||
return backendType;
|
||||
}
|
||||
|
|
|
@ -3,41 +3,41 @@ package org.gcube.contentmanager.storageclient.test;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
import org.gcube.contentmanager.storageclient.test.utils.Costants;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class CopyDirTest {
|
||||
|
||||
private static String owner="rcirillo";
|
||||
private String owner="rcirillo";
|
||||
// local file
|
||||
private static String localPath="src/test/resources/CostaRica1.jpg";
|
||||
private String localPath="src/test/resources/CostaRica1.jpg";
|
||||
//remote files
|
||||
private static String remoteOriginalFilePath="/test/img/original.jpg";
|
||||
private static String remoteOriginalFilePath2="/test/img/original2.jpg";
|
||||
private static String remoteCopyFilePath="/test/copyImg/img/original.jpg";
|
||||
private static String remoteCopyFilePath2="/test/copyImg/img/original2.jpg";
|
||||
private String remoteOriginalFilePath="/test/img/original.jpg";
|
||||
private String remoteOriginalFilePath2="/test/img/original2.jpg";
|
||||
private String remoteCopyFilePath="/test/copyImg/img/original.jpg";
|
||||
private String remoteCopyFilePath2="/test/copyImg/img/original2.jpg";
|
||||
//remote directories
|
||||
private static String remoteOriginalDirPath="/test/img/";
|
||||
private static String remoteCopyDirPath="/test/copyImg";
|
||||
private static String absoluteLocalPath;
|
||||
private static String newFilePath="src/test/resources";
|
||||
private static IClient client;
|
||||
private String remoteOriginalDirPath="/test/img/";
|
||||
private String remoteCopyDirPath="/test/copyImg";
|
||||
private String absoluteLocalPath;
|
||||
private String newFilePath="src/test/resources";
|
||||
private IClient client;
|
||||
// private String scope="/gcube/devsec";//"/d4science.research-infrastructures.eu/FARM";//"/CNR.it/ISTI";//"/gcube"; // "/d4science.research-infrastructures.eu/FARM/VTI";//
|
||||
private static String serviceClass="JUnitTest-CopyDir";
|
||||
private static String serviceName="StorageManager";
|
||||
private String serviceClass="JUnitTest-CopyDir";
|
||||
private String serviceName="StorageManager";
|
||||
|
||||
|
||||
|
||||
@BeforeClass
|
||||
public static void getClient() throws RemoteBackendException{
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
@Before
|
||||
public void getClient() throws RemoteBackendException{
|
||||
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
|
||||
|
||||
try {
|
||||
|
||||
|
@ -124,15 +124,15 @@ public class CopyDirTest {
|
|||
}
|
||||
|
||||
|
||||
private static void setLocalResources() {
|
||||
private void setLocalResources() {
|
||||
absoluteLocalPath=new File(localPath).getAbsolutePath();
|
||||
String dir=new File(absoluteLocalPath).getParent();
|
||||
newFilePath=dir+"/testJunitLink.jpg";
|
||||
absoluteLocalPath=new File(localPath).getAbsolutePath();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void deleteRemoteDir(){
|
||||
@After
|
||||
public void deleteRemoteDir(){
|
||||
client.removeDir().RDir(remoteCopyDirPath);
|
||||
client.removeDir().RDir(remoteOriginalDirPath);
|
||||
}
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
package org.gcube.contentmanager.storageclient.test;
|
||||
|
||||
import static org.gcube.contentmanager.storageclient.test.utils.Costants.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
import org.gcube.contentmanager.storageclient.test.utils.Costants;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -39,15 +38,19 @@ public class CopyTest {
|
|||
|
||||
@Before
|
||||
public void getClient() throws RemoteBackendException{
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
|
||||
|
||||
try {
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, DEFAULT_MEMORY_TYPE).getClient();
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
|
||||
assertNotNull(client);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
setLocalResources();
|
||||
// String id=client.put(true).LFile(absoluteLocalFrog).RFile(remoteOriginalFilePath);
|
||||
// System.out.println("id of the following path "+remoteOriginalFilePath+" is: "+id );
|
||||
// assertNotNull(id);
|
||||
|
||||
}
|
||||
|
||||
|
@ -57,7 +60,7 @@ public class CopyTest {
|
|||
*/
|
||||
@Test
|
||||
public void removeCopiedFileTest() throws RemoteBackendException {
|
||||
// put orignal file
|
||||
// put orignal file
|
||||
String id=client.put(true).LFile(absoluteLocalFrog).RFile(remoteOriginalFilePath);
|
||||
System.out.println("id of the following path "+remoteOriginalFilePath+" is: "+id );
|
||||
//first copy
|
||||
|
@ -66,7 +69,6 @@ public class CopyTest {
|
|||
File f =new File(newFilePath);
|
||||
System.out.println("path new File downloaded: "+f.getAbsolutePath());
|
||||
assertTrue(f.exists());
|
||||
// removing local and copied file
|
||||
removeLocalFile();
|
||||
removeCopiedFile(remoteCopyPath, "test/copyDir/");
|
||||
checkOriginalFileIsAlive();
|
||||
|
@ -148,7 +150,6 @@ public class CopyTest {
|
|||
File f =new File(newFilePath2);
|
||||
System.out.println("path new File downloaded: "+f.getAbsolutePath());
|
||||
assertTrue(f.exists());
|
||||
|
||||
// check if the remote file is a dog
|
||||
assertEquals(dogSize, f.length());
|
||||
// removeCopiedFile(remoteCopyPath, "test/copyDir/");
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package org.gcube.contentmanager.storageclient.test;
|
||||
|
||||
import static org.gcube.contentmanager.storageclient.test.utils.Costants.DEFAULT_SCOPE_STRING;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
import org.gcube.contentmanager.storageclient.test.utils.Costants;
|
||||
|
@ -26,7 +25,7 @@ public class CountingTest {
|
|||
|
||||
@Before
|
||||
public void getClient() throws RemoteBackendException{
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
|
||||
try {
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.PUBLIC, Costants.DEFAULT_MEMORY_TYPE).getClient();
|
||||
assertNotNull(client);
|
||||
|
@ -63,7 +62,6 @@ public class CountingTest {
|
|||
System.out.println(owner+" volume: "+userVolume);
|
||||
}
|
||||
|
||||
|
||||
// @After
|
||||
// public void sleep(){
|
||||
// try {
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
|
@ -17,35 +17,32 @@ import org.gcube.contentmanager.storageclient.test.utils.Costants;
|
|||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DownloadsTest {
|
||||
|
||||
private static String owner="rcirillo";
|
||||
private static String localPath="src/test/resources/CostaRica1.jpg";
|
||||
private static String remotePath="/test/img/CostaRica1.jpg";
|
||||
private static String remotePath1="/test/img/CostaRica2.jpg";
|
||||
private static String absoluteLocalPath;
|
||||
private static String newFilePath="src/test/resources";
|
||||
private static IClient client;
|
||||
private String owner="rcirillo";
|
||||
private String localPath="src/test/resources/CostaRica1.jpg";
|
||||
private String remotePath="/test/img/CostaRica1.jpg";
|
||||
private String remotePath1="/test/img/CostaRica2.jpg";
|
||||
private String absoluteLocalPath;
|
||||
private String newFilePath="src/test/resources";
|
||||
private IClient client;
|
||||
// private String scope="/d4science.research-infrastructures.eu"; //"/gcube";//"/gcube";//"/d4science.research-infrastructures.eu"; //"/gcube/devsec";//"/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";// //"/CNR.it";// ///gcube/devsec/devVRE"; //"/CNR.it/ISTI";//"/gcube/devsec/devVRE"; // /d4science.research-infrastructures.eu"; //"/d4science.research-infrastructures.eu"; //"/CNR.it/ISTI";//
|
||||
private static String serviceClass="JUnitTest";
|
||||
private static String serviceName="StorageManager";
|
||||
private String serviceClass="JUnitTest";
|
||||
private String serviceName="StorageManager";
|
||||
private String NotExistingId="5a5c7d1d1b9b060285bbe2bd";
|
||||
private static String id;
|
||||
private static String id1;
|
||||
private String id;
|
||||
private String id1;
|
||||
private String encryptedId="OE5tOCtuTUt5eXVNd3JkRDlnRFpDY1h1MVVWaTg0cUtHbWJQNStIS0N6Yz0";//"SG1EN2JFNXIELzZ1czdsSkRIa0Evd3VzcGFHU3J6L2RHbWJQNStIS0N6Yz0";//"OE5tOCtuTUt5eXVNd3JkRDlnRFpDY1h1MVVWaTg0cUtHbWJQNStIS0N6Yz0";//"SThtL0xRU281M2UzY29ldE44SkhkbzVkMlBWVmM4aEJHbWJQNStIS0N6Yz0";//"dExaYzNKelNyQVZMemxpcXplVXYzZGN4OGZTQ2w4aU5HbWJQNStIS0N6Yz0";//"Mm9nc0tZbXR1TVI2cVRxL3pVUElrRXJkbk9vVDY2eEJHbWJQNStIS0N6Yz0";//"FemRmUEFtRGVZMnozcEdBekVHU3E4Skt5dkh2OXJObHFHbWJQNStIS0N6Yz0";//"L0p3OGJjUHhFaEJoTmppdjlsK0l0Z0h1b3VpVlloUzVHbWJQNStIS0N6Yz0";//"NWJTRFdxQkQxclJHV05FbExrRDJjL0g4QTBwSnV1TVdHbWJQNStIS0N6Yz0";//"M2JIM2hqNUNyRkxBdG00cnRaWDBpUGxRTmtVQmtEdXBHbWJQNStIS0N6Yz0";//"lfV6BqnBWUbN5dUiQ6xpkMgI69wEwcm6Ygh60bFzaL3h2Run5e9uZMoTix+ykL5H";//"huivj74/QCHnj376YGe/FicgYHSHcwph7SoMty7FBmAh+80AzGQtOdanne6zJBd5";//"lfV6BqnBWUbN5dUiQ6xpkMgI69wEwcm6Ygh60bFzaL3h2Run5e9uZMoTix+ykL5H";//"bksxMGVWTlZ3WjM5Z1ZXYXlUOUtMZzVSNlBhZXFGb05HbWJQNStIS0N6Yz0";//"bEVydmtsOHhCclZMZGd4cEtnTVQzZXQ5UVNxWHZURGJHbWJQNStIS0N6Yz0";//"bEVydmtsOHhCclZMZGd4cEtnTVQz";//"cHEvek1sbjdBaWJkc0s4SzZpSUJpU0c2ZEgyOEVyUGJHbWJQNStIS0N6Yz0";//"RnpoMy9ZaVRoRkZjbk8ybGx0QnlRR";//"L1pWTlV3ZWxPbHRyMloxZ0JnWUVHdHYvUnZDVHJiMTBHbWJQNStIS0N6Yz0";
|
||||
|
||||
|
||||
@BeforeClass
|
||||
public static void getClient() throws RemoteBackendException{
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
@Before
|
||||
public void getClient() throws RemoteBackendException{
|
||||
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
|
||||
// ScopeProvider.instance.set(scope);
|
||||
try {
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE, Costants.BACKEND_TYPE).getClient();
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
|
||||
assertNotNull(client);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
|
@ -53,11 +50,10 @@ public class DownloadsTest {
|
|||
}
|
||||
setLocalResources();
|
||||
id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
|
||||
System.out.println("upload done. Returned id "+id);
|
||||
System.out.println("upload done ");
|
||||
id1=client.put(true).LFile(absoluteLocalPath).RFile(remotePath1);
|
||||
System.out.println("upload done. Returned id1: "+id1);
|
||||
System.out.println("upload done ");
|
||||
assertNotNull(id);
|
||||
assertNotNull(id1);
|
||||
|
||||
}
|
||||
|
||||
|
@ -101,8 +97,8 @@ public class DownloadsTest {
|
|||
|
||||
@Test
|
||||
public void downloadByInputStream() throws IOException, InterruptedException {
|
||||
downloadByIS(id1);
|
||||
downloadByIS(id);
|
||||
downloadByIS(id1);
|
||||
|
||||
}
|
||||
|
||||
|
@ -168,8 +164,8 @@ public class DownloadsTest {
|
|||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void removeRemoteFile() throws RemoteBackendException{
|
||||
@After
|
||||
public void removeRemoteFile() throws RemoteBackendException{
|
||||
String id=client.remove().RFile(remotePath);
|
||||
System.out.println("removeRemotePath id: "+id);
|
||||
String id1=client.remove().RFile(remotePath1);
|
||||
|
@ -185,7 +181,7 @@ public class DownloadsTest {
|
|||
}
|
||||
|
||||
|
||||
private static void setLocalResources() {
|
||||
private void setLocalResources() {
|
||||
absoluteLocalPath=new File(localPath).getAbsolutePath();
|
||||
String dir=new File(absoluteLocalPath).getParent();
|
||||
newFilePath=dir+"/Junit.jpg";
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.io.File;
|
|||
import java.util.List;
|
||||
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
|
@ -43,7 +43,7 @@ public class DuplicateTest {
|
|||
|
||||
@Before
|
||||
public void getClient() throws RemoteBackendException{
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
|
||||
|
||||
try {
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
|
||||
|
|
|
@ -3,8 +3,7 @@ package org.gcube.contentmanager.storageclient.test;
|
|||
import static org.junit.Assert.*;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
|
@ -37,7 +36,7 @@ public class ForceCloseTest {
|
|||
|
||||
@Before
|
||||
public void getClient(){
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
|
||||
try {
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
|
||||
assertNotNull(client);
|
||||
|
@ -54,6 +53,12 @@ public class ForceCloseTest {
|
|||
|
||||
@Test
|
||||
public void forceCloseTest(){
|
||||
// try {
|
||||
// Thread.sleep(10000);
|
||||
// } catch (InterruptedException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
client.forceClose();
|
||||
//download
|
||||
try {
|
||||
|
@ -61,9 +66,23 @@ public class ForceCloseTest {
|
|||
}catch(Exception e ) {
|
||||
assertNotNull(e);
|
||||
}
|
||||
// try {
|
||||
// client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
|
||||
// assertNotNull(client);
|
||||
// } catch (Exception e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// delete
|
||||
removeRemoteFile();
|
||||
client.forceClose();
|
||||
try {
|
||||
Thread.sleep(60000);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@After
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
package org.gcube.contentmanager.storageclient.test;
|
||||
|
||||
import static org.gcube.contentmanager.storageclient.test.utils.Costants.DEFAULT_SCOPE_STRING;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.gcube.common.resources.gcore.GenericResource;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.resources.gcore.utils.XPathHelper;
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.contentmanager.storageclient.test.utils.Costants;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.ISClientConnector;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
|
@ -23,11 +19,12 @@ import org.w3c.dom.Node;
|
|||
import org.w3c.dom.NodeList;
|
||||
|
||||
public class FwsQueryTest {
|
||||
|
||||
|
||||
String scope="/gcube/devsec";
|
||||
|
||||
@Before
|
||||
public void setscope(){
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));;
|
||||
ScopeProvider.instance.set(scope);
|
||||
}
|
||||
|
||||
// @Test
|
||||
|
@ -94,8 +91,7 @@ public class FwsQueryTest {
|
|||
public void getRR() throws Exception{
|
||||
System.out.println("retrieve server from RuntimeResource");
|
||||
ISClientConnector isConnector= new ISClientConnector();
|
||||
ServiceEndpoint resource = isConnector.getStorageEndpoint();
|
||||
assertNotNull(resource);
|
||||
ServiceEndpoint resource = isConnector.getStorageEndpoint(scope);
|
||||
String[] server=isConnector.retrieveConnectionInfo(resource);
|
||||
for(int j=0; j<server.length; j++){
|
||||
System.out.println("s" +j+" = "+server[j]);
|
||||
|
|
|
@ -5,8 +5,8 @@ import static org.junit.Assert.*;
|
|||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
|
@ -14,29 +14,27 @@ import org.gcube.contentmanager.storageclient.test.utils.Costants;
|
|||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class GetMetaFileTest {
|
||||
|
||||
private static String owner="rcirillo";
|
||||
private static String localPath="src/test/resources/CostaRica1.jpg";
|
||||
private static String remotePath="/test/img2/CostaRica1.jpg";
|
||||
private static String remotePath2="/test/img2/CostaRica2.jpg";
|
||||
private static String absoluteLocalPath;
|
||||
private static String newFilePath="src/test/resources";
|
||||
private static IClient client;
|
||||
private String owner="rcirillo";
|
||||
private String localPath="src/test/resources/CostaRica1.jpg";
|
||||
private String remotePath="/test/img2/CostaRica1.jpg";
|
||||
private String remotePath2="/test/img2/CostaRica2.jpg";
|
||||
private String absoluteLocalPath;
|
||||
private String newFilePath="src/test/resources";
|
||||
private IClient client;
|
||||
// private String scope="/gcube/devsec"; //"/d4science.research-infrastructures.eu"; ///gcube/devsec/devVRE"; //"/CNR.it/ISTI";//"/gcube/devsec/devVRE"; // /d4science.research-infrastructures.eu"; //"/d4science.research-infrastructures.eu"; //"/CNR.it/ISTI";//
|
||||
private static String serviceClass="JUnitTest";
|
||||
private static String serviceName="StorageManager";
|
||||
private static String id;
|
||||
private static String id2;
|
||||
private String serviceClass="JUnitTest";
|
||||
private String serviceName="StorageManager";
|
||||
private String id;
|
||||
private String id2;
|
||||
|
||||
@BeforeClass
|
||||
public static void getClient() throws RemoteBackendException{
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
@Before
|
||||
public void getClient() throws RemoteBackendException{
|
||||
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
|
||||
try {
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.PUBLIC, Costants.DEFAULT_MEMORY_TYPE).getClient();
|
||||
assertNotNull(client);
|
||||
|
@ -55,7 +53,7 @@ public class GetMetaFileTest {
|
|||
|
||||
@Test
|
||||
public void getMetaFileByPath() throws RemoteBackendException {
|
||||
RequestObject f= client.getMetaFile().RFile(remotePath);
|
||||
MyFile f= client.getMetaFile().RFile(remotePath);
|
||||
// System.out.println("mime is: "+f.getMimeType());
|
||||
client.put(true, "image/png").LFile("src/test/resources/dog.jpg").RFile(remotePath);
|
||||
f= client.getMetaFile().RFile(remotePath);
|
||||
|
@ -72,7 +70,7 @@ public class GetMetaFileTest {
|
|||
|
||||
@Test
|
||||
public void getMetaFileById() throws RemoteBackendException {
|
||||
RequestObject f= client.getMetaFile().RFile(id);
|
||||
MyFile f= client.getMetaFile().RFile(id);
|
||||
assertNotNull(f);
|
||||
assertEquals(id, f.getId());
|
||||
print(f);
|
||||
|
@ -83,15 +81,15 @@ public class GetMetaFileTest {
|
|||
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void removeRemoteFile() throws RemoteBackendException{
|
||||
client.remove().RFile(remotePath);
|
||||
client.remove().RFile(remotePath2);
|
||||
@After
|
||||
public void removeRemoteFile() throws RemoteBackendException{
|
||||
String id=client.remove().RFile(remotePath);
|
||||
String id2=client.remove().RFile(remotePath2);
|
||||
List<StorageObject> list=client.showDir().RDir("test/img2");
|
||||
assertTrue(list.isEmpty());
|
||||
}
|
||||
|
||||
private void print(RequestObject f) {
|
||||
private void print(MyFile f) {
|
||||
System.out.println("\t name "+f.getName());
|
||||
System.out.println("\t size "+f.getSize());
|
||||
System.out.println("\t owner "+f.getOwner());
|
||||
|
@ -109,7 +107,7 @@ public class GetMetaFileTest {
|
|||
}
|
||||
|
||||
|
||||
private static void setLocalResources() {
|
||||
private void setLocalResources() {
|
||||
absoluteLocalPath=new File(localPath).getAbsolutePath();
|
||||
String dir=new File(absoluteLocalPath).getParent();
|
||||
newFilePath=dir+"/testJunit.jpg";
|
||||
|
|
|
@ -8,17 +8,18 @@ import java.io.FileOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanager.storageclient.test.utils.Costants;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class HLcheckTest {
|
||||
|
||||
|
||||
|
@ -29,7 +30,7 @@ public class HLcheckTest {
|
|||
private String absoluteLocalPath;
|
||||
private String newFilePath="src/test/resources";
|
||||
private IClient client;
|
||||
private String scope="/d4science.research-infrastructures.eu";//"/gcube";//"/d4science.research-infrastructures.eu";//Costants.DEFAULT_SCOPE_STRING;//"/gcube/devsec";//"/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";// //"/CNR.it";// ///gcube/devsec/devVRE"; //"/CNR.it/ISTI";//"/gcube/devsec/devVRE"; // /d4science.research-infrastructures.eu"; //"/d4science.research-infrastructures.eu"; //"/CNR.it/ISTI";//
|
||||
// private String scope="/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";//Costants.DEFAULT_SCOPE_STRING;//"/gcube/devsec";//"/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";// //"/CNR.it";// ///gcube/devsec/devVRE"; //"/CNR.it/ISTI";//"/gcube/devsec/devVRE"; // /d4science.research-infrastructures.eu"; //"/d4science.research-infrastructures.eu"; //"/CNR.it/ISTI";//
|
||||
private String serviceClass="org.gcube.portlets.user";//"JUnitTest";
|
||||
private String serviceName="home-library";//"test-home-library";//"StorageManager";
|
||||
private String id;
|
||||
|
@ -37,10 +38,10 @@ public class HLcheckTest {
|
|||
|
||||
@Before
|
||||
public void getClient() throws RemoteBackendException{
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
|
||||
// ScopeProvider.instance.set(scope);
|
||||
try {
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED).getClient();
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_SCOPE_STRING, false).getClient();
|
||||
assertNotNull(client);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
|
@ -55,7 +56,7 @@ public class HLcheckTest {
|
|||
|
||||
}
|
||||
|
||||
// @Test
|
||||
@Test
|
||||
public void downloadByPath() throws RemoteBackendException {
|
||||
String idFound=client.get().LFile(newFilePath).RFile(remotePath);
|
||||
System.out.println("downloadByPath id: "+idFound+" id orig "+id );
|
||||
|
@ -65,14 +66,14 @@ public class HLcheckTest {
|
|||
removeLocalFile();
|
||||
}
|
||||
|
||||
// @Test
|
||||
@Test
|
||||
public void downloadByInputStream() throws IOException, InterruptedException {
|
||||
downloadByIS(id);
|
||||
downloadByIS(id1);
|
||||
|
||||
}
|
||||
|
||||
// @Test
|
||||
@Test
|
||||
public void downloadById() throws RemoteBackendException{
|
||||
// String idReturned=client.get().LFile(newFilePath).RFileById(id);
|
||||
String idReturned=client.get().LFile(newFilePath).RFile(id);
|
||||
|
@ -86,9 +87,6 @@ public class HLcheckTest {
|
|||
|
||||
@Test
|
||||
public void downloadBySpecificIdOnlyForTest() throws RemoteBackendException{
|
||||
//// String file="/home/rcirillo-pc/Downloads/ce1159aa-a87f-4074-a3f9-36fe26d62f87-d4science.research-infrastructures.eu-gCubeApps-DESCRAMBLE.zip";
|
||||
// String file="/Users/roberto/VivianaOtero/detailed_simulation_4327.csv";
|
||||
// String idReturned=client.get().LFile(file).RFile("60830489d56b08199c3407c6");
|
||||
String idReturned=client.get().LFile(newFilePath).RFileById(id);
|
||||
// String file="/home/rcirillo-pc/Downloads/ce1159aa-a87f-4074-a3f9-36fe26d62f87-d4science.research-infrastructures.eu-gCubeApps-DESCRAMBLE.zip";
|
||||
// String idReturned=client.get().LFile(absoluteLocalPath).RFile("5f6a1f405b0bde3544cbd3be");
|
||||
|
@ -103,7 +101,7 @@ public class HLcheckTest {
|
|||
|
||||
|
||||
|
||||
// @After
|
||||
@After
|
||||
public void removeRemoteFile() throws RemoteBackendException{
|
||||
String id=client.remove().RFile(remotePath);
|
||||
System.out.println("removeRemotePath id: "+id);
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
package org.gcube.contentmanager.storageclient.test;
|
||||
|
||||
import org.gcube.common.security.Owner;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
public class ICSecret extends Secret{
|
||||
|
||||
private String context;
|
||||
|
||||
protected ICSecret(String context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Owner getOwner() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getHTTPAuthorizationHeaders() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExpired() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(){ return true; }
|
||||
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@ import static org.junit.Assert.*;
|
|||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
|
@ -32,7 +32,7 @@ public class LinkTest {
|
|||
|
||||
@Before
|
||||
public void getClient() throws RemoteBackendException{
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
|
||||
|
||||
try {
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.gcube.contentmanager.storageclient.test;
|
||||
|
||||
import static org.gcube.contentmanager.storageclient.test.utils.Costants.DEFAULT_SCOPE_STRING;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
@ -8,7 +7,7 @@ import static org.junit.Assert.assertTrue;
|
|||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
|
@ -38,7 +37,7 @@ public class LockTest {
|
|||
|
||||
@Before
|
||||
public void getClient(){
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
|
||||
try {
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
|
||||
assertNotNull(client);
|
||||
|
|
|
@ -4,37 +4,37 @@ import static org.junit.Assert.*;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
import org.gcube.contentmanager.storageclient.test.utils.Costants;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MoveDirTest {
|
||||
|
||||
private static String owner="rcirillo";
|
||||
private static String localPath="src/test/resources/CostaRica1.jpg";
|
||||
private static String remoteOriginalFilePath="/test/move/img/original.jpg";
|
||||
private static String remoteOriginalFilePath2="/test/move/img/original2.jpg";
|
||||
private static String remoteMovePath="/test/move/";
|
||||
private static String remoteMovePath2="/test/trash/";
|
||||
private static String remoteMoveFilePath="/test/trash/move/img/original.jpg";
|
||||
private static String remoteMoveFilePath2="/test/trash/move/img/original2.jpg";
|
||||
private static String absoluteLocalPath;
|
||||
private static String newFilePath="src/test/resources";
|
||||
private static IClient client;
|
||||
private String owner="rcirillo";
|
||||
private String localPath="src/test/resources/CostaRica1.jpg";
|
||||
private String remoteOriginalFilePath="/test/move/img/original.jpg";
|
||||
private String remoteOriginalFilePath2="/test/move/img/original2.jpg";
|
||||
private String remoteMovePath="/test/move/";
|
||||
private String remoteMovePath2="/test/trash/";
|
||||
private String remoteMoveFilePath="/test/trash/move/img/original.jpg";
|
||||
private String remoteMoveFilePath2="/test/trash/move/img/original2.jpg";
|
||||
private String absoluteLocalPath;
|
||||
private String newFilePath="src/test/resources";
|
||||
private IClient client;
|
||||
// private String scope="/gcube/devsec";//"/d4science.research-infrastructures.eu";//"/CNR.it/ISTI";//"/gcube"; // "/d4science.research-infrastructures.eu/FARM/VTI";//
|
||||
private static String serviceClass="JUnitTest-MoveDir";
|
||||
private static String serviceName="StorageManager";
|
||||
private String serviceClass="JUnitTest-MoveDir";
|
||||
private String serviceName="StorageManager";
|
||||
|
||||
@BeforeClass
|
||||
public static void getClient() throws RemoteBackendException{
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
@Before
|
||||
public void getClient() throws RemoteBackendException{
|
||||
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
|
||||
|
||||
try {
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
|
||||
|
@ -82,20 +82,20 @@ public class MoveDirTest {
|
|||
}
|
||||
|
||||
|
||||
private static void setLocalResources() {
|
||||
private void setLocalResources() {
|
||||
absoluteLocalPath=new File(localPath).getAbsolutePath();
|
||||
String dir=new File(absoluteLocalPath).getParent();
|
||||
newFilePath=dir+"/testJunitMoveOp.jpg";
|
||||
absoluteLocalPath=new File(localPath).getAbsolutePath();
|
||||
}
|
||||
|
||||
private static void removeLocalFile(){
|
||||
private void removeLocalFile(){
|
||||
File f=new File(newFilePath);
|
||||
f.delete();
|
||||
assertFalse(f.exists());
|
||||
}
|
||||
|
||||
private static void checkOriginalFileIsAlive(String remoteOriginalFilePath) {
|
||||
private void checkOriginalFileIsAlive(String remoteOriginalFilePath) {
|
||||
String id=null;
|
||||
try{
|
||||
id=client.get().LFile(newFilePath).RFile(remoteOriginalFilePath);
|
||||
|
@ -103,15 +103,15 @@ public class MoveDirTest {
|
|||
assertNull(id);
|
||||
}
|
||||
|
||||
private static void checkMoveFileIsAlive() {
|
||||
private void checkMoveFileIsAlive() {
|
||||
String id=client.get().LFile(newFilePath).RFile(remoteMovePath);
|
||||
System.out.println("id link is alive: "+id);
|
||||
assertNotNull(id);
|
||||
removeLocalFile();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void removeRemoteDirs(){
|
||||
@After
|
||||
public void removeRemoteDirs(){
|
||||
client.removeDir().RDir(remoteMovePath2);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,7 @@ package org.gcube.contentmanager.storageclient.test;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
import org.gcube.contentmanager.storageclient.test.utils.Costants;
|
||||
|
@ -30,7 +29,7 @@ public class MoveTest {
|
|||
|
||||
@Before
|
||||
public void getClient() throws RemoteBackendException{
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
|
||||
|
||||
try {
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
|
||||
|
|
|
@ -1,41 +1,41 @@
|
|||
package org.gcube.contentmanager.storageclient.test;
|
||||
|
||||
import static org.gcube.contentmanager.storageclient.test.utils.Costants.DEFAULT_SCOPE_STRING;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
import org.gcube.contentmanager.storageclient.test.utils.Costants;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PropertiesTest {
|
||||
|
||||
private static String owner="rcirillo";
|
||||
private static String localPath="src/test/resources/CostaRica1.jpg";
|
||||
private static String remotePath="/test/mimeTest/CostaRica1.jpg";
|
||||
private static String absoluteLocalPath;
|
||||
private static String newFilePath="src/test/resources";
|
||||
private static IClient client;
|
||||
private static String scope="/gcube/devsec"; //"/d4science.research-infrastructures.eu"; ///gcube/devsec/devVRE"; //"/CNR.it/ISTI";//"/gcube/devsec/devVRE"; // /d4science.research-infrastructures.eu"; //"/d4science.research-infrastructures.eu"; //"/CNR.it/ISTI";//
|
||||
private static String serviceClass="JUnitTest";
|
||||
private static String serviceName="StorageManager";
|
||||
private static String id;
|
||||
private static String field="mimetype";
|
||||
private static String value="image/png";
|
||||
private String owner="rcirillo";
|
||||
private String localPath="src/test/resources/CostaRica1.jpg";
|
||||
private String remotePath="/test/mimeTest/CostaRica1.jpg";
|
||||
private String absoluteLocalPath;
|
||||
private String newFilePath="src/test/resources";
|
||||
private IClient client;
|
||||
// private String scope="/gcube/devsec"; //"/d4science.research-infrastructures.eu"; ///gcube/devsec/devVRE"; //"/CNR.it/ISTI";//"/gcube/devsec/devVRE"; // /d4science.research-infrastructures.eu"; //"/d4science.research-infrastructures.eu"; //"/CNR.it/ISTI";//
|
||||
private String serviceClass="JUnitTest";
|
||||
private String serviceName="StorageManager";
|
||||
private String id;
|
||||
private String field="mimetype";
|
||||
private String value="image/png";
|
||||
|
||||
@BeforeClass
|
||||
public static void getClient() throws RemoteBackendException{
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
@Before
|
||||
public void getClient() throws RemoteBackendException{
|
||||
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
|
||||
try {
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.PUBLIC, Costants.DEFAULT_MEMORY_TYPE).getClient();
|
||||
assertNotNull(client);
|
||||
|
@ -46,8 +46,6 @@ public class PropertiesTest {
|
|||
setLocalResources();
|
||||
id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
|
||||
assertNotNull(id);
|
||||
String result= client.setMetaInfo(field, value).RFile(id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,12 +53,12 @@ public class PropertiesTest {
|
|||
public void getPropertyByPath() throws RemoteBackendException {
|
||||
String valueFound= client.getMetaInfo(field).RFile(remotePath);
|
||||
System.out.println("value found for property: "+field+" is "+valueFound);
|
||||
RequestObject f= client.getMetaFile().RFile(remotePath);
|
||||
MyFile f= client.getMetaFile().RFile(remotePath);
|
||||
assertNotNull(f);
|
||||
print(f);
|
||||
String result= client.setMetaInfo(field, value).RFile(remotePath);
|
||||
System.out.println("new property set ");
|
||||
RequestObject f1= client.getMetaFile().RFile(remotePath);
|
||||
MyFile f1= client.getMetaFile().RFile(remotePath);
|
||||
print(f1);
|
||||
assertNotNull(f1);
|
||||
assertEquals(f1.getMimeType(), value);
|
||||
|
@ -72,35 +70,36 @@ public class PropertiesTest {
|
|||
public void getPropertyById() throws RemoteBackendException {
|
||||
String valueFound= client.getMetaInfo(field).RFile(id);
|
||||
System.out.println("value found for property: "+field+" is "+valueFound);
|
||||
RequestObject f= client.getMetaFile().RFile(id);
|
||||
MyFile f= client.getMetaFile().RFile(id);
|
||||
assertNotNull(f);
|
||||
print(f);
|
||||
String result= client.setMetaInfo(field, value).RFile(id);
|
||||
System.out.println("new property set ");
|
||||
RequestObject f1= client.getMetaFile().RFile(id);
|
||||
MyFile f1= client.getMetaFile().RFile(id);
|
||||
print(f1);
|
||||
assertNotNull(f1);
|
||||
assertEquals(f1.getMimeType(), value);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
// @Test
|
||||
public void setProperty() throws RemoteBackendException {
|
||||
RequestObject f= client.getMetaFile().RFile(remotePath);
|
||||
String result= client.setMetaInfo(field, value).RFile(id);
|
||||
MyFile f= client.getMetaFile().RFile(remotePath);
|
||||
assertNotNull(f);
|
||||
print(f);
|
||||
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void removeRemoteFile() throws RemoteBackendException{
|
||||
@After
|
||||
public void removeRemoteFile() throws RemoteBackendException{
|
||||
String id=client.remove().RFile(remotePath);
|
||||
List<StorageObject> list=client.showDir().RDir("test/mimeTest");
|
||||
assertTrue(list.isEmpty());
|
||||
removeLocalFile();
|
||||
}
|
||||
|
||||
private void print(RequestObject f) {
|
||||
private void print(MyFile f) {
|
||||
System.out.println("\t name "+f.getName());
|
||||
System.out.println("\t size "+f.getSize());
|
||||
System.out.println("\t owner "+f.getOwner());
|
||||
|
@ -112,14 +111,14 @@ public class PropertiesTest {
|
|||
}
|
||||
|
||||
|
||||
private static void removeLocalFile(){
|
||||
private void removeLocalFile(){
|
||||
File f=new File(newFilePath);
|
||||
f.delete();
|
||||
assertFalse(f.exists());
|
||||
}
|
||||
|
||||
|
||||
private static void setLocalResources() {
|
||||
private void setLocalResources() {
|
||||
absoluteLocalPath=new File(localPath).getAbsolutePath();
|
||||
String dir=new File(absoluteLocalPath).getParent();
|
||||
newFilePath=dir+"/testJunit.jpg";
|
||||
|
|
|
@ -5,7 +5,7 @@ import static org.junit.Assert.*;
|
|||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
|
@ -33,7 +33,7 @@ public class RemoveTest {
|
|||
|
||||
@Before
|
||||
public void getClient() throws RemoteBackendException{
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
|
||||
try {
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
|
||||
assertNotNull(client);
|
||||
|
|
|
@ -7,7 +7,7 @@ import static org.junit.Assert.*;
|
|||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
|
@ -33,7 +33,7 @@ public class RemoveVolatileArea {
|
|||
|
||||
@Before
|
||||
public void getClient() throws RemoteBackendException{
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
|
||||
try {
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
|
||||
assertNotNull(client);
|
||||
|
@ -47,7 +47,7 @@ public class RemoveVolatileArea {
|
|||
|
||||
}
|
||||
|
||||
// @Test
|
||||
@Test
|
||||
public void removeVolatile(){
|
||||
client.removeDir().RDir("/Home/roberto.cirillo/Workspace/Trash/");
|
||||
}
|
||||
|
|
|
@ -3,14 +3,12 @@
|
|||
*/
|
||||
package org.gcube.contentmanager.storageclient.test;
|
||||
|
||||
import static org.gcube.contentmanager.storageclient.test.utils.Costants.DEFAULT_SCOPE_STRING;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
|
@ -44,7 +42,7 @@ public class ReplaceFileTest {
|
|||
|
||||
@Before
|
||||
public void getClient(){
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
|
||||
try {
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
|
||||
assertNotNull(client);
|
||||
|
|
|
@ -8,7 +8,7 @@ import static org.junit.Assert.*;
|
|||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
|
@ -16,7 +16,6 @@ import org.gcube.contentmanager.storageclient.test.utils.Costants;
|
|||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
@ -25,29 +24,29 @@ import org.junit.Test;
|
|||
*/
|
||||
public class SoftCopyTest {
|
||||
|
||||
private static String owner="rcirillo";
|
||||
private static String localFrog="src/test/resources/CostaRica1.jpg";//"src/test/resources/testFile.txt";//"src/test/resources/CostaRica1.jpg";
|
||||
private static String localDog="src/test/resources/dog.jpg";
|
||||
private String owner="rcirillo";
|
||||
private String localFrog="src/test/resources/CostaRica1.jpg";//"src/test/resources/testFile.txt";//"src/test/resources/CostaRica1.jpg";
|
||||
private String localDog="src/test/resources/dog.jpg";
|
||||
private String remoteOriginalFilePath="/test/frog.jpg";
|
||||
private String remoteCopyPath="/test/SoftCopy1/frog1.jpg";
|
||||
private String remoteCopyPath2="/test/SoftCopy2/frog2.jpg";
|
||||
private String remoteCopyPath3="/test/SoftCopy3/frog3.jpg";
|
||||
private String remoteCopyPath3="/test/SoftCopy3/frog3.jpg";
|
||||
private String remoteCopyDir="/test/copyDir/";
|
||||
private static String absoluteLocalFrog;
|
||||
private static String absoluteLocalDog;
|
||||
private static String newFilePath="src/test/resources";
|
||||
private static IClient client;
|
||||
private static String serviceClass="CopyTest";
|
||||
private static String serviceName="StorageManager";
|
||||
private static String newFilePath2;
|
||||
private static long frogSize;
|
||||
private static long dogSize;
|
||||
private String absoluteLocalFrog;
|
||||
private String absoluteLocalDog;
|
||||
private String newFilePath="src/test/resources";
|
||||
private IClient client;
|
||||
private String serviceClass="CopyTest";
|
||||
private String serviceName="StorageManager";
|
||||
private String newFilePath2;
|
||||
private long frogSize;
|
||||
private long dogSize;
|
||||
|
||||
|
||||
|
||||
@BeforeClass
|
||||
public static void getClient() throws RemoteBackendException{
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
@Before
|
||||
public void getClient() throws RemoteBackendException{
|
||||
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
|
||||
|
||||
try {
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
|
||||
|
@ -273,7 +272,7 @@ public class SoftCopyTest {
|
|||
}
|
||||
|
||||
|
||||
private static void setLocalResources() {
|
||||
private void setLocalResources() {
|
||||
File f1=new File(localFrog);
|
||||
absoluteLocalFrog=f1.getAbsolutePath();
|
||||
frogSize=f1.length();
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
|
@ -20,26 +20,25 @@ import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
|
|||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class UploadsTest {
|
||||
|
||||
private static String owner="rcirillo";
|
||||
private static String localPath="src/test/resources/CostaRica.jpg";//"src/test/resources/empty.txt";//"src/test/resources/CostaRica1.jpg";
|
||||
private static String localPath1="src/test/resources/CostaRica1.jpg";
|
||||
private String owner="rcirillo";
|
||||
private String localPath="src/test/resources/CostaRica.jpg";//"src/test/resources/empty.txt";//"src/test/resources/CostaRica1.jpg";
|
||||
private String localPath1="src/test/resources/CostaRica1.jpg";
|
||||
private String remotePath="/tests/img/tabulardatadump.tar.gz";//"/tests/img/CostaRica1.jpg";//"/tests/img/empty.txt";//
|
||||
private static String absoluteLocalPath;
|
||||
private static String absoluteLocalPath1;
|
||||
private String absoluteLocalPath;
|
||||
private String absoluteLocalPath1;
|
||||
// private String newFilePath="src/test/resources";
|
||||
private static IClient client;
|
||||
private IClient client;
|
||||
// private String scope="/gcube";//"/d4science.research-infrastructures.eu"; //"/d4science.research-infrastructures.eu"; //"/gcube/devsec";//"/d4science.research-infrastructures.eu"; //"/CNR.it";////"/gcube/devsec";//""/CNR.it/ISTI";//"/gcube";//"/gcube/devNext/NextNext";//
|
||||
private static String serviceClass="JUnitTest";
|
||||
private static String serviceName="StorageManager";
|
||||
private String serviceClass="JUnitTest";
|
||||
private String serviceName="StorageManager";
|
||||
|
||||
@BeforeClass
|
||||
public static void getClient(){
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
@Before
|
||||
public void getClient(){
|
||||
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
|
||||
try {
|
||||
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
|
||||
assertNotNull(client);
|
||||
|
@ -137,12 +136,10 @@ public class UploadsTest {
|
|||
|
||||
|
||||
|
||||
private static void setLocalResources() {
|
||||
private void setLocalResources() {
|
||||
absoluteLocalPath=new File(localPath).getAbsolutePath();
|
||||
String dir=new File(absoluteLocalPath).getParent();
|
||||
absoluteLocalPath1=new File(localPath1).getAbsolutePath();
|
||||
String dir1=new File(absoluteLocalPath1).getParent();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -10,12 +10,14 @@ import java.net.URL;
|
|||
import java.net.URLConnection;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
import org.gcube.contentmanager.storageclient.model.protocol.smp.Handler;
|
||||
import org.gcube.contentmanager.storageclient.test.utils.Costants;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -43,7 +45,7 @@ public class UrlResolverByIdTest {
|
|||
|
||||
@Before
|
||||
public void init() throws RemoteBackendException{
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
|
||||
try {
|
||||
client = new StorageClient(serviceClass, serviceName, owner , AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
|
||||
} catch (Exception e) {
|
||||
|
@ -56,48 +58,116 @@ public class UrlResolverByIdTest {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void getHttpsbyId() throws RemoteBackendException {
|
||||
// id="5aa16dfe02cadc50bff0eaf1";//"5aa16dfe02cadc50bff0eaf7";//"5a0c1cddf1d47d0c2fea0c1c";//"5a0c1cddf1d47d0c2fea0c1c";//"5a056737f1d47d0c2fe1ccb8";//"5a048c4cf1d47d0c2fe10537";//client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
|
||||
String url=client.getHttpsUrl(true).RFile(id);
|
||||
System.out.println("httpsUrl generated: "+url);
|
||||
// @Test
|
||||
public void getUrlbyIdNotPaylloadCheck() throws RemoteBackendException {
|
||||
String url=client.getUrl(true).RFile(remotePath);
|
||||
System.out.println("url generated: "+url);
|
||||
assertNotNull(url);
|
||||
id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
|
||||
System.out.println("id retrieved: "+id);
|
||||
client.moveFile().from(remotePath).to(newPath);
|
||||
verifyUrl(url);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void getUrlbyId() throws RemoteBackendException {
|
||||
// id="5aa16dfe02cadc50bff0eaf1";//"5aa16dfe02cadc50bff0eaf7";//"5a0c1cddf1d47d0c2fea0c1c";//"5a0c1cddf1d47d0c2fea0c1c";//"5a056737f1d47d0c2fe1ccb8";//"5a048c4cf1d47d0c2fe10537";//client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
|
||||
String url=client.getHttpUrl(true).RFile(id);
|
||||
// String url=client.getUrl().RFileById(id);
|
||||
System.out.println("httpUrl generated: "+url);
|
||||
assertNotNull(url);
|
||||
// id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
|
||||
|
||||
|
||||
// System.out.println("id retrieved: "+id);
|
||||
// client.moveFile().from(remotePath).to(newPath);
|
||||
// verifyUrl(url);
|
||||
}
|
||||
|
||||
|
||||
// @Test
|
||||
// public void getUrlbyId() throws RemoteBackendException {
|
||||
//// id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
|
||||
// String url=client.getHttpUrl().RFileById("5aa16dfe02cadc50bff0eaf7");
|
||||
// System.out.println("url generated: "+url);
|
||||
// assertNotNull(url);
|
||||
//// url=url+"-VLT";
|
||||
// System.out.println("id retrieved: "+id);
|
||||
// client.moveFile().from(remotePath).to(newPath);
|
||||
// verifyUrl(url);
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void getUrlbyPath() throws RemoteBackendException {
|
||||
id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
|
||||
String url=client.getHttpsUrl(true).RFile(remotePath);
|
||||
String url=client.getUrl(true).RFile(remotePath);
|
||||
System.out.println("url generated: "+url);
|
||||
assertNotNull(url);
|
||||
System.out.println("id retrieved: "+id);
|
||||
client.moveFile().from(remotePath).to(newPath);
|
||||
verifyUrl(url);
|
||||
client.moveFile().from(newPath).to(remotePath);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFilebyEncryptedId() throws RemoteBackendException {
|
||||
id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
|
||||
String url=client.getHttpsUrl(true).RFile(remotePath);
|
||||
String url=client.getUrl(true).RFile(remotePath);
|
||||
System.out.println("url generated: "+url);
|
||||
assertNotNull(url);
|
||||
String idEncrypted=url.substring(url.lastIndexOf(".org/")+5);
|
||||
System.out.println("id encrypted: "+id);
|
||||
client.get().RFileAsInputStream(remotePath);
|
||||
client.moveFile().from(remotePath).to(newPath);
|
||||
verifyUrl(url);
|
||||
client.moveFile().from(newPath).to(remotePath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* download the file and verify if the file exist
|
||||
* @param url
|
||||
*/
|
||||
|
||||
private void verifyUrl(String url) {
|
||||
Handler.activateProtocol();
|
||||
URL smsHome = null;
|
||||
try {
|
||||
smsHome = new URL(url);
|
||||
} catch (MalformedURLException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
URLConnection uc = null;
|
||||
File f=null;
|
||||
try {
|
||||
uc = ( URLConnection ) smsHome.openConnection ( );
|
||||
InputStream is=uc.getInputStream();
|
||||
f=new File(localNewPath);
|
||||
FileOutputStream out=new FileOutputStream(f);
|
||||
byte buf[]=new byte[1024];
|
||||
int len=0;
|
||||
System.out.println("InputStream "+is);
|
||||
while((len=is.read(buf))>0){
|
||||
out.write(buf,0,len);
|
||||
}
|
||||
out.close();
|
||||
is.close();
|
||||
}catch(Exception e ){
|
||||
e.printStackTrace();
|
||||
assertTrue(false);
|
||||
}
|
||||
assertTrue(f.exists());
|
||||
}
|
||||
|
||||
@After
|
||||
public void removeRemoteFile() throws RemoteBackendException{
|
||||
String id=client.remove().RFile(remotePath);
|
||||
List<StorageObject> list=client.showDir().RDir("Uritest/img");
|
||||
assertTrue(list.isEmpty());
|
||||
// String id2=client.remove().RFile(newPath);
|
||||
// List<StorageObject> list2=client.showDir().RDir("Uritest/img5");
|
||||
// assertTrue(list.isEmpty());
|
||||
removeLocalFiles();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
package org.gcube.contentmanager.storageclient.test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
import org.gcube.contentmanager.storageclient.test.utils.Costants;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -26,7 +31,7 @@ public class UrlResolverTest {
|
|||
|
||||
@Before
|
||||
public void init() throws RemoteBackendException{
|
||||
SecretManagerProvider.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
|
||||
try {
|
||||
client = new StorageClient(serviceClass, serviceName, owner , AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
|
||||
} catch (Exception e) {
|
||||
|
@ -36,11 +41,17 @@ public class UrlResolverTest {
|
|||
setLocalResources();
|
||||
String id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void getHttpsUrl() throws RemoteBackendException {
|
||||
String url=client.getHttpsUrl().RFile(remotePath);
|
||||
public void getUrl() throws RemoteBackendException {
|
||||
String url=client.getUrl().RFile(remotePath);
|
||||
System.out.println("url generated: "+url);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getHttpUrl() throws RemoteBackendException {
|
||||
String url=client.getHttpUrl().RFile(remotePath);
|
||||
System.out.println("HttpUrl generated: "+url);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package org.gcube.contentmanager.storageclient.test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.gcube.common.scope.impl.ServiceMapScannerMediator;
|
||||
import org.gcube.contentmanager.storageclient.test.utils.Costants;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class scopeValidationTest {
|
||||
|
||||
static ServiceMapScannerMediator scanner;
|
||||
// String scope="/gcube";
|
||||
|
||||
@BeforeClass
|
||||
public static void init(){
|
||||
scanner=new ServiceMapScannerMediator();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
assertTrue(scanner.isValid(Costants.DEFAULT_SCOPE_STRING));
|
||||
}
|
||||
|
||||
}
|
|
@ -4,7 +4,6 @@
|
|||
package org.gcube.contentmanager.storageclient.test.utils;
|
||||
|
||||
|
||||
import org.gcube.contentmanager.storageclient.wrapper.BackendType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
|
||||
|
||||
|
||||
|
@ -15,8 +14,7 @@ import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
|
|||
public final class Costants {
|
||||
|
||||
public static final MemoryType DEFAULT_MEMORY_TYPE = MemoryType.PERSISTENT;
|
||||
public static final String DEFAULT_SCOPE_STRING="/gcube/devsec/devVRE";//"/gcube/devNext/NextNext";//"/gcube/devsec/devVRE";
|
||||
public static final String DEFAULT_SCOPE_STRING="/gcube";
|
||||
public static final String DEFAULT_PASS_PHRASE="this is a phrasethis is a phrase";
|
||||
public static final BackendType BACKEND_TYPE=BackendType.MongoDB;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue