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); storageHubClientService.deleteItemById(itemId);
}catch(Exception e){ }catch(Exception e){
LOGGER.error("Delete item by id error: "+e.getMessage()); LOGGER.error("Error on deleting the trash item by id: "+itemId,e);
throw new Exception("Erro on deleting the item. "+e.getMessage()); throw e;
} }
} }
@ -910,7 +910,6 @@ public final class WorkspaceStorageHubClientService implements Workspace{
try{ try{
Item baseFolderTrash = storageHubClientService.openTrash(); Item baseFolderTrash = storageHubClientService.openTrash();
return HLMapper.toWorkspaceItem(baseFolderTrash); return HLMapper.toWorkspaceItem(baseFolderTrash);
}catch(Exception e){ }catch(Exception e){
throw new Exception("Error on getting the Trash content: "+e.getMessage()); 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); return HLMapper.toWorkspaceItem(theItem);
}catch(Exception e){ }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 //CONVERTING TRASH ITEM
if(item.isTrashed() && item instanceof TrashItem){ if(item.isTrashed() && item instanceof TrashItem){
type = WorkspaceItemType.TRASH_ITEM; 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(); 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; org.gcube.common.storagehubwrapper.shared.tohl.impl.TrashItem theTrashItem = (org.gcube.common.storagehubwrapper.shared.tohl.impl.TrashItem) theItem;
theTrashItem.setDeletedBy(trashItem.getDeletedBy()); theTrashItem.setDeletedBy(trashItem.getDeletedBy());
@ -307,6 +308,7 @@ public class HLMapper {
theTrashItem.setDeletedFrom(trashItem.getDeletedFrom()); theTrashItem.setDeletedFrom(trashItem.getDeletedFrom());
theTrashItem.setLenght(trashItem.getLenght()); theTrashItem.setLenght(trashItem.getLenght());
theTrashItem.setMimeType(trashItem.getMimeType()); theTrashItem.setMimeType(trashItem.getMimeType());
isFolder = trashItem.isFolder(); //DO NOT MOVE THIS SET isFolder = trashItem.isFolder(); //DO NOT MOVE THIS SET
if(isFolder) //Avoiding null exception on if(isFolder) //Avoiding null exception on
type = WorkspaceItemType.TRASH_FOLDER; type = WorkspaceItemType.TRASH_FOLDER;