1
19
20 package com.liferay.portlet.journalarticles.action;
21
22 import com.liferay.portal.NoSuchGroupException;
23 import com.liferay.portal.kernel.portlet.ConfigurationAction;
24 import com.liferay.portal.kernel.servlet.SessionErrors;
25 import com.liferay.portal.kernel.servlet.SessionMessages;
26 import com.liferay.portal.kernel.util.Constants;
27 import com.liferay.portal.kernel.util.ParamUtil;
28 import com.liferay.portal.service.GroupLocalServiceUtil;
29 import com.liferay.portlet.PortletPreferencesFactoryUtil;
30
31 import javax.portlet.ActionRequest;
32 import javax.portlet.ActionResponse;
33 import javax.portlet.PortletConfig;
34 import javax.portlet.PortletPreferences;
35 import javax.portlet.RenderRequest;
36 import javax.portlet.RenderResponse;
37
38
44 public class ConfigurationActionImpl implements ConfigurationAction {
45
46 public void processAction(
47 PortletConfig portletConfig, ActionRequest actionRequest,
48 ActionResponse actionResponse)
49 throws Exception {
50
51 try {
52 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
53
54 if (!cmd.equals(Constants.UPDATE)) {
55 return;
56 }
57
58 long groupId = ParamUtil.getLong(actionRequest, "groupId");
59 String type = ParamUtil.getString(actionRequest, "type");
60 String pageURL = ParamUtil.getString(actionRequest, "pageURL");
61 int pageDelta = ParamUtil.getInteger(actionRequest, "pageDelta");
62 String orderByCol = ParamUtil.getString(
63 actionRequest, "orderByCol");
64 String orderByType = ParamUtil.getString(
65 actionRequest, "orderByType");
66
67 GroupLocalServiceUtil.getGroup(groupId);
68
69 String portletResource = ParamUtil.getString(
70 actionRequest, "portletResource");
71
72 PortletPreferences prefs =
73 PortletPreferencesFactoryUtil.getPortletSetup(
74 actionRequest, portletResource);
75
76 prefs.setValue("group-id", String.valueOf(groupId));
77 prefs.setValue("type", type);
78 prefs.setValue("page-url", pageURL);
79 prefs.setValue("page-delta", String.valueOf(pageDelta));
80 prefs.setValue("order-by-col", orderByCol);
81 prefs.setValue("order-by-type", orderByType);
82
83 prefs.store();
84
85 SessionMessages.add(
86 actionRequest, portletConfig.getPortletName() + ".doConfigure");
87 }
88 catch (NoSuchGroupException nsge) {
89 SessionErrors.add(actionRequest, nsge.getClass().getName());
90 }
91 }
92
93 public String render(
94 PortletConfig portletConfig, RenderRequest renderRequest,
95 RenderResponse renderResponse)
96 throws Exception {
97
98 return "/html/portlet/journal_articles/configuration.jsp";
99 }
100
101 }