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.journalarticles.action;
16  
17  import com.liferay.portal.kernel.portlet.BaseConfigurationAction;
18  import com.liferay.portal.kernel.util.Constants;
19  import com.liferay.portal.kernel.util.ParamUtil;
20  import com.liferay.portlet.PortletPreferencesFactoryUtil;
21  
22  import javax.portlet.ActionRequest;
23  import javax.portlet.ActionResponse;
24  import javax.portlet.PortletConfig;
25  import javax.portlet.PortletPreferences;
26  import javax.portlet.RenderRequest;
27  import javax.portlet.RenderResponse;
28  
29  /**
30   * <a href="ConfigurationActionImpl.java.html"><b><i>View Source</i></b></a>
31   *
32   * @author Brian Wing Shun Chan
33   */
34  public class ConfigurationActionImpl extends BaseConfigurationAction {
35  
36      public void processAction(
37              PortletConfig portletConfig, ActionRequest actionRequest,
38              ActionResponse actionResponse)
39          throws Exception {
40  
41          String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
42  
43          if (!cmd.equals(Constants.UPDATE)) {
44              return;
45          }
46  
47          long groupId = ParamUtil.getLong(actionRequest, "groupId");
48          String type = ParamUtil.getString(actionRequest, "type");
49          String structureId = ParamUtil.getString(actionRequest, "structureId");
50          String pageURL = ParamUtil.getString(actionRequest, "pageURL");
51          int pageDelta = ParamUtil.getInteger(actionRequest, "pageDelta");
52          String orderByCol = ParamUtil.getString(actionRequest, "orderByCol");
53          String orderByType = ParamUtil.getString(actionRequest, "orderByType");
54  
55          String portletResource = ParamUtil.getString(
56              actionRequest, "portletResource");
57  
58          PortletPreferences preferences =
59              PortletPreferencesFactoryUtil.getPortletSetup(
60                  actionRequest, portletResource);
61  
62          preferences.setValue("group-id", String.valueOf(groupId));
63          preferences.setValue("type", type);
64          preferences.setValue("structure-id", structureId);
65          preferences.setValue("page-url", pageURL);
66          preferences.setValue("page-delta", String.valueOf(pageDelta));
67          preferences.setValue("order-by-col", orderByCol);
68          preferences.setValue("order-by-type", orderByType);
69  
70          preferences.store();
71  
72          actionResponse.sendRedirect(
73              ParamUtil.getString(actionRequest, "redirect"));
74      }
75  
76      public String render(
77              PortletConfig portletConfig, RenderRequest renderRequest,
78              RenderResponse renderResponse)
79          throws Exception {
80  
81          return "/html/portlet/journal_articles/configuration.jsp";
82      }
83  
84  }