001
014
015 package com.liferay.portal.apache.bridges.struts;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portal.kernel.util.HttpUtil;
020 import com.liferay.portlet.PortletResponseImpl;
021 import com.liferay.portlet.PortletURLImplWrapper;
022
023 import org.apache.portals.bridges.struts.StrutsPortletURL;
024
025
028 public class LiferayStrutsPortletURLImpl extends PortletURLImplWrapper {
029
030 public LiferayStrutsPortletURLImpl(
031 PortletResponseImpl portletResponseImpl, long plid, String lifecycle) {
032
033 super(portletResponseImpl, plid, lifecycle);
034 }
035
036 public void setParameter(String name, String value) {
037 super.setParameter(name, value);
038
039
040
041
042 String decodedValue = HttpUtil.decodeURL(value);
043
044 try {
045 if (name.equals(StrutsPortletURL.PAGE)) {
046 String[] urlComponents = decodedValue.split("\\?", 2);
047
048 if (urlComponents.length != 2) {
049 return;
050 }
051
052 String[] nameValue = urlComponents[1].split("\\&");
053
054 for (int i = 0; i < nameValue.length; i++) {
055 String[] nameValuePair = nameValue[i].split("\\=", 2);
056
057 if (nameValuePair.length == 2) {
058 super.setParameter(nameValuePair[0], nameValuePair[1]);
059 }
060 else if (nameValuePair.length == 1) {
061 super.setParameter(nameValuePair[0], "true");
062 }
063 }
064 }
065 }
066 catch (Throwable t) {
067 _log.error("Could not parse Struts page query string " + value, t);
068 }
069 }
070
071 private static Log _log = LogFactoryUtil.getLog(
072 LiferayStrutsPortletURLImpl.class);
073
074 }