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