From 75ca47980e41cf84779802fc6ff6acec63e963a7 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Thu, 20 Sep 2018 13:03:00 +0000 Subject: [PATCH] Added method isItemShared git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/storagehub-client-wrapper@171538 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../server/StorageHubClientService.java | 14 ++++++++++++++ .../WorkspaceStorageHubClientService.java | 19 +++++++++++++++++++ .../shared/tohl/WorkspaceItemType.java | 2 -- 3 files changed, 33 insertions(+), 2 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 f7a5d27..df7c417 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java @@ -167,6 +167,20 @@ public class StorageHubClientService { } + + /** + * Checks if is item shared. + * + * @param itemId the item id + * @return true, if is item shared + * @throws Exception the exception + */ + public boolean isItemShared(String itemId) throws Exception { + setContextProviders(scope, authorizationToken); + return shcClient.open(itemId).asItem().get().isShared(); + + } + /** * Gets the root shared 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 18c47c4..762e66c 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java @@ -507,6 +507,25 @@ public final class WorkspaceStorageHubClientService implements Workspace{ } + /** + * Checks if is item shared. + * + * @param itemId the item id + * @return true, if is item shared + * @throws Exception the exception + */ + public boolean isItemShared(String itemId) throws Exception { + Validate.notNull(itemId,"The input itemId is null"); + try{ + return storageHubClientService.isItemShared(itemId); + + }catch(Exception e){ + throw new Exception("Error cheking if the item is shared: "+e.getMessage()); + } + + } + + diff --git a/src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/WorkspaceItemType.java b/src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/WorkspaceItemType.java index 5b7ff74..9cee96b 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/WorkspaceItemType.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/WorkspaceItemType.java @@ -43,8 +43,6 @@ public enum WorkspaceItemType { */ TRASH_ITEM, - VRE_FOLDER; - } \ No newline at end of file