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.assettagsnavigation.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          long classNameId = ParamUtil.getLong(actionRequest, "classNameId");
49          String displayStyle = ParamUtil.getString(
50              actionRequest, "displayStyle");
51          boolean showAssetCount = ParamUtil.getBoolean(
52              actionRequest, "showAssetCount");
53          boolean showZeroAssetCount = ParamUtil.getBoolean(
54              actionRequest, "showZeroAssetCount");
55  
56          String portletResource = ParamUtil.getString(
57              actionRequest, "portletResource");
58  
59          PortletPreferences preferences =
60              PortletPreferencesFactoryUtil.getPortletSetup(
61                  actionRequest, portletResource);
62  
63          preferences.setValue("classNameId", String.valueOf(classNameId));
64          preferences.setValue("displayStyle", displayStyle);
65          preferences.setValue("showAssetCount", String.valueOf(showAssetCount));
66          preferences.setValue(
67              "showZeroAssetCount", String.valueOf(showZeroAssetCount));
68  
69          preferences.store();
70  
71          SessionMessages.add(
72              actionRequest, portletConfig.getPortletName() + ".doConfigure");
73      }
74  
75      public String render(
76              PortletConfig portletConfig, RenderRequest renderRequest,
77              RenderResponse renderResponse)
78          throws Exception {
79  
80          return "/html/portlet/asset_tags_navigation/configuration.jsp";
81      }
82  
83  }