Merge pull request 'task_23225' (!4) from task_23225 into master

Reviewed-on: #4
This commit is contained in:
Francesco Mangiacrapa 2022-05-03 15:58:54 +02:00
commit 074f7866ea
8 changed files with 100 additions and 33 deletions

View File

@ -11,7 +11,12 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="src" path="src/test/resources"/> <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>

View File

@ -2,4 +2,5 @@ eclipse.preferences.version=1
encoding//src/main/java=UTF-8 encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8 encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8 encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8 encoding/<project>=UTF-8

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> <?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -9,7 +11,9 @@
<wb-module deploy-name="workspace-tree-widget"> <wb-module deploy-name="workspace-tree-widget">
@ -19,7 +23,9 @@
<wb-resource deploy-path="/" source-path="/src/main/java"/> <wb-resource deploy-path="/" source-path="/src/main/java"/>
@ -29,7 +35,9 @@
<wb-resource deploy-path="/" source-path="/src/main/resources"/> <wb-resource deploy-path="/" source-path="/src/main/resources"/>
@ -38,7 +46,9 @@
<wb-resource deploy-path="/" source-path="/target/generated-sources/annotations"/> <wb-resource deploy-path="/" source-path="/target/generated-sources/annotations"/>
@ -48,7 +58,9 @@
</wb-module> </wb-module>

View File

