diff --git a/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java b/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java index 4684b67..9563836 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java @@ -402,6 +402,56 @@ public class StorageHubClientService { + /** + * Open trash. + * + * @return the item + * @throws Exception the exception + */ + public Item openTrash() throws Exception{ + + return shcClient.openTrash().get(); + + } + + + + /** + * Empty trash. + * + * @throws Exception the exception + */ + public void emptyTrash() throws Exception{ + + shcClient.emptyTrash(); + + } + + + /** + * Restore thrash item. + * + * @param itemId the item id + * @return the item + * @throws Exception the exception + */ + public Item restoreThrashItem(String itemId) throws Exception{ + + Validate.notNull(itemId, "Bad invoking restore trash item the "+itemId+" is null"); + + FolderContainer container = shcClient.restoreThrashItem(itemId); + + if(container!=null){ + FolderItem item = container.get(); + if(item!=null){ + return item; + }else + throw new Exception("Restoring failed, FolderItem is null"); + }else + throw new Exception("Restoring failed, contanier is null"); + + } + /* (non-Javadoc) * @see java.lang.Object#toString() 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 f4a4a74..6ac8463 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java @@ -28,7 +28,6 @@ import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WrongDestinatio import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WrongItemTypeException; import org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceFolder; import org.gcube.common.storagehubwrapper.shared.tohl.items.URLFileItem; -import org.gcube.common.storagehubwrapper.shared.tohl.trash.WorkspaceTrashItem; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -530,7 +529,7 @@ public final class WorkspaceStorageHubClientService implements Workspace{ * Gets the VRE folders id. * * @return the VRE folders id - * @throws Exception + * @throws Exception the exception */ public String getVREFoldersId() throws Exception{ try{ @@ -542,6 +541,57 @@ public final class WorkspaceStorageHubClientService implements Workspace{ } + /* (non-Javadoc) + * @see org.gcube.common.storagehubwrapper.server.tohl.Workspace#getTrash() + */ + public WorkspaceItem getTrash() + throws Exception { + try{ + Item baseFolderTrash = storageHubClientService.openTrash(); + return HLMapper.toWorkspaceItem(baseFolderTrash); + + }catch(Exception e){ + throw new Exception("Error getting the Trash content: "+e.getMessage()); + } + } + + + /** + * Empty trash. + * + * @throws Exception the exception + */ + public void emptyTrash() throws Exception{ + + try{ + storageHubClientService.emptyTrash(); + + }catch(Exception e){ + throw new Exception("Error emptying the Trash: "+e.getMessage()); + } + + } + + + /** + * Restore thrash item. + * + * @param itemId the item id + * @return the item + * @throws Exception the exception + */ + public Item restoreThrashItem(String itemId) throws Exception{ + + try{ + return storageHubClientService.restoreThrashItem(itemId); + + }catch(Exception e){ + throw new Exception("Error restoring the Trash Item: "+e.getMessage()); + } + + } + + @@ -806,16 +856,6 @@ public final class WorkspaceStorageHubClientService implements Workspace{ return null; } - /* (non-Javadoc) - * @see org.gcube.portal.storagehubwrapper.shared.Workspace#getTrash() - */ - @Override - public WorkspaceTrashItem getTrash() - throws InternalErrorException, ItemNotFoundException { - - // TODO Auto-generated method stub - return null; - } /* (non-Javadoc) * @see org.gcube.portal.storagehubwrapper.shared.Workspace#getMySpecialFolders() 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 e28463f..053cf3f 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 @@ -8,6 +8,7 @@ import java.io.InputStream; import java.util.List; import java.util.Map; +import org.gcube.common.storagehub.model.items.Item; import org.gcube.common.storagehub.model.types.GenericItemType; import org.gcube.common.storagehubwrapper.shared.ACLType; import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder; @@ -22,7 +23,6 @@ import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WorkspaceFolder import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WrongDestinationException; import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WrongItemTypeException; import org.gcube.common.storagehubwrapper.shared.tohl.items.URLFileItem; -import org.gcube.common.storagehubwrapper.shared.tohl.trash.WorkspaceTrashItem; @@ -215,10 +215,49 @@ public interface Workspace{ * Gets the VRE folders id. * * @return the VRE folders id - * @throws Exception + * @throws Exception the exception */ public String getVREFoldersId() throws Exception; + /** + * Get Trash Folder. + * + * @return the trash folder + * @throws InternalErrorException the internal error exception + * @throws ItemNotFoundException the item not found exception + * @throws Exception the exception + */ + public WorkspaceItem getTrash() throws InternalErrorException, ItemNotFoundException, Exception; + + + /** + * Empty trash. + * + * @throws Exception the exception + */ + public void emptyTrash() throws Exception; + + + + /** + * Restore thrash item. + * + * @param itemId the item id + * @return the item + * @throws Exception the exception + */ + public Item restoreThrashItem(String itemId) throws Exception; + + + + + + + + + + + @@ -545,14 +584,7 @@ public interface Workspace{ */ public WorkspaceItem unshare(String itemId) throws InternalErrorException, ItemNotFoundException; - /** - * Get Trash Folder. - * - * @return the trash folder - * @throws InternalErrorException the internal error exception - * @throws ItemNotFoundException the item not found exception - */ - public WorkspaceTrashItem getTrash() throws InternalErrorException, ItemNotFoundException; + /** * Get MySpecialFolders.