001    /**
002     * Copyright (c) 2000-2010 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            public void processAction(
040                            ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
041                            ActionRequest actionRequest, ActionResponse actionResponse)
042                    throws Exception {
043    
044                    String className = ParamUtil.getString(actionRequest, "className");
045                    long classPK = ParamUtil.getLong(actionRequest, "classPK");
046                    String reporterEmailAddress = ParamUtil.getString(
047                            actionRequest, "reporterEmailAddress");
048                    long reportedUserId = ParamUtil.getLong(
049                            actionRequest, "reportedUserId");
050                    String contentTitle = ParamUtil.getString(
051                            actionRequest, "contentTitle");
052                    String contentURL = ParamUtil.getString(actionRequest, "contentURL");
053                    String reason = ParamUtil.getString(actionRequest, "reason");
054    
055                    ServiceContext serviceContext = ServiceContextFactory.getInstance(
056                            "com.liferay.portlet.flags.model.FlagsEntry", actionRequest);
057    
058                    FlagsEntryServiceUtil.addEntry(
059                            className, classPK, reporterEmailAddress, reportedUserId,
060                            contentTitle, contentURL, reason, serviceContext);
061    
062                    setForward(actionRequest, ActionConstants.COMMON_NULL);
063            }
064    
065            public ActionForward render(
066                            ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
067                            RenderRequest renderRequest, RenderResponse renderResponse)
068                    throws Exception {
069    
070                    return mapping.findForward(
071                            getForward(renderRequest, "portlet.flags.edit_entry"));
072            }
073    
074    }