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