Updated method as List<Member> getSharedFolderMembers
This commit is contained in:
parent
6ef3fe98bc
commit
4081445ef7
|
@ -3,7 +3,7 @@
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [v1.1.2-SNAPSHOT] - 2022-04-28
|
## [v1.2.0-SNAPSHOT] - 2022-04-28
|
||||||
|
|
||||||
#### Enhancements
|
#### Enhancements
|
||||||
|
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -11,7 +11,7 @@
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>storagehub-client-wrapper</artifactId>
|
<artifactId>storagehub-client-wrapper</artifactId>
|
||||||
<version>1.1.2-SNAPSHOT</version>
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
<name>storagehub-client-wrapper</name>
|
<name>storagehub-client-wrapper</name>
|
||||||
<description>This is a wrapper of storagehub-client library. It allows to interact with storagehub in a simplified way by exposing several utilities. Moreover, It exposes by another inteface java beans as defined in (the old) HL interfaces</description>
|
<description>This is a wrapper of storagehub-client library. It allows to interact with storagehub in a simplified way by exposing several utilities. Moreover, It exposes by another inteface java beans as defined in (the old) HL interfaces</description>
|
||||||
<scm>
|
<scm>
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.gcube.common.storagehub.client.dsl.ListResolver;
|
||||||
import org.gcube.common.storagehub.client.dsl.ListResolverTyped;
|
import org.gcube.common.storagehub.client.dsl.ListResolverTyped;
|
||||||
import org.gcube.common.storagehub.client.dsl.OpenResolver;
|
import org.gcube.common.storagehub.client.dsl.OpenResolver;
|
||||||
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
||||||
|
import org.gcube.common.storagehub.client.dsl.Util;
|
||||||
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
||||||
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
||||||
import org.gcube.common.storagehub.client.proxies.WorkspaceManagerClient;
|
import org.gcube.common.storagehub.client.proxies.WorkspaceManagerClient;
|
||||||
|
@ -38,6 +39,8 @@ import org.gcube.common.storagehub.model.items.nodes.ImageContent;
|
||||||
import org.gcube.common.storagehub.model.service.Version;
|
import org.gcube.common.storagehub.model.service.Version;
|
||||||
import org.gcube.common.storagehubwrapper.server.converter.HLMapper;
|
import org.gcube.common.storagehubwrapper.server.converter.HLMapper;
|
||||||
import org.gcube.common.storagehubwrapper.shared.ACLType;
|
import org.gcube.common.storagehubwrapper.shared.ACLType;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.Member;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.Member.TYPE;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -568,37 +571,38 @@ public class StorageHubClientService {
|
||||||
* @return the shared folder members
|
* @return the shared folder members
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public List<String> getSharedFolderMembers(String folderId) throws Exception {
|
public List<Member> getSharedFolderMembers(String folderId) throws Exception {
|
||||||
|
|
||||||
setContextProviders(scope, authorizationToken);
|
setContextProviders(scope, authorizationToken);
|
||||||
Item item = getItem(folderId, false, true);
|
Item item = getItem(folderId, false, true);
|
||||||
List<String> users = null;
|
List<Member> members = null;
|
||||||
if (item instanceof SharedFolder) {
|
if (item instanceof SharedFolder) {
|
||||||
SharedFolder sharedFolder = (SharedFolder) item;
|
SharedFolder sharedFolder = (SharedFolder) item;
|
||||||
|
String vreGroupName = null;
|
||||||
if (sharedFolder.isVreFolder()) {
|
if (sharedFolder.isVreFolder()) {
|
||||||
logger.info("Reading users from VRE folder by shClient.getVreFolderManager");
|
vreGroupName = Util.getVREGroupFromContext(scope);
|
||||||
users = shClient.getVreFolderManager(sharedFolder.getTitle()).getUsers();
|
logger.info("vreGroupName is: " + vreGroupName);
|
||||||
if (users == null) {
|
|
||||||
logger.warn("No users found, returning empty list of logins");
|
|
||||||
return new ArrayList<String>(1);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
logger.info("Reading users from ACLs");
|
logger.info("Reading users from ACLs");
|
||||||
List<ACL> listACL = shClient.open(folderId).asFolder().getAcls();
|
List<ACL> listACL = shClient.open(folderId).asFolder().getAcls();
|
||||||
if (listACL == null) {
|
if (listACL == null) {
|
||||||
throw new Exception("The item with " + folderId + " has not a valid ACLs");
|
throw new Exception("The item with " + folderId + " has not a valid ACLs");
|
||||||
}
|
}
|
||||||
users = new ArrayList<String>(listACL.size());
|
members = new ArrayList<Member>(listACL.size());
|
||||||
for (ACL acl : listACL) {
|
for (ACL acl : listACL) {
|
||||||
users.add(acl.getPricipal());
|
Member member = new Member(acl.getPricipal(), Member.TYPE.USER);
|
||||||
|
if (vreGroupName != null && item.getTitle() != null && item.getTitle().compareTo(vreGroupName) == 0) {
|
||||||
|
member.setMemberType(TYPE.GROUP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("The item with " + folderId + " is not a Shared Folder");
|
throw new Exception("The item with " + folderId + " is not a Shared Folder");
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Returning " + users.size() + " user/s");
|
logger.info("Returning " + members.size() + " user/s");
|
||||||
return users;
|
return members;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.gcube.common.storagehub.model.service.Version;
|
||||||
import org.gcube.common.storagehubwrapper.server.converter.HLMapper;
|
import org.gcube.common.storagehubwrapper.server.converter.HLMapper;
|
||||||
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
||||||
import org.gcube.common.storagehubwrapper.shared.ACLType;
|
import org.gcube.common.storagehubwrapper.shared.ACLType;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.Member;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InsufficientPrivilegesException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InsufficientPrivilegesException;
|
||||||
|
@ -684,7 +685,7 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
||||||
* @see org.gcube.portal.storagehubwrapper.server.tohl.Workspace#getSharedFolderMembers(java.lang.String)
|
* @see org.gcube.portal.storagehubwrapper.server.tohl.Workspace#getSharedFolderMembers(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<String> getSharedFolderMembers(String folderId) throws Exception {
|
public List<Member> getSharedFolderMembers(String folderId) throws Exception {
|
||||||
|
|
||||||
try{
|
try{
|
||||||
LOGGER.debug("called Shared Folder Members");
|
LOGGER.debug("called Shared Folder Members");
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.gcube.common.storagehub.model.items.Item;
|
||||||
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountEntry;
|
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountEntry;
|
||||||
import org.gcube.common.storagehubwrapper.server.WorkspaceStorageHubClientService;
|
import org.gcube.common.storagehubwrapper.server.WorkspaceStorageHubClientService;
|
||||||
import org.gcube.common.storagehubwrapper.shared.ACLType;
|
import org.gcube.common.storagehubwrapper.shared.ACLType;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.Member;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
||||||
|
@ -193,7 +194,7 @@ public interface Workspace {
|
||||||
* @return the shared folder members
|
* @return the shared folder members
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public List<String> getSharedFolderMembers(String folderid) throws Exception;
|
public List<Member> getSharedFolderMembers(String folderid) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if an item with the specified name exists in the specified folder.
|
* Check if an item with the specified name exists in the specified folder.
|
||||||
|
|
|
@ -0,0 +1,98 @@
|
||||||
|
package org.gcube.common.storagehubwrapper.shared;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class Member.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Apr 29, 2022
|
||||||
|
*/
|
||||||
|
public class Member implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1454948336452658186L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Enum TYPE.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Apr 29, 2022
|
||||||
|
*/
|
||||||
|
public static enum TYPE {
|
||||||
|
USER, GROUP
|
||||||
|
}
|
||||||
|
|
||||||
|
private String identity;
|
||||||
|
private TYPE memberType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new member.
|
||||||
|
*/
|
||||||
|
public Member() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Member(String identity, TYPE memberType) {
|
||||||
|
super();
|
||||||
|
this.identity = identity;
|
||||||
|
this.memberType = memberType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the identity.
|
||||||
|
*
|
||||||
|
* @return the identity
|
||||||
|
*/
|
||||||
|
public String getIdentity() {
|
||||||
|
return identity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the member type.
|
||||||
|
*
|
||||||
|
* @return the member type
|
||||||
|
*/
|
||||||
|
public TYPE getMemberType() {
|
||||||
|
return memberType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the identity.
|
||||||
|
*
|
||||||
|
* @param identity the new identity
|
||||||
|
*/
|
||||||
|
public void setIdentity(String identity) {
|
||||||
|
this.identity = identity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the member type.
|
||||||
|
*
|
||||||
|
* @param memberType the new member type
|
||||||
|
*/
|
||||||
|
public void setMemberType(TYPE memberType) {
|
||||||
|
this.memberType = memberType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To string.
|
||||||
|
*
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("Member [identity=");
|
||||||
|
builder.append(identity);
|
||||||
|
builder.append(", memberType=");
|
||||||
|
builder.append(memberType);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue