001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.service.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.model.MembershipRequest;
020    import com.liferay.portal.security.permission.ActionKeys;
021    import com.liferay.portal.service.ServiceContext;
022    import com.liferay.portal.service.base.MembershipRequestServiceBaseImpl;
023    import com.liferay.portal.service.permission.GroupPermissionUtil;
024    
025    /**
026     * @author Jorge Ferrer
027     */
028    public class MembershipRequestServiceImpl
029            extends MembershipRequestServiceBaseImpl {
030    
031            @Override
032            public MembershipRequest addMembershipRequest(
033                            long groupId, String comments, ServiceContext serviceContext)
034                    throws PortalException, SystemException {
035    
036                    return membershipRequestLocalService.addMembershipRequest(
037                            getUserId(), groupId, comments, serviceContext);
038            }
039    
040            @Override
041            public void deleteMembershipRequests(long groupId, int statusId)
042                    throws PortalException, SystemException {
043    
044                    GroupPermissionUtil.check(
045                            getPermissionChecker(), groupId, ActionKeys.ASSIGN_MEMBERS);
046    
047                    membershipRequestLocalService.deleteMembershipRequests(
048                            groupId, statusId);
049            }
050    
051            @Override
052            public MembershipRequest getMembershipRequest(long membershipRequestId)
053                    throws PortalException, SystemException {
054    
055                    return membershipRequestLocalService.getMembershipRequest(
056                            membershipRequestId);
057            }
058    
059            @Override
060            public void updateStatus(
061                            long membershipRequestId, String reviewComments, int statusId,
062                            ServiceContext serviceContext)
063                    throws PortalException, SystemException {
064    
065                    MembershipRequest membershipRequest =
066                            membershipRequestPersistence.findByPrimaryKey(membershipRequestId);
067    
068                    GroupPermissionUtil.check(
069                            getPermissionChecker(), membershipRequest.getGroupId(),
070                            ActionKeys.ASSIGN_MEMBERS);
071    
072                    membershipRequestLocalService.updateStatus(
073                            getUserId(), membershipRequestId, reviewComments, statusId, true,
074                            serviceContext);
075            }
076    
077    }