1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.polls.service.impl;
21  
22  import com.liferay.portal.PortalException;
23  import com.liferay.portal.SystemException;
24  import com.liferay.portal.security.permission.ActionKeys;
25  import com.liferay.portal.service.permission.PortletPermissionUtil;
26  import com.liferay.portal.util.PortletKeys;
27  import com.liferay.portlet.polls.model.PollsChoice;
28  import com.liferay.portlet.polls.model.PollsQuestion;
29  import com.liferay.portlet.polls.service.base.PollsQuestionServiceBaseImpl;
30  import com.liferay.portlet.polls.service.permission.PollsQuestionPermission;
31  
32  import java.util.List;
33  
34  /**
35   * <a href="PollsQuestionServiceImpl.java.html"><b><i>View Source</i></b></a>
36   *
37   * @author Brian Wing Shun Chan
38   *
39   */
40  public class PollsQuestionServiceImpl extends PollsQuestionServiceBaseImpl {
41  
42      public PollsQuestion addQuestion(
43              long plid, String title, String description,
44              int expirationDateMonth, int expirationDateDay,
45              int expirationDateYear, int expirationDateHour,
46              int expirationDateMinute, boolean neverExpire,
47              List<PollsChoice> choices, boolean addCommunityPermissions,
48              boolean addGuestPermissions)
49          throws PortalException, SystemException {
50  
51          PortletPermissionUtil.check(
52              getPermissionChecker(), plid, PortletKeys.POLLS,
53              ActionKeys.ADD_QUESTION);
54  
55          return pollsQuestionLocalService.addQuestion(
56              getUserId(), plid, title, description, expirationDateMonth,
57              expirationDateDay, expirationDateYear, expirationDateHour,
58              expirationDateMinute, neverExpire, choices,
59              addCommunityPermissions, addGuestPermissions);
60      }
61  
62      public PollsQuestion addQuestion(
63              long plid, String title, String description,
64              int expirationDateMonth, int expirationDateDay,
65              int expirationDateYear, int expirationDateHour,
66              int expirationDateMinute, boolean neverExpire,
67              List<PollsChoice> choices, String[] communityPermissions,
68              String[] guestPermissions)
69          throws PortalException, SystemException {
70  
71          PortletPermissionUtil.check(
72              getPermissionChecker(), plid, PortletKeys.POLLS,
73              ActionKeys.ADD_QUESTION);
74  
75          return pollsQuestionLocalService.addQuestion(
76              getUserId(), plid, title, description, expirationDateMonth,
77              expirationDateDay, expirationDateYear, expirationDateHour,
78              expirationDateMinute, neverExpire, choices, communityPermissions,
79              guestPermissions);
80      }
81  
82      public void deleteQuestion(long questionId)
83          throws PortalException, SystemException {
84  
85          PollsQuestionPermission.check(
86              getPermissionChecker(), questionId, ActionKeys.DELETE);
87  
88          pollsQuestionLocalService.deleteQuestion(questionId);
89      }
90  
91      public PollsQuestion getQuestion(long questionId)
92          throws PortalException, SystemException {
93  
94          PollsQuestionPermission.check(
95              getPermissionChecker(), questionId, ActionKeys.VIEW);
96  
97          return pollsQuestionLocalService.getQuestion(questionId);
98      }
99  
100     public PollsQuestion updateQuestion(
101             long questionId, String title, String description,
102             int expirationDateMonth, int expirationDateDay,
103             int expirationDateYear, int expirationDateHour,
104             int expirationDateMinute, boolean neverExpire,
105             List<PollsChoice> choices)
106         throws PortalException, SystemException {
107 
108         PollsQuestionPermission.check(
109             getPermissionChecker(), questionId, ActionKeys.UPDATE);
110 
111         return pollsQuestionLocalService.updateQuestion(
112             getUserId(), questionId, title, description, expirationDateMonth,
113             expirationDateDay, expirationDateYear, expirationDateHour,
114             expirationDateMinute, neverExpire, choices);
115     }
116 
117 }