Compare commits
41 Commits
master
...
v3.0.1-SNA
@ -0,0 +1,7 @@
|
||||
/target/
|
||||
/.classpath
|
||||
/*.project
|
||||
/.settings
|
||||
/.idea/target/
|
||||
/src/test/resources/
|
||||
/.idea/
|
@ -1,12 +1,13 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
@ -1,5 +1,27 @@
|
||||
# Changelog for storage-manager-wrapper
|
||||
|
||||
## [v4.0.0-SNAPSHOT]
|
||||
* 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
|
||||
|
||||
## [v3.0.1-SNAPSHOT]
|
||||
* removed http protocol;
|
||||
* deprecated old smp classes
|
||||
* fix JUnitTests
|
||||
* upgrade JUnit to 4.12
|
||||
|
||||
## [v3.0.0] 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
|
||||
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
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
|
||||
|
@ -1,2 +0,0 @@
|
||||
${gcube.license}
|
||||
|
@ -1 +0,0 @@
|
||||
* Roberto Cirillo (roberto.cirillo@isti.cnr.it), CNR Pisa, Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo"
|
Binary file not shown.
@ -1,55 +0,0 @@
|
||||
<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>
|
@ -1,32 +0,0 @@
|
||||
<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>
|
@ -1,25 +0,0 @@
|
||||
<?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>
|
@ -1 +0,0 @@
|
||||
${scm.url}
|
@ -1,15 +0,0 @@
|
||||
log4j.rootLogger=DEBUG, A1, stdout
|
||||
log4j.appender.A1=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.A1.File=log.txt
|
||||
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
|
||||
# ***** Max file size is set to 100KB
|
||||
log4j.appender.A1.MaxFileSize=100MB
|
||||
# ***** Keep one backup file
|
||||
log4j.appender.A1.MaxBackupIndex=1
|
||||
|
||||
#CONSOLE
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Threshold=INFO
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=[%t] %-5p %c %d{dd MMM yyyy ;HH:mm:ss.SSS} - %m%n
|
@ -1,155 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,146 +0,0 @@
|
||||
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];
|
||||
}
|
||||
|
||||
}
|
@ -1,137 +0,0 @@
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
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.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;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ForceCloseTest {
|
||||
|
||||
|
||||
private String owner="rcirillo";
|
||||
private String localPath="src/test/resources/CostaRica.jpg";
|
||||
private String localPath2="src/test/resources/dog.jpg";
|
||||
private String localPathDownload="src/test/resources/download.png";
|
||||
private String remotePath="/test/test-resources/CostaRica1.jpg";
|
||||
private String absoluteLocalPath;
|
||||
private String absoluteLocalPath2;
|
||||
private String absoluteLocalPathDownload;
|
||||
private String newFilePath="src/test/resources";
|
||||
private String remoteDirPath= "test/test-forceclose";
|
||||
private IClient client;
|
||||
private String serviceClass="JUnitTest-ForceCloseTest";
|
||||
private String serviceName="StorageManager";
|
||||
private static final Logger logger = LoggerFactory.getLogger(ForceCloseTest.class);
|
||||
|
||||
@Before
|
||||
public void getClient(){
|
||||
SecretManagerProvider.instance.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
|
||||
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();
|
||||
}
|
||||
setLocalResources();
|
||||
//upload costaRica
|
||||
String id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
|
||||
System.out.println("UploadByPath id: "+id);
|
||||
assertNotNull(id);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void forceCloseTest(){
|
||||
client.forceClose();
|
||||
//download
|
||||
try {
|
||||
client.get().LFile(absoluteLocalPathDownload).RFile(remotePath);
|
||||
}catch(Exception e ) {
|
||||
assertNotNull(e);
|
||||
}
|
||||
// delete
|
||||
removeRemoteFile();
|
||||
client.forceClose();
|
||||
}
|
||||
|
||||
@After
|
||||
public void removeLocalFile(){
|
||||
File f=new File(newFilePath);
|
||||
f.delete();
|
||||
assertFalse(f.exists());
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void removeRemoteFile() throws RemoteBackendException{
|
||||
|
||||
List<StorageObject> list = printDir(remoteDirPath);
|
||||
client.remove().RFile(remotePath);
|
||||
list = printDir(remoteDirPath);
|
||||
assertTrue(list.isEmpty());
|
||||
}
|
||||
|
||||
private List<StorageObject> printDir(String dir) {
|
||||
List<StorageObject> list=client.showDir().RDir(dir);
|
||||
for(StorageObject obj : list){
|
||||
System.out.println("found "+obj.getName()+" and id " +obj.getId());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
private void setLocalResources() {
|
||||
absoluteLocalPath=new File(localPath).getAbsolutePath();
|
||||
String dir=new File(absoluteLocalPath).getParent();
|
||||
newFilePath=dir+"/testJunit.jpg";
|
||||
absoluteLocalPath=new File(localPath).getAbsolutePath();
|
||||
absoluteLocalPath2=new File(localPath2).getAbsolutePath();
|
||||
absoluteLocalPathDownload=new File(localPathDownload).getAbsolutePath();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
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 new Owner("guest", Collections.emptyList(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getHTTPAuthorizationHeaders() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExpired() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 220 KiB After Width: | Height: | Size: 346 KiB |
Loading…
Reference in New Issue