Added uploadArchive method

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/storagehub-client-wrapper@171507 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-09-18 14:47:48 +00:00
parent 3fa88ee8d3
commit 6f5e725b0b
3 changed files with 65 additions and 0 deletions

View File

@ -300,6 +300,28 @@ public class StorageHubClientService {
}
/**
* Upload archive.
*
* @param folderId the folder id
* @param is the is
* @param extractionFolderName the extraction folder name
* @return the item
* @throws Exception the exception
*/
public Item uploadArchive(String folderId, InputStream is, String extractionFolderName) throws Exception{
try {
FolderContainer folderCont = shcClient.open(folderId).asFolder().uploadArchive(is, extractionFolderName);
return folderCont.get();
} catch (Exception e) {
logger.error("Error during uploading the archive with extractionFolderName: "+extractionFolderName+" in the folderId: "+folderId, e);
throw new Exception("Error during uploading the archive. Try again", e);
}
}
/**
* Gets the shared folder members.
*

View File

@ -483,6 +483,29 @@ public final class WorkspaceStorageHubClientService implements Workspace{
}
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.server.tohl.Workspace#uploadFile(java.lang.String, java.io.InputStream, java.lang.String, java.lang.String)
*/
@Override
public WorkspaceItem uploadArchive(
String folderId, InputStream is, String extractionFolderName)
throws
WorkspaceFolderNotFoundException, InternalErrorException,
ItemAlreadyExistException, WrongDestinationException, InsufficientPrivilegesException{
WorkspaceItem wsItem = null;
try {
Item item = storageHubClientService.uploadArchive(folderId, is, extractionFolderName);
wsItem = HLMapper.toWorkspaceItem(item);
}
catch (Exception e) {
logger.error("Error during upload archive", e);
throw new InternalErrorException(e.getMessage());
}
return wsItem;
}

View File

@ -638,4 +638,24 @@ public interface Workspace{
*/
List<WorkspaceItem> getPublicFolders() throws InternalErrorException;
/**
* Upload archive.
*
* @param folderId the folder id
* @param is the is
* @param extractionFolderName the extraction folder name
* @return the workspace item
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
* @throws InternalErrorException the internal error exception
* @throws ItemAlreadyExistException the item already exist exception
* @throws WrongDestinationException the wrong destination exception
* @throws InsufficientPrivilegesException
*/
WorkspaceItem uploadArchive(
String folderId, InputStream is, String extractionFolderName)
throws
WorkspaceFolderNotFoundException, InternalErrorException,
ItemAlreadyExistException, WrongDestinationException, InsufficientPrivilegesException;
}