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.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    }