portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r772001 - in /portals/jetspeed-2/portal/trunk: components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/ components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/ jetspeed-api/src/main/java/org/ap...
Date Tue, 05 May 2009 22:52:42 GMT
Author: ate
Date: Tue May  5 22:52:41 2009
New Revision: 772001

URL: http://svn.apache.org/viewvc?rev=772001&view=rev
Log:
Fix for JS2-987: Portal request parameterMap must be captured before invoking a portlet on
WebSphere
See: https://issues.apache.org/jira/browse/JS2-987

Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletRequestContextImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/AbstractNavigationalState.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PathNavigationalState.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionNavigationalState.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/state/NavigationalState.java

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletRequestContextImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletRequestContextImpl.java?rev=772001&r1=772000&r2=772001&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletRequestContextImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletRequestContextImpl.java
Tue May  5 22:52:41 2009
@@ -17,7 +17,6 @@
 
 package org.apache.jetspeed.container.impl;
 
-import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -113,7 +112,6 @@
         return publicRenderParameterNames.isEmpty() ? false : publicRenderParameterNames.contains(name);
     }
         
-    @SuppressWarnings("unchecked")
     public Map<String, String[]> getPrivateParameterMap()
     {
         if (privateParameters == null)
@@ -183,40 +181,17 @@
             
             //get request params
             if (mergeRequestParameters)
-            {
-                String encoding = (String)containerRequest.getAttribute(PortalReservedParameters.PREFERED_CHARACTERENCODING_ATTRIBUTE);
-                boolean decode = containerRequest.getAttribute(PortalReservedParameters.PARAMETER_ALREADY_DECODED_ATTRIBUTE)
== null
-                        && encoding != null;
-                if (decode)
-                {
-                    containerRequest.setAttribute(PortalReservedParameters.PARAMETER_ALREADY_DECODED_ATTRIBUTE,new
Boolean(true));
-                }
-                for (Enumeration parameters = containerRequest.getParameterNames(); parameters.hasMoreElements();)
+            {                
+                for (Map.Entry<String,String[]> entry : ns.getRequestParameterMap().entrySet())
                 {
-                    String paramName = (String) parameters.nextElement();
-                    String[] paramValues = containerRequest.getParameterValues(paramName);
-
-                    if (decode)
-                    {
-                        for (int i = 0; i < paramValues.length; i++)
-                        {
-                            try
-                            {
-                                paramValues[i] = new String(paramValues[i].getBytes("ISO-8859-1"),
encoding);
-                            }
-                            catch (UnsupportedEncodingException e)
-                            {
-                                ;
-                            }
-                        }
-                    }
-                    String[] navValues = privateParameters.get(paramName);
+                    String[] navValues = privateParameters.get(entry.getKey());
                     if (navValues == null)
                     {
-                        privateParameters.put(paramName, paramValues);
+                        privateParameters.put(entry.getKey(), entry.getValue());
                     }
                     else
                     {
+                        String[] paramValues = entry.getValue();
                         String[] combined = new String[navValues.length+paramValues.length];
                         if (mergeRequestParametersBefore)
                         {
@@ -228,7 +203,7 @@
                             System.arraycopy(navValues,0,combined,0,navValues.length);
                             System.arraycopy(paramValues,0,combined,navValues.length,paramValues.length);
                         }
-                        privateParameters.put(paramName, combined);
+                        privateParameters.put(entry.getKey(), combined);
                     }
                 }
             }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/AbstractNavigationalState.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/AbstractNavigationalState.java?rev=772001&r1=772000&r2=772001&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/AbstractNavigationalState.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/AbstractNavigationalState.java
Tue May  5 22:52:41 2009
@@ -24,10 +24,12 @@
 
 import javax.portlet.PortletMode;
 import javax.portlet.WindowState;
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
 import javax.xml.namespace.QName;
 
 import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.PortalReservedParameters;
 import org.apache.jetspeed.aggregator.PortletContent;
 import org.apache.jetspeed.cache.ContentCacheKey;
 import org.apache.jetspeed.cache.JetspeedContentCache;
@@ -50,6 +52,7 @@
     private PortletWindowRequestNavigationalStates requestStates;
     protected JetspeedContentCache cache;
     protected JetspeedContentCache decorationCache;
+    protected Map<String,String[]> requestParameterMap;
     
     public AbstractNavigationalState(NavigationalStateCodec codec, JetspeedContentCache cache)
     {
@@ -152,6 +155,33 @@
         return targetResolved;
     }
     
+    @SuppressWarnings("unchecked")
+    protected void resolveRequestParameterMap(RequestContext context)
+    {
+        HttpServletRequest request = context.getRequest();
+        requestParameterMap = Collections.unmodifiableMap(new HashMap<String,String[]>(request.getParameterMap()));
+        String encoding = (String)request.getAttribute(PortalReservedParameters.PREFERED_CHARACTERENCODING_ATTRIBUTE);
+        if (encoding != null && request.getAttribute(PortalReservedParameters.PARAMETER_ALREADY_DECODED_ATTRIBUTE)
== null)
+        {
+            request.setAttribute(PortalReservedParameters.PARAMETER_ALREADY_DECODED_ATTRIBUTE,new
Boolean(true));
+            for (Map.Entry<String,String[]> entry : requestParameterMap.entrySet())
+            {
+                String[] paramValues = entry.getValue();
+                for (int i = 0; i < paramValues.length; i++)
+                {
+                    try
+                    {
+                        paramValues[i] = new String(paramValues[i].getBytes("ISO-8859-1"),
encoding);
+                    }
+                    catch (UnsupportedEncodingException e)
+                    {
+                        ;
+                    }
+                }
+            }
+        }
+    }
+    
     protected void resolvePublicParametersMap()
     {
         HashMap<QName, String[]> map = null;
@@ -421,6 +451,15 @@
             }
         }
     }
