diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 8ea82ec..cfa6374 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -4,9 +4,6 @@ - - uses - diff --git a/distro/changelog.xml b/distro/changelog.xml index 4c5993f..09cfc6c 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -142,5 +142,7 @@ date="${buildDate}"> [Feature #16263] Added new dataminer-invocation-model + [Task #16296] Bug fixes + \ No newline at end of file diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java index 71cfcd8..02b141d 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java @@ -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); } diff --git a/src/main/java/org/gcube/datatransfer/resolver/storage/StorageClientInstance.java b/src/main/java/org/gcube/datatransfer/resolver/storage/StorageClientInstance.java new file mode 100644 index 0000000..87579d9 --- /dev/null +++ b/src/main/java/org/gcube/datatransfer/resolver/storage/StorageClientInstance.java @@ -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(); + } + + + +}