1
22
23 package com.liferay.taglib.portlet;
24
25 import com.liferay.portal.kernel.log.Log;
26 import com.liferay.portal.kernel.log.LogFactoryUtil;
27 import com.liferay.portal.kernel.util.BooleanWrapper;
28 import com.liferay.portal.kernel.util.LongWrapper;
29 import com.liferay.portal.kernel.util.MethodInvoker;
30 import com.liferay.portal.kernel.util.MethodWrapper;
31 import com.liferay.portal.kernel.util.NullWrapper;
32 import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
33 import com.liferay.portal.kernel.util.StringPool;
34 import com.liferay.taglib.util.ParamAndPropertyAncestorTagImpl;
35
36 import java.util.Map;
37
38 import javax.portlet.PortletRequest;
39
40 import javax.servlet.jsp.JspException;
41 import javax.servlet.jsp.PageContext;
42
43
49 public class ActionURLTag extends ParamAndPropertyAncestorTagImpl {
50
51 public static String doTag(
52 String lifecycle, String windowState, String portletMode,
53 String var, String varImpl, Boolean secure,
54 Boolean copyCurrentRenderParameters, Boolean escapeXml, String name,
55 String resourceID, String cacheability, String portletName,
56 Boolean anchor, Boolean encrypt, long doAsUserId,
57 Boolean portletConfiguration, Map<String, String[]> params,
58 boolean writeOutput, PageContext pageContext)
59 throws Exception {
60
61 Object returnObj = null;
62
63 Thread currentThread = Thread.currentThread();
64
65 ClassLoader contextClassLoader = currentThread.getContextClassLoader();
66
67 try {
68 currentThread.setContextClassLoader(
69 PortalClassLoaderUtil.getClassLoader());
70
71 Object windowStateWrapper = windowState;
72
73 if (windowStateWrapper == null) {
74 windowStateWrapper = new NullWrapper(String.class.getName());
75 }
76
77 Object portletModeWrapper = portletMode;
78
79 if (portletModeWrapper == null) {
80 portletModeWrapper = new NullWrapper(String.class.getName());
81 }
82
83 Object varWrapper = var;
84
85 if (varWrapper == null) {
86 varWrapper = new NullWrapper(String.class.getName());
87 }
88
89 Object varImplWrapper = varImpl;
90
91 if (varImplWrapper == null) {
92 varImplWrapper = new NullWrapper(String.class.getName());
93 }
94
95 Object secureWrapper = secure;
96
97 if (secureWrapper == null) {
98 secureWrapper = new NullWrapper(Boolean.class.getName());
99 }
100
101 Object copyCurrentRenderParametersWrapper =
102 copyCurrentRenderParameters;
103
104 if (copyCurrentRenderParametersWrapper == null) {
105 copyCurrentRenderParametersWrapper = new NullWrapper(
106 Boolean.class.getName());
107 }
108
109 Object escapeXmlWrapper = escapeXml;
110
111 if (escapeXmlWrapper == null) {
112 escapeXmlWrapper = new NullWrapper(Boolean.class.getName());
113 }
114
115 Object nameWrapper = name;
116
117 if (nameWrapper == null) {
118 nameWrapper = new NullWrapper(String.class.getName());
119 }
120
121 Object resourceIDWrapper = resourceID;
122
123 if (resourceIDWrapper == null) {
124 resourceIDWrapper = new NullWrapper(String.class.getName());
125 }
126
127 Object cacheabilityWrapper = cacheability;
128
129 if (cacheabilityWrapper == null) {
130 cacheabilityWrapper = new NullWrapper(String.class.getName());
131 }
132
133 Object portletNameWrapper = portletName;
134
135 if (portletNameWrapper == null) {
136 portletNameWrapper = new NullWrapper(String.class.getName());
137 }
138
139 Object anchorWrapper = anchor;
140
141 if (anchorWrapper == null) {
142 anchorWrapper = new NullWrapper(Boolean.class.getName());
143 }
144
145 Object encryptWrapper = encrypt;
146
147 if (encryptWrapper == null) {
148 encryptWrapper = new NullWrapper(Boolean.class.getName());
149 }
150
151 Object portletConfigurationWrapper = portletConfiguration;
152
153 if (portletConfigurationWrapper == null) {
154 portletConfigurationWrapper = new NullWrapper(
155 Boolean.class.getName());
156 }
157
158 Object paramsWrapper = params;
159
160 if (paramsWrapper == null) {
161 paramsWrapper = new NullWrapper(Map.class.getName());
162 }
163
164 MethodWrapper methodWrapper = new MethodWrapper(
165 _TAG_CLASS, _TAG_DO_END_METHOD,
166 new Object[] {
167 lifecycle, windowStateWrapper, portletModeWrapper,
168 varWrapper, varImplWrapper, secureWrapper,
169 copyCurrentRenderParametersWrapper, escapeXmlWrapper,
170 nameWrapper, resourceIDWrapper, cacheabilityWrapper,
171 portletNameWrapper, anchorWrapper, encryptWrapper,
172 new LongWrapper(doAsUserId), portletConfigurationWrapper,
173 paramsWrapper, new BooleanWrapper(writeOutput), pageContext
174 });
175
176 returnObj = MethodInvoker.invoke(methodWrapper);
177 }
178 catch (Exception e) {
179 _log.error(e, e);
180
181 throw e;
182 }
183 finally {
184 currentThread.setContextClassLoader(contextClassLoader);
185 }
186
187 if (returnObj != null) {
188 return returnObj.toString();
189 }
190 else {
191 return StringPool.BLANK;
192 }
193 }
194
195 public int doEndTag() throws JspException {
196 try {
197 doTag(
198 getLifecycle(), _windowState, _portletMode, _var, _varImpl,
199 _secure, _copyCurrentRenderParameters, _escapeXml, _name,
200 _resourceID, _cacheability, _portletName, _anchor, _encrypt,
201 _doAsUserId, _portletConfiguration, getParams(), true,
202 pageContext);
203 }
204 catch (Exception e) {
205 if (e instanceof JspException) {
206 throw (JspException)e;
207 }
208 else {
209 throw new JspException(e);
210 }
211 }
212 finally {
213 clearParams();
214 clearProperties();
215 }
216
217 return EVAL_PAGE;
218 }
219
220 public String getLifecycle() {
221 return PortletRequest.ACTION_PHASE;
222 }
223
224 public void setWindowState(String windowState) {
225 _windowState = windowState;
226 }
227
228 public void setPortletMode(String portletMode) {
229 _portletMode = portletMode;
230 }
231
232 public void setVar(String var) {
233 _var = var;
234 }
235
236 public void setVarImpl(String varImpl) {
237 _varImpl = varImpl;
238 }
239
240 public void setSecure(boolean secure) {
241 _secure = Boolean.valueOf(secure);
242 }
243
244 public void setCopyCurrentRenderParameters(
245 boolean copyCurrentRenderParameters) {
246
247 _copyCurrentRenderParameters = Boolean.valueOf(
248 copyCurrentRenderParameters);
249 }
250
251 public void setEscapeXml(boolean escapeXml) {
252 _escapeXml = Boolean.valueOf(escapeXml);
253 }
254
255 public void setName(String name) {
256 _name = name;
257 }
258
259 public void setId(String resourceID) {
260 _resourceID = resourceID;
261 }
262
263 public void setCacheability(String cacheability) {
264 _cacheability = cacheability;
265 }
266
267 public void setPortletName(String portletName) {
268 _portletName = portletName;
269 }
270
271 public void setAnchor(boolean anchor) {
272 _anchor = Boolean.valueOf(anchor);
273 }
274
275 public void setEncrypt(boolean encrypt) {
276 _encrypt = Boolean.valueOf(encrypt);
277 }
278
279 public void setDoAsUserId(long doAsUserId) {
280 _doAsUserId = doAsUserId;
281 }
282
283 public void setPortletConfiguration(boolean portletConfiguration) {
284 _portletConfiguration = Boolean.valueOf(portletConfiguration);
285 }
286
287 private static final String _TAG_CLASS =
288 "com.liferay.portal.servlet.taglib.portlet.ActionURLTagUtil";
289
290 private static final String _TAG_DO_END_METHOD = "doEndTag";
291
292 private static Log _log = LogFactoryUtil.getLog(ActionURLTag.class);
293
294 private String _windowState;
295 private String _portletMode;
296 private String _var;
297 private String _varImpl;
298 private Boolean _secure;
299 private Boolean _copyCurrentRenderParameters;
300 private Boolean _escapeXml;
301 private String _name;
302 private String _resourceID;
303 private String _cacheability;
304 private String _portletName;
305 private Boolean _anchor;
306 private Boolean _encrypt;
307 private long _doAsUserId;
308 private Boolean _portletConfiguration;
309
310 }