diff --git a/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java b/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java index 3fe1bf7..c105ea8 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java @@ -349,13 +349,19 @@ public class StorageHubClientService { * Download file. * * @param itemId the item id + * @param versionName the version name. If is null or empty returns the latest version of file * @param nodeIdsToExclude the node ids to exclude * @return the stream descriptor * @throws Exception the exception */ - public StreamDescriptor downloadFile(String itemId, String nodeIdsToExclude) throws Exception{ + public StreamDescriptor downloadFile(String itemId, String versionName, String... nodeIdsToExclude) throws Exception{ - StreamDescriptor streamDesc = shcClient.open(itemId).asFile().download(nodeIdsToExclude); + StreamDescriptor streamDesc; + if(versionName!=null && !versionName.isEmpty()){ + streamDesc = shcClient.open(itemId).asFile().downloadSpecificVersion(versionName); + }else{ + streamDesc = shcClient.open(itemId).asFile().download(nodeIdsToExclude); + } return new StreamDescriptor(streamDesc.getStream(), streamDesc.getFileName()); } diff --git a/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java b/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java index a6aef12..69267ae 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java @@ -642,15 +642,16 @@ public final class WorkspaceStorageHubClientService implements Workspace{ * * @param itemId the item id * @param fileName the file name + * @param versionName the version name * @param nodeIdsToExclude the node ids to exclude * @return the file stream descriptor * @throws Exception the exception */ @Override - public ItemStreamDescriptor downloadFile(String itemId, String fileName, String nodeIdsToExclude) throws Exception{ + public ItemStreamDescriptor downloadFile(String itemId, String fileName, String versionName, String... nodeIdsToExclude) throws Exception{ try { - StreamDescriptor streamDesc = storageHubClientService.downloadFile(itemId, nodeIdsToExclude); + StreamDescriptor streamDesc = storageHubClientService.downloadFile(itemId, versionName, nodeIdsToExclude); return new org.gcube.common.storagehubwrapper.shared.tohl.impl.StreamDescriptor(streamDesc.getStream(), streamDesc.getFileName()); } catch (Exception e) { logger.error("Error on downloading the file: "+fileName+ " with id: "+itemId, e); diff --git a/src/main/java/org/gcube/common/storagehubwrapper/server/tohl/Workspace.java b/src/main/java/org/gcube/common/storagehubwrapper/server/tohl/Workspace.java index c52942b..36cfd26 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/tohl/Workspace.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/tohl/Workspace.java @@ -769,13 +769,12 @@ public interface Workspace{ * * @param itemId the item id * @param fileName the file name + * @param versionName the version name. If is null or empty returns the latest version of file * @param nodeIdsToExclude the node ids to exclude * @return the item stream descriptor * @throws Exception the exception */ - ItemStreamDescriptor downloadFile( - String itemId, String fileName, String nodeIdsToExclude) - throws Exception; + ItemStreamDescriptor downloadFile(String itemId, String fileName, String versionName, String... nodeIdsToExclude) throws Exception; /**