001    /**
002     * Copyright (c) 2000-2010 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.base.MembershipRequestServiceBaseImpl;
022    import com.liferay.portal.service.permission.GroupPermissionUtil;
023    
024    /**
025     * @author Jorge Ferrer
026     */
027    public class MembershipRequestServiceImpl
028            extends MembershipRequestServiceBaseImpl {
029    
030            public MembershipRequest addMembershipRequest(long groupId, String comments)
031                    throws PortalException, SystemException {
032    
033                    return membershipRequestLocalService.addMembershipRequest(
034                            getUserId(), groupId, comments);
035            }
036    
037            public void deleteMembershipRequests(long groupId, int statusId)
038                    throws PortalException, SystemException {
039    
040                    GroupPermissionUtil.check(
041                            getPermissionChecker(), groupId, ActionKeys.ASSIGN_MEMBERS);
042    
043                    membershipRequestLocalService.deleteMembershipRequests(
044                            groupId, statusId);
045            }
046    
047            public MembershipRequest getMembershipRequest(long membershipRequestId)
048                    throws SystemException, PortalException {
049    
050                    return membershipRequestLocalService.getMembershipRequest(
051                            membershipRequestId);
052            }
053    
054            public void updateStatus(
055                            long membershipRequestId, String reviewComments, int statusId)
056                    throws PortalException, SystemException {
057    
058                    MembershipRequest membershipRequest =
059                            membershipRequestPersistence.findByPrimaryKey(membershipRequestId);
060    
061                    GroupPermissionUtil.check(
062                            getPermissionChecker(), membershipRequest.getGroupId(),
063                            ActionKeys.ASSIGN_MEMBERS);
064    
065                    membershipRequestLocalService.updateStatus(
066                            getUserId(), membershipRequestId, reviewComments, statusId);
067            }
068    
069    }