1
14
15 package com.liferay.portlet.webproxy.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.HttpUtil;
21 import com.liferay.portal.kernel.util.ParamUtil;
22 import com.liferay.portal.kernel.util.StringUtil;
23 import com.liferay.portlet.PortletPreferencesFactoryUtil;
24
25 import javax.portlet.ActionRequest;
26 import javax.portlet.ActionResponse;
27 import javax.portlet.PortletConfig;
28 import javax.portlet.PortletPreferences;
29 import javax.portlet.RenderRequest;
30 import javax.portlet.RenderResponse;
31
32
37 public class ConfigurationActionImpl extends BaseConfigurationAction {
38
39 public void processAction(
40 PortletConfig portletConfig, ActionRequest actionRequest,
41 ActionResponse actionResponse)
42 throws Exception {
43
44 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
45
46 if (!cmd.equals(Constants.UPDATE)) {
47 return;
48 }
49
50 String initUrl = ParamUtil.getString(actionRequest, "initUrl");
51
52 if (!initUrl.startsWith("/") &&
53 !StringUtil.startsWith(initUrl, "http://") &&
54 !StringUtil.startsWith(initUrl, "https://") &&
55 !StringUtil.startsWith(initUrl, "mhtml://")) {
56
57 initUrl = HttpUtil.getProtocol(actionRequest) + "://" + initUrl;
58 }
59
60 String scope = ParamUtil.getString(actionRequest, "scope");
61 String proxyHost = ParamUtil.getString(actionRequest, "proxyHost");
62 String proxyPort = ParamUtil.getString(actionRequest, "proxyPort");
63 String proxyAuthentication = ParamUtil.getString(
64 actionRequest, "proxyAuthentication");
65 String proxyAuthenticationUsername = ParamUtil.getString(
66 actionRequest, "proxyAuthenticationUsername");
67 String proxyAuthenticationPassword = ParamUtil.getString(
68 actionRequest, "proxyAuthenticationPassword");
69 String proxyAuthenticationHost = ParamUtil.getString(
70 actionRequest, "proxyAuthenticationHost");
71 String proxyAuthenticationDomain = ParamUtil.getString(
72 actionRequest, "proxyAuthenticationDomain");
73 String stylesheet = ParamUtil.getString(actionRequest, "stylesheet");
74
75 String portletResource = ParamUtil.getString(
76 actionRequest, "portletResource");
77
78 PortletPreferences prefs =
79 PortletPreferencesFactoryUtil.getPortletSetup(
80 actionRequest, portletResource);
81
82 prefs.setValue("initUrl", initUrl);
83 prefs.setValue("scope", scope);
84 prefs.setValue("proxyHost", proxyHost);
85 prefs.setValue("proxyPort", proxyPort);
86 prefs.setValue("proxyAuthentication", proxyAuthentication);
87 prefs.setValue(
88 "proxyAuthenticationUsername", proxyAuthenticationUsername);
89 prefs.setValue(
90 "proxyAuthenticationPassword", proxyAuthenticationPassword);
91 prefs.setValue("proxyAuthenticationHost", proxyAuthenticationHost);
92 prefs.setValue("proxyAuthenticationDomain", proxyAuthenticationDomain);
93 prefs.setValue("stylesheet", stylesheet);
94
95 prefs.store();
96
97 SessionMessages.add(
98 actionRequest, portletConfig.getPortletName() + ".doConfigure");
99 }
100
101 public String render(
102 PortletConfig portletConfig, RenderRequest renderRequest,
103 RenderResponse renderResponse)
104 throws Exception {
105
106 return "/html/portlet/web_proxy/configuration.jsp";
107 }
108
109 }