001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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    }