1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portlet.blogsaggregator.action;
16  
17  import com.liferay.portal.kernel.portlet.BaseConfigurationAction;
18  import com.liferay.portal.kernel.servlet.SessionMessages;
19  import com.liferay.portal.kernel.util.Constants;
20  import com.liferay.portal.kernel.util.ParamUtil;
21  import com.liferay.portlet.PortletPreferencesFactoryUtil;
22  
23  import javax.portlet.ActionRequest;
24  import javax.portlet.ActionResponse;
25  import javax.portlet.PortletConfig;
26  import javax.portlet.PortletPreferences;
27  import javax.portlet.RenderRequest;
28  import javax.portlet.RenderResponse;
29  
30  /**
31   * <a href="ConfigurationActionImpl.java.html"><b><i>View Source</i></b></a>
32   *
33   * @author Jorge Ferrer
34   */
35  public class ConfigurationActionImpl extends BaseConfigurationAction {
36  
37      public void processAction(
38              PortletConfig portletConfig, ActionRequest actionRequest,
39              ActionResponse actionResponse)
40          throws Exception {
41  
42          String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
43  
44          if (!cmd.equals(Constants.UPDATE)) {
45              return;
46          }
47  
48          String selectionMethod = ParamUtil.getString(
49              actionRequest, "selectionMethod");
50          String organizationId = ParamUtil.getString(
51              actionRequest, "organizationId");
52          String displayStyle = ParamUtil.getString(
53              actionRequest, "displayStyle");
54          int max = ParamUtil.getInteger(actionRequest, "max");
55          boolean enableRssSubscription = ParamUtil.getBoolean(
56              actionRequest, "enableRssSubscription");
57          boolean showTags = ParamUtil.getBoolean(
58              actionRequest, "showTags");
59  
60          String portletResource = ParamUtil.getString(
61              actionRequest, "portletResource");
62  
63          PortletPreferences preferences =
64              PortletPreferencesFactoryUtil.getPortletSetup(
65                  actionRequest, portletResource);
66  
67          preferences.setValue("selection-method", selectionMethod);
68          preferences.setValue("organization-id", organizationId);
69          preferences.setValue("display-style", displayStyle);
70          preferences.setValue("max", String.valueOf(max));
71          preferences.setValue(
72              "enable-rss-subscription", String.valueOf(enableRssSubscription));
73          preferences.setValue("show-tags", String.valueOf(showTags));
74  
75          preferences.store();
76  
77          SessionMessages.add(
78              actionRequest, portletConfig.getPortletName() + ".doConfigure");
79      }
80  
81      public String render(
82              PortletConfig portletConfig, RenderRequest renderRequest,
83              RenderResponse renderResponse)
84          throws Exception {
85  
86          return "/html/portlet/blogs_aggregator/configuration.jsp";
87      }
88  
89  }