001    /**
002     * Copyright (c) 2000-2012 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.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            public MembershipRequest addMembershipRequest(
032                            long groupId, String comments, ServiceContext serviceContext)
033                    throws PortalException, SystemException {
034    
035                    return membershipRequestLocalService.addMembershipRequest(
036                            getUserId(), groupId, comments, serviceContext);
037            }
038    
039            public void deleteMembershipRequests(long groupId, int statusId)
040                    throws PortalException, SystemException {
041    
042                    GroupPermissionUtil.check(
043                            getPermissionChecker(), groupId, ActionKeys.ASSIGN_MEMBERS);
044    
045                    membershipRequestLocalService.deleteMembershipRequests(
046                            groupId, statusId);
047            }
048    
049            public MembershipRequest getMembershipRequest(long membershipRequestId)
050                    throws PortalException, SystemException {
051    
052                    return membershipRequestLocalService.getMembershipRequest(
053                            membershipRequestId);
054            }
055    
056            public void updateStatus(
057                            long membershipRequestId, String reviewComments, int statusId,
058                            ServiceContext serviceContext)
059                    throws PortalException, SystemException {
060    
061                    MembershipRequest membershipRequest =
062                            membershipRequestPersistence.findByPrimaryKey(membershipRequestId);
063    
064                    GroupPermissionUtil.check(
065                            getPermissionChecker(), membershipRequest.getGroupId(),
066                            ActionKeys.ASSIGN_MEMBERS);
067    
068                    membershipRequestLocalService.updateStatus(
069                            getUserId(), membershipRequestId, reviewComments, statusId, true,
070                            serviceContext);
071            }
072    
073    }