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 7519733..d7d4fe0 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java @@ -6,6 +6,7 @@ package org.gcube.common.storagehubwrapper.server; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -680,14 +681,9 @@ public final class WorkspaceStorageHubClientService implements Workspace{ } - /** - * Move items. - * - * @param itemIds the item ids - * @param folderDestinationId the folder destination id - * @throws Exception the exception - */ - public void moveItems(List itemIds, String folderDestinationId) throws Exception{ + + @Override + public void moveItems(List itemIds, String folderDestinationId) throws ItemNotFoundException, WrongDestinationException, InsufficientPrivilegesException, InternalErrorException, ItemAlreadyExistException, Exception { FolderContainer destFolderContainer = null; @@ -718,15 +714,8 @@ public final class WorkspaceStorageHubClientService implements Workspace{ } - /** - * Copy file items. - * - * @param itemIds the item ids - * @param folderDestinationId the folder destination id - * @return the list - * @throws Exception the exception - */ - public List copyFileItems(List itemIds, String folderDestinationId) throws Exception{ + @Override + public List copyFileItems(List itemIds, String folderDestinationId) throws ItemNotFoundException, WrongDestinationException, InternalErrorException, ItemAlreadyExistException, InsufficientPrivilegesException, Exception { FolderContainer destFolderContainer = null; @@ -763,6 +752,30 @@ public final class WorkspaceStorageHubClientService implements Workspace{ } + /* (non-Javadoc) + * @see org.gcube.common.storagehubwrapper.server.tohl.Workspace#copyFile(java.lang.String, java.lang.String) + */ + @Override + public WorkspaceItem copyFile(String itemId, String folderDestinationId) throws ItemNotFoundException, WrongDestinationException, InternalErrorException, ItemAlreadyExistException, InsufficientPrivilegesException, Exception { + + List list = copyFileItems(Arrays.asList(itemId), folderDestinationId); + + return list==null||list.isEmpty()?null:list.get(0); + + } + + + /* (non-Javadoc) + * @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{ + + moveItems(Arrays.asList(itemId), folderDestinationId); + + } + + + @@ -823,19 +836,6 @@ public final class WorkspaceStorageHubClientService implements Workspace{ } - /* (non-Javadoc) - * @see org.gcube.portal.storagehubwrapper.shared.Workspace#moveItem(java.lang.String, java.lang.String) - */ - @Override - public WorkspaceItem moveItem(String itemId, String destinationFolderId) - throws ItemNotFoundException, WrongDestinationException, - InsufficientPrivilegesException, InternalErrorException, - ItemAlreadyExistException, WorkspaceFolderNotFoundException { - - // TODO Auto-generated method stub - return null; - } - /* (non-Javadoc) * @see org.gcube.portal.storagehubwrapper.shared.Workspace#renameItem(java.lang.String, java.lang.String) */ @@ -883,33 +883,6 @@ public final class WorkspaceStorageHubClientService implements Workspace{ } - /* (non-Javadoc) - * @see org.gcube.portal.storagehubwrapper.shared.Workspace#copy(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public WorkspaceItem copy( - String itemId, String newName, String destinationFolderId) - throws ItemNotFoundException, WrongDestinationException, - InternalErrorException, ItemAlreadyExistException, - InsufficientPrivilegesException, WorkspaceFolderNotFoundException { - - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see org.gcube.portal.storagehubwrapper.shared.Workspace#copy(java.lang.String, java.lang.String) - */ - @Override - public WorkspaceItem copy(String itemId, String destinationFolderId) - throws ItemNotFoundException, WrongDestinationException, - InternalErrorException, ItemAlreadyExistException, - InsufficientPrivilegesException, WorkspaceFolderNotFoundException { - - // TODO Auto-generated method stub - return null; - } - /* (non-Javadoc) * @see org.gcube.portal.storagehubwrapper.shared.Workspace#searchByName(java.lang.String, java.lang.String) */ diff --git a/src/main/java/org/gcube/common/storagehubwrapper/server/tohl/Workspace.java b/src/main/java/org/gcube/common/storagehubwrapper/server/tohl/Workspace.java index 147d6c7..c77d08b 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/tohl/Workspace.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/tohl/Workspace.java @@ -355,19 +355,21 @@ public interface Workspace{ */ public void deleteItem(String itemId) throws ItemNotFoundException, InternalErrorException, InsufficientPrivilegesException, Exception; + /** - * Move a workspaceItem to a specified destination. - * @param itemId the item to move. - * @param destinationFolderId the destination folder. - * @return the moved workspaceItem - * @throws ItemNotFoundException if the specified item has not been found. - * @throws WrongDestinationException if the specified destination has not been found. - * @throws InsufficientPrivilegesException if the user don't have sufficient privileges to perform this operation. - * @throws InternalErrorException if an internal error occurs. - * @throws ItemAlreadyExistException if the destination folder have a children with same name. - * @throws WorkspaceFolderNotFoundException if the destination folder is not found. + * Move item. + * + * @param itemId the item id + * @param destinationFolderId the destination folder id + * @throws ItemNotFoundException the item not found exception + * @throws WrongDestinationException the wrong destination exception + * @throws InsufficientPrivilegesException the insufficient privileges exception + * @throws InternalErrorException the internal error exception + * @throws ItemAlreadyExistException the item already exist exception + * @throws WorkspaceFolderNotFoundException the workspace folder not found exception + * @throws Exception the exception */ - public WorkspaceItem moveItem(String itemId, String destinationFolderId) throws ItemNotFoundException, WrongDestinationException, InsufficientPrivilegesException, InternalErrorException, ItemAlreadyExistException, WorkspaceFolderNotFoundException; + public void moveItem(String itemId, String destinationFolderId) throws ItemNotFoundException, WrongDestinationException, InsufficientPrivilegesException, InternalErrorException, ItemAlreadyExistException, WorkspaceFolderNotFoundException, Exception; /** * Rename an item. @@ -412,36 +414,58 @@ public interface Workspace{ public void remove(String itemName, String folderId) throws ItemNotFoundException, InternalErrorException, InsufficientPrivilegesException, WrongItemTypeException; /** - * Copy an item from a folder to another folder. + * Copy file. * - * @param itemId the item to copy. - * @param newName the item new name. - * @param destinationFolderId the destination folder id. - * @return the item copy. - * @throws ItemNotFoundException if the item has not been found. - * @throws WrongDestinationException if the destination have a wrong type. - * @throws InternalErrorException if an internal error occurs. - * @throws ItemAlreadyExistException if an item with same name already exist in the destination folder. - * @throws InsufficientPrivilegesException if the user don't have sufficient privileges to perform this operation. - * @throws WorkspaceFolderNotFoundException if the destination folder has not been found. + * @param itemId the item id + * @param folderDestinationId the folder destination id + * @return the list + * @throws ItemNotFoundException the item not found exception + * @throws WrongDestinationException the wrong destination exception + * @throws InternalErrorException the internal error exception + * @throws ItemAlreadyExistException the item already exist exception + * @throws InsufficientPrivilegesException the insufficient privileges exception + * @throws Exception the exception */ - public WorkspaceItem copy(String itemId, String newName, String destinationFolderId) throws ItemNotFoundException, WrongDestinationException, InternalErrorException, ItemAlreadyExistException, InsufficientPrivilegesException, WorkspaceFolderNotFoundException; + WorkspaceItem copyFile(String itemId, String folderDestinationId) + throws ItemNotFoundException, WrongDestinationException, + InternalErrorException, ItemAlreadyExistException, + InsufficientPrivilegesException, Exception; /** - * Copy an item from a folder to another folder. The item copy have the same name of the original. + * Copy file items. * - * @param itemId the item to copy. - * @param destinationFolderId the destination folder id, can't be the same of the item (can't have the same name). - * @return the item copy. - * @throws ItemNotFoundException if the item has not been found. - * @throws WrongDestinationException if the destination have a wrong type. - * @throws InternalErrorException if an internal error occurs. - * @throws ItemAlreadyExistException if an item with same name already exist in the destination folder. - * @throws InsufficientPrivilegesException if the user don't have sufficient privileges to perform this operation. - * @throws WorkspaceFolderNotFoundException if the destination folder has not been found. + * @param itemIds the item ids + * @param folderDestinationId the folder destination id + * @return the list + * @throws ItemNotFoundException the item not found exception + * @throws WrongDestinationException the wrong destination exception + * @throws InternalErrorException the internal error exception + * @throws ItemAlreadyExistException the item already exist exception + * @throws InsufficientPrivilegesException the insufficient privileges exception + * @throws Exception the exception */ - public WorkspaceItem copy(String itemId, String destinationFolderId) throws ItemNotFoundException, WrongDestinationException, InternalErrorException, ItemAlreadyExistException, InsufficientPrivilegesException, WorkspaceFolderNotFoundException; + List copyFileItems( + List itemIds, String folderDestinationId) + throws ItemNotFoundException, WrongDestinationException, + InternalErrorException, ItemAlreadyExistException, + InsufficientPrivilegesException, Exception; + /** + * Move items. + * + * @param itemIds the item ids + * @param folderDestinationId the folder destination id + * @throws ItemNotFoundException the item not found exception + * @throws WrongDestinationException the wrong destination exception + * @throws InsufficientPrivilegesException the insufficient privileges exception + * @throws InternalErrorException the internal error exception + * @throws ItemAlreadyExistException the item already exist exception + * @throws Exception the exception + */ + void moveItems(List itemIds, String folderDestinationId) + throws ItemNotFoundException, WrongDestinationException, + InsufficientPrivilegesException, InternalErrorException, + ItemAlreadyExistException, Exception; /** * Search by Name. @@ -738,4 +762,5 @@ public interface Workspace{ String folderId, String folderName, String nodeIdsToExclude) throws Exception; + }