Author: mpodolin
Date: 2010-03-24 10:57:52 -0400 (Wed, 24 Mar 2010)
New Revision: 2357
Modified:
portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
Log:
JBEPP-202: the GTNPORTAL-337 ported to the EPP branch
Modified:
portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
===================================================================
---
portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-03-24
13:30:20 UTC (rev 2356)
+++
portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-03-24
14:57:52 UTC (rev 2357)
@@ -19,8 +19,6 @@
package org.exoplatform.portal.application;
-import com.sun.syndication.feed.atom.Link;
-
import org.exoplatform.Constants;
import org.exoplatform.commons.utils.PortalPrinter;
import org.exoplatform.commons.utils.WriterPrinter;
@@ -40,6 +38,7 @@
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.core.UIComponent;
import org.exoplatform.webui.core.lifecycle.HtmlValidator;
+import org.gatein.common.http.QueryStringParser;
import org.w3c.dom.Element;
import javax.xml.transform.OutputKeys;
@@ -54,6 +53,7 @@
import java.io.Writer;
import java.net.URLDecoder;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -115,6 +115,8 @@
private List<Element> extraMarkupHeaders;
private final PortalURLBuilder urlBuilder;
+
+ private Map<String, String[]> parameterMap;
public JavascriptManager getJavascriptManager()
{
@@ -131,7 +133,7 @@
//The encoding needs to be set before reading any of the parameters since the
parameters's encoding
- //is set at the first acces.
+ //is set at the first access.
//TODO use the encoding from the locale-config.xml file
response_.setContentType("text/html; charset=UTF-8");
@@ -144,6 +146,17 @@
log.error("Encoding not supported", e);
}
+ // Query parameters from the request will be set in the servlet container url
encoding and not
+ // necessarly in utf-8 format. So we need to directly parse the parameters from the
query string.
+ parameterMap = new HashMap<String, String[]>();
+ parameterMap.putAll(request_.getParameterMap());
+ String queryString = req.getQueryString();
+ if (queryString != null)
+ {
+ Map<String, String[]> queryParams =
QueryStringParser.getInstance().parseQueryString(queryString);
+ parameterMap.putAll(queryParams);
+ }
+
ajaxRequest_ = "true".equals(req.getParameter("ajaxRequest"));
String cache = req.getParameter(CACHE_LEVEL);
if (cache != null)
@@ -152,8 +165,15 @@
}
requestURI_ = URLDecoder.decode(req.getRequestURI(), "UTF-8");
- String pathInfo = req.getPathInfo();
- if (pathInfo == null)
+
+ // req.getPathInfo will already have the encoding set from the server.
+ // We need to use the UTF-8 value since this is how we store the portal name.
+ // Reconstructing the getPathInfo from the non server decoded values.
+ String servletPath = URLDecoder.decode(req.getServletPath(), "UTF-8");
+ String contextPath = URLDecoder.decode(req.getContextPath(), "UTF-8");
+ String pathInfo = requestURI_.substring((servletPath + contextPath).length());
+
+ if (pathInfo == null || pathInfo.length() == 0)
{
pathInfo = "/";
}
@@ -241,17 +261,24 @@
public String getRequestParameter(String name)
{
- return request_.getParameter(name);
+ if (parameterMap.get(name) != null && parameterMap.get(name).length >
0)
+ {
+ return parameterMap.get(name)[0];
+ }
+ else
+ {
+ return null;
+ }
}
public String[] getRequestParameterValues(String name)
{
- return request_.getParameterValues(name);
+ return parameterMap.get(name);
}
public Map<String, String[]> getPortletParameters()
{
- Map<String, String[]> unsortedParams = getRequest().getParameterMap();
+ Map<String, String[]> unsortedParams = parameterMap;
Map<String, String[]> sortedParams = new HashMap<String, String[]>();
Set<String> keys = unsortedParams.keySet();
for (String key : keys)
Modified:
portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
===================================================================
---
portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-03-24
13:30:20 UTC (rev 2356)
+++
portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-03-24
14:57:52 UTC (rev 2357)
@@ -644,7 +644,7 @@
I invocation;
HttpServletRequest servletRequest = prc.getRequest();
HashMap<String, String[]> allParams = new HashMap<String, String[]>();
- allParams.putAll(servletRequest.getParameterMap());
+ allParams.putAll(prc.getPortletParameters());
allParams.putAll(this.getPublicParameters());
allParams.remove(ExoPortletInvocationContext.NAVIGATIONAL_STATE_PARAM_NAME);
if (type.equals(ActionInvocation.class))
Show replies by date