improved AcceptMembershipRequests method

This commit is contained in:
Massimiliano Assante 2020-10-19 12:49:58 +02:00
parent e93669c2f0
commit 4d01a9a38b
2 changed files with 8 additions and 7 deletions

View File

@ -4,11 +4,11 @@
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.2] - 2020-10-16
## [v2.5.2] - 2020-10-19
Bug Fix
[#19978] LiferayUserManager#listMembershipRequestsByGroup issue in returned list
[#19978] LiferayUserManager#listMembershipRequestsByGroup issue in returned list and improved AcceptMembershipRequests method
## [v2.5.1] [r4.25.0] - 2020-07-10

View File

@ -973,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();