From 2e0b2afa53307ec28e807b957d38d127762440d3 Mon Sep 17 00:00:00 2001 From: francesco Date: Fri, 13 Mar 2020 12:56:58 +0100 Subject: [PATCH] Calling search with excludeTrashed = true Added a check with instance of TrahItem --- .../server/StorageHubClientService.java | 10 +++++----- .../server/WorkspaceStorageHubClientService.java | 2 +- .../storagehubwrapper/server/converter/HLMapper.java | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) 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 83a6353..ac7b0d2 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java @@ -570,14 +570,14 @@ public class StorageHubClientService { /** - * Search by text. + * Search for text. * - * @param name the name + * @param text the text * @param folderId the folder id * @return the list * @throws Exception the exception */ - public List searchByText(String name, String folderId) throws Exception { + public List searchForText(String text, String folderId) throws Exception { Item item; try { @@ -588,8 +588,8 @@ public class StorageHubClientService { } if(item instanceof FolderItem || item instanceof SharedFolder || item instanceof VreFolder){ - //return shcClient.open(folderId).asFolder().findByName(name).withContent().getItems(); - return shcClient.open(folderId).asFolder().search(name).withContent().getItems(); + //this does not return the trashed items + return shcClient.open(folderId).asFolder().search(text,true).withContent().getItems(); }else throw new Exception("The input folder id is not a folder"); } 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 a59d4fe..b8b02d3 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java @@ -667,7 +667,7 @@ public final class WorkspaceStorageHubClientService implements Workspace{ LOGGER.debug("called text"); Validate.notNull(folderId,"The input folderid is null"); try { - List items = storageHubClientService.searchByText(text, folderId); + List items = storageHubClientService.searchForText(text, folderId); List wsItems = null; if(items!=null){ wsItems = new ArrayList(items.size()); diff --git a/src/main/java/org/gcube/common/storagehubwrapper/server/converter/HLMapper.java b/src/main/java/org/gcube/common/storagehubwrapper/server/converter/HLMapper.java index c2753bc..94555cd 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/converter/HLMapper.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/converter/HLMapper.java @@ -296,7 +296,7 @@ public class HLMapper { } //CONVERTING TRASH ITEM - if(item.isTrashed()){ + if(item.isTrashed() && item instanceof TrashItem){ type = WorkspaceItemType.TRASH_ITEM; TrashItem trashItem = (TrashItem) item; //?? theItem = new org.gcube.common.storagehubwrapper.shared.tohl.impl.TrashItem();