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