+    
+    public Map<String,String[]> getRequestParameterMap()
+    {
+        if (requestParameterMap == null)
+        {
+            requestParameterMap = Collections.emptyMap();
+        }
+        return requestParameterMap;
+    }
 
     public Map<String, String[]> getParameterMap(PortletWindow window)
     {

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PathNavigationalState.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PathNavigationalState.java?rev=772001&r1=772000&r2=772001&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PathNavigationalState.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PathNavigationalState.java
Tue May  5 22:52:41 2009
@@ -50,6 +50,7 @@
             resolvePublicParametersMap();
             syncPublicRequestParameters(context, false);
             resetRequestPortletWindowPublicRenderParameters();
+            resolveRequestParameterMap(context);
             return result;
         }
     }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionNavigationalState.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionNavigationalState.java?rev=772001&r1=772000&r2=772001&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionNavigationalState.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionNavigationalState.java
Tue May  5 22:52:41 2009
@@ -138,6 +138,7 @@
             }
             syncPublicRequestParameters(context, transientNavState);
             resetRequestPortletWindowPublicRenderParameters();
+            resolveRequestParameterMap(context);
             
             return result;
         }

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/state/NavigationalState.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/state/NavigationalState.java?rev=772001&r1=772000&r2=772001&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/state/NavigationalState.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/state/NavigationalState.java
Tue May  5 22:52:41 2009
@@ -144,6 +144,23 @@
      */
     PortletWindow getMaximizedWindow();
         
+    /**
+     * Provides a "safe" copy of the client/portal request parameterMap, with the values
+     * already (re)encode in the preferred or requested character encoding
+     * <p>
+     * This parameterMap is created early (and only once) to protect against dynamic
+     * modification by certain webcontainers like Websphere which might change the contents
+     * of the original request parametersMap during request dispatching with additional
+     * query string parameters.
+     * </p>
+     * <p>
+     * Furthermore, when using parallel rendering this is even more critical to do upfront
+     * and only once while still in the initial portal request Thread.
+     * </p>
+     * @return
+     */
+    Map<String, String[]> getRequestParameterMap();
+    
     Map<String, String[]> getParameterMap(PortletWindow window);
 
     boolean isActionScopedRequestAttributes(PortletWindow window);



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message