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 ee232f4..63e757a 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java @@ -17,6 +17,8 @@ import org.gcube.common.storagehub.model.acls.ACL; import org.gcube.common.storagehub.model.items.FolderItem; import org.gcube.common.storagehub.model.items.Item; import org.gcube.common.storagehub.model.items.SharedFolder; +import org.gcube.common.storagehubwrapper.server.converter.ObjectMapper; +import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -69,7 +71,7 @@ public class StorageHubClientService { * Gets the root. * * @return the root - * @throws Exception + * @throws Exception the exception */ public FolderItem getRoot() throws Exception { setContextProviders(scope, authorizationToken); @@ -96,7 +98,6 @@ public class StorageHubClientService { * Gets the children. * * @param id the id - * @param excludeNodes the exclude nodes * @return the children */ public List getChildren(String id){ @@ -110,7 +111,7 @@ public class StorageHubClientService { * * @param itemId the item id * @return the item - * @throws Exception + * @throws Exception the exception */ public Item getItem(String itemId) throws Exception{ setContextProviders(scope, authorizationToken); @@ -139,7 +140,7 @@ public class StorageHubClientService { * @param folderName the folder name * @param folderDescription the folder description * @return the item - * @throws Exception + * @throws Exception the exception */ public Item createFolder(String parentId, String folderName, String folderDescription) throws Exception { setContextProviders(scope, authorizationToken); @@ -175,10 +176,11 @@ public class StorageHubClientService { /** * Gets the user acl for folder id. * - * @param request the request + * @param infrastructureName the infrastructure name + * @param userName the user name * @param folderId the folder id * @return the user acl for folder id - * @throws Exception + * @throws Exception the exception */ public String getUserACLForFolderId(String infrastructureName, String userName, String folderId) throws Exception { setContextProviders(scope, authorizationToken); @@ -241,6 +243,30 @@ public class StorageHubClientService { } } + + /** + * Gets the shared folder members. + * + * @param folderId the folder id + * @return the shared folder members + * @throws Exception the exception + */ + public List getSharedFolderMembers(String folderId) throws Exception { + Item item; + try { + item = getItem(folderId); + if(item instanceof SharedFolder){ + return ObjectMapper.toListLogins((SharedFolder)item); + }else + throw new Exception("The item with "+folderId+ " is not a Shared Folder"); + + }catch (Exception e) { + logger.error("Error during get item with id: "+folderId,e); + throw new ItemNotFoundException(e.getMessage()); + } + } + + /* (non-Javadoc) * @see java.lang.Object#toString() */ 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 6374900..9dc02ac 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java @@ -12,10 +12,8 @@ import java.util.Map; import org.apache.commons.lang.Validate; import org.gcube.common.storagehub.model.items.FolderItem; import org.gcube.common.storagehub.model.items.Item; -import org.gcube.common.storagehub.model.items.SharedFolder; import org.gcube.common.storagehub.model.types.GenericItemType; import org.gcube.common.storagehubwrapper.server.converter.HLMapper; -import org.gcube.common.storagehubwrapper.server.converter.PortalMapper; import org.gcube.common.storagehubwrapper.server.tohl.Workspace; import org.gcube.common.storagehubwrapper.shared.ACLType; import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem; @@ -400,23 +398,7 @@ public final class WorkspaceStorageHubClientService implements Workspace{ public List getSharedFolderMembers(String folderId) throws Exception { Validate.notNull(folderId,"The input folderid is null"); - - Item item; - try { - - item = storageHubClientService.getItem(folderId); - - }catch (Exception e) { - logger.error("Error during get item with id: "+folderId,e); - throw new ItemNotFoundException(e.getMessage()); - } - - Validate.notNull(item, "The item with id "+folderId+" was not found"); - - if(item instanceof SharedFolder){ - return PortalMapper.toWorkspaceSharedFolderMembers((SharedFolder)item); - }else - throw new Exception("The item with "+folderId+ " is not a Shared Folder"); + return storageHubClientService.getSharedFolderMembers(folderId); } diff --git a/src/main/java/org/gcube/common/storagehubwrapper/server/converter/PortalMapper.java b/src/main/java/org/gcube/common/storagehubwrapper/server/converter/ObjectMapper.java similarity index 77% rename from src/main/java/org/gcube/common/storagehubwrapper/server/converter/PortalMapper.java rename to src/main/java/org/gcube/common/storagehubwrapper/server/converter/ObjectMapper.java index 46f6ec5..d996b63 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/converter/PortalMapper.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/converter/ObjectMapper.java @@ -13,23 +13,25 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; + /** - * The Class PortalMapper. + * The Class ObjectMapper. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * Jun 26, 2018 */ -public class PortalMapper { +public class ObjectMapper { + + private static Logger logger = LoggerFactory.getLogger(ObjectMapper.class); - private static Logger logger = LoggerFactory.getLogger(PortalMapper.class); /** - * To workspace shared folder members. + * To list logins. * * @param sharedfolder the sharedfolder * @return the list */ - public static List toWorkspaceSharedFolderMembers(SharedFolder sharedfolder){ + public static List toListLogins(SharedFolder sharedfolder){ Metadata users = sharedfolder.getUsers(); Map mapMember = users.getValues();