From 34246fa021b95249505af0361a9c9565679c1893 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Mon, 24 Sep 2018 14:37:58 +0000 Subject: [PATCH] added remove items git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/storagehub-client-wrapper@171650 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../WorkspaceStorageHubClientService.java | 36 ++++++++++++------- .../server/tohl/Workspace.java | 5 +-- 2 files changed, 26 insertions(+), 15 deletions(-) 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 6ac8463..fe6660a 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.HashMap; import java.util.List; import java.util.Map; @@ -482,6 +483,27 @@ public final class WorkspaceStorageHubClientService implements Workspace{ } } + /* (non-Javadoc) + * @see org.gcube.portal.storagehubwrapper.shared.Workspace#removeItems(java.lang.String[]) + */ + @Override + public Map removeItems(String... id) + throws ItemNotFoundException, InternalErrorException, + InsufficientPrivilegesException { + + Map errors = new HashMap(); + + for (int i = 0; i < id.length; i++) { + try{ + deleteItem(id[i]); + }catch(Exception e){ + errors.put(id[i], e.getMessage()); + } + } + + return errors; + } + /* (non-Javadoc) * @see org.gcube.portal.storagehubwrapper.server.tohl.Workspace#uploadFile(java.lang.String, java.io.InputStream, java.lang.String, java.lang.String) */ @@ -567,7 +589,7 @@ public final class WorkspaceStorageHubClientService implements Workspace{ storageHubClientService.emptyTrash(); }catch(Exception e){ - throw new Exception("Error emptying the Trash: "+e.getMessage()); + throw new Exception("Error emptying the Trash: ",e); } } @@ -902,18 +924,6 @@ public final class WorkspaceStorageHubClientService implements Workspace{ return 0; } - /* (non-Javadoc) - * @see org.gcube.portal.storagehubwrapper.shared.Workspace#removeItems(java.lang.String[]) - */ - @Override - public Map removeItems(String... id) - throws ItemNotFoundException, InternalErrorException, - InsufficientPrivilegesException { - - // TODO Auto-generated method stub - return null; - } - /* (non-Javadoc) * @see org.gcube.portal.storagehubwrapper.shared.Workspace#createVREFolder(java.lang.String, java.lang.String, java.lang.String, org.gcube.portal.storagehubwrapper.shared.ACLType) */ 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 053cf3f..24deb4b 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 @@ -623,11 +623,12 @@ public interface Workspace{ */ public int getTotalItems() throws InternalErrorException; + /** - * Remove a list of items identified by ids. + * Removes the items. * * @param id the id - * @return a map of errors: Map + * @return the map of errors (id,error) * @throws ItemNotFoundException the item not found exception * @throws InternalErrorException the internal error exception * @throws InsufficientPrivilegesException the insufficient privileges exception