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