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