001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.polls.action;
016    
017    import com.liferay.portal.kernel.util.ParamUtil;
018    import com.liferay.portal.service.ServiceContext;
019    import com.liferay.portal.service.ServiceContextFactory;
020    import com.liferay.portlet.polls.service.PollsVoteServiceUtil;
021    import com.liferay.portlet.polls.util.PollsUtil;
022    
023    import javax.portlet.ActionRequest;
024    import javax.portlet.PortletConfig;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     * @author Mate Thurzo
029     */
030    public class ViewQuestionAction extends EditQuestionAction {
031    
032            @Override
033            protected void updateQuestion(
034                            PortletConfig portletConfig, ActionRequest actionRequest)
035                    throws Exception {
036    
037                    long questionId = ParamUtil.getLong(actionRequest, "questionId");
038                    long choiceId = ParamUtil.getLong(actionRequest, "choiceId");
039    
040                    ServiceContext serviceContext = ServiceContextFactory.getInstance(
041                            actionRequest);
042    
043                    PollsVoteServiceUtil.addVote(questionId, choiceId, serviceContext);
044    
045                    PollsUtil.saveVote(actionRequest, questionId);
046            }
047    
048    }