1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portlet.polls.service.impl;
16  
17  import com.liferay.portal.PortalException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.security.permission.ActionKeys;
20  import com.liferay.portal.service.ServiceContext;
21  import com.liferay.portlet.polls.model.PollsChoice;
22  import com.liferay.portlet.polls.model.PollsQuestion;
23  import com.liferay.portlet.polls.service.base.PollsQuestionServiceBaseImpl;
24  import com.liferay.portlet.polls.service.permission.PollsPermission;
25  import com.liferay.portlet.polls.service.permission.PollsQuestionPermission;
26  
27  import java.util.List;
28  
29  /**
30   * <a href="PollsQuestionServiceImpl.java.html"><b><i>View Source</i></b></a>
31   *
32   * @author Brian Wing Shun Chan
33   */
34  public class PollsQuestionServiceImpl extends PollsQuestionServiceBaseImpl {
35  
36      public PollsQuestion addQuestion(
37              String title, String description, int expirationDateMonth,
38              int expirationDateDay, int expirationDateYear,
39              int expirationDateHour,int expirationDateMinute,
40              boolean neverExpire, List<PollsChoice> choices,
41              ServiceContext serviceContext)
42          throws PortalException, SystemException {
43  
44          PollsPermission.check(
45              getPermissionChecker(), serviceContext.getScopeGroupId(),
46              ActionKeys.ADD_QUESTION);
47  
48          return pollsQuestionLocalService.addQuestion(
49              getUserId(), title, description, expirationDateMonth,
50              expirationDateDay, expirationDateYear, expirationDateHour,
51              expirationDateMinute, neverExpire, choices, serviceContext);
52      }
53  
54      public void deleteQuestion(long questionId)
55          throws PortalException, SystemException {
56  
57          PollsQuestionPermission.check(
58              getPermissionChecker(), questionId, ActionKeys.DELETE);
59  
60          pollsQuestionLocalService.deleteQuestion(questionId);
61      }
62  
63      public PollsQuestion getQuestion(long questionId)
64          throws PortalException, SystemException {
65  
66          PollsQuestionPermission.check(
67              getPermissionChecker(), questionId, ActionKeys.VIEW);
68  
69          return pollsQuestionLocalService.getQuestion(questionId);
70      }
71  
72      public PollsQuestion updateQuestion(
73              long questionId, String title, String description,
74              int expirationDateMonth, int expirationDateDay,
75              int expirationDateYear, int expirationDateHour,
76              int expirationDateMinute, boolean neverExpire,
77              List<PollsChoice> choices, ServiceContext serviceContext)
78          throws PortalException, SystemException {
79  
80          PollsQuestionPermission.check(
81              getPermissionChecker(), questionId, ActionKeys.UPDATE);
82  
83          return pollsQuestionLocalService.updateQuestion(
84              getUserId(), questionId, title, description, expirationDateMonth,
85              expirationDateDay, expirationDateYear, expirationDateHour,
86              expirationDateMinute, neverExpire, choices, serviceContext);
87      }
88  
89  }