retrieve new parameters from ServiceEndpoint: backendToken, region
This commit is contained in:
parent
bd082de4f2
commit
3fc8eda0a5
|
@ -3,6 +3,7 @@ package org.gcube.contentmanager.storageclient.wrapper;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||||
|
@ -28,6 +29,7 @@ public class Configuration {
|
||||||
private String sn;
|
private String sn;
|
||||||
private String user;
|
private String user;
|
||||||
private String password;
|
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 String passPhrase;
|
||||||
private ISClientConnector isclient;
|
private ISClientConnector isclient;
|
||||||
// the scope used for discovering the runtimeResource
|
// the scope used for discovering the runtimeResource
|
||||||
|
@ -36,12 +38,17 @@ public class Configuration {
|
||||||
private String[] volatileHost;
|
private String[] volatileHost;
|
||||||
private String[] persistentHosts;
|
private String[] persistentHosts;
|
||||||
private String resolverHost;
|
private String resolverHost;
|
||||||
|
private String region;
|
||||||
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(Configuration.class);
|
private static final Logger logger = LoggerFactory.getLogger(Configuration.class);
|
||||||
private 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 WRITE_CONCERN_PROPERTY_NAME="write_concern";
|
||||||
private static final String READ_PREFERENCE_PROPERTY_NAME="read_preference";
|
private static final String READ_PREFERENCE_PROPERTY_NAME="read_preference";
|
||||||
private static final String DB_PROPERTY_NAME="collection";
|
private static final String DB_PROPERTY_NAME="collection";
|
||||||
private static final String DB_STRING_SEPARATOR=";";
|
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
|
* home library need a special configuration
|
||||||
*/
|
*/
|
||||||
|
@ -85,7 +92,7 @@ public class Configuration {
|
||||||
* @param memory indicates the type of memory used by the storage: Persistent or Volatile
|
* @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, BackendType backend){
|
public Configuration(String sc, String sn, String scopeString, String owner, String clientID, String accessType, String memory, String backend){
|
||||||
this.sc=sc;
|
this.sc=sc;
|
||||||
this.sn=sn;
|
this.sn=sn;
|
||||||
this.owner=owner;
|
this.owner=owner;
|
||||||
|
@ -93,7 +100,7 @@ public class Configuration {
|
||||||
this.typeAccess=accessType;
|
this.typeAccess=accessType;
|
||||||
this.memoryType=memory;
|
this.memoryType=memory;
|
||||||
setScopeString(scopeString);
|
setScopeString(scopeString);
|
||||||
setBackendType(backend.toString());
|
setBackendType(backend);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,6 +115,10 @@ public class Configuration {
|
||||||
}
|
}
|
||||||
logger.debug("RuntimeResource scope "+RRScope);
|
logger.debug("RuntimeResource scope "+RRScope);
|
||||||
ServiceEndpoint resource=getISClient().getStorageEndpoint(RRScope);
|
ServiceEndpoint resource=getISClient().getStorageEndpoint(RRScope);
|
||||||
|
|
||||||
|
//in this case a specific backend type is passed as input parameter
|
||||||
|
if (!Objects.isNull(getBackendType()))
|
||||||
|
getISClient().setBackendType(getBackendType());
|
||||||
if(resource ==null )
|
if(resource ==null )
|
||||||
throw new IllegalStateException("the storage resource is not present on IS in scope: "+RRScope);
|
throw new IllegalStateException("the storage resource is not present on IS in scope: "+RRScope);
|
||||||
List<ServiceEndpoint> resolverResource =getISClient().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);
|
||||||
|
@ -123,10 +134,14 @@ public class Configuration {
|
||||||
serverFound=getISClient().retrieveConnectionInfo(resource);
|
serverFound=getISClient().retrieveConnectionInfo(resource);
|
||||||
setUser(getISClient().getUsername());
|
setUser(getISClient().getUsername());
|
||||||
setPassword(getISClient().password);
|
setPassword(getISClient().password);
|
||||||
|
setRegion(getISClient().getRegion());
|
||||||
|
if (!Objects.isNull(getBackendType()))
|
||||||
setBackendType(getISClient().getBackendType(resource));
|
setBackendType(getISClient().getBackendType(resource));
|
||||||
}else{
|
}else{
|
||||||
|
if (!Objects.isNull(getBackendType()))
|
||||||
setBackendType(checkVarEnvBackendType());
|
setBackendType(checkVarEnvBackendType());
|
||||||
if(getBackendType() == null) setBackendType(DEFAULT_BACKEND_TYPE);
|
else
|
||||||
|
setBackendType(DEFAULT_BACKEND_TYPE);
|
||||||
setUser(checkVarEnvUser());
|
setUser(checkVarEnvUser());
|
||||||
setPassword(checkVarEnvPassword());
|
setPassword(checkVarEnvPassword());
|
||||||
}
|
}
|
||||||
|
@ -141,15 +156,46 @@ public class Configuration {
|
||||||
throw new IllegalStateException("Resource not found on Information System");
|
throw new IllegalStateException("Resource not found on Information System");
|
||||||
}else{
|
}else{
|
||||||
setEnvironment(setAreaStorage(getSc(), getSn()));
|
setEnvironment(setAreaStorage(getSc(), getSn()));
|
||||||
|
// if the backend is mongodb we should set a separated server for volatile area
|
||||||
|
if(getBackendType().equals(BackendType.MongoDB)) {
|
||||||
setServerHosts(newServer, isclient, resource);
|
setServerHosts(newServer, isclient, resource);
|
||||||
try {
|
try {
|
||||||
setPassPhrase(retrieveEncryptionPhrase());
|
setPassPhrase(retrieveEncryptionField(PASS_PHRASE_FIELD));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.debug("Configuration parameters retrieved: host: "+getPersistentHosts()+" user: "+getUser());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Retrieve a valid configuration from IS for instantiating the engine
|
||||||
|
// */
|
||||||
|
// public void getConfiguration2(){
|
||||||
|
// String currentScope=ScopeProvider.instance.get();
|
||||||
|
// ServiceEndpoint resource=getISClient().getStorageEndpoint(currentScope);
|
||||||
|
// if((getMemoryType() != null) && ((getMemoryType().equals(MemoryType.VOLATILE.toString()) || (getMemoryType().equals(MemoryType.BOTH.toString()))))){
|
||||||
|
// setVolatileHost(isclient.getVolatileHost(resource));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void setServerHosts(String[] newServer, ISClientConnector isclient, ServiceEndpoint resource) {
|
private void setServerHosts(String[] newServer, ISClientConnector isclient, ServiceEndpoint resource) {
|
||||||
if((getMemoryType() != null) && ((getMemoryType().equals(MemoryType.VOLATILE.toString()) || (getMemoryType().equals(MemoryType.BOTH.toString()))))){
|
if((getMemoryType() != null) && ((getMemoryType().equals(MemoryType.VOLATILE.toString()) || (getMemoryType().equals(MemoryType.BOTH.toString()))))){
|
||||||
setVolatileHost(isclient.getVolatileHost(resource));
|
setVolatileHost(isclient.getVolatileHost(resource));
|
||||||
|
@ -222,6 +268,7 @@ public class Configuration {
|
||||||
}
|
}
|
||||||
if (dbNames.length > 1)
|
if (dbNames.length > 1)
|
||||||
logger.debug("multiple collection discovered");
|
logger.debug("multiple collection discovered");
|
||||||
|
if (Objects.isNull(engine.getDbNames()))
|
||||||
engine.setDbNames(dbNames);
|
engine.setDbNames(dbNames);
|
||||||
}
|
}
|
||||||
// added db check also on volatile are
|
// added db check also on volatile are
|
||||||
|
@ -338,7 +385,7 @@ public class Configuration {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public String retrieveEncryptionPhrase() throws Exception {
|
public String retrieveEncryptionPhrase() throws Exception {
|
||||||
String currentScope=ScopeProvider.instance.get();
|
String currentScope=ScopeProvider.instance.get();
|
||||||
logger.debug("retrieve encryption prhase on scope: "+currentScope);
|
logger.debug("retrieve encryption prhase on scope: "+currentScope);
|
||||||
|
@ -351,6 +398,18 @@ public class Configuration {
|
||||||
return decryptString;
|
return decryptString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String retrieveEncryptionField(String fieldName) throws Exception {
|
||||||
|
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().retrievePropertyValue(fieldName, currentScope);
|
||||||
|
logger.info("encrypted prhase is "+encryptedKey);
|
||||||
|
String decryptString=(!Objects.isNull(encryptedKey))?org.gcube.common.encryption.StringEncrypter.getEncrypter().decrypt(encryptedKey):null;
|
||||||
|
return decryptString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getClientID() {
|
public String getClientID() {
|
||||||
return clientID;
|
return clientID;
|
||||||
|
@ -494,4 +553,12 @@ public class Configuration {
|
||||||
this.sn = sn;
|
this.sn = sn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRegion() {
|
||||||
|
return region;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegion(String region) {
|
||||||
|
this.region = region;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -8,6 +8,8 @@ import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.gcube.common.encryption.StringEncrypter;
|
import org.gcube.common.encryption.StringEncrypter;
|
||||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||||
import org.gcube.contentmanager.storageclient.wrapper.BackendType;
|
import org.gcube.contentmanager.storageclient.wrapper.BackendType;
|
||||||
|
@ -35,6 +37,7 @@ public class ISClientConnector {
|
||||||
protected String username;
|
protected String username;
|
||||||
protected String password;
|
protected String password;
|
||||||
protected ServiceEndpoint storageResource;
|
protected ServiceEndpoint storageResource;
|
||||||
|
public String region;
|
||||||
private static HashMap<String, Object> isCache;
|
private static HashMap<String, Object> isCache;
|
||||||
|
|
||||||
public ISClientConnector(){
|
public ISClientConnector(){
|
||||||
|
@ -85,26 +88,38 @@ public class ISClientConnector {
|
||||||
|
|
||||||
|
|
||||||
private String[] fillConnectionFields(ServiceEndpoint resource) {
|
private String[] fillConnectionFields(ServiceEndpoint resource) {
|
||||||
|
logger.debug("fillConnectionsFields method ");
|
||||||
if(resource!=null){
|
if(resource!=null){
|
||||||
|
logger.debug("checking resource "+resource.id());
|
||||||
String [] server=new String[resource.profile().accessPoints().size()];
|
String [] server=new String[resource.profile().accessPoints().size()];
|
||||||
int i=0;
|
if(!Objects.isNull(getBackendType())) {
|
||||||
|
logger.info("searching backend: "+getBackendType());
|
||||||
for (AccessPoint ap:resource.profile().accessPoints()) {
|
for (AccessPoint ap:resource.profile().accessPoints()) {
|
||||||
if (ap.name().equals("server"+(i+1))) {
|
if((!getBackendType().equals(BackendType.MongoDB) && (ap.name().equals(getBackendType())))){
|
||||||
server[i] = ap.address();
|
//in v1.6.0 we are considering only one accessPoint for a backend except for mongodb.
|
||||||
|
server[0] = ap.address();
|
||||||
// if presents, try to get user and password
|
// if presents, try to get user and password
|
||||||
setUsername(ap.username());
|
setUsername(ap.username());
|
||||||
decryptPwd(ap);
|
decryptPwd(ap);
|
||||||
i++;
|
setRegion(retrievePropertyValue(ap, "region"));
|
||||||
}else if((!getBackendType().equals(BackendType.MongoDB) && (ap.name().equals(getBackendType())))){
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
int i=0;
|
||||||
|
|
||||||
|
for (AccessPoint ap:resource.profile().accessPoints()) {
|
||||||
|
if (ap.name().equals("server"+(i+1))) {
|
||||||
// in this case, the backend type has been set in the constructor hence we want to use this one
|
// in this case, the backend type has been set in the constructor hence we want to use this one
|
||||||
// if presents, try to get user and password
|
// if presents, try to get user and password
|
||||||
setUsername(ap.username());
|
setUsername(ap.username());
|
||||||
decryptPwd(ap);
|
decryptPwd(ap);
|
||||||
//in v1.6.0 we are considering only one accessPoint for a backend except for mongodb.
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setBackendType(retrievePropertyValue(resource, "type"));
|
setBackendType(retrievePropertyValue(resource, "type"));
|
||||||
|
}
|
||||||
|
|
||||||
String [] volatileHost= new String [1];
|
String [] volatileHost= new String [1];
|
||||||
volatileHost[0]=retrievePropertyValue(resource, "volatile");
|
volatileHost[0]=retrievePropertyValue(resource, "volatile");
|
||||||
setVolatileHost(volatileHost);
|
setVolatileHost(volatileHost);
|
||||||
|
@ -116,6 +131,9 @@ public class ISClientConnector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void decryptPwd(AccessPoint ap) {
|
private void decryptPwd(AccessPoint ap) {
|
||||||
// set password default value to empty string
|
// set password default value to empty string
|
||||||
setPassword("");
|
setPassword("");
|
||||||
|
@ -177,6 +195,17 @@ public class ISClientConnector {
|
||||||
return value;
|
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) {
|
private String retrievePropertyValue(ServiceEndpoint res, String name) {
|
||||||
Iterator<AccessPoint> it= res.profile().accessPoints().iterator();
|
Iterator<AccessPoint> it= res.profile().accessPoints().iterator();
|
||||||
AccessPoint ap=(AccessPoint)it.next();
|
AccessPoint ap=(AccessPoint)it.next();
|
||||||
|
@ -241,6 +270,14 @@ public class ISClientConnector {
|
||||||
this.storageResource = storageResource;
|
this.storageResource = storageResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setRegion(String region) {
|
||||||
|
this.region=region;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRegion() {
|
||||||
|
return region;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,9 +1,12 @@
|
||||||
package org.gcube.contentmanager.storageclient.wrapper;
|
package org.gcube.contentmanager.storageclient.wrapper;
|
||||||
|
|
||||||
import org.gcube.contentmanager.storageclient.wrapper.BackendType;
|
import org.gcube.contentmanager.storageclient.wrapper.BackendType;
|
||||||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||||
//import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
//import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
||||||
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
|
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.impl.ServiceEngine;
|
import org.gcube.contentmanagement.blobstorage.service.impl.ServiceEngine;
|
||||||
|
@ -264,7 +267,11 @@ public class StorageClient {
|
||||||
* @throws IllegalStateException if the resource is not found on the IS
|
* @throws IllegalStateException if the resource is not found on the IS
|
||||||
*/
|
*/
|
||||||
public IClient getClient(){
|
public IClient getClient(){
|
||||||
Configuration cfg= new Configuration(serviceClass, serviceName, scopeString, owner, clientID, typeAccess.toString(), memoryType.toString());
|
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());
|
||||||
cfg.getConfiguration();
|
cfg.getConfiguration();
|
||||||
ServiceEngine engine= new ServiceEngine(cfg.getPersistentHosts(), cfg.getVolatileHost(), cfg.getEnvironment(), cfg.getTypeAccess(), cfg.getOwner(), cfg.getMemoryType());
|
ServiceEngine engine= new ServiceEngine(cfg.getPersistentHosts(), cfg.getVolatileHost(), cfg.getEnvironment(), cfg.getTypeAccess(), cfg.getOwner(), cfg.getMemoryType());
|
||||||
// set additional fields for the new engine object
|
// set additional fields for the new engine object
|
||||||
|
@ -275,8 +282,11 @@ public class StorageClient {
|
||||||
engine.setBackendUser(cfg.getUser());
|
engine.setBackendUser(cfg.getUser());
|
||||||
engine.setBackendPassword(cfg.getPassword());
|
engine.setBackendPassword(cfg.getPassword());
|
||||||
engine.setResolverHost(cfg.getResolverHost());
|
engine.setResolverHost(cfg.getResolverHost());
|
||||||
if(cfg.getPassPhrase()!=null)
|
engine.setRegion(cfg.getRegion());
|
||||||
|
if(cfg.getPassPhrase()!=null) {
|
||||||
engine.setPassPhrase(cfg.getPassPhrase());
|
engine.setPassPhrase(cfg.getPassPhrase());
|
||||||
|
engine.setToken(cfg.getPassPhrase());
|
||||||
|
}
|
||||||
if(getMemoryType() !=null)
|
if(getMemoryType() !=null)
|
||||||
engine.setGcubeMemoryType(getMemoryType().toString());
|
engine.setGcubeMemoryType(getMemoryType().toString());
|
||||||
engine.setGcubeScope(ScopeProvider.instance.get());
|
engine.setGcubeScope(ScopeProvider.instance.get());
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
|
@ -53,7 +53,7 @@ public class GetMetaFileTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getMetaFileByPath() throws RemoteBackendException {
|
public void getMetaFileByPath() throws RemoteBackendException {
|
||||||
MyFile f= client.getMetaFile().RFile(remotePath);
|
RequestObject f= client.getMetaFile().RFile(remotePath);
|
||||||
// System.out.println("mime is: "+f.getMimeType());
|
// System.out.println("mime is: "+f.getMimeType());
|
||||||
client.put(true, "image/png").LFile("src/test/resources/dog.jpg").RFile(remotePath);
|
client.put(true, "image/png").LFile("src/test/resources/dog.jpg").RFile(remotePath);
|
||||||
f= client.getMetaFile().RFile(remotePath);
|
f= client.getMetaFile().RFile(remotePath);
|
||||||
|
@ -70,7 +70,7 @@ public class GetMetaFileTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getMetaFileById() throws RemoteBackendException {
|
public void getMetaFileById() throws RemoteBackendException {
|
||||||
MyFile f= client.getMetaFile().RFile(id);
|
RequestObject f= client.getMetaFile().RFile(id);
|
||||||
assertNotNull(f);
|
assertNotNull(f);
|
||||||
assertEquals(id, f.getId());
|
assertEquals(id, f.getId());
|
||||||
print(f);
|
print(f);
|
||||||
|
@ -89,7 +89,7 @@ public class GetMetaFileTest {
|
||||||
assertTrue(list.isEmpty());
|
assertTrue(list.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void print(MyFile f) {
|
private void print(RequestObject f) {
|
||||||
System.out.println("\t name "+f.getName());
|
System.out.println("\t name "+f.getName());
|
||||||
System.out.println("\t size "+f.getSize());
|
System.out.println("\t size "+f.getSize());
|
||||||
System.out.println("\t owner "+f.getOwner());
|
System.out.println("\t owner "+f.getOwner());
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
|
@ -53,12 +53,12 @@ public class PropertiesTest {
|
||||||
public void getPropertyByPath() throws RemoteBackendException {
|
public void getPropertyByPath() throws RemoteBackendException {
|
||||||
String valueFound= client.getMetaInfo(field).RFile(remotePath);
|
String valueFound= client.getMetaInfo(field).RFile(remotePath);
|
||||||
System.out.println("value found for property: "+field+" is "+valueFound);
|
System.out.println("value found for property: "+field+" is "+valueFound);
|
||||||
MyFile f= client.getMetaFile().RFile(remotePath);
|
RequestObject f= client.getMetaFile().RFile(remotePath);
|
||||||
assertNotNull(f);
|
assertNotNull(f);
|
||||||
print(f);
|
print(f);
|
||||||
String result= client.setMetaInfo(field, value).RFile(remotePath);
|
String result= client.setMetaInfo(field, value).RFile(remotePath);
|
||||||
System.out.println("new property set ");
|
System.out.println("new property set ");
|
||||||
MyFile f1= client.getMetaFile().RFile(remotePath);
|
RequestObject f1= client.getMetaFile().RFile(remotePath);
|
||||||
print(f1);
|
print(f1);
|
||||||
assertNotNull(f1);
|
assertNotNull(f1);
|
||||||
assertEquals(f1.getMimeType(), value);
|
assertEquals(f1.getMimeType(), value);
|
||||||
|
@ -70,12 +70,12 @@ public class PropertiesTest {
|
||||||
public void getPropertyById() throws RemoteBackendException {
|
public void getPropertyById() throws RemoteBackendException {
|
||||||
String valueFound= client.getMetaInfo(field).RFile(id);
|
String valueFound= client.getMetaInfo(field).RFile(id);
|
||||||
System.out.println("value found for property: "+field+" is "+valueFound);
|
System.out.println("value found for property: "+field+" is "+valueFound);
|
||||||
MyFile f= client.getMetaFile().RFile(id);
|
RequestObject f= client.getMetaFile().RFile(id);
|
||||||
assertNotNull(f);
|
assertNotNull(f);
|
||||||
print(f);
|
print(f);
|
||||||
String result= client.setMetaInfo(field, value).RFile(id);
|
String result= client.setMetaInfo(field, value).RFile(id);
|
||||||
System.out.println("new property set ");
|
System.out.println("new property set ");
|
||||||
MyFile f1= client.getMetaFile().RFile(id);
|
RequestObject f1= client.getMetaFile().RFile(id);
|
||||||
print(f1);
|
print(f1);
|
||||||
assertNotNull(f1);
|
assertNotNull(f1);
|
||||||
assertEquals(f1.getMimeType(), value);
|
assertEquals(f1.getMimeType(), value);
|
||||||
|
@ -85,7 +85,7 @@ public class PropertiesTest {
|
||||||
// @Test
|
// @Test
|
||||||
public void setProperty() throws RemoteBackendException {
|
public void setProperty() throws RemoteBackendException {
|
||||||
String result= client.setMetaInfo(field, value).RFile(id);
|
String result= client.setMetaInfo(field, value).RFile(id);
|
||||||
MyFile f= client.getMetaFile().RFile(remotePath);
|
RequestObject f= client.getMetaFile().RFile(remotePath);
|
||||||
assertNotNull(f);
|
assertNotNull(f);
|
||||||
print(f);
|
print(f);
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ public class PropertiesTest {
|
||||||
removeLocalFile();
|
removeLocalFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void print(MyFile f) {
|
private void print(RequestObject f) {
|
||||||
System.out.println("\t name "+f.getName());
|
System.out.println("\t name "+f.getName());
|
||||||
System.out.println("\t size "+f.getSize());
|
System.out.println("\t size "+f.getSize());
|
||||||
System.out.println("\t owner "+f.getOwner());
|
System.out.println("\t owner "+f.getOwner());
|
||||||
|
|
Loading…
Reference in New Issue