diff --git a/distro/changelog.xml b/distro/changelog.xml index 2d23cf8..8002344 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -5,9 +5,11 @@ [Task #12533] added trash operations [Task #12556] added download facility [Task #12601] added download folder facility - [Task #12604] Migrate Move operation to StorageHub - [Task #12603] Migrate Copy operation to StorageHub - [Task #12603] Migrate Rename facility to StorageHub + [Task #12604] added Move operation to StorageHub + [Task #12603] added Copy operation to StorageHub + [Task #12603] added Rename facility to StorageHub + [Task #12603] added Public Link facility to StorageHub + 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 37e2007..2526266 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java @@ -1,6 +1,7 @@ package org.gcube.common.storagehubwrapper.server; import java.io.InputStream; +import java.net.URL; import java.util.List; import org.apache.commons.lang.Validate; @@ -562,6 +563,22 @@ public class StorageHubClientService { } + /** + * Gets the file public link. + * + * @param fileItemId the file item id + * @return the file public link + * @throws Exception the exception + */ + public URL getFilePublicLink(String fileItemId) throws Exception{ + + Validate.notNull(fileItemId, "Bad invoking get public link, the itemId is null"); + + return shcClient.open(fileItemId).asFile().getPublicLink(); + + } + + /* (non-Javadoc) * @see java.lang.Object#toString() */ 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 6f15c09..d1220a4 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java @@ -5,6 +5,7 @@ package org.gcube.common.storagehubwrapper.server; import java.io.IOException; import java.io.InputStream; +import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -682,6 +683,9 @@ public final class WorkspaceStorageHubClientService implements Workspace{ + /* (non-Javadoc) + * @see org.gcube.common.storagehubwrapper.server.tohl.Workspace#moveItems(java.util.List, java.lang.String) + */ @Override public List moveItems(List itemIds, String folderDestinationId) throws ItemNotFoundException, WrongDestinationException, InsufficientPrivilegesException, InternalErrorException, ItemAlreadyExistException, Exception { @@ -718,6 +722,9 @@ public final class WorkspaceStorageHubClientService implements Workspace{ } + /* (non-Javadoc) + * @see org.gcube.common.storagehubwrapper.server.tohl.Workspace#copyFileItems(java.util.List, java.lang.String) + */ @Override public List copyFileItems(List itemIds, String folderDestinationId) throws ItemNotFoundException, WrongDestinationException, InternalErrorException, ItemAlreadyExistException, InsufficientPrivilegesException, Exception { @@ -800,6 +807,25 @@ public final class WorkspaceStorageHubClientService implements Workspace{ } + /** + * Gets the file public link. + * + * @param fileItemId the file item id + * @return the file public link + * @throws Exception the exception + */ + public URL getFilePublicLink(String fileItemId) throws Exception{ + + try{ + return storageHubClientService.getFilePublicLink(fileItemId); + }catch(Exception e){ + logger.error("Error on getting public link: "+fileItemId, e); + String error = e.getMessage()!=null?e.getMessage():"Operation not allowed"; + throw new Exception("Error on getting public link. "+error); + } + } + +