1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.journalarticles.action;
21  
22  import com.liferay.portal.kernel.portlet.BaseConfigurationAction;
23  import com.liferay.portal.kernel.util.Constants;
24  import com.liferay.portal.kernel.util.ParamUtil;
25  import com.liferay.portlet.PortletPreferencesFactoryUtil;
26  
27  import javax.portlet.ActionRequest;
28  import javax.portlet.ActionResponse;
29  import javax.portlet.PortletConfig;
30  import javax.portlet.PortletPreferences;
31  import javax.portlet.RenderRequest;
32  import javax.portlet.RenderResponse;
33  
34  /**
35   * <a href="ConfigurationActionImpl.java.html"><b><i>View Source</i></b></a>
36   *
37   * @author Brian Wing Shun Chan
38   *
39   */
40  public class ConfigurationActionImpl extends BaseConfigurationAction {
41  
42      public void processAction(
43              PortletConfig portletConfig, ActionRequest actionRequest,
44              ActionResponse actionResponse)
45          throws Exception {
46  
47          String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
48  
49          if (!cmd.equals(Constants.UPDATE)) {
50              return;
51          }
52  
53          long groupId = ParamUtil.getLong(actionRequest, "groupId");
54          String type = ParamUtil.getString(actionRequest, "type");
55          String structureId = ParamUtil.getString(actionRequest, "structureId");
56          String pageURL = ParamUtil.getString(actionRequest, "pageURL");
57          int pageDelta = ParamUtil.getInteger(actionRequest, "pageDelta");
58          String orderByCol = ParamUtil.getString(actionRequest, "orderByCol");
59          String orderByType = ParamUtil.getString(actionRequest, "orderByType");
60  
61          String portletResource = ParamUtil.getString(
62              actionRequest, "portletResource");
63  
64          PortletPreferences preferences =
65              PortletPreferencesFactoryUtil.getPortletSetup(
66                  actionRequest, portletResource);
67  
68          preferences.setValue("group-id", String.valueOf(groupId));
69          preferences.setValue("type", type);
70          preferences.setValue("structure-id", structureId);
71          preferences.setValue("page-url", pageURL);
72          preferences.setValue("page-delta", String.valueOf(pageDelta));
73          preferences.setValue("order-by-col", orderByCol);
74          preferences.setValue("order-by-type", orderByType);
75  
76          preferences.store();
77  
78          actionResponse.sendRedirect(
79              ParamUtil.getString(actionRequest, "redirect"));
80      }
81  
82      public String render(
83              PortletConfig portletConfig, RenderRequest renderRequest,
84              RenderResponse renderResponse)
85          throws Exception {
86  
87          return "/html/portlet/journal_articles/configuration.jsp";
88      }
89  
90  }