Author: julien_viet
Date: 2011-01-14 18:24:04 -0500 (Fri, 14 Jan 2011)
New Revision: 5751
Modified:
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/DispatchedHttpServletRequest.java
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/PortletRequestAttributes.java
components/pc/trunk/test/core/src/test/java/org/gatein/pc/test/portlet/jsr286/tck/dispatcher/RFRIContainerAttributesTestCase.java
components/pc/trunk/test/core/src/test/java/org/gatein/pc/test/portlet/jsr286/tck/dispatcher/RIRFContainerAttributesTestCase.java
components/pc/trunk/test/core/src/test/java/org/gatein/pc/test/portlet/jsr286/tck/dispatcher/RIRIContainerAttributesTestCase.java
Log:
GTNPC-50 : Request dispatching issues with Jetty
Modified:
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/DispatchedHttpServletRequest.java
===================================================================
---
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/DispatchedHttpServletRequest.java 2011-01-14
20:09:15 UTC (rev 5750)
+++
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/DispatchedHttpServletRequest.java 2011-01-14
23:24:04 UTC (rev 5751)
@@ -44,6 +44,7 @@
import javax.portlet.PortletConfig;
import java.security.Principal;
import java.util.Enumeration;
+import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;
import java.util.LinkedList;
@@ -246,49 +247,40 @@
public final String getPathInfo()
{
- if (infos != null)
- {
- return infos[PATH_INFO];
- }
- else
- {
- return (String)preq.getAttribute(INCLUDE_KEYS[PATH_INFO]);
- }
+ return getSpecAttribute(PATH_INFO);
}
public final String getQueryString()
{
- if (infos != null)
- {
- return infos[QUERY_STRING];
- }
- else
- {
- return (String)preq.getAttribute(INCLUDE_KEYS[QUERY_STRING]);
- }
+ return getSpecAttribute(QUERY_STRING);
}
public final String getRequestURI()
{
- if (infos != null)
- {
- return infos[REQUEST_URI];
- }
- else
- {
- return (String)preq.getAttribute(INCLUDE_KEYS[REQUEST_URI]);
- }
+ return getSpecAttribute(REQUEST_URI);
}
public final String getServletPath()
{
- if (infos != null)
+ return getSpecAttribute(SERVLET_PATH);
+ }
+
+ private String getSpecAttribute(int index)
+ {
+ if (dispatches.getFirst().getPath() == null)
{
- return infos[SERVLET_PATH];
+ return null;
}
else
{
- return (String)preq.getAttribute(INCLUDE_KEYS[SERVLET_PATH]);
+ if (infos != null)
+ {
+ return infos[index];
+ }
+ else
+ {
+ return (String)preq.getAttribute(INCLUDE_KEYS[index]);
+ }
}
}
@@ -313,55 +305,53 @@
{
if (s != null)
{
-// Map<String, String> containerAttributes =
containerAttributesStack.getLast();
-
- //
-// if (containerAttributes.containsKey(s))
-// {
-// return containerAttributes.get(s);
-// }
-
- if (dispatches.getLast().getType() == DispatchType.INCLUDE)
+ if (ALL_CONTAINER_ATTRIBUTES.contains(s))
{
- for (String key : INCLUDE_KEYS)
+ Dispatch dispatch = dispatches.getLast();
+ if (dispatch.getType() == DispatchType.INCLUDE)
{
- if (key.equals(s))
+ if (dispatch.getPath() == null)
{
- return preq.getAttribute(key);
+ return null;
}
+ else
+ {
+ for (String key : INCLUDE_KEYS)
+ {
+ if (key.equals(s))
+ {
+ return preq.getAttribute(key);
+ }
+ }
+ }
}
- }
- else
- {
- for (int i = 0;i < FORWARD_KEYS.length;i++)
+ else
{
- if (FORWARD_KEYS[i].equals(s))
+ for (ListIterator<Dispatch> it =
dispatches.listIterator(dispatches.size());it.hasPrevious();)
{
- if (infos != null)
+ if (it.previous().getPath() == null)
{
- return infos[i];
+ return null;
}
- else
+ }
+ for (int i = 0;i < FORWARD_KEYS.length;i++)
+ {
+ if (FORWARD_KEYS[i].equals(s))
{
- return preq.getAttribute(INCLUDE_KEYS[i]);
+ if (infos != null)
+ {
+ return infos[i];
+ }
+ else
+ {
+ return preq.getAttribute(INCLUDE_KEYS[i]);
+ }
}
}
}
}
//
- String[] containerKeys = dispatches.getLast().getType() == DispatchType.FORWARD
? FORWARD_KEYS : INCLUDE_KEYS;
-
- //
- for (int i = 0;i < containerKeys.length;i++)
- {
- if (containerKeys[i].equals(s))
- {
- return preq.getAttribute(INCLUDE_KEYS[i]);
- }
- }
-
- //
if (ALL_CONTAINER_ATTRIBUTES.contains(s))
{
return null;
@@ -628,139 +618,8 @@
}
this.infos = infos;
}
-
-
-// String path = dispatch.getPath();
-//
-// //
-// String[] infos;
-// if (path != null)
-// {
-// infos = build(path);
-//
-// //
-// if (dispatch.getType() == DispatchType.INCLUDE)
-// {
-// Map<String, String> containerAttributes = new HashMap<String,
String>();
-// for (int i = 0;i < infos.length;i++)
-// {
-// String value = infos[i];
-// if (value != null)
-// {
-// containerAttributes.put(INCLUDE_KEYS[i], value);
-// }
-// }
-// containerAttributesStack.addLast(containerAttributes);
-// }
-// else
-// {
-// if (containerAttributesStack.size() == 0)
-// {
-// Map<String, String> containerAttributes = new HashMap<String,
String>();
-// for (int i = 0;i < infos.length;i++)
-// {
-// String value = infos[i];
-// if (value != null)
-// {
-// containerAttributes.put(FORWARD_KEYS[i], value);
-// }
-// }
-// containerAttributesStack.addLast(containerAttributes);
-// }
-// else
-// {
-// Map<String, String> containerAttributes = new HashMap<String,
String>();
-// for (int i = 0;i < this.infos.length;i++)
-// {
-// String value = this.infos[i];
-// if (value != null)
-// {
-// containerAttributes.put(FORWARD_KEYS[i], value);
-// }
-// }
-// containerAttributesStack.addLast(containerAttributes);
-// }
-// }
-// }
-// else
-// {
-// infos = new String[5];
-//
-// //
-// Map<String, String> containerAttributes = Collections.emptyMap();
-// containerAttributesStack.addLast(containerAttributes);
-// }
-//
-// //
-// return infos;
}
-// private String[] build(String path)
-// {
-// if (path == null)
-// {
-// throw new IllegalArgumentException();
-// }
-//
-// //
-// String servletPath;
-// String pathInfo;
-// String queryString;
-// int endOfServletPath = path.indexOf('/', 1);
-// if (endOfServletPath == -1)
-// {
-// endOfServletPath = path.indexOf('?', 1);
-// if (endOfServletPath == -1)
-// {
-// servletPath = path;
-// pathInfo = "";
-// queryString = "";
-// }
-// else
-// {
-// servletPath = path.substring(0, endOfServletPath);
-// pathInfo = null;
-// queryString = path.substring(endOfServletPath + 1);
-// }
-// }
-// else
-// {
-// servletPath = path.substring(0, endOfServletPath);
-// int endOfPathInfo = path.indexOf('?', endOfServletPath + 1);
-// if (endOfPathInfo == -1)
-// {
-// pathInfo = path.substring(endOfServletPath);
-// queryString = "";
-// }
-// else
-// {
-// pathInfo = path.substring(endOfServletPath, endOfPathInfo);
-// queryString = path.substring(endOfPathInfo + 1);
-// }
-// }
-//
-// //
-// String[] infos = new String[5];
-//
-// //
-// StringBuffer requestURI = new StringBuffer(preq.getContextPath());
-// requestURI.append(servletPath);
-// if (pathInfo != null)
-// {
-// requestURI.append(pathInfo);
-// infos[PATH_INFO] = pathInfo;
-// }
-//
-// //
-// infos[SERVLET_PATH] = servletPath;
-// infos[QUERY_STRING] = queryString;
-// infos[REQUEST_URI] = requestURI.toString();
-// infos[CONTEXT_PATH] = preq.getContextPath();
-//
-// //
-// return infos;
-// }
-
void popDispatch()
{
if (dispatches.size() == 2)
Modified:
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/PortletRequestAttributes.java
===================================================================
---
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/PortletRequestAttributes.java 2011-01-14
20:09:15 UTC (rev 5750)
+++
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/PortletRequestAttributes.java 2011-01-14
23:24:04 UTC (rev 5751)
@@ -148,7 +148,7 @@
{
value = attributes.get(name);
}
- if (value == null && wreq != null)
+ if (value == null)
{
value = wreq.getAttribute(name);
}
Modified:
components/pc/trunk/test/core/src/test/java/org/gatein/pc/test/portlet/jsr286/tck/dispatcher/RFRIContainerAttributesTestCase.java
===================================================================
---
components/pc/trunk/test/core/src/test/java/org/gatein/pc/test/portlet/jsr286/tck/dispatcher/RFRIContainerAttributesTestCase.java 2011-01-14
20:09:15 UTC (rev 5750)
+++
components/pc/trunk/test/core/src/test/java/org/gatein/pc/test/portlet/jsr286/tck/dispatcher/RFRIContainerAttributesTestCase.java 2011-01-14
23:24:04 UTC (rev 5751)
@@ -45,9 +45,6 @@
public class RFRIContainerAttributesTestCase extends
DispatchedContainerAttributesTestCase
{
- /** . */
- public static final Map<String, String> EXPECTED_ATTRIBUTES_SET =
buildAttributes();
-
private static Map<String, String> buildAttributes()
{
Map<String, String> map = new HashMap<String, String>();
Modified:
components/pc/trunk/test/core/src/test/java/org/gatein/pc/test/portlet/jsr286/tck/dispatcher/RIRFContainerAttributesTestCase.java
===================================================================
---
components/pc/trunk/test/core/src/test/java/org/gatein/pc/test/portlet/jsr286/tck/dispatcher/RIRFContainerAttributesTestCase.java 2011-01-14
20:09:15 UTC (rev 5750)
+++
components/pc/trunk/test/core/src/test/java/org/gatein/pc/test/portlet/jsr286/tck/dispatcher/RIRFContainerAttributesTestCase.java 2011-01-14
23:24:04 UTC (rev 5751)
@@ -45,9 +45,6 @@
public class RIRFContainerAttributesTestCase extends
DispatchedContainerAttributesTestCase
{
- /** . */
- public static final Map<String, String> EXPECTED_ATTRIBUTES_SET =
buildAttributes();
-
private static Map<String, String> buildAttributes()
{
Map<String, String> map = new HashMap<String, String>();
Modified:
components/pc/trunk/test/core/src/test/java/org/gatein/pc/test/portlet/jsr286/tck/dispatcher/RIRIContainerAttributesTestCase.java
===================================================================
---
components/pc/trunk/test/core/src/test/java/org/gatein/pc/test/portlet/jsr286/tck/dispatcher/RIRIContainerAttributesTestCase.java 2011-01-14
20:09:15 UTC (rev 5750)
+++
components/pc/trunk/test/core/src/test/java/org/gatein/pc/test/portlet/jsr286/tck/dispatcher/RIRIContainerAttributesTestCase.java 2011-01-14
23:24:04 UTC (rev 5751)
@@ -44,9 +44,6 @@
public class RIRIContainerAttributesTestCase extends
DispatchedContainerAttributesTestCase
{
- /** . */
- public static final Map<String, String> EXPECTED_ATTRIBUTES_SET =
buildAttributes();
-
private static Map<String, String> buildAttributes()
{
Map<String, String> map = new HashMap<String, String>();