001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet.polls.service.impl;
022:
023: import com.liferay.portal.PortalException;
024: import com.liferay.portal.SystemException;
025: import com.liferay.portal.kernel.security.permission.ActionKeys;
026: import com.liferay.portal.service.permission.PortletPermissionUtil;
027: import com.liferay.portal.util.PortletKeys;
028: import com.liferay.portlet.polls.model.PollsQuestion;
029: import com.liferay.portlet.polls.service.base.PollsQuestionServiceBaseImpl;
030: import com.liferay.portlet.polls.service.permission.PollsQuestionPermission;
031:
032: import java.util.List;
033:
034: /**
035: * <a href="PollsQuestionServiceImpl.java.html"><b><i>View Source</i></b></a>
036: *
037: * @author Brian Wing Shun Chan
038: *
039: */
040: public class PollsQuestionServiceImpl extends
041: PollsQuestionServiceBaseImpl {
042:
043: public PollsQuestion addQuestion(long plid, String title,
044: String description, int expirationDateMonth,
045: int expirationDateDay, int expirationDateYear,
046: int expirationDateHour, int expirationDateMinute,
047: boolean neverExpire, List choices,
048: boolean addCommunityPermissions, boolean addGuestPermissions)
049: throws PortalException, SystemException {
050:
051: PortletPermissionUtil.check(getPermissionChecker(), plid,
052: PortletKeys.POLLS, ActionKeys.ADD_QUESTION);
053:
054: return pollsQuestionLocalService.addQuestion(getUserId(), plid,
055: title, description, expirationDateMonth,
056: expirationDateDay, expirationDateYear,
057: expirationDateHour, expirationDateMinute, neverExpire,
058: choices, addCommunityPermissions, addGuestPermissions);
059: }
060:
061: public PollsQuestion addQuestion(long plid, String title,
062: String description, int expirationDateMonth,
063: int expirationDateDay, int expirationDateYear,
064: int expirationDateHour, int expirationDateMinute,
065: boolean neverExpire, List choices,
066: String[] communityPermissions, String[] guestPermissions)
067: throws PortalException, SystemException {
068:
069: PortletPermissionUtil.check(getPermissionChecker(), plid,
070: PortletKeys.POLLS, ActionKeys.ADD_QUESTION);
071:
072: return pollsQuestionLocalService.addQuestion(getUserId(), plid,
073: title, description, expirationDateMonth,
074: expirationDateDay, expirationDateYear,
075: expirationDateHour, expirationDateMinute, neverExpire,
076: choices, communityPermissions, guestPermissions);
077: }
078:
079: public void deleteQuestion(long questionId) throws PortalException,
080: SystemException {
081:
082: PollsQuestionPermission.check(getPermissionChecker(),
083: questionId, ActionKeys.DELETE);
084:
085: pollsQuestionLocalService.deleteQuestion(questionId);
086: }
087:
088: public PollsQuestion getQuestion(long questionId)
089: throws PortalException, SystemException {
090:
091: PollsQuestionPermission.check(getPermissionChecker(),
092: questionId, ActionKeys.VIEW);
093:
094: return pollsQuestionLocalService.getQuestion(questionId);
095: }
096:
097: public PollsQuestion updateQuestion(long questionId, String title,
098: String description, int expirationDateMonth,
099: int expirationDateDay, int expirationDateYear,
100: int expirationDateHour, int expirationDateMinute,
101: boolean neverExpire, List choices) throws PortalException,
102: SystemException {
103:
104: PollsQuestionPermission.check(getPermissionChecker(),
105: questionId, ActionKeys.UPDATE);
106:
107: return pollsQuestionLocalService.updateQuestion(getUserId(),
108: questionId, title, description, expirationDateMonth,
109: expirationDateDay, expirationDateYear,
110: expirationDateHour, expirationDateMinute, neverExpire,
111: choices);
112: }
113:
114: }
|