1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.flags.action;
16  
17  import com.liferay.portal.kernel.util.ParamUtil;
18  import com.liferay.portal.service.ServiceContext;
19  import com.liferay.portal.service.ServiceContextFactory;
20  import com.liferay.portal.struts.ActionConstants;
21  import com.liferay.portal.struts.PortletAction;
22  import com.liferay.portlet.flags.service.FlagsEntryServiceUtil;
23  
24  import javax.portlet.ActionRequest;
25  import javax.portlet.ActionResponse;
26  import javax.portlet.PortletConfig;
27  import javax.portlet.RenderRequest;
28  import javax.portlet.RenderResponse;
29  
30  import org.apache.struts.action.ActionForm;
31  import org.apache.struts.action.ActionForward;
32  import org.apache.struts.action.ActionMapping;
33  
34  /**
35   * <a href="EditEntryAction.java.html"><b><i>View Source</i></b></a>
36   *
37   * @author Julio Camarero
38   */
39  public class EditEntryAction extends PortletAction {
40  
41      public void processAction(
42              ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
43              ActionRequest actionRequest, ActionResponse actionResponse)
44          throws Exception {
45  
46          String className = ParamUtil.getString(actionRequest, "className");
47          long classPK = ParamUtil.getLong(actionRequest, "classPK");
48          String reporterEmailAddress = ParamUtil.getString(
49              actionRequest, "reporterEmailAddress");
50          long reportedUserId = ParamUtil.getLong(
51              actionRequest, "reportedUserId");
52          String contentTitle = ParamUtil.getString(
53              actionRequest, "contentTitle");
54          String contentURL = ParamUtil.getString(actionRequest, "contentURL");
55          String reason = ParamUtil.getString(actionRequest, "reason");
56  
57          ServiceContext serviceContext = ServiceContextFactory.getInstance(
58              "com.liferay.portlet.flags.model.FlagsEntry", actionRequest);
59  
60          FlagsEntryServiceUtil.addEntry(
61              className, classPK, reporterEmailAddress, reportedUserId,
62              contentTitle, contentURL, reason, serviceContext);
63  
64          setForward(actionRequest, ActionConstants.COMMON_NULL);
65      }
66  
67      public ActionForward render(
68              ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
69              RenderRequest renderRequest, RenderResponse renderResponse)
70          throws Exception {
71  
72          return mapping.findForward(
73              getForward(renderRequest, "portlet.flags.edit_entry"));
74      }
75  
76  }