1
22
23 package com.liferay.taglib.portlet;
24
25 import com.liferay.portal.kernel.util.BooleanWrapper;
26 import com.liferay.portal.kernel.util.LongWrapper;
27 import com.liferay.portal.kernel.util.MethodInvoker;
28 import com.liferay.portal.kernel.util.MethodWrapper;
29 import com.liferay.portal.kernel.util.NullWrapper;
30 import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
31 import com.liferay.portal.kernel.util.StringPool;
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 import org.apache.commons.logging.Log;
42 import org.apache.commons.logging.LogFactory;
43
44
50 public class ActionURLTag extends ParamAndPropertyAncestorTagImpl {
51
52 public static String doTag(
53 String lifecycle, String windowState, String portletMode,
54 String var, String varImpl, Boolean secure,
55 Boolean copyCurrentRenderParameters, Boolean escapeXml, String name,
56 String resourceID, String cacheability, String portletName,
57 Boolean anchor, Boolean encrypt, long doAsUserId,
58 Boolean portletConfiguration, Map<String, String[]> params,
59 boolean writeOutput, PageContext pageContext)
60 throws Exception {
61
62 Object returnObj = null;
63
64 ClassLoader contextClassLoader =
65 Thread.currentThread().getContextClassLoader();
66
67 try {
68 Thread.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 Thread.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 }
215
216 return EVAL_PAGE;
217 }
218
219 public String getLifecycle() {
220 return PortletRequest.ACTION_PHASE;
221 }
222
223 public void setWindowState(String windowState) {
224 _windowState = windowState;
225 }
226
227 public void setPortletMode(String portletMode) {
228 _portletMode = portletMode;
229 }
230
231 public void setVar(String var) {
232 _var = var;
233 }
234
235 public void setVarImpl(String varImpl) {
236 _varImpl = varImpl;
237 }
238
239 public void setSecure(boolean secure) {
240 _secure = Boolean.valueOf(secure);
241 }
242
243 public void setCopyCurrentRenderParameters(
244 boolean copyCurrentRenderParameters) {
245
246 _copyCurrentRenderParameters = Boolean.valueOf(
247 copyCurrentRenderParameters);
248 }
249
250 public void setEscapeXml(boolean escapeXml) {
251 _escapeXml = Boolean.valueOf(escapeXml);
252 }
253
254 public void setName(String name) {
255 _name = name;
256 }
257
258 public void setId(String resourceID) {
259 _resourceID = resourceID;
260 }
261
262 public void setCacheability(String cacheability) {
263 _cacheability = cacheability;
264 }
265
266 public void setPortletName(String portletName) {
267 _portletName = portletName;
268 }
269
270 public void setAnchor(boolean anchor) {
271 _anchor = Boolean.valueOf(anchor);
272 }
273
274 public void setEncrypt(boolean encrypt) {
275 _encrypt = Boolean.valueOf(encrypt);
276 }
277
278 public void setDoAsUserId(long doAsUserId) {
279 _doAsUserId = doAsUserId;
280 }
281
282 public void setPortletConfiguration(boolean portletConfiguration) {
283 _portletConfiguration = Boolean.valueOf(portletConfiguration);
284 }
285
286 private static final String _TAG_CLASS =
287 "com.liferay.portal.servlet.taglib.portlet.ActionURLTagUtil";
288
289 private static final String _TAG_DO_END_METHOD = "doEndTag";
290
291 private static Log _log = LogFactory.getLog(ActionURLTag.class);
292
293 private String _windowState;
294 private String _portletMode;
295 private String _var;
296 private String _varImpl;
297 private Boolean _secure;
298 private Boolean _copyCurrentRenderParameters;
299 private Boolean _escapeXml;
300 private String _name;
301 private String _resourceID;
302 private String _cacheability;
303 private String _portletName;
304 private Boolean _anchor;
305 private Boolean _encrypt;
306 private long _doAsUserId;
307 private Boolean _portletConfiguration;
308
309 }