propagated the exception thrown by SHUB for restore and delete operation

This commit is contained in:
Francesco Mangiacrapa 2020-05-19 16:27:33 +02:00
parent 807ea16878
commit d62d1b4c8a
2 changed files with 7 additions and 5 deletions

View File

@ -792,8 +792,8 @@ public final class WorkspaceStorageHubClientService implements Workspace{
storageHubClientService.deleteItemById(itemId);
}catch(Exception e){
LOGGER.error("Delete item by id error: "+e.getMessage());
throw new Exception("Erro on deleting the item. "+e.getMessage());
LOGGER.error("Error on deleting the trash item by id: "+itemId,e);
throw e;
}
}
@ -910,7 +910,6 @@ public final class WorkspaceStorageHubClientService implements Workspace{
try{
Item baseFolderTrash = storageHubClientService.openTrash();
return HLMapper.toWorkspaceItem(baseFolderTrash);
}catch(Exception e){
throw new Exception("Error on getting the Trash content: "+e.getMessage());
}
@ -951,7 +950,8 @@ public final class WorkspaceStorageHubClientService implements Workspace{
return HLMapper.toWorkspaceItem(theItem);
}catch(Exception e){
throw new Exception("Error on restoring the Trash Item: "+e.getMessage());
LOGGER.error("Error on restoring the trash item by id: "+itemId,e);
throw e;
}
}

View File

@ -298,7 +298,8 @@ public class HLMapper {
//CONVERTING TRASH ITEM
if(item.isTrashed() && item instanceof TrashItem){
type = WorkspaceItemType.TRASH_ITEM;
TrashItem trashItem = (TrashItem) item; //??
TrashItem trashItem = (TrashItem) item;
itemName = trashItem.getTitle(); //IN CASE OF TRASHED ITEM THE NAME IS THE ID, SO I'M USING THE TITLE
theItem = new org.gcube.common.storagehubwrapper.shared.tohl.impl.TrashItem();
org.gcube.common.storagehubwrapper.shared.tohl.impl.TrashItem theTrashItem = (org.gcube.common.storagehubwrapper.shared.tohl.impl.TrashItem) theItem;
theTrashItem.setDeletedBy(trashItem.getDeletedBy());
@ -307,6 +308,7 @@ public class HLMapper {
theTrashItem.setDeletedFrom(trashItem.getDeletedFrom());
theTrashItem.setLenght(trashItem.getLenght());
theTrashItem.setMimeType(trashItem.getMimeType());
isFolder = trashItem.isFolder(); //DO NOT MOVE THIS SET
if(isFolder) //Avoiding null exception on
type = WorkspaceItemType.TRASH_FOLDER;