1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.polls.service.impl;
24  
25  import com.liferay.portal.PortalException;
26  import com.liferay.portal.SystemException;
27  import com.liferay.portal.security.permission.ActionKeys;
28  import com.liferay.portal.service.ServiceContext;
29  import com.liferay.portlet.polls.model.PollsChoice;
30  import com.liferay.portlet.polls.model.PollsQuestion;
31  import com.liferay.portlet.polls.service.base.PollsQuestionServiceBaseImpl;
32  import com.liferay.portlet.polls.service.permission.PollsPermission;
33  import com.liferay.portlet.polls.service.permission.PollsQuestionPermission;
34  
35  import java.util.List;
36  
37  /**
38   * <a href="PollsQuestionServiceImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * @author Brian Wing Shun Chan
41   */
42  public class PollsQuestionServiceImpl extends PollsQuestionServiceBaseImpl {
43  
44      public PollsQuestion addQuestion(
45              String title, String description, int expirationDateMonth,
46              int expirationDateDay, int expirationDateYear,
47              int expirationDateHour,int expirationDateMinute,
48              boolean neverExpire, List<PollsChoice> choices,
49              ServiceContext serviceContext)
50          throws PortalException, SystemException {
51  
52          PollsPermission.check(
53              getPermissionChecker(), serviceContext.getScopeGroupId(),
54              ActionKeys.ADD_QUESTION);
55  
56          return pollsQuestionLocalService.addQuestion(
57              getUserId(), title, description, expirationDateMonth,
58              expirationDateDay, expirationDateYear, expirationDateHour,
59              expirationDateMinute, neverExpire, choices, serviceContext);
60      }
61  
62      public void deleteQuestion(long questionId)
63          throws PortalException, SystemException {
64  
65          PollsQuestionPermission.check(
66              getPermissionChecker(), questionId, ActionKeys.DELETE);
67  
68          pollsQuestionLocalService.deleteQuestion(questionId);
69      }
70  
71      public PollsQuestion getQuestion(long questionId)
72          throws PortalException, SystemException {
73  
74          PollsQuestionPermission.check(
75              getPermissionChecker(), questionId, ActionKeys.VIEW);
76  
77          return pollsQuestionLocalService.getQuestion(questionId);
78      }
79  
80      public PollsQuestion updateQuestion(
81              long questionId, String title, String description,
82              int expirationDateMonth, int expirationDateDay,
83              int expirationDateYear, int expirationDateHour,
84              int expirationDateMinute, boolean neverExpire,
85              List<PollsChoice> choices, ServiceContext serviceContext)
86          throws PortalException, SystemException {
87  
88          PollsQuestionPermission.check(
89              getPermissionChecker(), questionId, ActionKeys.UPDATE);
90  
91          return pollsQuestionLocalService.updateQuestion(
92              getUserId(), questionId, title, description, expirationDateMonth,
93              expirationDateDay, expirationDateYear, expirationDateHour,
94              expirationDateMinute, neverExpire, choices, serviceContext);
95      }
96  
97  }