From 7792737ae101bf49317430fe32122bd47908d8b0 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 17 Apr 2020 14:43:14 +0200 Subject: [PATCH] Task #19087 added also the method getParentsForExplorerById --- .../WorkspaceStorageHubClientService.java | 29 +++++++++++++++++++ .../server/tohl/Workspace.java | 13 ++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) 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 8b76fc5..d6bf2c3 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java @@ -402,6 +402,35 @@ public final class WorkspaceStorageHubClientService implements Workspace{ return toParents; } + + + /** + * Gets the parents for explorer by id. This call is the same of {@link WorkspaceStorageHubClientService#getParentsById(String)} + * except to getRoot called inside (to check if a parent is root or not). {@link WorkspaceItem#isRoot()} returns always false. + * + * @param id the id + * @return the parents for explorer by id + * @throws InternalErrorException the internal error exception + * @throws Exception the exception + */ + @Override + public List getParentsForExplorerById(String id) + throws InternalErrorException, Exception { + + LOGGER.debug("called get Parents by Id"); + Validate.notNull(id,"The input id is null"); + List parents = storageHubClientService.getParents(id); + List toParents = new ArrayList(parents.size()); + + for (Item item : parents) { + WorkspaceItem child = HLMapper.toWorkspaceItem(item, withAccounting, withFileDetails, withMapProperties); + //setIsRoot((org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceItem) child); + toParents.add(child); + } + + return toParents; + } + /** * Creates the folder. 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 3f1308a..b739b85 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 @@ -515,7 +515,7 @@ public interface Workspace{ throws InternalErrorException, ItemNotFoundException, WrongItemTypeException; /** - * Gets the item. + * Gets the item for Explorer * * @param itemId the item id * @param withAccounting the with accounting @@ -528,6 +528,17 @@ public interface Workspace{ */ WorkspaceItem getItemForExplorer(String itemId, boolean withAccounting, boolean withFileDetails, boolean withMapProperties) throws ItemNotFoundException, InternalErrorException, Exception; + + /** + * Gets the parents for explorer by id. This call is the same of {@link WorkspaceStorageHubClientService#getParentsById(String)} + * except to getRoot called inside (to check if a parent is root or not). {@link WorkspaceItem#isRoot()} returns always false. + * + * @param id the id + * @return the parents for explorer by id + * @throws InternalErrorException the internal error exception + * @throws Exception the exception + */ + List getParentsForExplorerById(String id) throws InternalErrorException, Exception; /* *