001    /**
002     * Copyright (c) 2000-2013 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            @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    }