1
22
23 package com.liferay.portal.apache.bridges.struts;
24
25 import com.liferay.portal.kernel.log.Log;
26 import com.liferay.portal.kernel.log.LogFactoryUtil;
27 import com.liferay.portal.kernel.util.HttpUtil;
28 import com.liferay.portlet.PortletResponseImpl;
29 import com.liferay.portlet.PortletURLImplWrapper;
30
31 import org.apache.portals.bridges.struts.StrutsPortletURL;
32
33
38 public class LiferayStrutsPortletURLImpl extends PortletURLImplWrapper {
39
40 public LiferayStrutsPortletURLImpl(
41 PortletResponseImpl portletResponseImpl, long plid, String lifecycle) {
42
43 super(portletResponseImpl, plid, lifecycle);
44 }
45
46 public void setParameter(String name, String value) {
47 super.setParameter(name, value);
48
49
52 String decodedValue = HttpUtil.decodeURL(value);
53
54 try {
55 if (name.equals(StrutsPortletURL.PAGE)) {
56 String[] urlComponents = decodedValue.split("\\?", 2);
57
58 if (urlComponents.length != 2) {
59 return;
60 }
61
62 String[] nameValue = urlComponents[1].split("\\&");
63
64 for (int i = 0; i < nameValue.length; i++) {
65 String[] nameValuePair = nameValue[i].split("\\=", 2);
66
67 if (nameValuePair.length == 2) {
68 super.setParameter(nameValuePair[0], nameValuePair[1]);
69 }
70 else if (nameValuePair.length == 1) {
71 super.setParameter(nameValuePair[0], "true");
72 }
73 }
74 }
75 }
76 catch (Throwable t) {
77 _log.error("Could not parse Struts page query string " + value, t);
78 }
79 }
80
81 private static Log _log =
82 LogFactoryUtil.getLog(LiferayStrutsPortletURLImpl.class);
83
84 }