public void updateStatus( long replierUserId, long membershipRequestId, String replyComments, int statusId) throws PortalException, SystemException { validate(replyComments); MembershipRequest membershipRequest = membershipRequestPersistence.findByPrimaryKey(membershipRequestId); membershipRequest.setReplyComments(replyComments); membershipRequest.setReplyDate(new Date()); membershipRequest.setReplierUserId(replierUserId); membershipRequest.setStatusId(statusId); membershipRequestPersistence.update(membershipRequest, false); if (statusId == MembershipRequestConstants.STATUS_APPROVED) { long[] addUserIds = new long[] {membershipRequest.getUserId()}; userLocalService.addGroupUsers(membershipRequest.getGroupId(), addUserIds); } try { notify( membershipRequest.getUserId(), membershipRequest, PropsKeys.COMMUNITIES_EMAIL_MEMBERSHIP_REPLY_SUBJECT, PropsKeys.COMMUNITIES_EMAIL_MEMBERSHIP_REPLY_BODY); } catch (IOException ioe) { throw new SystemException(ioe); } }
public MembershipRequest addMembershipRequest(long userId, long groupId, String comments) throws PortalException, SystemException { User user = userPersistence.findByPrimaryKey(userId); Date now = new Date(); validate(comments); long membershipRequestId = counterLocalService.increment(); MembershipRequest membershipRequest = membershipRequestPersistence.create(membershipRequestId); membershipRequest.setCompanyId(user.getCompanyId()); membershipRequest.setUserId(userId); membershipRequest.setCreateDate(now); membershipRequest.setGroupId(groupId); membershipRequest.setComments(comments); membershipRequest.setStatusId(MembershipRequestConstants.STATUS_PENDING); membershipRequestPersistence.update(membershipRequest, false); try { notifyCommunityAdministrators(membershipRequest); } catch (IOException ioe) { throw new SystemException(ioe); } return membershipRequest; }