diff --git a/.classpath b/.classpath
index 465f44d..7a5d917 100644
--- a/.classpath
+++ b/.classpath
@@ -11,7 +11,12 @@
-
+
+
+
+
+
+
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
index 839d647..29abf99 100644
--- a/.settings/org.eclipse.core.resources.prefs
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -2,4 +2,5 @@ eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
+encoding//src/test/resources=UTF-8
encoding/=UTF-8
diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
index 43e6002..42ab2a4 100644
--- a/.settings/org.eclipse.wst.common.component
+++ b/.settings/org.eclipse.wst.common.component
@@ -1,5 +1,7 @@
-
+
+
+
@@ -9,7 +11,9 @@
-
+
+
+
@@ -19,7 +23,9 @@
-
+
+
+
@@ -29,7 +35,9 @@
-
+
+
+
@@ -38,7 +46,9 @@
-
+
+
+
@@ -48,7 +58,9 @@
-
+
+
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b61cb95..b57c60a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,12 @@
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).
+## [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
#### Enhancements
diff --git a/pom.xml b/pom.xml
index 805fdac..e8acab8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
org.gcube.portlets.user
workspace-tree-widget
- 6.34.3
+ 6.35.0-SNAPSHOT
gCube Workspace Tree Widget
gCube Workspace Tree Widget is a widget to navigate and interact with gCube Workspace
diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/notifications/tostoragehub/NotificationStorageHubUtil.java b/src/main/java/org/gcube/portlets/user/workspace/server/notifications/tostoragehub/NotificationStorageHubUtil.java
index 2566285..73ca09a 100644
--- a/src/main/java/org/gcube/portlets/user/workspace/server/notifications/tostoragehub/NotificationStorageHubUtil.java
+++ b/src/main/java/org/gcube/portlets/user/workspace/server/notifications/tostoragehub/NotificationStorageHubUtil.java
@@ -9,6 +9,7 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest;
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.WorkspaceItem;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
@@ -160,18 +161,13 @@ public class NotificationStorageHubUtil {
if(isFolderAndShared(rootSharedFolder)){ //JUST TO BE SURE
- List listPortalLogin = workspace.getSharedFolderMembers(rootSharedFolder.getId());
- logger.debug("StorageHub returned "+ listPortalLogin.size() + " user/s");
+ List listMembers = workspace.getSharedFolderMembers(rootSharedFolder.getId());
+ logger.debug("StorageHub returned "+ listMembers.size() + " user/s");
if(!WsUtil.isWithinPortal())
- return StorageHubToWorkpaceConverter.buildGxtInfoContactFromPortalLoginTestMode(listPortalLogin);
-
- List listContacts = new ArrayList(listPortalLogin.size());
- for (String login : listPortalLogin) {
- listContacts.add(StorageHubToWorkpaceConverter.buildGxtInfoContactFromPortalLogin(login));
- }
+ return StorageHubToWorkpaceConverter.buildGxtInfoContactFromPortalLoginTestMode(listMembers);
- return listContacts;
+ return StorageHubToWorkpaceConverter.listMembersToListContact(listMembers);
}
else
logger.debug("the item with id: "+rootSharedFolder.getId()+ " is not "+WorkspaceItemType.SHARED_FOLDER);
diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/tostoragehub/StorageHubToWorkpaceConverter.java b/src/main/java/org/gcube/portlets/user/workspace/server/tostoragehub/StorageHubToWorkpaceConverter.java
index 6e54c78..0ae9e70 100644
--- a/src/main/java/org/gcube/portlets/user/workspace/server/tostoragehub/StorageHubToWorkpaceConverter.java
+++ b/src/main/java/org/gcube/portlets/user/workspace/server/tostoragehub/StorageHubToWorkpaceConverter.java
@@ -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.AccountFolderEntryRenaming;
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.WorkspaceItemType;
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.widgets.workspacesharingwidget.shared.InfoContactModel;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -134,7 +140,8 @@ public class StorageHubToWorkpaceConverter implements Serializable {
public FileModel toTreeFileModel(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem,
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);
}
@@ -149,11 +156,11 @@ public class StorageHubToWorkpaceConverter implements Serializable {
public FileGridModel toGridFileModel(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem,
FileModel parentFolderModel) throws InternalErrorException {
- FileGridModel fileGridModel = ObjectStorageHubToWorkpaceMapper.toGridFileModelItem(wrappedItem, parentFolderModel, loggedUser);
+ FileGridModel fileGridModel = ObjectStorageHubToWorkpaceMapper.toGridFileModelItem(wrappedItem,
+ parentFolderModel, loggedUser);
return (FileGridModel) setSynchedWithWsThredds(fileGridModel, wrappedItem);
}
-
-
+
protected FileModel setSynchedWithWsThredds(FileModel fileModel, WorkspaceItem wrappedItem) {
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);
}
+ public static List listMembersToListContact(List members) {
+ logger.info("listMembersToListContact called for " + members.size() + " member/s");
+
+ List listContacts = new ArrayList();
+ 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 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
* WORKSPACESPECIALFOLDER**** REMOVE THIS METHOD AND ADDING INSTANCE OF AT
@@ -346,7 +394,8 @@ public class StorageHubToWorkpaceConverter implements Serializable {
.isPublicFolder(); // TODO
FileModel parentModel = 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,
isPublicDir);
@@ -881,12 +930,12 @@ public class StorageHubToWorkpaceConverter implements Serializable {
return hashTestUser;
}
- public static List buildGxtInfoContactFromPortalLoginTestMode(List listPortalLogin) {
+ public static List buildGxtInfoContactFromPortalLoginTestMode(List listMemebers) {
List listContact = new ArrayList();
- for (String portalLogin : listPortalLogin)
- listContact.add(getHashTestUsers().get(portalLogin));
+ for (Member member : listMemebers)
+ listContact.add(getHashTestUsers().get(member.getIdentity()));
return listContact;
}
diff --git a/src/test/java/org/gcube/portlets/user/workspace/junit/WEA_AP_Reader.java b/src/test/java/org/gcube/portlets/user/workspace/junit/WEA_AP_Reader.java
index ff3dce6..83ea251 100644
--- a/src/test/java/org/gcube/portlets/user/workspace/junit/WEA_AP_Reader.java
+++ b/src/test/java/org/gcube/portlets/user/workspace/junit/WEA_AP_Reader.java
@@ -2,27 +2,25 @@ package org.gcube.portlets.user.workspace.junit;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.workspace.server.reader.ApplicationProfileReader;
-import org.junit.Test;
public class WEA_AP_Reader {
- String scope = "/gcube/devsec/devVRE";
- String resourceName = "Workspace-Explorer-App";
- String appID = "org.gcube.portlets.user.workspaceexplorerapp.server.WorkspaceExplorerAppServiceImpl";
+ public static String SCOPE = "/d4science.research-infrastructures.eu";
+ public static String resourceName = "Workspace-Explorer-App";
+ public static String appID = "org.gcube.portlets.user.workspaceexplorerapp.server.WorkspaceExplorerAppServiceImpl";
- @Test
+ // @Test
public void readAP() {
try {
// ScopeProvider.instance.set("/d4science.research-infrastructures.eu/D4Research/Limnodata");
- ScopeProvider.instance.set(scope);
+ ScopeProvider.instance.set(SCOPE);
ApplicationProfileReader ap = new ApplicationProfileReader(resourceName, appID);
- System.out.println("ApplicationProfile found: "+ap.readProfileFromInfrastrucure());
+ System.out.println("ApplicationProfile found: " + ap.readProfileFromInfrastrucure());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
-
}