1
19
20 package com.liferay.portlet.webproxy.action;
21
22 import com.liferay.portal.kernel.portlet.ConfigurationAction;
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 implements ConfigurationAction {
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 prefs =
85 PortletPreferencesFactoryUtil.getPortletSetup(
86 actionRequest, portletResource);
87
88 prefs.setValue("initUrl", initUrl);
89 prefs.setValue("scope", scope);
90 prefs.setValue("proxyHost", proxyHost);
91 prefs.setValue("proxyPort", proxyPort);
92 prefs.setValue("proxyAuthentication", proxyAuthentication);
93 prefs.setValue(
94 "proxyAuthenticationUsername", proxyAuthenticationUsername);
95 prefs.setValue(
96 "proxyAuthenticationPassword", proxyAuthenticationPassword);
97 prefs.setValue("proxyAuthenticationHost", proxyAuthenticationHost);
98 prefs.setValue("proxyAuthenticationDomain", proxyAuthenticationDomain);
99 prefs.setValue("stylesheet", stylesheet);
100
101 prefs.store();
102
103 SessionMessages.add(
104 actionRequest, portletConfig.getPortletName() + ".doConfigure");
105 }
106
107 public String render(
108 PortletConfig portletConfig, RenderRequest renderRequest,
109 RenderResponse renderResponse)
110 throws Exception {
111
112 return "/html/portlet/web_proxy/configuration.jsp";
113 }
114
115 }