Migrate Rename facility to StorageHub

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/storagehub-client-wrapper@172102 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-10-09 15:38:06 +00:00
parent 5cf7def8e9
commit 6e8f680fb6
4 changed files with 63 additions and 21 deletions

View File

@ -7,6 +7,7 @@
<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>
</Changeset>
<Changeset component="org.gcube.common.storagehubwrapper.0-1-0"
date="2018-06-20">

View File

@ -543,6 +543,25 @@ public class StorageHubClientService {
}
/**
* Rename item.
*
* @param itemId the item id
* @param newName the new name
* @return the item
* @throws Exception the exception
*/
public Item renameItem(String itemId, String newName) throws Exception{
Validate.notNull(itemId, "Bad invoking rename item, the itemId is null");
OpenResolver resolver = shcClient.open(itemId).asItem().rename(newName);
return resolver.asItem().get();
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/

View File

@ -780,6 +780,35 @@ public final class WorkspaceStorageHubClientService implements Workspace{
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#renameItem(java.lang.String, java.lang.String)
*/
@Override
public WorkspaceItem renameItem(String itemId, String newName)
throws ItemNotFoundException, InternalErrorException,
ItemAlreadyExistException, InsufficientPrivilegesException, Exception{
try{
Item item = storageHubClientService.renameItem(itemId, newName);
return HLMapper.toWorkspaceItem(item);
}catch(Exception e){
logger.error("Error on renaming item with id: "+itemId, e);
String error = e.getMessage()!=null?e.getMessage():"Operation not allowed";
throw new Exception("Error on renaming. "+error);
}
}
@ -841,17 +870,7 @@ public final class WorkspaceStorageHubClientService implements Workspace{
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#renameItem(java.lang.String, java.lang.String)
*/
@Override
public void renameItem(String itemId, String newName)
throws ItemNotFoundException, InternalErrorException,
ItemAlreadyExistException, InsufficientPrivilegesException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#changeDescription(java.lang.String, java.lang.String)

View File

@ -256,6 +256,20 @@ public interface Workspace{
/**
* Rename an item.
*
* @param itemId the item id.
* @param newName the new name.
* @return the workspace item
* @throws ItemNotFoundException if the item has not been found.
* @throws InternalErrorException if an internal error occurs.
* @throws ItemAlreadyExistException if the user don't have sufficient privileges to perform this operation.
* @throws InsufficientPrivilegesException the insufficient privileges exception
* @throws Exception the exception
*/
public WorkspaceItem renameItem(String itemId, String newName) throws ItemNotFoundException, InternalErrorException, ItemAlreadyExistException, InsufficientPrivilegesException, Exception;
@ -372,17 +386,6 @@ public interface Workspace{
*/
public WorkspaceItem moveItem(String itemId, String destinationFolderId) throws ItemNotFoundException, WrongDestinationException, InsufficientPrivilegesException, InternalErrorException, ItemAlreadyExistException, WorkspaceFolderNotFoundException, Exception;
/**
* Rename an item.
*
* @param itemId the item id.
* @param newName the new name.
* @throws ItemNotFoundException if the item has not been found.
* @throws InternalErrorException if an internal error occurs.
* @throws ItemAlreadyExistException if the user don't have sufficient privileges to perform this operation.
* @throws InsufficientPrivilegesException the insufficient privileges exception
*/
public void renameItem(String itemId, String newName) throws ItemNotFoundException, InternalErrorException, ItemAlreadyExistException, InsufficientPrivilegesException;
/**
* Change an item description.