1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.tasks.service.impl;
16  
17  import com.liferay.portal.kernel.exception.PortalException;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.security.permission.ActionKeys;
20  import com.liferay.portal.service.permission.GroupPermissionUtil;
21  import com.liferay.portlet.tasks.model.TasksProposal;
22  import com.liferay.portlet.tasks.model.TasksReview;
23  import com.liferay.portlet.tasks.service.base.TasksReviewServiceBaseImpl;
24  
25  /**
26   * <a href="TasksReviewServiceImpl.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Raymond Augé
29   * @author Brian Wing Shun Chan
30   */
31  public class TasksReviewServiceImpl extends TasksReviewServiceBaseImpl {
32  
33      public TasksReview approveReview(long proposalId, int stage)
34          throws PortalException, SystemException {
35  
36          TasksProposal proposal = tasksProposalPersistence.findByPrimaryKey(
37              proposalId);
38  
39          GroupPermissionUtil.check(
40              getPermissionChecker(), proposal.getGroupId(),
41              ActionKeys.APPROVE_PROPOSAL);
42  
43          return tasksReviewLocalService.approveReview(
44              getUserId(), proposalId, stage);
45      }
46  
47      public TasksReview rejectReview(long proposalId, int stage)
48          throws PortalException, SystemException {
49  
50          TasksProposal proposal = tasksProposalPersistence.findByPrimaryKey(
51              proposalId);
52  
53          GroupPermissionUtil.check(
54              getPermissionChecker(), proposal.getGroupId(),
55              ActionKeys.APPROVE_PROPOSAL);
56  
57          return tasksReviewLocalService.rejectReview(
58              getUserId(), proposalId, stage);
59      }
60  
61      public void updateReviews(long proposalId, long[][] userIdsPerStage)
62          throws PortalException, SystemException {
63  
64          TasksProposal proposal = tasksProposalPersistence.findByPrimaryKey(
65              proposalId);
66  
67          GroupPermissionUtil.check(
68              getPermissionChecker(), proposal.getGroupId(),
69              ActionKeys.ASSIGN_REVIEWER);
70  
71          tasksReviewLocalService.updateReviews(
72              proposalId, getUserId(), userIdsPerStage);
73      }
74  
75  }