Compare commits

...

13 Commits

15 changed files with 195 additions and 215 deletions

View File

@ -27,7 +27,7 @@
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="owner.project.facets" value="java"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>

View File

@ -3,7 +3,9 @@ org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8

64
CHANGELOG.md Normal file
View File

@ -0,0 +1,64 @@
# Changelog for user management library
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).
## [v2.5.4] - 2022-07-06
- Feature #23622 added Catalogue-Manager and Moderator roles
## [v2.5.3] - 2021-04-12
[#20889] UserManagement enhancement: add the roles "Data-Editor"
## [v2.5.2] - 2020-10-19
Bug Fix
[#19978] LiferayUserManager#listMembershipRequestsByGroup issue in returned list and improved AcceptMembershipRequests method
## [v2.5.1]- 2020-07-10
[#19603]Enhance performance of VRE membership requests retrieval by adding dedicated method for retrieving pending requests by groupid
## [v2.5.0] - 2020-03-21
Added getRandomAdmin user method and(improved performance for method for getting listUsersByGroupAndRole
## [v2.4.2] - 2019-02-28
[#16190] Avoid returning Liferay Site Roles in UserManagement Core Library
## [v2.4.0] - 2018-03-08
Create user method automatic set email as verified
Added list users methods by range
Added search users method by groupId and Keywords
## [v2.3.1] - 2017-07-01
Improvements on Liferay's JSON APIs.
## [v2.3.0] - 2017-02-01
Added partial support to Liferay's JSON apis.
## [v2.2.0] - 2016-012-06
Added method to read VirtualGroups associated to sites
[#6115] Fix for bug
## [v2.1.0] - 2016-09-28
Added efficient method to retireve VRE logo URLs
Replaced logging from liferay so that it is possible to change level at runtime
## [v2.0.0] - 2016-06-23
First release after upgrading to Liferay 6.2

26
FUNDING.md Normal file
View File

@ -0,0 +1,26 @@
# Acknowledgments
The projects leading to this software have received funding from a series of European Union programmes including:
- the Sixth Framework Programme for Research and Technological Development
- [DILIGENT](https://cordis.europa.eu/project/id/004260) (grant no. 004260).
- the Seventh Framework Programme for research, technological development and demonstration
- [D4Science](https://cordis.europa.eu/project/id/212488) (grant no. 212488);
- [D4Science-II](https://cordis.europa.eu/project/id/239019) (grant no.239019);
- [ENVRI](https://cordis.europa.eu/project/id/283465) (grant no. 283465);
- [iMarine](https://cordis.europa.eu/project/id/283644) (grant no. 283644);
- [EUBrazilOpenBio](https://cordis.europa.eu/project/id/288754) (grant no. 288754).
- the H2020 research and innovation programme
- [SoBigData](https://cordis.europa.eu/project/id/654024) (grant no. 654024);
- [PARTHENOS](https://cordis.europa.eu/project/id/654119) (grant no. 654119);
- [EGI-Engage](https://cordis.europa.eu/project/id/654142) (grant no. 654142);
- [ENVRI PLUS](https://cordis.europa.eu/project/id/654182) (grant no. 654182);
- [BlueBRIDGE](https://cordis.europa.eu/project/id/675680) (grant no. 675680);
- [PerformFISH](https://cordis.europa.eu/project/id/727610) (grant no. 727610);
- [AGINFRA PLUS](https://cordis.europa.eu/project/id/731001) (grant no. 731001);
- [DESIRA](https://cordis.europa.eu/project/id/818194) (grant no. 818194);
- [ARIADNEplus](https://cordis.europa.eu/project/id/823914) (grant no. 823914);
- [RISIS 2](https://cordis.europa.eu/project/id/824091) (grant no. 824091);
- [EOSC-Pillar](https://cordis.europa.eu/project/id/857650) (grant no. 857650);
- [Blue Cloud](https://cordis.europa.eu/project/id/862409) (grant no. 862409);
- [SoBigData-PlusPlus](https://cordis.europa.eu/project/id/871042) (grant no. 871042);

View File

@ -19,11 +19,11 @@ See [Releases](https://code-repo.d4science.org/gCubeSystem/usermanagement-core/r
## Authors
* **Massimiliano Assante** - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience)
* **Massimiliano Assante** ([ORCID](https://orcid.org/0000-0002-3761-1492)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/People/M.Assante)
## Maintainers
* **Massimiliano Assante** - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience)
* **Massimiliano Assante** ([ORCID](https://orcid.org/0000-0002-3761-1492)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/People/M.Assante)
## License
@ -36,12 +36,4 @@ open-source software toolkit used for building and operating Hybrid Data
Infrastructures enabling the dynamic deployment of Virtual Research Environments
by favouring the realisation of reuse oriented policies.
The projects leading to this software have received funding from a series of European Union programmes including:
- the Sixth Framework Programme for Research and Technological Development
- DILIGENT (grant no. 004260);
- the Seventh Framework Programme for research, technological development and demonstration
- D4Science (grant no. 212488), D4Science-II (grant no.239019), ENVRI (grant no. 283465), EUBrazilOpenBio (grant no. 288754), iMarine(grant no. 283644);
- the H2020 research and innovation programme
- BlueBRIDGE (grant no. 675680), EGIEngage (grant no. 654142), ENVRIplus (grant no. 654182), Parthenos (grant no. 654119), SoBigData (grant no. 654024),DESIRA (grant no. 818194), ARIADNEplus (grant no. 823914), RISIS2 (grant no. 824091), PerformFish (grant no. 727610), AGINFRAplus (grant no. 731001);
The projects leading to this software have received funding from a series of European Union programmes see [FUNDING.md](FUNDING.md)

View File

@ -1 +0,0 @@
${gcube.license}

View File

@ -1,45 +0,0 @@
The gCube System
------------------------------------------------------------
${gcube.description}
${gcube.funding}
Version
--------------------------------------------------
${version} (${buildDate})
Please see the file named "changelog.xml" in this directory for the release notes.
Authors
-------
Massimiliano Assante (massimiliano.assante-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
Maintainers
-----------
Massimiliano Assante (massimiliano.assante-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
Documentation
-------------
Documentation is available on - line from the Projects Documentation wiki:
{gcube.wikiRoot}/gcube/index.php/UserManagement_Core
Support
--------------------------------------------------
Bugs and support requests can be reported in the gCube issue tracking tool:
${gcube.issueTracking}
Licensing
--------------------------------------------------
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.

View File

@ -1,73 +0,0 @@
<ReleaseNotes>
<Changeset
component="org.gcube.vo-management.usermanagement-core.2-5-0"
date="2020-03-21">
<Change>Added getRandomAdmin user method and(improved performance for
method for getting listUsersByGroupAndRole
</Change>
<Change>Ported to Git</Change>
</Changeset>
<Changeset
component="org.gcube.vo-management.usermanagement-core.2-4-2"
date="2019-02-28">
<Change>Feature #16190, avoid returning Liferay Site Roles in
UserManagement Core Library
</Change>
</Changeset>
<Changeset
component="org.gcube.vo-management.usermanagement-core.2-4-0"
date="2018-03-08">
<Change>Create user method automatic set email as verified
</Change>
<Change>Added list users methods by range
</Change>
<Change>Added search users method by groupId and Keywords
</Change>
</Changeset>
<Changeset
component="org.gcube.vo-management.usermanagement-core.2-3-2"
date="2017-12-01">
<Change>Added user number to group model.
</Change>
</Changeset>
<Changeset
component="org.gcube.vo-management.usermanagement-core.2-3-1"
date="2017-08-01">
<Change>Improvements on Liferay's APIs.
</Change>
</Changeset>
<Changeset
component="org.gcube.vo-management.usermanagement-core.2-3-1"
date="2017-07-01">
<Change>Improvements on Liferay's APIs.
</Change>
</Changeset>
<Changeset
component="org.gcube.vo-management.usermanagement-core.2-3-0"
date="2017-02-01">
<Change>Added partial support to Liferay's JSON apis.
</Change>
</Changeset>
<Changeset
component="org.gcube.vo-management.usermanagement-core.2-2-0"
date="2016-12-06">
<Change>Added method to read VirtualGroups associated to sites
</Change>
<Change>Fix for bug #6115
</Change>
</Changeset>
<Changeset
component="org.gcube.vo-management.usermanagement-core.2-1-0"
date="2016-09-28">
<Change>Added efficient method to retireve VRE logo URLs</Change>
<Change>Replaced logging from liferay so that it is possible to
change
level at runtime
</Change>
</Changeset>
<Changeset
component="org.gcube.vo-management.usermanagement-core.2-0-0"
date="2016-06-23">
<Change>First release after upgrading to Liferay 6.2</Change>
</Changeset>
</ReleaseNotes>

View File

@ -1,41 +0,0 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>servicearchive</id>
<formats>
<format>tar.gz</format>
</formats>
<baseDirectory>/</baseDirectory>
<fileSets>
<fileSet>
<directory>${distroDirectory}</directory>
<outputDirectory>/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<includes>
<include>README</include>
<include>LICENSE</include>
<include>changelog.xml</include>
</includes>
<fileMode>755</fileMode>
<filtered>true</filtered>
</fileSet>
<fileSet>
<directory>target/apidocs</directory>
<outputDirectory>/${artifactId}/doc/api</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<fileMode>755</fileMode>
</fileSet>
</fileSets>
<files>
<file>
<source>${distroDirectory}/profile.xml</source>
<outputDirectory>./</outputDirectory>
<filtered>true</filtered>
</file>
<file>
<source>target/${build.finalName}.jar</source>
<outputDirectory>/${artifactId}</outputDirectory>
</file>
</files>
</assembly>

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ID></ID>
<Type>Library</Type>
<Profile>
<Description>ASL Social Library</Description>
<Class>ApplicationSupportLayer</Class>
<Name>${artifactId}</Name>
<Version>1.0.0</Version>
<Packages>
<Software>
<Name>${artifactId}</Name>
<Version>${version}</Version>
<MavenCoordinates>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
</MavenCoordinates>
<Files>
<File>${build.finalName}.jar</File>
</Files>
</Software>
</Packages>
</Profile>
</Resource>

View File

@ -10,7 +10,7 @@
</parent>
<groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId>
<version>2.5.0</version>
<version>2.5.4</version>
<packaging>jar</packaging>
<name>User Management API</name>
@ -25,8 +25,6 @@
<properties>
<liferay.version>6.2.5</liferay.version>
<distroDirectory>distro</distroDirectory>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<json.simple.version>1.1.1</json.simple.version>
@ -37,7 +35,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>3.6.0</version>
<version>3.6.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -71,7 +69,6 @@
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>${json.simple.version}</version>
</dependency>
</dependencies>
<build>

View File

@ -297,6 +297,15 @@ public interface UserManager {
* @throws UserRetrievalFault
*/
List<GCubeMembershipRequest> listMembershipRequestsByGroup(long groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
/**
*
* @param groupId the LR groupId
* @return the list of {@link GCubeMembershipRequest} with status requested and users given the LR GroupId @see {@link MembershipRequestStatus}
* @throws UserManagementSystemException
* @throws GroupRetrievalFault
* @throws UserRetrievalFault
*/
List<GCubeMembershipRequest> listPendingMembershipRequestsByGroup(long groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
/**
*
* @param requestId

View File

@ -29,6 +29,9 @@ import org.gcube.vomanagement.usermanagement.model.GatewayRolesNames;
import org.gcube.vomanagement.usermanagement.model.MembershipRequestStatus;
import org.gcube.vomanagement.usermanagement.util.ManagementUtils;
import com.liferay.portal.kernel.dao.orm.DynamicQuery;
import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
@ -38,6 +41,7 @@ import com.liferay.portal.kernel.util.DigesterUtil;
import com.liferay.portal.kernel.util.HttpUtil;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.OrderByComparatorFactoryUtil;
import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
import com.liferay.portal.model.Contact;
import com.liferay.portal.model.EmailAddress;
import com.liferay.portal.model.Group;
@ -878,10 +882,63 @@ public class LiferayUserManager implements UserManager {
} catch (SystemException e) {
e.printStackTrace();
}
DynamicQuery queryListPendingMembershipRequestsByGroup = DynamicQueryFactoryUtil.forClass
(MembershipRequest.class, PortalClassLoaderUtil.getClassLoader());
queryListPendingMembershipRequestsByGroup.add(PropertyFactoryUtil.forName("groupId").eq(new Long(groupId)));
List<GCubeMembershipRequest> toReturn = new ArrayList<GCubeMembershipRequest>();
try {
int requestesNo = MembershipRequestLocalServiceUtil.getMembershipRequestsCount();
for (MembershipRequest req : MembershipRequestLocalServiceUtil.getMembershipRequests(0, requestesNo)) {
@SuppressWarnings("unchecked")
List<MembershipRequest> list = MembershipRequestLocalServiceUtil.dynamicQuery(queryListPendingMembershipRequestsByGroup);
for (MembershipRequest req : list) {
if (req.getGroupId() == groupId) {
try {
toReturn.add(mapLRMembershipRequest(req));
} catch (com.liferay.portal.NoSuchUserException e) {
_log.warn("Could not map membership request, userid no longer exists: "+req.getUserId());
}
}
}
} catch (SystemException e) {
e.printStackTrace();
} catch (PortalException e) {
e.printStackTrace();
}
return toReturn;
}
/*
* MEMBERSHIP REQUESTS
*/
/**
* {@inheritDoc}
*/
@Override
public List<GCubeMembershipRequest> listPendingMembershipRequestsByGroup(long groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault {
try {
Group g = GroupLocalServiceUtil.getGroup(groupId);
_log.debug("Asked for pending users list of group: "+g.getName());
} catch (PortalException e1) {
throw new GroupRetrievalFault("Group not existing", groupId, e1);
} catch (SystemException e) {
e.printStackTrace();
}
DynamicQuery queryListPendingMembershipRequestsByGroup = DynamicQueryFactoryUtil.forClass
(MembershipRequest.class, PortalClassLoaderUtil.getClassLoader());
queryListPendingMembershipRequestsByGroup.add(PropertyFactoryUtil.forName("statusId").eq(new Integer ("2")));
queryListPendingMembershipRequestsByGroup.add(PropertyFactoryUtil.forName("groupId").eq(new Long(groupId)));
List<GCubeMembershipRequest> toReturn = new ArrayList<GCubeMembershipRequest>();
try {
@SuppressWarnings("unchecked")
List<MembershipRequest> list = MembershipRequestLocalServiceUtil.dynamicQuery(queryListPendingMembershipRequestsByGroup);
for (MembershipRequest req : list) {
if (req.getGroupId() == groupId) {
toReturn.add(mapLRMembershipRequest(req));
}
@ -916,16 +973,17 @@ public class LiferayUserManager implements UserManager {
public GCubeMembershipRequest acceptMembershipRequest(long requestUserId,long groupId, boolean addUserToGroup, String replyUsername, String replyComment) throws UserManagementSystemException, GroupRetrievalFault, UserManagementPortalException {
try {
GCubeUser replyMan = getUserByUsername(replyUsername);
List<GCubeMembershipRequest> requests = listMembershipRequestsByGroup(groupId);
for (GCubeMembershipRequest req : requests) {
if (req.getRequestingUser().getUserId() == requestUserId) {
List<MembershipRequest> requests = MembershipRequestLocalServiceUtil.getMembershipRequests(requestUserId, groupId, 0);
//List<GCubeMembershipRequest> requests = listMembershipRequestsByGroup(groupId);
for (MembershipRequest req : requests) {
if (req.getUserId() == requestUserId) {
MembershipRequestLocalServiceUtil.updateStatus(replyMan.getUserId(), req.getMembershipRequestId(), replyComment, 1, addUserToGroup, new ServiceContext());
//the method above just adds the user to the VRE, it is needed to add the user to the parent Sites as well (VO and RootVO)
assignUserToGroup(GroupLocalServiceUtil.getGroup(groupId).getParentGroupId(), requestUserId);
_log.info("Accepted membership request: requestUserId="+requestUserId);
return mapLRMembershipRequest(MembershipRequestLocalServiceUtil.getMembershipRequest(req.getMembershipRequestId()));
}
}
}
} catch (UserRetrievalFault e) {
e.printStackTrace();

View File

@ -466,6 +466,14 @@ public class LiferayWSUserManager implements UserManager{
// TODO Auto-generated method stub
return null;
}
@Override
public List<GCubeMembershipRequest> listPendingMembershipRequestsByGroup(
long groupId) throws UserManagementSystemException,
GroupRetrievalFault, UserRetrievalFault {
// TODO Auto-generated method stub
return null;
}
@Override
public GCubeMembershipRequest getMembershipRequestsById(

View File

@ -1,13 +1,22 @@
package org.gcube.vomanagement.usermanagement.model;
/**
* @deprecated As of gCube 5.13 version please refer to <a href="https://code-repo.d4science.org/gCubeSystem/oidc-library">oidc-library</a>
*
*/
@Deprecated
public enum GatewayRolesNames {
ACCOUNTING_MANAGER("Accounting-Manager"),
CATALOGUE_ADMIN("Catalogue-Admin"),
CATALOGUE_EDITOR("Catalogue-Editor"),
CATALOGUE_MANAGER("Catalogue-Manager"),
CATALOGUE_MODERATOR("Catalogue-Moderator"),
INFRASTRUCTURE_MANAGER("Infrastructure-Manager"),
DATAMINER_MANAGER("DataMiner-Manager"),
DATA_MANAGER("Data-Manager"),
DATA_EDITOR("Data-Editor"),
VRE_MANAGER("VRE-Manager"),
VRE_DESIGNER("VRE-Designer"),
VO_ADMIN("VO-Admin"),
INFRASTRUCTURE_MANAGER("Infrastructure-Manager"),
DATA_MANAGER("Data-Manager"),
CATALOGUE_ADMIN("Catalogue-Admin"),
CATALOGUE_EDITOR("Catalogue-Editor");
VO_ADMIN("VO-Admin");
private String name;