the storage dependency was changed in 2.0
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/speciesdiscovery@73837 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
181bc4a5f2
commit
e5cbf10f83
|
@ -14,12 +14,12 @@
|
|||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry including="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
|
||||
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#Thu Jun 16 10:18:26 CEST 2011
|
||||
eclipse.preferences.version=1
|
||||
filesCopiedToWebInfLib=
|
||||
googleCloudSqlEnabled=false
|
||||
localDevMySqlEnabled=true
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
eclipse.preferences.version=1
|
||||
jarsExcludedFromWebInfLib=
|
||||
lastWarOutDir=/home/backup-old-home/francesco-mangiacrapa/workspace/speciesdiscovery/target/species-discovery-3.0.0-SNAPSHOT
|
||||
lastWarOutDir=/home/francesco-mangiacrapa/wseclipse/speciesdiscovery(trunk)/target/species-discovery-3.0.0-SNAPSHOT
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
|
45
pom.xml
45
pom.xml
|
@ -52,12 +52,12 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-fw-clients</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>org.gcube.core</groupId> -->
|
||||
<!-- <artifactId>common-fw-clients</artifactId> -->
|
||||
<!-- <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version> -->
|
||||
<!-- <scope>runtime</scope> -->
|
||||
<!-- </dependency> -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.data.spd</groupId>
|
||||
|
@ -76,7 +76,8 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.data.spd</groupId>
|
||||
<artifactId>spd-model</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<!-- <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version> -->
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -91,21 +92,36 @@
|
|||
<dependency>
|
||||
<groupId>org.eclipse.persistence</groupId>
|
||||
<artifactId>eclipselink</artifactId>
|
||||
<version>2.4.0</version>
|
||||
<version>2.4.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.persistence</groupId>
|
||||
<artifactId>javax.persistence</artifactId>
|
||||
<version>2.0.4.v201112161009</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Storage dependecies -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-wrapper</artifactId>
|
||||
<version>[1.0.1-SNAPSHOT, 1.1.0-SNAPSHOT)</version>
|
||||
<!-- <version>[1.0.1-SNAPSHOT, 1.1.0-SNAPSHOT)</version> -->
|
||||
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-core</artifactId>
|
||||
<version>[1.0.1-SNAPSHOT, 1.11.0-SNAPSHOT)</version>
|
||||
<!-- <version>[1.0.1-SNAPSHOT, 1.11.0-SNAPSHOT)</version> -->
|
||||
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-resource-link-plugin</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -150,7 +166,7 @@
|
|||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>1.3.166</version>
|
||||
<version>1.3.170</version>
|
||||
<!-- <scope>provided</scope> -->
|
||||
</dependency>
|
||||
|
||||
|
@ -212,12 +228,7 @@
|
|||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-resource-link-plugin</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>home-library</artifactId>
|
||||
|
|
|
@ -1,82 +1,97 @@
|
|||
package org.gcube.portlets.user.speciesdiscovery.server.util;
|
||||
|
||||
//import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
//import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanager.storageclient.model.protocol.smp.StringEncrypter;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
//import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanager.storageclient.model.protocol.smp.Handler;
|
||||
//import org.gcube.contentmanager.storageclient.model.protocol.smp.StringEncrypter;
|
||||
//import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
//import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
|
||||
public class StorageUtil {
|
||||
protected static GCUBELog logger = new GCUBELog(StorageUtil.class);
|
||||
|
||||
public static InputStream getInputStreamByStorageClient(String url) throws Exception {
|
||||
|
||||
logger.trace("url :" + url);
|
||||
|
||||
String [] urlParam=url.split("\\?");
|
||||
// String param=urlParam[1];
|
||||
logger.info("String encrypted "+urlParam[1]);
|
||||
String param=new StringEncrypter("DES").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 scopeType=null;
|
||||
AccessType type = 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((serviceName==null) || (serviceClass==null) || (owner == null) || (scopeType==null) || (type == null))
|
||||
throw new MalformedURLException();
|
||||
GCUBEScope scope=GCUBEScope.getScope(scopeType);
|
||||
String location=extractLocation(urlParam[0]);
|
||||
|
||||
logger.trace("Storage instance with parameters "+serviceClass+" "+serviceName+" "+owner+" "+type+" "+scope+ " location: "+urlParam[0]);
|
||||
IClient client=new StorageClient(serviceClass, serviceName, owner, type, scope, server).getClient();
|
||||
InputStream is=null;
|
||||
is=client.get().RFileAStream(location);
|
||||
|
||||
// logger.trace("url :" + url);
|
||||
//
|
||||
// String [] urlParam=url.split("\\?");
|
||||
//// String param=urlParam[1];
|
||||
// logger.info("String encrypted "+urlParam[1]);
|
||||
// String param=new StringEncrypter("DES").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 scopeType=null;
|
||||
// AccessType type = 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((serviceName==null) || (serviceClass==null) || (owner == null) || (scopeType==null) || (type == null))
|
||||
// throw new MalformedURLException();
|
||||
// GCUBEScope scope=GCUBEScope.getScope(scopeType);
|
||||
// String location=extractLocation(urlParam[0]);
|
||||
//
|
||||
// logger.trace("Storage instance with parameters "+serviceClass+" "+serviceName+" "+owner+" "+type+" "+scope+ " location: "+urlParam[0]);
|
||||
// IClient client=new StorageClient(serviceClass, serviceName, owner, type, scope, server).getClient();
|
||||
// InputStream is=null;
|
||||
// is=client.get().RFileAStream(location);
|
||||
// createFileTest(is);
|
||||
|
||||
|
||||
Handler.activateProtocol();
|
||||
URL smsHome = null;
|
||||
try {
|
||||
smsHome = new URL(url);
|
||||
} catch (MalformedURLException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
URLConnection uc = null;
|
||||
uc = ( URLConnection ) smsHome.openConnection ( );
|
||||
InputStream is=uc.getInputStream();
|
||||
return is;
|
||||
}
|
||||
|
||||
public static String extractLocation(String url) {
|
||||
String [] loc=url.split("//");
|
||||
logger.trace("url extracted: "+loc[1]);
|
||||
return loc[1];
|
||||
}
|
||||
// public static String extractLocation(String url) {
|
||||
// String [] loc=url.split("//");
|
||||
// logger.trace("url extracted: "+loc[1]);
|
||||
// return loc[1];
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
Reference in New Issue