updated moveItems
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/storagehub-client-wrapper@171977 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
9d92f3617a
commit
9632887519
|
@ -12,6 +12,7 @@ import org.gcube.common.storagehub.client.dsl.FolderContainer;
|
||||||
import org.gcube.common.storagehub.client.dsl.GenericItemContainer;
|
import org.gcube.common.storagehub.client.dsl.GenericItemContainer;
|
||||||
import org.gcube.common.storagehub.client.dsl.ItemContainer;
|
import org.gcube.common.storagehub.client.dsl.ItemContainer;
|
||||||
import org.gcube.common.storagehub.client.dsl.ListResolver;
|
import org.gcube.common.storagehub.client.dsl.ListResolver;
|
||||||
|
import org.gcube.common.storagehub.client.dsl.OpenResolver;
|
||||||
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
||||||
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
||||||
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
||||||
|
@ -505,16 +506,18 @@ public class StorageHubClientService {
|
||||||
/**
|
/**
|
||||||
* Move item.
|
* Move item.
|
||||||
*
|
*
|
||||||
* @param itemId the move item id
|
* @param itemId the item id
|
||||||
* @param destFolderContainer the dest folder container
|
* @param destFolderContainer the dest folder container
|
||||||
|
* @return the abstract file item
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public void moveItem(String itemId, FolderContainer destFolderContainer) throws Exception{
|
public AbstractFileItem moveItem(String itemId, FolderContainer destFolderContainer) throws Exception{
|
||||||
|
|
||||||
Validate.notNull(itemId, "Bad invoking move file, the itemId is null");
|
Validate.notNull(itemId, "Bad invoking move file, the itemId is null");
|
||||||
Validate.notNull(destFolderContainer, "Bad invoking move file, the itemId is null");
|
Validate.notNull(destFolderContainer, "Bad invoking move file, the itemId is null");
|
||||||
|
|
||||||
shcClient.open(itemId).asItem().move(destFolderContainer);
|
OpenResolver openResolver = shcClient.open(itemId).asItem().move(destFolderContainer);
|
||||||
|
return openResolver.asFile().get();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -683,7 +683,7 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void moveItems(List<String> itemIds, String folderDestinationId) throws ItemNotFoundException, WrongDestinationException, InsufficientPrivilegesException, InternalErrorException, ItemAlreadyExistException, Exception {
|
public List<WorkspaceItem> moveItems(List<String> itemIds, String folderDestinationId) throws ItemNotFoundException, WrongDestinationException, InsufficientPrivilegesException, InternalErrorException, ItemAlreadyExistException, Exception {
|
||||||
|
|
||||||
FolderContainer destFolderContainer = null;
|
FolderContainer destFolderContainer = null;
|
||||||
|
|
||||||
|
@ -696,15 +696,20 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
||||||
|
|
||||||
destFolderContainer = storageHubClientService.getFolderContainer(folderDestinationId);
|
destFolderContainer = storageHubClientService.getFolderContainer(folderDestinationId);
|
||||||
|
|
||||||
|
List<WorkspaceItem> toReturnItems = new ArrayList<WorkspaceItem>(itemIds.size());
|
||||||
|
|
||||||
for (String itemId : itemIds) {
|
for (String itemId : itemIds) {
|
||||||
|
|
||||||
try{
|
try{
|
||||||
storageHubClientService.moveItem(itemId, destFolderContainer);
|
AbstractFileItem movedItem = storageHubClientService.moveItem(itemId, destFolderContainer);
|
||||||
|
toReturnItems.add(HLMapper.toWorkspaceItem(movedItem));
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("Error on moving the item with id: "+itemId+ " in the folder id: "+destFolderContainer.get().getId(), e);
|
logger.error("Error on moving the item with id: "+itemId+ " in the folder id: "+destFolderContainer.get().getId(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return toReturnItems;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error on moving item/items in the folder with id: "+folderDestinationId, e);
|
logger.error("Error on moving item/items in the folder with id: "+folderDestinationId, e);
|
||||||
String error = e.getMessage()!=null?e.getMessage():"";
|
String error = e.getMessage()!=null?e.getMessage():"";
|
||||||
|
@ -768,9 +773,12 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.common.storagehubwrapper.server.tohl.Workspace#moveItem(java.lang.String, java.lang.String)
|
* @see org.gcube.common.storagehubwrapper.server.tohl.Workspace#moveItem(java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void moveItem(String itemId, String folderDestinationId) throws ItemNotFoundException, WrongDestinationException, InsufficientPrivilegesException, ItemAlreadyExistException, InternalErrorException, Exception{
|
@Override
|
||||||
|
public WorkspaceItem moveItem(String itemId, String folderDestinationId) throws ItemNotFoundException, WrongDestinationException, InsufficientPrivilegesException, ItemAlreadyExistException, InternalErrorException, Exception{
|
||||||
|
|
||||||
moveItems(Arrays.asList(itemId), folderDestinationId);
|
List<WorkspaceItem> list = moveItems(Arrays.asList(itemId), folderDestinationId);
|
||||||
|
|
||||||
|
return list==null||list.isEmpty()?null:list.get(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -361,6 +361,7 @@ public interface Workspace{
|
||||||
*
|
*
|
||||||
* @param itemId the item id
|
* @param itemId the item id
|
||||||
* @param destinationFolderId the destination folder id
|
* @param destinationFolderId the destination folder id
|
||||||
|
* @return the workspace item
|
||||||
* @throws ItemNotFoundException the item not found exception
|
* @throws ItemNotFoundException the item not found exception
|
||||||
* @throws WrongDestinationException the wrong destination exception
|
* @throws WrongDestinationException the wrong destination exception
|
||||||
* @throws InsufficientPrivilegesException the insufficient privileges exception
|
* @throws InsufficientPrivilegesException the insufficient privileges exception
|
||||||
|
@ -369,7 +370,7 @@ public interface Workspace{
|
||||||
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
|
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public void moveItem(String itemId, String destinationFolderId) throws ItemNotFoundException, WrongDestinationException, InsufficientPrivilegesException, InternalErrorException, ItemAlreadyExistException, WorkspaceFolderNotFoundException, Exception;
|
public WorkspaceItem moveItem(String itemId, String destinationFolderId) throws ItemNotFoundException, WrongDestinationException, InsufficientPrivilegesException, InternalErrorException, ItemAlreadyExistException, WorkspaceFolderNotFoundException, Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rename an item.
|
* Rename an item.
|
||||||
|
@ -455,6 +456,7 @@ public interface Workspace{
|
||||||
*
|
*
|
||||||
* @param itemIds the item ids
|
* @param itemIds the item ids
|
||||||
* @param folderDestinationId the folder destination id
|
* @param folderDestinationId the folder destination id
|
||||||
|
* @return the list
|
||||||
* @throws ItemNotFoundException the item not found exception
|
* @throws ItemNotFoundException the item not found exception
|
||||||
* @throws WrongDestinationException the wrong destination exception
|
* @throws WrongDestinationException the wrong destination exception
|
||||||
* @throws InsufficientPrivilegesException the insufficient privileges exception
|
* @throws InsufficientPrivilegesException the insufficient privileges exception
|
||||||
|
@ -462,7 +464,7 @@ public interface Workspace{
|
||||||
* @throws ItemAlreadyExistException the item already exist exception
|
* @throws ItemAlreadyExistException the item already exist exception
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
void moveItems(List<String> itemIds, String folderDestinationId)
|
List<WorkspaceItem> moveItems(List<String> itemIds, String folderDestinationId)
|
||||||
throws ItemNotFoundException, WrongDestinationException,
|
throws ItemNotFoundException, WrongDestinationException,
|
||||||
InsufficientPrivilegesException, InternalErrorException,
|
InsufficientPrivilegesException, InternalErrorException,
|
||||||
ItemAlreadyExistException, Exception;
|
ItemAlreadyExistException, Exception;
|
||||||
|
|
Loading…
Reference in New Issue