Added Trash Operations
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/storagehub-client-wrapper@171588 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c96d95cd70
commit
6beba38c33
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue