Fixing the issue reported at https://support.d4science.org/issues/16296#note-6
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@178807 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
2b09f79962
commit
ccab9de9c2
|
@ -4,9 +4,6 @@
|
|||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
<dependent-module archiveName="dataminer-invocation-model-0.2.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/dataminer-invocation-model-TRUNK/dataminer-invocation-model-TRUNK">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<property name="context-root" value="uri-resolver"/>
|
||||
<property name="java-output-path" value="/uri-resolver/target/classes"/>
|
||||
</wb-module>
|
||||
|
|
|
@ -142,5 +142,7 @@
|
|||
date="${buildDate}">
|
||||
<Change>[Feature #16263] Added new dataminer-invocation-model
|
||||
</Change>
|
||||
<Change>[Task #16296] Bug fixes
|
||||
</Change>
|
||||
</Changeset>
|
||||
</ReleaseNotes>
|
|
@ -24,6 +24,7 @@ import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
|
|||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
import org.gcube.datatransfer.resolver.ConstantsResolver;
|
||||
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
||||
import org.gcube.datatransfer.resolver.storage.StorageClientInstance;
|
||||
import org.gcube.datatransfer.resolver.util.SingleFileStreamingOutput;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -114,12 +115,13 @@ public class StorageIDResolver {
|
|||
throw ExceptionManager.badRequestException(httpRequest, "Missing mandatory path parameter "+STORAGE_ID, StorageIDResolver.class, help);
|
||||
}
|
||||
|
||||
StorageClient client = getStorageClientInstance(storageId);
|
||||
StorageClientInstance scInstance = buildStorageClientInstance(storageId);
|
||||
String toSEID = null;
|
||||
IClient iClient = null;
|
||||
|
||||
storageId = scInstance.getStorageId(); //IT SHOULD BE CHANGED es. removing the suffix '-VLT'
|
||||
logger.info("I'm using the storageId {}",storageId);
|
||||
try{
|
||||
iClient = client.getClient();
|
||||
iClient = scInstance.getStorageClient().getClient();
|
||||
toSEID = iClient.getId(storageId); //to Storage Encrypted ID
|
||||
logger.info("Decoded ID"+" = "+ toSEID);
|
||||
}catch(Exception e){
|
||||
|
@ -144,7 +146,14 @@ public class StorageIDResolver {
|
|||
|
||||
//Reading the contentType from Storage Metadata only if the passed contentType is null
|
||||
if(contentType==null || contentType.isEmpty())
|
||||
contentType = file.getMimeType();
|
||||
contentType = file.getMimeType()
|
||||
/**
|
||||
* Gets the storage client instance.
|
||||
*
|
||||
* @param storageId the storage id
|
||||
* @return the storage client instance
|
||||
* @throws Exception the exception
|
||||
*/;
|
||||
|
||||
}catch (Exception e) {
|
||||
logger.warn("Error when getting file metadata from storage, printing this warning and trying to continue..", e);
|
||||
|
@ -231,11 +240,13 @@ public class StorageIDResolver {
|
|||
logger.warn("storageId not found");
|
||||
throw ExceptionManager.badRequestException(httpRequest, "Storage Client Exception when getting file from storage with id: "+storageId, this.getClass(), help);
|
||||
}
|
||||
StorageClient client = getStorageClientInstance(storageId);
|
||||
StorageClientInstance client = buildStorageClientInstance(storageId);
|
||||
String toSEID = null;
|
||||
IClient iClient = null;
|
||||
storageId = client.getStorageId(); //IT SHOULD BE CHANGED es. removing the suffix '-VLT'
|
||||
logger.info("I'm using the storageId {}",storageId);
|
||||
try{
|
||||
iClient = client.getClient();
|
||||
iClient = client.getStorageClient().getClient();
|
||||
toSEID = iClient.getId(storageId); //to Storage Encrypted ID
|
||||
logger.debug("Decoded ID"+" = "+ toSEID);
|
||||
}catch(Exception e){
|
||||
|
@ -277,15 +288,15 @@ public class StorageIDResolver {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the storage client instance.
|
||||
* Builds the storage client instance.
|
||||
*
|
||||
* @param storageId the storage id
|
||||
* @return the storage client instance
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
protected static StorageClient getStorageClientInstance(String storageId) throws Exception{
|
||||
protected static StorageClientInstance buildStorageClientInstance(String storageId) throws Exception{
|
||||
|
||||
MemoryType memory=null;
|
||||
if(storageId.endsWith(org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants.VOLATILE_URL_IDENTIFICATOR)){
|
||||
|
@ -299,7 +310,7 @@ public class StorageIDResolver {
|
|||
else
|
||||
client=new StorageClient(StorageIDResolver.class.getName(), StorageIDResolver.class.getSimpleName(), STORAGEID_RESOLVER, AccessType.PUBLIC, memory);
|
||||
|
||||
return client;
|
||||
return new StorageClientInstance(client, memory, storageId);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
package org.gcube.datatransfer.resolver.storage;
|
||||
|
||||
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
|
||||
/**
|
||||
* The Class StorageClientInstance.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Apr 2, 2019
|
||||
*/
|
||||
public class StorageClientInstance {
|
||||
|
||||
|
||||
StorageClient storageClient;
|
||||
MemoryType memory;
|
||||
String storageId;
|
||||
|
||||
/**
|
||||
* Instantiates a new storage client instance.
|
||||
*/
|
||||
public StorageClientInstance() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new storage client instance.
|
||||
*
|
||||
* @param storageClient the storage client
|
||||
* @param memory the memory
|
||||
* @param storageId the storage id
|
||||
*/
|
||||
public StorageClientInstance(StorageClient storageClient, MemoryType memory, String storageId) {
|
||||
super();
|
||||
this.storageClient = storageClient;
|
||||
this.memory = memory;
|
||||
this.storageId = storageId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the storage client.
|
||||
*
|
||||
* @return the storage client
|
||||
*/
|
||||
public StorageClient getStorageClient() {
|
||||
return storageClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the storage client.
|
||||
*
|
||||
* @param storageClient the new storage client
|
||||
*/
|
||||
public void setStorageClient(StorageClient storageClient) {
|
||||
this.storageClient = storageClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the memory.
|
||||
*
|
||||
* @return the memory
|
||||
*/
|
||||
public MemoryType getMemory() {
|
||||
return memory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the memory.
|
||||
*
|
||||
* @param memory the new memory
|
||||
*/
|
||||
public void setMemory(MemoryType memory) {
|
||||
this.memory = memory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the storage id.
|
||||
*
|
||||
* @return the storage id
|
||||
*/
|
||||
public String getStorageId() {
|
||||
return storageId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the storage id.
|
||||
*
|
||||
* @param storageId the new storage id
|
||||
*/
|
||||
public void setStorageId(String storageId) {
|
||||
this.storageId = storageId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("StorageClientInstance [storageClient=");
|
||||
builder.append(storageClient);
|
||||
builder.append(", memory=");
|
||||
builder.append(memory);
|
||||
builder.append(", storageId=");
|
||||
builder.append(storageId);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue