001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.polls.service.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.security.permission.ActionKeys;
020    import com.liferay.portal.service.ServiceContext;
021    import com.liferay.portlet.polls.model.PollsChoice;
022    import com.liferay.portlet.polls.model.PollsQuestion;
023    import com.liferay.portlet.polls.service.base.PollsQuestionServiceBaseImpl;
024    import com.liferay.portlet.polls.service.permission.PollsPermission;
025    import com.liferay.portlet.polls.service.permission.PollsQuestionPermission;
026    
027    import java.util.List;
028    import java.util.Locale;
029    import java.util.Map;
030    
031    /**
032     * @author Brian Wing Shun Chan
033     * @author Julio Camarero
034     */
035    public class PollsQuestionServiceImpl extends PollsQuestionServiceBaseImpl {
036    
037            @Override
038            public PollsQuestion addQuestion(
039                            Map<Locale, String> titleMap, Map<Locale, String> descriptionMap,
040                            int expirationDateMonth, int expirationDateDay,
041                            int expirationDateYear, int expirationDateHour,
042                            int expirationDateMinute, boolean neverExpire,
043                            List<PollsChoice> choices, ServiceContext serviceContext)
044                    throws PortalException, SystemException {
045    
046                    PollsPermission.check(
047                            getPermissionChecker(), serviceContext.getScopeGroupId(),
048                            ActionKeys.ADD_QUESTION);
049    
050                    return pollsQuestionLocalService.addQuestion(
051                            getUserId(), titleMap, descriptionMap, expirationDateMonth,
052                            expirationDateDay, expirationDateYear, expirationDateHour,
053                            expirationDateMinute, neverExpire, choices, serviceContext);
054            }
055    
056            @Override
057            public void deleteQuestion(long questionId)
058                    throws PortalException, SystemException {
059    
060                    PollsQuestionPermission.check(
061                            getPermissionChecker(), questionId, ActionKeys.DELETE);
062    
063                    pollsQuestionLocalService.deleteQuestion(questionId);
064            }
065    
066            @Override
067            public PollsQuestion getQuestion(long questionId)
068                    throws PortalException, SystemException {
069    
070                    PollsQuestionPermission.check(
071                            getPermissionChecker(), questionId, ActionKeys.VIEW);
072    
073                    return pollsQuestionLocalService.getQuestion(questionId);
074            }
075    
076            @Override
077            public PollsQuestion updateQuestion(
078                            long questionId, Map<Locale, String> titleMap,
079                            Map<Locale, String> descriptionMap, int expirationDateMonth,
080                            int expirationDateDay, int expirationDateYear,
081                            int expirationDateHour, int expirationDateMinute,
082                            boolean neverExpire, List<PollsChoice> choices,
083                            ServiceContext serviceContext)
084                    throws PortalException, SystemException {
085    
086                    PollsQuestionPermission.check(
087                            getPermissionChecker(), questionId, ActionKeys.UPDATE);
088    
089                    return pollsQuestionLocalService.updateQuestion(
090                            getUserId(), questionId, titleMap, descriptionMap,
091                            expirationDateMonth, expirationDateDay, expirationDateYear,
092                            expirationDateHour, expirationDateMinute, neverExpire, choices,
093                            serviceContext);
094            }
095    
096    }