Moved to v 6.35.0-SNAPSHOT. Updated the method

NotificationStorageHubUtil according to #23225
This commit is contained in:
Francesco Mangiacrapa 2022-05-02 15:11:48 +02:00
parent 0c0ead6389
commit 2f172d6b56
8 changed files with 100 additions and 33 deletions

View File

@ -11,7 +11,12 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</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">
<attributes>
<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/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=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">
@ -9,7 +11,9 @@
<wb-module deploy-name="workspace-tree-widget">
@ -19,7 +23,9 @@
<wb-resource deploy-path="/" source-path="/src/main/java"/>
@ -29,7 +35,9 @@
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
@ -38,7 +46,9 @@
<wb-resource deploy-path="/" source-path="/target/generated-sources/annotations"/>
@ -48,7 +58,9 @@
</wb-module>

View File

@ -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 VREs
## [v6.34.3] - 2022-03-24
#### Enhancements

View File

@ -11,7 +11,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>workspace-tree-widget</artifactId>
<version>6.34.3</version>
<version>6.35.0-SNAPSHOT</version>
<name>gCube Workspace Tree Widget</name>
<description>
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 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<String> listPortalLogin = workspace.getSharedFolderMembers(rootSharedFolder.getId());
logger.debug("StorageHub returned "+ listPortalLogin.size() + " user/s");
List<Member> listMembers = workspace.getSharedFolderMembers(rootSharedFolder.getId());
logger.debug("StorageHub returned "+ listMembers.size() + " user/s");
if(!WsUtil.isWithinPortal())
return StorageHubToWorkpaceConverter.buildGxtInfoContactFromPortalLoginTestMode(listPortalLogin);
List<InfoContactModel> listContacts = new ArrayList<InfoContactModel>(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);

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.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<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
* 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<InfoContactModel> buildGxtInfoContactFromPortalLoginTestMode(List<String> listPortalLogin) {
public static List<InfoContactModel> buildGxtInfoContactFromPortalLoginTestMode(List<Member> listMemebers) {
List<InfoContactModel> listContact = new ArrayList<InfoContactModel>();
for (String portalLogin : listPortalLogin)
listContact.add(getHashTestUsers().get(portalLogin));
for (Member member : listMemebers)
listContact.add(getHashTestUsers().get(member.getIdentity()));
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.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();
}
}
}