001    /**
002     * Copyright (c) 2000-2012 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.flags.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.portal.struts.ActionConstants;
021    import com.liferay.portal.struts.PortletAction;
022    import com.liferay.portlet.flags.service.FlagsEntryServiceUtil;
023    
024    import javax.portlet.ActionRequest;
025    import javax.portlet.ActionResponse;
026    import javax.portlet.PortletConfig;
027    import javax.portlet.RenderRequest;
028    import javax.portlet.RenderResponse;
029    
030    import org.apache.struts.action.ActionForm;
031    import org.apache.struts.action.ActionForward;
032    import org.apache.struts.action.ActionMapping;
033    
034    /**
035     * @author Julio Camarero
036     */
037    public class EditEntryAction extends PortletAction {
038    
039            @Override
040            public void processAction(
041                            ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
042                            ActionRequest actionRequest, ActionResponse actionResponse)
043                    throws Exception {
044    
045                    String className = ParamUtil.getString(actionRequest, "className");
046                    long classPK = ParamUtil.getLong(actionRequest, "classPK");
047                    String reporterEmailAddress = ParamUtil.getString(
048                            actionRequest, "reporterEmailAddress");
049                    long reportedUserId = ParamUtil.getLong(
050                            actionRequest, "reportedUserId");
051                    String contentTitle = ParamUtil.getString(
052                            actionRequest, "contentTitle");
053                    String contentURL = ParamUtil.getString(actionRequest, "contentURL");
054                    String reason = ParamUtil.getString(actionRequest, "reason");
055    
056                    ServiceContext serviceContext = ServiceContextFactory.getInstance(
057                            "com.liferay.portlet.flags.model.FlagsEntry", actionRequest);
058    
059                    FlagsEntryServiceUtil.addEntry(
060                            className, classPK, reporterEmailAddress, reportedUserId,
061                            contentTitle, contentURL, reason, serviceContext);
062    
063                    setForward(actionRequest, ActionConstants.COMMON_NULL);
064            }
065    
066            @Override
067            public ActionForward render(
068                            ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
069                            RenderRequest renderRequest, RenderResponse renderResponse)
070                    throws Exception {
071    
072                    return mapping.findForward(
073                            getForward(renderRequest, "portlet.flags.edit_entry"));
074            }
075    
076    }