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.permission.PortletPermissionUtil;
29  import com.liferay.portal.util.PortletKeys;
30  import com.liferay.portlet.polls.model.PollsChoice;
31  import com.liferay.portlet.polls.model.PollsQuestion;
32  import com.liferay.portlet.polls.service.base.PollsQuestionServiceBaseImpl;
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              long plid, String title, String description,
46              int expirationDateMonth, int expirationDateDay,
47              int expirationDateYear, int expirationDateHour,
48              int expirationDateMinute, boolean neverExpire,
49              List<PollsChoice> choices, boolean addCommunityPermissions,
50              boolean addGuestPermissions)
51          throws PortalException, SystemException {
52  
53          PortletPermissionUtil.check(
54              getPermissionChecker(), plid, PortletKeys.POLLS,
55              ActionKeys.ADD_QUESTION);
56  
57          return pollsQuestionLocalService.addQuestion(
58              getUserId(), plid, title, description, expirationDateMonth,
59              expirationDateDay, expirationDateYear, expirationDateHour,
60              expirationDateMinute, neverExpire, choices,
61              addCommunityPermissions, addGuestPermissions);
62      }
63  
64      public PollsQuestion addQuestion(
65              long plid, String title, String description,
66              int expirationDateMonth, int expirationDateDay,
67              int expirationDateYear, int expirationDateHour,
68              int expirationDateMinute, boolean neverExpire,
69              List<PollsChoice> choices, String[] communityPermissions,
70              String[] guestPermissions)
71          throws PortalException, SystemException {
72  
73          PortletPermissionUtil.check(
74              getPermissionChecker(), plid, PortletKeys.POLLS,
75              ActionKeys.ADD_QUESTION);
76  
77          return pollsQuestionLocalService.addQuestion(
78              getUserId(), plid, title, description, expirationDateMonth,
79              expirationDateDay, expirationDateYear, expirationDateHour,
80              expirationDateMinute, neverExpire, choices, communityPermissions,
81              guestPermissions);
82      }
83  
84      public void deleteQuestion(long questionId)
85          throws PortalException, SystemException {
86  
87          PollsQuestionPermission.check(
88              getPermissionChecker(), questionId, ActionKeys.DELETE);
89  
90          pollsQuestionLocalService.deleteQuestion(questionId);
91      }
92  
93      public PollsQuestion getQuestion(long questionId)
94          throws PortalException, SystemException {
95  
96          PollsQuestionPermission.check(
97              getPermissionChecker(), questionId, ActionKeys.VIEW);
98  
99          return pollsQuestionLocalService.getQuestion(questionId);
100     }
101 
102     public PollsQuestion updateQuestion(
103             long questionId, String title, String description,
104             int expirationDateMonth, int expirationDateDay,
105             int expirationDateYear, int expirationDateHour,
106             int expirationDateMinute, boolean neverExpire,
107             List<PollsChoice> choices)
108         throws PortalException, SystemException {
109 
110         PollsQuestionPermission.check(
111             getPermissionChecker(), questionId, ActionKeys.UPDATE);
112 
113         return pollsQuestionLocalService.updateQuestion(
114             getUserId(), questionId, title, description, expirationDateMonth,
115             expirationDateDay, expirationDateYear, expirationDateHour,
116             expirationDateMinute, neverExpire, choices);
117     }
118 
119 }