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