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.journalcontentsearch.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 Richard Beatty
34   * @author Raymond Augé
35   */
36  public class ConfigurationActionImpl extends BaseConfigurationAction {
37  
38      public void processAction(
39              PortletConfig portletConfig, ActionRequest actionRequest,
40              ActionResponse actionResponse)
41          throws Exception {
42  
43          String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
44  
45          if (!cmd.equals(Constants.UPDATE)) {
46              return;
47          }
48  
49          boolean showListed = ParamUtil.getBoolean(
50              actionRequest, "showListed");
51          String targetPortletId = ParamUtil.getString(
52              actionRequest, "targetPortletId");
53          String type = ParamUtil.getString(actionRequest, "type");
54  
55          String portletResource = ParamUtil.getString(
56              actionRequest, "portletResource");
57  
58          PortletPreferences preferences =
59              PortletPreferencesFactoryUtil.getPortletSetup(
60                  actionRequest, portletResource);
61  
62          preferences.setValue("show-listed", String.valueOf(showListed));
63          preferences.setValue("target-portlet-id", targetPortletId);
64          preferences.setValue("type", type);
65  
66          preferences.store();
67  
68          SessionMessages.add(
69              actionRequest, portletConfig.getPortletName() + ".doConfigure");
70      }
71  
72      public String render(
73              PortletConfig portletConfig, RenderRequest renderRequest,
74              RenderResponse renderResponse)
75          throws Exception {
76  
77          return "/html/portlet/journal_content_search/configuration.jsp";
78      }
79  
80  }