@ -4,6 +4,12 @@
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).
## [v6.35.0-SNAPSHOT] - 2022-05-02
#### Enhancements
- [#23225] Updated the method to read the members of (VRE or Simple) shared folders
## [v6.34.3] - 2022-03-24 ## [v6.34.3] - 2022-03-24
#### Enhancements #### Enhancements

View File

@ -11,7 +11,7 @@
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>workspace-tree-widget</artifactId> <artifactId>workspace-tree-widget</artifactId>
<version>6.34.3</version> <version>6.35.0-SNAPSHOT</version>
<name>gCube Workspace Tree Widget</name> <name>gCube Workspace Tree Widget</name>
<description> <description>
gCube Workspace Tree Widget is a widget to navigate and interact with gCube Workspace gCube Workspace Tree Widget is a widget to navigate and interact with gCube Workspace

View File

@ -9,6 +9,7 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.gcube.common.storagehub.model.types.WorkspaceItemType; import org.gcube.common.storagehub.model.types.WorkspaceItemType;
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;
@ -160,18 +161,13 @@ public class NotificationStorageHubUtil {
if(isFolderAndShared(rootSharedFolder)){ //JUST TO BE SURE if(isFolderAndShared(rootSharedFolder)){ //JUST TO BE SURE
List<String> listPortalLogin = workspace.getSharedFolderMembers(rootSharedFolder.getId()); List<Member> listMembers = workspace.getSharedFolderMembers(rootSharedFolder.getId());
logger.debug("StorageHub returned "+ listPortalLogin.size() + " user/s"); logger.debug("StorageHub returned "+ listMembers.size() + " user/s");
if(!WsUtil.isWithinPortal()) if(!WsUtil.isWithinPortal())
return StorageHubToWorkpaceConverter.buildGxtInfoContactFromPortalLoginTestMode(listPortalLogin); return StorageHubToWorkpaceConverter.buildGxtInfoContactFromPortalLoginTestMode(listMembers);
List<InfoContactModel> listContacts = new ArrayList<InfoContactModel>(listPortalLogin.size());
for (String login : listPortalLogin) {
listContacts.add(StorageHubToWorkpaceConverter.buildGxtInfoContactFromPortalLogin(login));
}
return listContacts; return StorageHubToWorkpaceConverter.listMembersToListContact(listMembers);
} }
else else
logger.debug("the item with id: "+rootSharedFolder.getId()+ " is not "+WorkspaceItemType.SHARED_FOLDER); logger.debug("the item with id: "+rootSharedFolder.getId()+ " is not "+WorkspaceItemType.SHARED_FOLDER);

View File

@ -25,6 +25,7 @@ import org.gcube.common.storagehub.model.items.nodes.accounting.AccountFolderEnt
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountFolderEntryRemoval; import org.gcube.common.storagehub.model.items.nodes.accounting.AccountFolderEntryRemoval;
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountFolderEntryRenaming; import org.gcube.common.storagehub.model.items.nodes.accounting.AccountFolderEntryRenaming;
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountingEntryType; import org.gcube.common.storagehub.model.items.nodes.accounting.AccountingEntryType;
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.WorkspaceItemType; import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItemType;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder; import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
@ -44,6 +45,11 @@ import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingEntryTyp
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField; import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel; import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import org.gcube.usecases.ws.thredds.model.ContainerType; import org.gcube.usecases.ws.thredds.model.ContainerType;
import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -134,7 +140,8 @@ public class StorageHubToWorkpaceConverter implements Serializable {
public FileModel toTreeFileModel(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem, public FileModel toTreeFileModel(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem,
FileModel parentFolderModel, Boolean isParentShared) throws InternalErrorException { FileModel parentFolderModel, Boolean isParentShared) throws InternalErrorException {
FileModel fileModel = ObjectStorageHubToWorkpaceMapper.toTreeFileModelItem(wrappedItem, parentFolderModel, isParentShared, loggedUser); FileModel fileModel = ObjectStorageHubToWorkpaceMapper.toTreeFileModelItem(wrappedItem, parentFolderModel,
isParentShared, loggedUser);
return setSynchedWithWsThredds(fileModel, wrappedItem); return setSynchedWithWsThredds(fileModel, wrappedItem);
} }
@ -149,11 +156,11 @@ public class StorageHubToWorkpaceConverter implements Serializable {
public FileGridModel toGridFileModel(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem, public FileGridModel toGridFileModel(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem,
FileModel parentFolderModel) throws InternalErrorException { FileModel parentFolderModel) throws InternalErrorException {
FileGridModel fileGridModel = ObjectStorageHubToWorkpaceMapper.toGridFileModelItem(wrappedItem, parentFolderModel, loggedUser); FileGridModel fileGridModel = ObjectStorageHubToWorkpaceMapper.toGridFileModelItem(wrappedItem,
parentFolderModel, loggedUser);
return (FileGridModel) setSynchedWithWsThredds(fileGridModel, wrappedItem); return (FileGridModel) setSynchedWithWsThredds(fileGridModel, wrappedItem);
} }
protected FileModel setSynchedWithWsThredds(FileModel fileModel, WorkspaceItem wrappedItem) { protected FileModel setSynchedWithWsThredds(FileModel fileModel, WorkspaceItem wrappedItem) {
logger.debug("called setSynchedThreddsStateFor item id: " + wrappedItem.getId()); logger.debug("called setSynchedThreddsStateFor item id: " + wrappedItem.getId());
@ -297,6 +304,47 @@ public class StorageHubToWorkpaceConverter implements Serializable {
return new InfoContactModel(portalLogin, portalLogin, fullName, emailDomain, false); return new InfoContactModel(portalLogin, portalLogin, fullName, emailDomain, false);
} }
public static List<InfoContactModel> listMembersToListContact(List<Member> members) {
logger.info("listMembersToListContact called for " + members.size() + " member/s");
List<InfoContactModel> listContacts = new ArrayList<InfoContactModel>();
UserManager userManager = new LiferayUserManager();
for (Member member : members) {
logger.debug("Resolving member: " + member);
boolean isGroup = member.getMemberType().equals(Member.TYPE.GROUP) ? true : false;
if (!isGroup) {
InfoContactModel icm = buildGxtInfoContactFromPortalLogin(member.getIdentity());
// HE/SHE IS A USER
listContacts.add(icm);
} else {
// HE/SHE IS A GROUP
logger.debug("The member: " + member + " is a group, resolving list of Users from "
+ LiferayUserManager.class.getSimpleName() + " for the group name: " + member.getName());
try {
List<GCubeUser> listUsers = userManager.listUsersByGroupName(member.getName());
if (listUsers != null) {
logger.debug("List of user for groupName are: " + listUsers.size());
for (GCubeUser user : listUsers) {
InfoContactModel icm = buildGxtInfoContactFromPortalLogin(user.getUsername());
listContacts.add(icm);
}
} else {
logger.warn("List of user for groupName: " + member.getName() + " is null");
}
} catch (UserManagementSystemException | GroupRetrievalFault | UserRetrievalFault e) {
logger.warn("Error occurrend on resolving the member: " + member.getName(), e);
}
}
}
logger.info("Returning " + listContacts.size() + " from members");
return listContacts;
}
/** /**
* TODO ********TEMPORARY SOLUTION HL MUST MANAGE SPECIAL FOLDER AS * TODO ********TEMPORARY SOLUTION HL MUST MANAGE SPECIAL FOLDER AS
* WORKSPACESPECIALFOLDER**** REMOVE THIS METHOD AND ADDING INSTANCE OF AT * WORKSPACESPECIALFOLDER**** REMOVE THIS METHOD AND ADDING INSTANCE OF AT
@ -346,7 +394,8 @@ public class StorageHubToWorkpaceConverter implements Serializable {
.isPublicFolder(); // TODO .isPublicFolder(); // TODO
FileModel parentModel = null; FileModel parentModel = null;
if (parent != null) if (parent != null)
parentModel = ObjectStorageHubToWorkpaceMapper.toTreeFileModelItem(parent, null, parent.isShared(), loggedUser); parentModel = ObjectStorageHubToWorkpaceMapper.toTreeFileModelItem(parent, null, parent.isShared(),
loggedUser);
FolderModel folder = new FolderModel(wsFolder.getId(), name, parentModel, true, wsFolder.isShared(), false, FolderModel folder = new FolderModel(wsFolder.getId(), name, parentModel, true, wsFolder.isShared(), false,
isPublicDir); isPublicDir);
@ -881,12 +930,12 @@ public class StorageHubToWorkpaceConverter implements Serializable {
return hashTestUser; return hashTestUser;
} }
public static List<InfoContactModel> buildGxtInfoContactFromPortalLoginTestMode(List<String> listPortalLogin) { public static List<InfoContactModel> buildGxtInfoContactFromPortalLoginTestMode(List<Member> listMemebers) {
List<InfoContactModel> listContact = new ArrayList<InfoContactModel>(); List<InfoContactModel> listContact = new ArrayList<InfoContactModel>();
for (String portalLogin : listPortalLogin) for (Member member : listMemebers)
listContact.add(getHashTestUsers().get(portalLogin)); listContact.add(getHashTestUsers().get(member.getIdentity()));
return listContact; return listContact;
} }

View File

@ -2,27 +2,25 @@ package org.gcube.portlets.user.workspace.junit;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.workspace.server.reader.ApplicationProfileReader; import org.gcube.portlets.user.workspace.server.reader.ApplicationProfileReader;
import org.junit.Test;
public class WEA_AP_Reader { public class WEA_AP_Reader {
String scope = "/gcube/devsec/devVRE"; public static String SCOPE = "/d4science.research-infrastructures.eu";
String resourceName = "Workspace-Explorer-App"; public static String resourceName = "Workspace-Explorer-App";
String appID = "org.gcube.portlets.user.workspaceexplorerapp.server.WorkspaceExplorerAppServiceImpl"; public static String appID = "org.gcube.portlets.user.workspaceexplorerapp.server.WorkspaceExplorerAppServiceImpl";
@Test // @Test
public void readAP() { public void readAP() {
try { try {
// ScopeProvider.instance.set("/d4science.research-infrastructures.eu/D4Research/Limnodata"); // ScopeProvider.instance.set("/d4science.research-infrastructures.eu/D4Research/Limnodata");
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(SCOPE);
ApplicationProfileReader ap = new ApplicationProfileReader(resourceName, appID); ApplicationProfileReader ap = new ApplicationProfileReader(resourceName, appID);
System.out.println("ApplicationProfile found: "+ap.readProfileFromInfrastrucure()); System.out.println("ApplicationProfile found: " + ap.readProfileFromInfrastrucure());
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
} }