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.portlet.tasks.service.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.security.permission.ActionKeys;
020    import com.liferay.portal.service.permission.GroupPermissionUtil;
021    import com.liferay.portlet.tasks.model.TasksProposal;
022    import com.liferay.portlet.tasks.model.TasksReview;
023    import com.liferay.portlet.tasks.service.base.TasksReviewServiceBaseImpl;
024    
025    /**
026     * @author Raymond Augé
027     * @author Brian Wing Shun Chan
028     */
029    public class TasksReviewServiceImpl extends TasksReviewServiceBaseImpl {
030    
031            public TasksReview approveReview(long proposalId, int stage)
032                    throws PortalException, SystemException {
033    
034                    TasksProposal proposal = tasksProposalPersistence.findByPrimaryKey(
035                            proposalId);
036    
037                    GroupPermissionUtil.check(
038                            getPermissionChecker(), proposal.getGroupId(),
039                            ActionKeys.APPROVE_PROPOSAL);
040    
041                    return tasksReviewLocalService.approveReview(
042                            getUserId(), proposalId, stage);
043            }
044    
045            public TasksReview rejectReview(long proposalId, int stage)
046                    throws PortalException, SystemException {
047    
048                    TasksProposal proposal = tasksProposalPersistence.findByPrimaryKey(
049                            proposalId);
050    
051                    GroupPermissionUtil.check(
052                            getPermissionChecker(), proposal.getGroupId(),
053                            ActionKeys.APPROVE_PROPOSAL);
054    
055                    return tasksReviewLocalService.rejectReview(
056                            getUserId(), proposalId, stage);
057            }
058    
059            public void updateReviews(long proposalId, long[][] userIdsPerStage)
060                    throws PortalException, SystemException {
061    
062                    TasksProposal proposal = tasksProposalPersistence.findByPrimaryKey(
063                            proposalId);
064    
065                    GroupPermissionUtil.check(
066                            getPermissionChecker(), proposal.getGroupId(),
067                            ActionKeys.ASSIGN_REVIEWER);
068    
069                    tasksReviewLocalService.updateReviews(
070                            proposalId, getUserId(), userIdsPerStage);
071            }
072    
073    }