added public link

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/storagehub-client-wrapper@173259 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-10-12 08:19:20 +00:00
parent b878496a2a
commit e63afe0688
3 changed files with 48 additions and 3 deletions

View File

@ -5,9 +5,11 @@
<Change>[Task #12533] added trash operations</Change>
<Change>[Task #12556] added download facility</Change>
<Change>[Task #12601] added download folder facility</Change>
<Change>[Task #12604] Migrate Move operation to StorageHub</Change>
<Change>[Task #12603] Migrate Copy operation to StorageHub</Change>
<Change>[Task #12603] Migrate Rename facility to StorageHub</Change>
<Change>[Task #12604] added Move operation to StorageHub</Change>
<Change>[Task #12603] added Copy operation to StorageHub</Change>
<Change>[Task #12603] added Rename facility to StorageHub</Change>
<Change>[Task #12603] added Public Link facility to StorageHub
</Change>
</Changeset>
<Changeset component="org.gcube.common.storagehubwrapper.0-1-0"
date="2018-06-20">

View File

@ -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()
*/

View File

@ -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<WorkspaceItem> moveItems(List<String> 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<WorkspaceItem> copyFileItems(List<String> 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);
}
}