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