You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by ms...@apache.org on 2015/02/16 16:54:43 UTC

[01/22] portals-pluto git commit: Worked on merge of V3.0 API. Further changes that do not impact Pluto code (javadoc)

Repository: portals-pluto
Updated Branches:
  refs/heads/V3Prototype 6f30042b0 -> 355084b02


Worked on merge of V3.0 API. Further changes that do not impact Pluto code (javadoc)


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/8423118c
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/8423118c
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/8423118c

Branch: refs/heads/V3Prototype
Commit: 8423118c31da03b2765c3486c9a7e193d15f014d
Parents: 6f30042
Author: Scott Nicklous <ms...@apache.org>
Authored: Tue Feb 3 17:56:11 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Tue Feb 3 17:56:11 2015 +0100

----------------------------------------------------------------------
 .../main/java/javax/portlet/PortletRequest.java | 79 +++++++++++++++----
 .../main/java/javax/portlet/RenderResponse.java | 20 +++--
 .../java/javax/portlet/ResourceRequest.java     | 83 ++++++++++++++++----
 portlet-api/src/main/javadoc/overview.html      | 10 +++
 portlet-api/src/main/javascript/portlet.js      | 73 ++++++++++++++++-
 5 files changed, 223 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/8423118c/portlet-api/src/main/java/javax/portlet/PortletRequest.java
----------------------------------------------------------------------
diff --git a/portlet-api/src/main/java/javax/portlet/PortletRequest.java b/portlet-api/src/main/java/javax/portlet/PortletRequest.java
index e42dc4d..6653538 100644
--- a/portlet-api/src/main/java/javax/portlet/PortletRequest.java
+++ b/portlet-api/src/main/java/javax/portlet/PortletRequest.java
@@ -28,19 +28,26 @@ import java.util.Locale;
 
 
 /**
- * The <CODE>PortletRequest</CODE> defines the base interface to provide client
- * request information to a portlet. The portlet container uses two specialized
- * versions of this interface when invoking a portlet, <CODE>ActionRequest</CODE>
- * and <CODE>RenderRequest</CODE>. The portlet container creates these objects and 
- * passes them as  arguments to the portlet's <CODE>processAction</CODE> and
- * <CODE>render</CODE> methods.
+ * <div class="changed_modified_3_0">The
+ * <CODE>PortletRequest</CODE> defines the base interface to provide client
+ * request information to a portlet. The portlet container uses specialized
+ * versions of this interface when invoking a portlet. 
+ * The portlet container creates these objects and 
+ * passes them as arguments to the corresponding request processing methods.
+ * <p>
+ * The <code>PortletRequest</code> also provides access to the portlet state.
+ * </div>
  * 
+ * @see PortletState
  * @see ActionRequest
+ * @see EventRequest
  * @see RenderRequest
+ * @see ResourceRequest
  */
 public interface PortletRequest
 {
     
+   
   /** Used to retrieve user information attributes with the 
    * <code>getAttribute</code> call. The user information is returned 
    * as a <code>Map</code> object. The portlet must define the 
@@ -285,6 +292,7 @@ public interface PortletRequest
   public static final String ACTION_SCOPE_ID = "javax.portlet.as";
   
   
+  
   /**
    * Returns true, if the given window state is valid
    * to be set for this portlet in the context
@@ -300,7 +308,7 @@ public interface PortletRequest
   public boolean isWindowStateAllowed(WindowState state);
 
 
-/**
+ /**
    * Returns true, if the given portlet mode is a valid
    * one to set for this portlet  in the context
    * of the current request.
@@ -343,11 +351,19 @@ public interface PortletRequest
 
 
   /**
-   * Returns the current portlet session or, if there is no current session,
+   * <span class="changed_modified_3_0">Returns</span> 
+   * the current portlet session or, if there is no current session,
    * creates one and returns the new session.
    *  <p>
    * Creating a new portlet session will result in creating
-   * a new <code>HttpSession</code> on which the portlet session is based on.
+   * a new <code>HttpSession</code> on which the portlet session is based.
+   * <p>
+   * <span class="changed_added_3_0"> 
+   * To make sure the session is properly maintained, you must call this method before 
+   * the response is committed. If the container is using cookies to maintain session 
+   * integrity and is asked to create a new session when the response is committed, 
+   * an <code>IllegalStateException</code> is thrown.
+   * </span>
    *
    * @return the portlet session
    */
@@ -356,7 +372,8 @@ public interface PortletRequest
 
 
   /**
-   * Returns the current portlet session or, if there is no current session
+   * <span class="changed_modified_3_0">Returns</span> 
+   * the current portlet session or, if there is no current session
    * and the given flag is <CODE>true</CODE>, creates one and returns
    * the new session.
    * <P>
@@ -364,7 +381,14 @@ public interface PortletRequest
    * portlet session, this method returns <CODE>null</CODE>.
    *  <p>
    * Creating a new portlet session will result in creating
-   * a new <code>HttpSession</code> on which the portlet session is based on.
+   * a new <code>HttpSession</code> on which the portlet session is based.
+   * <p>
+   * <span class="changed_added_3_0"> 
+   * To make sure the session is properly maintained, you must call this method before 
+   * the response is committed. If the container is using cookies to maintain session 
+   * integrity and is asked to create a new session when the response is committed, 
+   * an <code>IllegalStateException</code> is thrown.
+   * </span>
    * 
    * @param create
    *               <CODE>true</CODE> to create a new session, <BR>
@@ -615,8 +639,10 @@ public interface PortletRequest
    * @exception  java.lang.IllegalArgumentException 
    *                            if name is <code>null</code>.
    *
+   * @deprecated As of version 3.0. Use {@link #getRenderParameters()} instead.
    */
   
+  @Deprecated
   public String getParameter(String name);
 
 
@@ -636,8 +662,10 @@ public interface PortletRequest
    * 			the name of a request parameter; or an 
    *			empty <code>Enumeration</code> if the
    *			request has no parameters.
+   * @deprecated As of version 3.0. Use {@link #getRenderParameters()} instead.
    */
 
+  @Deprecated
   public java.util.Enumeration<String> getParameterNames();
 
 
@@ -662,13 +690,18 @@ public interface PortletRequest
    * @exception  java.lang.IllegalArgumentException 
    *                            if name is <code>null</code>.
    *
+   * @deprecated As of version 3.0. Use {@link #getRenderParameters()} instead.
    */
 
+  @Deprecated
   public String[] getParameterValues(String name);
 
 
   /** 
-   * Returns a <code>Map</code> of the parameters of this request.
+   * <span class="changed_modified_3_0">Returns</span> 
+   * a <code>Map</code> of 
+   * <span class="changed_modified_3_0">all public and private parameters</span> 
+   * of this request.
    * Request parameters are extra information sent with the request.  
    * The returned parameters are "x-www-form-urlencoded" decoded.
    * <p>
@@ -682,8 +715,11 @@ public interface PortletRequest
    *             if no parameters exist. The keys in the parameter
    *             map are of type String. The values in the parameter map are of type
    *             String array (<code>String[]</code>).
+   *             
+   * @deprecated As of version 3.0. Use {@link #getRenderParameters()} instead.
    */
 
+  @Deprecated
   public java.util.Map<String, String[]> getParameterMap();
 
 
@@ -897,13 +933,18 @@ public interface PortletRequest
    * @since 2.0
    * @return  array of cookie properties, or 
    *          <code>null</code> if no cookies exist.
-   * @see MimeResponse#addProperty(Cookie) 
+   * @see PortletResponse#addProperty(Cookie) 
    */
   public javax.servlet.http.Cookie[] getCookies();
   
+  
   /**
+   * <span class="changed_modified_3_0"> 
    * Returns a <code>Map</code> of the private parameters of this request.
-   * Private parameters are not shared with other portlets or components.  
+   * Private parameters are all those not declared to be public parameters 
+   * in the portlet deployment descriptor. They are not shared with other 
+   * portlets or components.
+   * </span>
    * The returned parameters are "x-www-form-urlencoded" decoded.
    * <p>
    * The values in the returned <code>Map</code> are from type
@@ -917,12 +958,16 @@ public interface PortletRequest
    *             if no private parameters exist. The keys in the parameter
    *             map are of type String. The values in the parameter map are of type
    *             String array (<code>String[]</code>).
+   *             
+   * @deprecated As of version 3.0. Use {@link #getRenderParameters()} instead.
    */
+
+  @Deprecated
   public java.util.Map<String, String[]> getPrivateParameterMap();
   
   /**
    * Returns a <code>Map</code> of the public parameters of this request.
-   * Public parameters may be shared with other portlets or components and
+   * Public parameters may be shared with other portlets or components as
    * defined in the portlet deployment descriptor with the 
    * <code>supported-public-render-parameter</code> element.  
    * The returned parameters are "x-www-form-urlencoded" decoded.
@@ -938,7 +983,11 @@ public interface PortletRequest
    *             if no public parameters exist. The keys in the parameter
    *             map are of type String. The values in the parameter map are of type
    *             String array (<code>String[]</code>).
+   *             
+   * @deprecated As of version 3.0. Use {@link #getRenderParameters()} instead.
    */
+
+  @Deprecated
   public java.util.Map<String, String[]> getPublicParameterMap();
 
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/8423118c/portlet-api/src/main/java/javax/portlet/RenderResponse.java
----------------------------------------------------------------------
diff --git a/portlet-api/src/main/java/javax/portlet/RenderResponse.java b/portlet-api/src/main/java/javax/portlet/RenderResponse.java
index fb2eccf..a822a49 100644
--- a/portlet-api/src/main/java/javax/portlet/RenderResponse.java
+++ b/portlet-api/src/main/java/javax/portlet/RenderResponse.java
@@ -25,11 +25,13 @@
 package javax.portlet;
 
 /**
- * The <CODE>RenderResponse</CODE> defines an object to assist a portlet in
- * sending a response to the portal. It extends the <CODE>MimeResponse</CODE>
- * interface to provide specific render response functionality to portlets.<br>
- * The portlet container creates a <CODE>RenderResponse</CODE> object and
- * passes it as argument to the portlet's <CODE>render</CODE> method.
+ * <span class="changed_modified_3_0">The</span>
+ * <CODE>RenderResponse</CODE> defines an object to assist a portlet in
+ * sending a response to the portal. It extends the
+ * <CODE>MimeResponse</CODE> interface to provide specific render
+ * response functionality to portlets.<br> The portlet container creates
+ * a <CODE>RenderResponse</CODE> object and passes it as argument to the
+ * portlet's <CODE>render</CODE> method.
  * 
  * @see RenderRequest
  * @see PortletResponse
@@ -49,7 +51,7 @@ public interface RenderResponse extends MimeResponse {
    
     
 	/**
-     * This method allows the portlet to tell the portal the next possible
+     * <span class="changed_modified_3_0">This</span> method allows the portlet to tell the portal the next possible
      * portlet modes that the make sense from the portlet point of view.
      * <p>
      * If set, the portal should honor these enumeration of portlet modes and
@@ -61,13 +63,15 @@ public interface RenderResponse extends MimeResponse {
      * portlet deployment descriptor are meaningful new portlet modes.
      * 
      * @param portletModes
-     *            <code>Enumeration</code> of <code>PortletMode</code> objects with the
+     *            <code>Enumeration</code> of <span class="changed_modified_3_0">objects 
+     *            of type <code>PortletMode</code> 
+     *            or any subtype of <code>PortletMode</code></span> with the
      *            next possible portlet modes that the make sense from the
      *            portlet point of view, must not be <code>null</code> or an
      *            empty enumeration.
      * @since 2.0
      */
-	public void setNextPossiblePortletModes(java.util.Collection<PortletMode> portletModes);
+	public void setNextPossiblePortletModes(java.util.Collection<? extends PortletMode> portletModes);
 
     /**
      * Sets the MIME type for the render response. The portlet should set the

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/8423118c/portlet-api/src/main/java/javax/portlet/ResourceRequest.java
----------------------------------------------------------------------
diff --git a/portlet-api/src/main/java/javax/portlet/ResourceRequest.java b/portlet-api/src/main/java/javax/portlet/ResourceRequest.java
index f2b121d..5aa77d0 100644
--- a/portlet-api/src/main/java/javax/portlet/ResourceRequest.java
+++ b/portlet-api/src/main/java/javax/portlet/ResourceRequest.java
@@ -25,7 +25,8 @@
 package javax.portlet;
 
 /**
- * The <code>ResourceRequest</code> interface represents the request
+ * <span class="changed_modified_3_0">The</span>
+ * <code>ResourceRequest</code> interface represents the request
  * send to the portlet for rendering resources.
  * 
  * It extends the ClientDataRequest interface and provides resource request
@@ -85,21 +86,6 @@ public interface ResourceRequest extends ClientDataRequest {
     public String getResourceID();
     
     /**
-     * Returns a <code>String</code> representing the current page state.
-     * 
-     * The content of the returned value is unspecified. It is to be passed to the
-     * Portlet Hub in order to conclude a Partial Action processing sequence. 
-     * <code>null</code> is a valid return value.
-     * 
-     * This call is only valid during Partial Action processing. If called at other times,
-     * the returned value is unspecified.
-     * 
-     * @return String to be passed to the Portlet Hub to conclude a Partial Action
-     *         processing sequence.
-     */
-    public String getPageState();
- 
-    /**
      * Returns a <code>Map</code> of the private render parameters of this request.
      * Private parameters are not shared with other portlets or components.  
      * The returned parameters are "x-www-form-urlencoded" decoded.
@@ -118,9 +104,34 @@ public interface ResourceRequest extends ClientDataRequest {
      *             if no private parameters exist. The keys in the parameter
      *             map are of type String. The values in the parameter map are of type
      *             String array (<code>String[]</code>).
+    *             
+    * @deprecated As of version 3.0. Use {@link PortletRequest#getRenderParameters()} instead.
      */
+
+   @Deprecated
     public java.util.Map<String, String[]> getPrivateRenderParameterMap();
     
+   /**
+    * <div class="changed_added_3_0">
+    * Returns a <code>String</code> representing the current page state.
+    * <p>
+    * The content of the returned value is unspecified. It is to be passed to the
+    * Portlet Hub in order to conclude a Partial Action processing sequence. 
+    * <code>null</code> is a valid return value.
+    * <p>
+    * This call is only valid during Partial Action processing. If called at other times,
+    * the returned value is unspecified.
+    * <p>
+    * The Partial Action processing sequence provides support for infrastructure components
+    * such as a JSF Portlet Bridge to obtain page state information for use by the
+    * JavaScript Portlet Hub component.
+    * </div>
+    * 
+    * @return String to be passed to the Portlet Hub to conclude a Partial Action
+    *         processing sequence.
+    */
+   public String getPageState();
+
     /**
      * Returns the portal preferred content type for the response.
      * <p>
@@ -156,4 +167,44 @@ public interface ResourceRequest extends ClientDataRequest {
      */
 	public String getCacheability();
 
+
+   /**
+    * <span class="changed_modified_3_0">Returns</span> 
+    * the current portlet mode of the portlet.
+    * <div class="changed_added_3_0">
+    * <p>
+    * If called during a request where the cache level is set to 
+    * <code>ResourceURL.FULL</code>, the portlet mode will not
+    * be available. 
+    * </div>
+    *
+    * @return   the portlet mode.
+    * <span class="changed_added_3_0">
+    *           The portlet mode UNDEFINED will be returned if the cache level is
+    *           set to <code>ResourceURL.FULL</code>.  
+    * </span>
+    */
+
+   public PortletMode getPortletMode ();
+
+
+   /**
+    * <span class="changed_modified_3_0">Returns</span> 
+    * the current window state of the portlet.
+    * <div class="changed_added_3_0">
+    * <p>
+    * If called during a request where the cache level is set to 
+    * <code>ResourceURL.FULL</code>, the window state will not
+    * be available. 
+    * </div>
+    *
+    * @return   the window state.
+    * <span class="changed_added_3_0">
+    *           The window state UNDEFINED will be returned if the cache level is
+    *           set to <code>ResourceURL.FULL</code>.  
+    * </span>
+    */
+
+   public WindowState getWindowState ();
+
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/8423118c/portlet-api/src/main/javadoc/overview.html
----------------------------------------------------------------------
diff --git a/portlet-api/src/main/javadoc/overview.html b/portlet-api/src/main/javadoc/overview.html
index b18d97c..25ab44b 100644
--- a/portlet-api/src/main/javadoc/overview.html
+++ b/portlet-api/src/main/javadoc/overview.html
@@ -16,6 +16,16 @@
     <!-- change class below to "indexContainer" to activate color changebars in the change history -->
     <div class="indexContainer-not">
     <ul>
+    <li>20150202: Updated PORTLETSPEC3-18: Updated methods
+    {@link javax.portlet.PortletConfig#getPortletModes PortletConfig.getPortletModes(String)} and
+    {@link javax.portlet.PortletConfig#getWindowStates PortletConfig.getWindowStates(String)}.
+    Added method 
+    {@link javax.portlet.PortletConfig#getPublicRenderParameterDefinitions PortletConfig.getPublicRenderParameterDefinitions()}.
+    See 
+    <a href="https://java.net/projects/portletspec3/pages/PortletConfiguration#PORTLETSPEC3-18"> 
+    portlet configuration description.
+    </a>
+    </li>
     <li>20141204: Updates for the
     <a href="../jsdoc/index.html" target="_top">Portlet Hub Ajax support</a>.
     Updated the following data structures:

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/8423118c/portlet-api/src/main/javascript/portlet.js
----------------------------------------------------------------------
diff --git a/portlet-api/src/main/javascript/portlet.js b/portlet-api/src/main/javascript/portlet.js
index bfffb69..4dbb0a1 100644
--- a/portlet-api/src/main/javascript/portlet.js
+++ b/portlet-api/src/main/javascript/portlet.js
@@ -833,6 +833,31 @@ var portlet = portlet || {};
    },
 
    /**
+    * Accepts an object containing changed portlet IDs. This 
+    * function is meant to be used by the Portlet Hub impl in order 
+    * to initiate an unsolicited state update for the input list of 
+    * portlet IDs.
+    *
+    * @returns {Promise}   fulfilled with the actual upddate function when
+    *                      the hub is not busy.
+    *
+    * @private
+    */
+   updateWhenIdle = function (upids) {
+      return new Promise (function (resolve) {
+         function update () {
+            if (busy) {
+               delay(update, 20);
+            } else {
+               busy = true;
+               resolve(updatePageState);
+            }
+         }
+         update();
+      });
+   },
+
+   /**
     * Updates the portlet state, taking the public render
     * parameters into account.
     * The portlet client requesting the change, represented
@@ -1146,7 +1171,7 @@ var portlet = portlet || {};
        * functions as passed in as an argument
        */
       return portlet.impl
-            .register(portletId)
+            .register(portletId, updateWhenIdle)
             .then(
                   function(portletImpl) {
 
@@ -1541,9 +1566,22 @@ var portlet = portlet || {};
              * an HTML form to be submitted.
              * The portlet hub will use this form to execute the action.
              * <p>
+             * If the form element is specified, the encoding type must be 
+             * 'application/x-www-form-urlencoded' or 'multipart/form-data'.
+             * The encoding type 'text/plain' is not supported.
+             * <p>
+             * If the encoding type is 'multipart/form-data', the submission method
+             * must be 'POST'.
+             * Form 'INPUT' elements of type 'FILE' are supported. 
+             * <p>
+             * If the encoding type is 'application/x-www-form-urlencoded', the submission method
+             * can be either 'GET' or 'POST'.
+             * However, form 'INPUT' elements of type 'FILE' are not supported. 
+             * <p>
              * Specification of <code>element</code> is optional.
              * If the <code>element</code> is not specified, the portlet hub will
-             * submit the action to the server in an appropriate manner.
+             * submit the action to the server by executing a 'POST' with an action
+             * URL containing any action parameters provided.
              * <p>
              * A portlet action is a blocking operation.
              * To allow for orderly state transitions, the portlet hub does not allow
@@ -1579,7 +1617,7 @@ var portlet = portlet || {};
              * @memberOf   PortletInit
              */
             action : function (actParams, element) {
-               var ii, arg, type, parms = null, el = null;
+               var ii, arg, type, parms = null, el = null, meth;
          
                console.log("Executing action for portlet: " + portletId);
                // check arguments. make sure there is a maximum of two
@@ -1610,6 +1648,35 @@ var portlet = portlet || {};
                             + " is of type " + type);
                   }
                }
+               
+               // if we're dealing with a form, verify method and enctype
+               
+               if (el) {
+                  meth = el.method ? el.method.toUpperCase() : undefined;
+            	   
+                  if (meth && (meth !== 'POST') && (meth !== 'GET')) {
+                       throwIllegalArgumentException("Invalid form method " + el.method + ". Allowed methods are GET & POST ");
+            	   }
+            	   
+            	   // allow the default, which is 'application/x-www-form-urlencoded' encoded, and also multipart/form-data
+            	   if (el.enctype && el.enctype !== 'application\/x-www-form-urlencoded' && el.enctype !== 'multipart\/form-data') {
+                       throwIllegalArgumentException("Invalid form enctype " + el.enctype + ". Allowed: 'application\/x-www-form-urlencoded' & 'multipart\/form-data'  ");
+            	   }
+            	   
+                  if (el.enctype && (el.enctype === 'multipart\/form-data') && (meth !== 'POST')) {
+                     throwIllegalArgumentException("Invalid method with multipart/form-data. Must be POST.");
+                  }
+                  
+                  // if the data is supposed to be urlencoded, we don't suport FILE element
+                  if (!el.enctype || (el.enctype === 'application\/x-www-form-urlencoded')) {
+                     for (ii = 0; ii < el.elements.length; ii++) {
+                        if (el.elements[ii].nodeName.toUpperCase() === 'INPUT'
+                            && el.elements[ii].type.toUpperCase() === 'FILE') {
+                           throwIllegalArgumentException("Must use enctype = 'multipart/form-data' with input type FILE.");
+                        }
+                     }
+                  }
+              }
          
                // everything ok, so do the action
          


[10/22] portals-pluto git commit: Worked on URL processing

Posted by ms...@apache.org.
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/14800b56/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
index 2e107ce..12f4d94 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
@@ -58,7 +58,8 @@ public class RelativePortalURLImpl implements PortalURL {
    private String                      cacheLevel;
    private String                      resourceID;
 
-   private boolean                     isClone            = false;
+   private int                         cloneId        = 0;
+   private static int                  cloneCtr       = 0;
 
    // provides the defined public render parameters and their relationships to
    // one another for the current page
@@ -89,14 +90,9 @@ public class RelativePortalURLImpl implements PortalURL {
 
    // Target window & type of URL
    URLType                             type               = URLType.Portal;                             // initially
-                                                                                                         // just
-                                                                                                         // addresses
-                                                                                                         // the
-                                                                                                         // portal
-                                                                                                         // in
-                                                                                                         // general
    String                              targetWindow       = null;
 
+   
    /**
     * Constructs a PortalURLImpl instance using customized port.
     * 
@@ -172,11 +168,10 @@ public class RelativePortalURLImpl implements PortalURL {
                   if (index >= 0) {
                      prpMapper.setValues(index, parms.get(parm));
                      if (isDebug) {
-                        StringBuilder txt = new StringBuilder(
-                              "Added public parameter: ");
+                        StringBuilder txt = new StringBuilder("Added public parameter: ");
                         txt.append(parm).append(", Values: ")
-                              .append(Arrays.toString(parms.get(parm)));
-                        txt.append(", isClone: " + isClone);
+                           .append(Arrays.toString(parms.get(parm)));
+                        txt.append(", Clone ID: " + cloneId);
                         LOG.debug(txt.toString());
                      }
                      continue;
@@ -192,11 +187,10 @@ public class RelativePortalURLImpl implements PortalURL {
                }
                parameters.add(pup); // add the new values
                if (isDebug) {
-                  StringBuilder txt = new StringBuilder(
-                        "Added private parameter: ");
-                  txt.append(parm).append(", Values: ")
-                        .append(Arrays.toString(parms.get(parm)));
-                  txt.append(", isClone: " + isClone);
+                  StringBuilder txt = new StringBuilder("Added private parameter: ");
+                  txt.append(parm).append(", Values: ").append(Arrays.toString(parms.get(parm)));
+                  txt.append(parm).append(", Type: ").append(ptype);
+                  txt.append(", Clone ID: " + cloneId);
                   LOG.debug(txt.toString());
                }
             }
@@ -217,13 +211,14 @@ public class RelativePortalURLImpl implements PortalURL {
    public void addParameter(PortalURLParameter param) {
       if (isDebug) {
          StringBuilder txt = new StringBuilder(
-               "Setting public render parameter: ");
+               "Setting private parameter: ");
          txt.append(" window ID: " + param.getWindowId());
          txt.append(", Name: " + param.getName());
          String vals = (param.getValues() == null) ? "null" : Arrays
                .toString(param.getValues());
          txt.append(", Values: " + vals);
-         txt.append(", isClone: " + isClone);
+         txt.append(", Type: " + param.getType());
+         txt.append(", Clone ID: " + cloneId);
          LOG.debug(txt.toString());
       }
       parameters.add(param);
@@ -294,8 +289,8 @@ public class RelativePortalURLImpl implements PortalURL {
          }
       }
       if (isDebug) {
-         StringBuilder txt = new StringBuilder("clearParameters Removing ");
-         txt.append(rem.size()).append(" elements.");
+         StringBuilder txt = new StringBuilder("Removing ");
+         txt.append(rem.size()).append(" elements. Window ID: ").append(windowId);
          LOG.debug(txt.toString());
       }
       parameters.removeAll(rem);
@@ -385,7 +380,10 @@ public class RelativePortalURLImpl implements PortalURL {
       portalURL.reqParamsProcessed = reqParamsProcessed;
       portalURL.type = type;
       portalURL.targetWindow = targetWindow;
-      portalURL.isClone = true;
+      portalURL.cloneId = ++cloneCtr;
+      if (isDebug) {
+         LOG.debug("Created clone ID= " + portalURL.cloneId + " from URL with clone ID= " +this.cloneId);
+      }
       return portalURL;
    }
 
@@ -407,6 +405,15 @@ public class RelativePortalURLImpl implements PortalURL {
    }
 
    public synchronized void merge(PortalURL url, String windowId) {
+      if (isDebug) {
+         if (url.getClass().isInstance(this)) {
+            RelativePortalURLImpl turl = (RelativePortalURLImpl) url;
+            StringBuilder txt = new StringBuilder();
+            txt.append("Merging URL with clone ID= ").append(turl.cloneId);
+            txt.append(" into URL with clone ID= ").append(cloneId);
+            LOG.debug(txt.toString());
+         }
+      }
       type = url.getType();
       targetWindow = url.getTargetWindow();
       setPortletMode(windowId, url.getPortletMode(windowId));
@@ -547,8 +554,8 @@ public class RelativePortalURLImpl implements PortalURL {
          }
       }
       if (isDebug) {
-         StringBuilder txt = new StringBuilder("clearResourceParameters Removing ");
-         txt.append(rem.size()).append(" elements.");
+         StringBuilder txt = new StringBuilder("Removing ");
+         txt.append(rem.size()).append(" elements. Window ID: ").append(window);
          LOG.debug(txt.toString());
       }
       parameters.removeAll(rem);

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/14800b56/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java
index 3ef681b..fd63474 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java
@@ -163,6 +163,11 @@ public class PortletParameterFactory {
       for (PortalURLPublicParameter prp : prps) {
          parameters.put(prp.getName(), prp.getValues().clone());
       }
+      
+      if (isDebug) {
+         LOGGER.debug("getPublicParameterMap returning " + parameters.size() + " parameters.");
+      }
+      
       return parameters;
    }
 


[22/22] portals-pluto git commit: Several changes: * Updated the Portlet Hub implementation to use the new URL encoding scheme * Updated the Portlet Hub API to return a promise that is fulfilled when the action is complete * Added a PH Parameter Test p

Posted by ms...@apache.org.
Several changes:
* Updated the Portlet Hub implementation to use the new URL encoding scheme
* Updated the Portlet Hub API to return a promise that is fulfilled when the
  action is complete
* Added a PH Parameter Test portlet that can be used to verify that
 parameters are correctly set and read through the Portlet Hub


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/355084b0
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/355084b0
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/355084b0

Branch: refs/heads/V3Prototype
Commit: 355084b02f0c77c4049c9adf1807af577b438ce1
Parents: 11bb397
Author: Scott Nicklous <ms...@apache.org>
Authored: Mon Feb 16 16:24:28 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Mon Feb 16 16:24:28 2015 +0100

----------------------------------------------------------------------
 .../src/main/java/basic/portlet/Constants.java  |   9 +
 .../java/basic/portlet/ParamTestPortlet.java    | 128 +++++++++++++
 .../src/main/webapp/WEB-INF/jsp/view-ptp.jsp    | 124 +++++++++++++
 .../src/main/webapp/WEB-INF/portlet.xml         |  21 +++
 pluto-portal/src/main/webapp/portlet.js         |  29 +--
 pluto-portal/src/main/webapp/portletHubImpl.js  | 183 ++++++++++---------
 portlet-api/src/main/javascript/portlet.js      |  35 ++--
 portlet-api/src/test/javascript/ActionTest.js   |  14 +-
 8 files changed, 425 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/355084b0/PortletHubDemo/src/main/java/basic/portlet/Constants.java
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/java/basic/portlet/Constants.java b/PortletHubDemo/src/main/java/basic/portlet/Constants.java
index e36609c..3d607b1 100644
--- a/PortletHubDemo/src/main/java/basic/portlet/Constants.java
+++ b/PortletHubDemo/src/main/java/basic/portlet/Constants.java
@@ -47,4 +47,13 @@ public class Constants {
    public final static String ATTRIB_MSGS = "msgs";
    
    public final static String DELIM = ";%;";
+
+   public final static String PARAM_NAME = "pName";
+   public final static String PARAM_VALUES = "pValues";
+   public final static String PARAM_REMTYPE = "remType";
+   public final static String PARAM_REMTYPE_REM = "remPRP";
+   public final static String PARAM_REMTYPE_SET = "setRP";
+   public final static String PARAM_SETTYPE = "setType";
+   public final static String PARAM_SETTYPE_VAL = "setVal";
+   public final static String PARAM_SETTYPE_VARRAY = "setVals";
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/355084b0/PortletHubDemo/src/main/java/basic/portlet/ParamTestPortlet.java
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/java/basic/portlet/ParamTestPortlet.java b/PortletHubDemo/src/main/java/basic/portlet/ParamTestPortlet.java
new file mode 100644
index 0000000..ab5b242
--- /dev/null
+++ b/PortletHubDemo/src/main/java/basic/portlet/ParamTestPortlet.java
@@ -0,0 +1,128 @@
+/*  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package basic.portlet;
+
+import static basic.portlet.Constants.*;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.logging.Logger;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+
+
+/**
+ * A purtlet hub portlet that allows parameter names & values to be entered and set.
+ * 
+ * @author Scott Nicklous
+ */
+public class ParamTestPortlet extends GenericPortlet {
+
+   // Set up logging
+   private static final String LOG_CLASS = ParamTestPortlet.class.getName();
+   @SuppressWarnings("unused")
+   private final Logger logger = Logger.getLogger(LOG_CLASS);
+   
+   private final HashSet<String> prpNames = new HashSet<String>();
+   
+   @Override
+   public void init() throws PortletException {
+      super.init();
+      Enumeration<String> names = getPublicRenderParameterNames();
+      for (String name : Collections.list(names)) {
+         prpNames.add(name);
+      }
+   }
+
+   protected void doView(RenderRequest req, RenderResponse resp)
+         throws PortletException, IOException {
+
+      
+      resp.setContentType("text/html");
+
+      PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(
+            "/WEB-INF/jsp/view-ptp.jsp");
+      rd.include(req, resp);
+
+   }
+   
+   /* (non-Javadoc)
+    * @see javax.portlet.GenericPortlet#serveResource(javax.portlet.ResourceRequest, javax.portlet.ResourceResponse)
+    */
+   @SuppressWarnings("deprecation")
+   @Override
+   public void serveResource(ResourceRequest req, ResourceResponse resp)
+         throws PortletException, IOException {
+      
+      resp.setContentType("text/html");
+      PrintWriter writer = resp.getWriter();
+      
+      StringBuilder txt = new StringBuilder();
+      String style = "style='min-width: 100px;'";
+      List<String> pnList = Collections.list(req.getParameterNames());
+      
+      // don't display the control  params
+      pnList.remove(PARAM_SETTYPE);
+      pnList.remove(PARAM_REMTYPE);
+      
+      for (String pn : pnList) {
+         // try to test all parameter apis
+         String val = req.getParameter(pn);
+         String[] vals = req.getParameterValues(pn);
+         txt.append("      <tr><td " + style + ">Name: ")
+            .append(pn)
+            .append("</td><td " + style + ">Val: ")
+            .append(val)
+            .append("</td><td " + style + ">Len: ")
+            .append(vals.length)
+            .append("</td><td " + style + ">Values: ")
+            .append(Arrays.toString(vals))
+            .append("</td></tr>\n");
+      }
+      
+      writer.write("<h3>Currently set render parameters:</h3>\n");
+      writer.write("<p>\n");
+      writer.write("   <table>");
+      writer.write(txt.toString());
+      writer.write("   </table>");
+      writer.write("</p>\n");
+
+      writer.write("<p><hr/></p>\n");
+      
+   }
+
+   // nothing to do in processAction
+   public void processAction(ActionRequest req, ActionResponse resp)
+         throws PortletException, IOException {
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/355084b0/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-ptp.jsp
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-ptp.jsp b/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-ptp.jsp
new file mode 100644
index 0000000..f4a429b
--- /dev/null
+++ b/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-ptp.jsp
@@ -0,0 +1,124 @@
+<%--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed  under the  License is distributed on an "AS IS" BASIS,
+WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+implied.
+
+See the License for the specific language governing permissions and
+limitations under the License.
+--%>
+<%@ page session="false" %>
+<%@ taglib uri="http://java.sun.com/portlet_2_0"  prefix="portlet" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ page import="static basic.portlet.Constants.*" %>
+
+<portlet:defineObjects />
+
+<h3>Parameter Tester</h3><hr/>
+<p>Enter parameter name and value and click 'send'.
+To enter multiple values, separate values with a ',' character.
+Entering 'null' as a value will cause the corresponding value in the values array to be set to null.
+Entering 'null' by itself will cause the parameter to be set to null (removed).
+Entering 'empty' by itself will set the parameter to an empty array.
+Leaving the value field empty will set the parameter to an array containing a single empty string.
+<p/>
+<p><hr/></p>
+<FORM id='<portlet:namespace/>-setParams' METHOD='POST' onsubmit='return false;' enctype='application/x-www-form-urlencoded' accept-charset='UTF-8'>
+   <table><tr><td align='left'>
+      Parameter Name:
+   </td><td colspan=2>
+   <input name='<portlet:namespace/>-pName' type='text' value='' size='50' maxlength='100'>
+   </td></tr><tr><td>
+      Parameter Values:
+   </td><td colspan=2>
+   <input name='<portlet:namespace/>-pVal' type='text' value='' size='50' maxlength='100'>
+   </td></tr><tr><td>
+   <INPUT VALUE='send' CLASS='portlet-form-button' TYPE='submit'>
+   </td></tr></table>
+</FORM>
+
+<p><hr/></p>
+<div id='<portlet:namespace/>-putResourceHere'></div>
+
+
+<script>
+(function () {
+   'use strict';
+    
+   var pid = '<portlet:namespace/>',
+       pnid = '<portlet:namespace/>-pName',
+       pvid = '<portlet:namespace/>-pVal',
+       msgdiv = '<portlet:namespace/>-putResourceHere',
+       formid = '<portlet:namespace/>-setParams',
+       currState,
+       hub,
+
+       
+   // Handler for onStateChange event
+   update = function (type, state) {
+      currState = state;
+      
+      hub.createResourceUrl().then(function (url) {
+         var xhr = new XMLHttpRequest();
+         console.log("PTP: got url: " + url);
+         xhr.onreadystatechange = function () {
+            if (xhr.readyState === 4 && xhr.status === 200) {
+               document.getElementById(msgdiv).innerHTML=xhr.responseText;
+            }
+         };
+         xhr.open("GET",url,true);
+         xhr.send();
+      });
+   };
+   
+
+   // Register portlet with Portlet Hub. Add listener for onStateChange event.
+   portlet.register(pid).then(function (pi) {
+      console.log("PTP Parameter Test Portlet: registered: " + pid);
+      hub = pi;
+      currState = hub.newState();
+      hub.addEventListener("portlet.onStateChange", update);
+   });
+   
+
+   // Handler for 'send' button click. Update parameters
+   document.getElementById(formid).addEventListener('submit', function (event) {
+      var pName = this[pnid].value,
+          pValue = this[pvid].value, 
+          nstate, vals, ii;
+      
+      console.log("PTP: updating parameters. PN=" + pName + ", PV=" + pValue);
+      
+      nstate = currState.clone();
+      if (pValue === 'null') {
+         nstate.p.remove(pName);
+      } else {
+         if (pValue === 'empty') {
+            nstate.parameters[pName] = [];
+         } else {
+            vals = pValue.split(",");
+            for (ii = 0; ii < vals.length; ii++) {
+               if (vals[ii] === 'null') {
+                  vals[ii] = null;
+               }
+            }
+            nstate.p.setValues(pName, vals);
+         }
+      }
+      
+      hub.setPortletState(nstate);
+      
+      event.preventDefault();
+   });
+      
+}());
+</script>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/355084b0/PortletHubDemo/src/main/webapp/WEB-INF/portlet.xml
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/webapp/WEB-INF/portlet.xml b/PortletHubDemo/src/main/webapp/WEB-INF/portlet.xml
index 9a516e3..9387fd7 100644
--- a/PortletHubDemo/src/main/webapp/WEB-INF/portlet.xml
+++ b/PortletHubDemo/src/main/webapp/WEB-INF/portlet.xml
@@ -112,6 +112,27 @@
 
       <supported-public-render-parameter>color</supported-public-render-parameter>
    </portlet>
+
+   <portlet>
+      <portlet-name>ParamTestPortlet</portlet-name>
+      <display-name>PH Parameter Test Portlet</display-name>
+      
+      <portlet-class>basic.portlet.ParamTestPortlet</portlet-class>
+
+      <supports>
+         <mime-type>text/html</mime-type>
+         <portlet-mode>VIEW</portlet-mode>
+      </supports>
+
+      <supported-locale>en</supported-locale>        
+
+      <portlet-info>
+         <title>PH Parameter Test Portlet</title>
+      </portlet-info>
+
+      <supported-public-render-parameter>imgName</supported-public-render-parameter>
+      <supported-public-render-parameter>color</supported-public-render-parameter>
+   </portlet>
    
    <event-definition>
       <qname>rp:Message</qname>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/355084b0/pluto-portal/src/main/webapp/portlet.js
----------------------------------------------------------------------
diff --git a/pluto-portal/src/main/webapp/portlet.js b/pluto-portal/src/main/webapp/portlet.js
index edbb8e0..7173472 100644
--- a/pluto-portal/src/main/webapp/portlet.js
+++ b/pluto-portal/src/main/webapp/portlet.js
@@ -1082,8 +1082,8 @@ var portlet = portlet || {};
       // If an error occurred, post the error to the onError handler, if one is present.
 
       pi = _registeredPortlets[pid];
-      pi.executeAction(parms, element).then(function (upids) {
-         updatePageState(upids);
+      return pi.executeAction(parms, element).then(function (upids) {
+         return updatePageState(upids);
       }, function (err) {
          busy = false;
          if (oeListeners[pid]) {
@@ -1583,13 +1583,6 @@ var portlet = portlet || {};
              * submit the action to the server by executing a 'POST' with an action
              * URL containing any action parameters provided.
              * <p>
-             * A portlet action is a blocking operation.
-             * To allow for orderly state transitions, the portlet hub does not allow
-             * this function to be used while a blocking operation is in progress.
-             * A blocking operation is considered to be in progress
-             * from the initial call until the final onStateChange event for that
-             * operation has been fired. See {@link portlet} for further information.
-             * <p>
              * The parameters may be specified in either order, individually,
              * or not at all. Examples of valid calls:
              * <code>
@@ -1598,6 +1591,15 @@ var portlet = portlet || {};
              * <br>action(actParams);
              * <br>action(element);
              * </code>
+             * <p>
+             * A portlet action is a blocking operation.
+             * To allow for orderly state transitions, the portlet hub does not allow
+             * this function to be used while a blocking operation is in progress.
+             * A blocking operation is considered to be in progress
+             * from the initial call until the final onStateChange event for that
+             * operation has been fired. See {@link portlet} for further information.
+             * <p>
+             * 
              *
              * @param   {PortletParameters}  actParams   Action parameters to be
              *                                           added to the URL
@@ -1605,6 +1607,9 @@ var portlet = portlet || {};
              * @param   {HTMLFormElement}    element     DOM element of form to be submitted
              *                                           (optional)
              *
+             * @returns {Promise}   A Promise object that is resolved with no argument
+             * 						when the action request has completed.
+             *
              * @throws  {IllegalArgumentException}
              *                   Thrown if the input parameters are invalid
              * @throws  {AccessDeniedException}
@@ -1643,13 +1648,15 @@ var portlet = portlet || {};
                         throwIllegalArgumentException("too many parameters arguments.");
                      }
                      parms = arg;
-                  } else {
+                  } else 
+                  if (arg !== undefined) { 
                      throwIllegalArgumentException("Invalid argument type. Argument " + (ii + 1)
                             + " is of type " + type);
                   }
                }
                
                // if we're dealing with a form, verify method and enctype
+               console.log("form element", el);
                
                if (el) {
                   meth = el.method ? el.method.toUpperCase() : undefined;
@@ -1680,7 +1687,7 @@ var portlet = portlet || {};
          
                // everything ok, so do the action
          
-               setupAction(portletId, parms, el);
+               return setupAction(portletId, parms, el);
             },
          
             /**

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/355084b0/pluto-portal/src/main/webapp/portletHubImpl.js
----------------------------------------------------------------------
diff --git a/pluto-portal/src/main/webapp/portletHubImpl.js b/pluto-portal/src/main/webapp/portletHubImpl.js
index 60eb8bf..89f0406 100644
--- a/pluto-portal/src/main/webapp/portletHubImpl.js
+++ b/pluto-portal/src/main/webapp/portletHubImpl.js
@@ -310,56 +310,42 @@ var portlet = portlet || {};
       return pageState.portlets[pid].state;
    },
    
-   /**
-    * Function to encode url tokens as Pluto likes it
-    */
-   plutoEncode = function (istr) {
-      var ENCODINGS = {
-            "_" :  "0x1",
-            "." :  "0x2",
-            "/" :  "0x3",
-            "\r" : "0x4",
-            "\n" : "0x5",
-            "<" :  "0x6",
-            ">" :  "0x7",
-            " " :  "0x8",
-            "#" :  "0x9",
-            "?" :  "0xa",
-            "\\" : "0xb",
-            "%" :  "0xc",
-            "|" :  "%7C"
-                      }, ii, ostr = "";
-      
-      for (ii=0; ii < istr.length; ii++) {
-         if (ENCODINGS[istr.charAt(ii)]) {
-            ostr += ENCODINGS[istr.charAt(ii)];
-         } else {
-            ostr += istr.charAt(ii);
-         }
-      }
-
-      return ostr;
-   },
-   
    
    // Constants used for URL Encoding/Decoding (copied from Pluto impl code)  ----------
-
+   
    PREFIX = "__",
-   DELIM = "_",
    PORTLET_ID = "pd",
-   ACTION = "ac",
-   RESOURCE = "rs",
    RESOURCE_ID = "ri",
    CACHE_LEVEL = "cl",
-   RENDER_PARAM = "rp",
-   PRIVATE_RENDER_PARAM = "pr",
-   PUBLIC_RENDER_PARAM = "sp",
    WINDOW_STATE = "ws",
    PORTLET_MODE = "pm",
-   VALUE_DELIM = "0x0",
+   
+   // The delimiter & special chars for the value encoding are chosen
+   // from the URL reserved delimiter characters that ARE ENCODED by the URLEncoder
+   // so that they will not appear encoded parameter names or values.
+   // See RFC 3986 & URLEncoder documentation.
+   VALUE_DELIM = ":",
+   VALUE_NULL = ",",
+   VALUE_ARRAY_EMPTY = "@",
+   DELIM = ";",
+   TOKEN_DELIM = "/",
+
+   ACTION = "ac",
+   RESOURCE = "rs",
+   AJAX_ACTION = "aa",       // new for portlet spec 3
+   PARTIAL_ACTION = "pa",    // new for portlet spec 3
+   RENDER = "re",            // new for portlet spec 3
+   
+   ACTION_PARAM = "av",      // new for portlet spec 3
+   RESOURCE_PARAM = "rv",    // new for portlet spec 3
+   RENDER_PARAM = "rp",
+   PUBLIC_RENDER_PARAM = "sp",
+   
+   
+   // constants for checking if portlet mode & window state have default values
+   VIEW = "VIEW",
+   NORMAL = "NORMAL",
 
-   AJAX_ACTION = "aa",              // new for portlet spec 3
-   PARTIAL_ACTION = "pa",           // new for portlet spec 3
    
    pidMap = {},
    
@@ -373,41 +359,61 @@ var portlet = portlet || {};
       for (ii = 0; ii < pids.length; ii++) {
          pid = pids[ii];
          pidMap[pid] = ii;
-         urlmap += "/" + PREFIX + PORTLET_ID;
-         urlmap += plutoEncode(pageState.portlets[pid].urlpid);
+         urlmap += TOKEN_DELIM + PREFIX + PORTLET_ID;
+         urlmap += encodeURIComponent(pageState.portlets[pid].urlpid);
          urlmap += DELIM + ii;
       }
       
       return urlmap;
    },
 
+   /**
+    * Helper for encoding a multivalued parameter
+    */
+   encodeParameter = function (name, vals) {
+	   var str = "", jj;
+	   if (vals) {
+		   str += encodeURIComponent(name);
+		   if (vals.length === 0) {
+			   str += VALUE_DELIM + VALUE_ARRAY_EMPTY;
+		   } else {
+			   for (jj=0; jj < vals.length; jj++) {
+				   if (vals[jj] === null) {
+					   str += VALUE_DELIM + VALUE_NULL;
+				   } else {
+					   str += VALUE_DELIM + encodeURIComponent(vals[jj]);
+				   }
+			   }
+		   }
+	   }
+	   return str;
+   },
    
    /**
     * Helper for generating parameter strings for the URL
     */
    genParmString = function (pid, name, type, group) {
-      var vals, jj, sep, str = "", wid = "", grpstr = "";
+      var vals, str = "", wid = "", grpstr = "";
       vals = pageState.portlets[pid].state.parameters[name];
       
-      // If encoding a render parameter, insert the pid in Pluto internal form 
-      // as opposed to namespace form -
-      
-      if (type === RENDER_PARAM || type === PUBLIC_RENDER_PARAM) {
-         wid = pidMap[pid];
-      }
-      
-      if (type === PUBLIC_RENDER_PARAM) {
-         grpstr = DELIM + plutoEncode(group);
-      }
-      
-      // If values are present, encode the multivalued parameter string
-      
-      if (vals) {
-         sep = VALUE_DELIM;
-         str += "/" + PREFIX + type + wid + grpstr + DELIM + encodeURIComponent(name);
-         for (jj=0; jj < vals.length; jj++) {
-            str += sep + encodeURIComponent(vals[jj]);
-         }
+      // if there are no values, return the empty string
+      if (vals !== undefined) {
+
+    	  // If encoding a render parameter, insert the pid in Pluto internal form 
+    	  // as opposed to namespace form -
+
+    	  if (type === RENDER_PARAM || type === PUBLIC_RENDER_PARAM
+    			  || type === ACTION_PARAM || type === RESOURCE_PARAM) {
+    		  wid = pidMap[pid];
+    	  }
+
+    	  if (type === PUBLIC_RENDER_PARAM) {
+    		  grpstr = DELIM + encodeURIComponent(group);
+    	  }
+
+    	  // If values are present, encode the multivalued parameter string
+
+    	  str += TOKEN_DELIM + PREFIX + type + wid + grpstr + DELIM + encodeParameter(name, vals);
       }
       return str;
    },
@@ -421,8 +427,13 @@ var portlet = portlet || {};
           ws = pageState.portlets[pid].state.windowState, 
           wid = pidMap[pid], str = "";
 
-      str += "/" + PREFIX + PORTLET_MODE + wid + DELIM + encodeURIComponent(pm);
-      str += "/" + PREFIX + WINDOW_STATE + wid + DELIM + encodeURIComponent(ws);
+      // Only add PM & WS if the values are not default
+      if (pm.toUpperCase() !== VIEW) {
+    	  str += TOKEN_DELIM + PREFIX + PORTLET_MODE + wid + DELIM + encodeURIComponent(pm);
+      }
+      if (ws.toUpperCase() !== NORMAL) {
+    	  str += TOKEN_DELIM + PREFIX + WINDOW_STATE + wid + DELIM + encodeURIComponent(ws);
+      }
 
       return str;
    },
@@ -442,7 +453,7 @@ var portlet = portlet || {};
    getUrl = function (type, pid, parms, cache) {
    
       var url = portlet.impl.getUrlBase(), ca = 'cacheLevelPage', parm, isAction = false,
-          sep = "", name, names, vals, ii, str, id, ids, tpid, prpstrings, group;
+          name, names, ii, str, id, ids, tpid, prpstrings, group, ptype;
           
       url += getPidMap();
        
@@ -456,19 +467,22 @@ var portlet = portlet || {};
       
       if (type === "RESOURCE") {
          // If generating resource URL, add resource window & cacheability
-         url += "/" + PREFIX + RESOURCE + pidMap[pid];
+         url += TOKEN_DELIM + PREFIX + RESOURCE + pidMap[pid];
          if (cache) {
             ca = cache;
          }
-         url += "/" + PREFIX + CACHE_LEVEL + plutoEncode(ca);
+         url += TOKEN_DELIM + PREFIX + CACHE_LEVEL + encodeURIComponent(ca);
+      } else if (type === "RENDER" && pid !== null) {
+         // Add Render window
+         url += TOKEN_DELIM + PREFIX + RENDER + pidMap[pid];
       } else if (type === "ACTION") {
-         // Add Ajax Action window
-         isAction = true;
-         url += "/" + PREFIX + AJAX_ACTION + pidMap[pid];
+          // Add Ajax Action window
+          isAction = true;
+          url += TOKEN_DELIM + PREFIX + AJAX_ACTION + pidMap[pid];
       } else if (type === "PARTIAL_ACTION") {
          // Add Partial Action window
          isAction = true;
-         url += "/" + PREFIX + PARTIAL_ACTION + pidMap[pid];
+         url += TOKEN_DELIM + PREFIX + PARTIAL_ACTION + pidMap[pid];
       }
       
       // Now add the state to the URL, taking into account cacheability if
@@ -500,7 +514,6 @@ var portlet = portlet || {};
          }
 
          // add the state for the target portlet for on-action urls.
-         // (Action URLs have only action parameters in the query string)
          // (for a render URL, pid can be null)
          if (!isAction && pid !== null) {
             url += genPMWSString(pid);  // portlet mode & window state
@@ -509,7 +522,7 @@ var portlet = portlet || {};
             for (name in names) {
                // Public render parameters are encoded separately
                if (names.hasOwnProperty(name) && !isPRP(pid, name)) {
-                  str += genParmString(pid, name, PRIVATE_RENDER_PARAM);
+                  str += genParmString(pid, name, RENDER_PARAM);
                }
             }
             url += str;
@@ -537,19 +550,17 @@ var portlet = portlet || {};
 
       }
 
-      // Encode resource or action parameters as query string
+      // Encode resource or action parameters
       if (parms) {
-         str = ""; sep = "?";
-         for (parm in parms) {
-            if (parms.hasOwnProperty(parm)) {
-               vals = parms[parm];
-               for (ii=0; ii < vals.length; ii++) {
-                  str += sep + encodeURIComponent(parm) + "=" + encodeURIComponent(vals[ii]);
-                  sep = "&";
-               }
-            }
-         }
-         url += str;
+    	  str = "";
+    	  ptype = isAction ? ACTION_PARAM : RESOURCE_PARAM;
+    	  for (parm in parms) {
+    		  if (parms.hasOwnProperty(parm)) {
+    	          str += TOKEN_DELIM + PREFIX + ptype + pidMap[pid] + DELIM;
+    			  str += encodeParameter(parm, parms[parm]);
+    		  }
+    	  }
+    	  url += str;
       }
 
       // Use Promise to allow for potential server communication - 

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/355084b0/portlet-api/src/main/javascript/portlet.js
----------------------------------------------------------------------
diff --git a/portlet-api/src/main/javascript/portlet.js b/portlet-api/src/main/javascript/portlet.js
index 4dbb0a1..d68b54a 100644
--- a/portlet-api/src/main/javascript/portlet.js
+++ b/portlet-api/src/main/javascript/portlet.js
@@ -825,9 +825,9 @@ var portlet = portlet || {};
       if (upids.length === 0) {
          busy = false;
       } else {
-      for (ii = 0; ii < upids.length; ii++) {
-         _updateStateForPortlet(upids[ii]);
-      }
+    	  for (ii = 0; ii < upids.length; ii++) {
+    		  _updateStateForPortlet(upids[ii]);
+    	  }
       }
 
    },
@@ -1082,8 +1082,8 @@ var portlet = portlet || {};
       // If an error occurred, post the error to the onError handler, if one is present.
 
       pi = _registeredPortlets[pid];
-      pi.executeAction(parms, element).then(function (upids) {
-         updatePageState(upids);
+      return pi.executeAction(parms, element).then(function (upids) {
+         return updatePageState(upids);
       }, function (err) {
          busy = false;
          if (oeListeners[pid]) {
@@ -1583,13 +1583,6 @@ var portlet = portlet || {};
              * submit the action to the server by executing a 'POST' with an action
              * URL containing any action parameters provided.
              * <p>
-             * A portlet action is a blocking operation.
-             * To allow for orderly state transitions, the portlet hub does not allow
-             * this function to be used while a blocking operation is in progress.
-             * A blocking operation is considered to be in progress
-             * from the initial call until the final onStateChange event for that
-             * operation has been fired. See {@link portlet} for further information.
-             * <p>
              * The parameters may be specified in either order, individually,
              * or not at all. Examples of valid calls:
              * <code>
@@ -1598,6 +1591,15 @@ var portlet = portlet || {};
              * <br>action(actParams);
              * <br>action(element);
              * </code>
+             * <p>
+             * A portlet action is a blocking operation.
+             * To allow for orderly state transitions, the portlet hub does not allow
+             * this function to be used while a blocking operation is in progress.
+             * A blocking operation is considered to be in progress
+             * from the initial call until the final onStateChange event for that
+             * operation has been fired. See {@link portlet} for further information.
+             * <p>
+             * 
              *
              * @param   {PortletParameters}  actParams   Action parameters to be
              *                                           added to the URL
@@ -1605,6 +1607,9 @@ var portlet = portlet || {};
              * @param   {HTMLFormElement}    element     DOM element of form to be submitted
              *                                           (optional)
              *
+             * @returns {Promise}   A Promise object that is resolved with no argument
+             * 						when the action request has completed.
+             *
              * @throws  {IllegalArgumentException}
              *                   Thrown if the input parameters are invalid
              * @throws  {AccessDeniedException}
@@ -1643,13 +1648,15 @@ var portlet = portlet || {};
                         throwIllegalArgumentException("too many parameters arguments.");
                      }
                      parms = arg;
-                  } else {
+                  } else 
+                  if (arg !== undefined) { 
                      throwIllegalArgumentException("Invalid argument type. Argument " + (ii + 1)
                             + " is of type " + type);
                   }
                }
                
                // if we're dealing with a form, verify method and enctype
+               console.log("form element", el);
                
                if (el) {
                   meth = el.method ? el.method.toUpperCase() : undefined;
@@ -1680,7 +1687,7 @@ var portlet = portlet || {};
          
                // everything ok, so do the action
          
-               setupAction(portletId, parms, el);
+               return setupAction(portletId, parms, el);
             },
          
             /**

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/355084b0/portlet-api/src/test/javascript/ActionTest.js
----------------------------------------------------------------------
diff --git a/portlet-api/src/test/javascript/ActionTest.js b/portlet-api/src/test/javascript/ActionTest.js
index 99fa385..f722597 100644
--- a/portlet-api/src/test/javascript/ActionTest.js
+++ b/portlet-api/src/test/javascript/ActionTest.js
@@ -187,13 +187,13 @@ describe('The portlet hub allows the portlet client to execute a portlet action'
          expect(testFunc).toThrowCustomException("IllegalArgumentException");
       });
 
-      it('throws an IllegalArgumentException if action parameters is undefined',function(){
-         var el = document.createElement("form");
-         var testFunc = function () {
-            hubA.action(undefined, el);
-         }
-         expect(testFunc).toThrowCustomException("IllegalArgumentException");
-      });
+//       it('throws an IllegalArgumentException if action parameters is undefined',function(){
+//          var el = document.createElement("form");
+//          var testFunc = function () {
+//             hubA.action(undefined, el);
+//          }
+//          expect(testFunc).toThrowCustomException("IllegalArgumentException");
+//       });
 
       it('throws an IllegalArgumentException if action parameters is invalid',function(){
          var parms  = {rp1 : "resVal"};


[12/22] portals-pluto git commit: Added traces to understand URL clone / merge processing

Posted by ms...@apache.org.
Added traces to understand URL clone / merge processing


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/53a16bc8
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/53a16bc8
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/53a16bc8

Branch: refs/heads/V3Prototype
Commit: 53a16bc8d94a3eebaa72a8bdee971c231e946ca7
Parents: 14800b5
Author: Scott Nicklous <ms...@apache.org>
Authored: Tue Feb 10 22:32:14 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Tue Feb 10 22:32:14 2015 +0100

----------------------------------------------------------------------
 .../pluto/driver/url/impl/RelativePortalURLImpl.java      | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/53a16bc8/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
index 12f4d94..2d022bb 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
@@ -115,6 +115,7 @@ public class RelativePortalURLImpl implements PortalURL {
       servletPath = buffer.toString();
       this.urlParser = urlParser;
       this.servletRequest = req;
+      this.cloneId = (++cloneCtr) + 10000;
    }
 
    /**
@@ -382,7 +383,12 @@ public class RelativePortalURLImpl implements PortalURL {
       portalURL.targetWindow = targetWindow;
       portalURL.cloneId = ++cloneCtr;
       if (isDebug) {
-         LOG.debug("Created clone ID= " + portalURL.cloneId + " from URL with clone ID= " +this.cloneId);
+         long tid = Thread.currentThread().getId();
+         StringBuilder txt = new StringBuilder();
+         txt.append("Created clone ID= ").append(portalURL.cloneId);
+         txt.append(" from URL with clone ID= ").append(this.cloneId);
+         txt.append(". ThreadId=").append(tid);
+         LOG.debug(txt.toString());
       }
       return portalURL;
    }
@@ -407,10 +413,12 @@ public class RelativePortalURLImpl implements PortalURL {
    public synchronized void merge(PortalURL url, String windowId) {
       if (isDebug) {
          if (url.getClass().isInstance(this)) {
+            long tid = Thread.currentThread().getId();
             RelativePortalURLImpl turl = (RelativePortalURLImpl) url;
             StringBuilder txt = new StringBuilder();
             txt.append("Merging URL with clone ID= ").append(turl.cloneId);
             txt.append(" into URL with clone ID= ").append(cloneId);
+            txt.append(". ThreadId=").append(tid);
             LOG.debug(txt.toString());
          }
       }


[11/22] portals-pluto git commit: Worked on URL processing

Posted by ms...@apache.org.
Worked on URL processing


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/14800b56
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/14800b56
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/14800b56

Branch: refs/heads/V3Prototype
Commit: 14800b564ef916529f6645e5afda4eb4f6951bde
Parents: b28c3d6
Author: Scott Nicklous <ms...@apache.org>
Authored: Tue Feb 10 18:32:00 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Tue Feb 10 18:32:00 2015 +0100

----------------------------------------------------------------------
 .../PortletStateAwareResponseContext.java       |   59 +-
 .../pluto/container/PortletURLProvider.java     |   60 +
 .../container/impl/PortletContainerImpl.java    |    2 +-
 .../container/impl/PortletRequestImpl.java      | 1429 +++++++++---------
 .../container/impl/StateAwareResponseImpl.java  |   80 +-
 .../PortletStateAwareResponseContextImpl.java   |  130 +-
 .../container/PortletURLProviderImpl.java       |  467 +++---
 .../driver/url/impl/RelativePortalURLImpl.java  |   53 +-
 .../driver/url/PortletParameterFactory.java     |    5 +
 9 files changed, 1305 insertions(+), 980 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/14800b56/pluto-container-api/src/main/java/org/apache/pluto/container/PortletStateAwareResponseContext.java
----------------------------------------------------------------------
diff --git a/pluto-container-api/src/main/java/org/apache/pluto/container/PortletStateAwareResponseContext.java b/pluto-container-api/src/main/java/org/apache/pluto/container/PortletStateAwareResponseContext.java
index e68b53d..c89354c 100644
--- a/pluto-container-api/src/main/java/org/apache/pluto/container/PortletStateAwareResponseContext.java
+++ b/pluto-container-api/src/main/java/org/apache/pluto/container/PortletStateAwareResponseContext.java
@@ -18,6 +18,7 @@ package org.apache.pluto.container;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import javax.portlet.Event;
 import javax.portlet.PortletMode;
@@ -57,8 +58,62 @@ public interface PortletStateAwareResponseContext extends PortletResponseContext
     void removePublicRenderParameter(QName qn, String identifier);
     
     /**
-     * Clears public render parameters except those that are marked for removal.
+     * Add a public render parameter for given window ID and parameter name
+     *  
+     * @param qn           QName
+     * @param identifier   Identifier for PRP
+     * @param values       values array
+     */
+    void addPublicRenderParameter(String windowId, String name, String[] values);
+    
+    /**
+     * Remove the PRP for the given window ID and parameter name
+     * 
+     * @param windowId
+     * @param name
+     */
+    void removePublicRenderParameter(String windowId, String name);
+    
+    /**
+     * Returns <code>true</code> if the given name representa a public render
+     * parameter for the given window.
+     * 
+     * @param windowId
+     * @param name
+     * @return
+     */
+    boolean isPublicRenderParameter(String windowId, String name);
+    
+    /**
+     * Retrieves the available private parameter names for the given window ID
+     * @param windowId
+     * @return
+     */
+    Set<String> getParameterNames(String windowId);
+    
+    /**
+     * Gets the values array for the given window ID and private parameter name
+     * @param windowId
+     * @param name
+     * @return
+     */
+    String[] getParameterValues(String windowId, String name);
+
+    /**
+     * Adds the specified private parameter if not already present, or updates the
+     * values for the parameter if it is already present.
+     * @param windowId
+     * @param name
+     * @param values
+     */
+    void setParameter(String windowId, String name, String[] values);
+    
+    /** 
+     * Removes the private parameter for the given window and name. Does nothing if the
+     * given parameter is not present.
+     * @param windowId
+     * @param name
      */
-    void clearPublicRenderParameters();
+    void removeParameter(String windowId, String name);
 
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/14800b56/pluto-container-api/src/main/java/org/apache/pluto/container/PortletURLProvider.java
----------------------------------------------------------------------
diff --git a/pluto-container-api/src/main/java/org/apache/pluto/container/PortletURLProvider.java b/pluto-container-api/src/main/java/org/apache/pluto/container/PortletURLProvider.java
index 17bfbad..11b0bb6 100644
--- a/pluto-container-api/src/main/java/org/apache/pluto/container/PortletURLProvider.java
+++ b/pluto-container-api/src/main/java/org/apache/pluto/container/PortletURLProvider.java
@@ -20,6 +20,7 @@ import java.io.IOException;
 import java.io.Writer;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import javax.portlet.PortletMode;
 import javax.portlet.PortletSecurityException;
@@ -81,10 +82,69 @@ public interface PortletURLProvider {
     void removePublicRenderParameter(QName qn, String identifier);
     
     /**
+     * Add a public render parameter for given window ID and parameter name
+     *  
+     * @param qn           QName
+     * @param identifier   Identifier for PRP
+     * @param values       values array
+     */
+    void addPublicRenderParameter(String windowId, String name, String[] values);
+    
+    /**
+     * Remove the PRP for the given window ID and parameter name
+     * 
+     * @param windowId
+     * @param name
+     */
+    void removePublicRenderParameter(String windowId, String name);
+    
+    /**
+     * Returns <code>true</code> if the given name representa a public render
+     * parameter for the given window.
+     * 
+     * @param windowId
+     * @param name
+     * @return
+     */
+    boolean isPublicRenderParameter(String windowId, String name);
+   
+    /**
      * Clears public render parameters except those that are marked for removal.
      */
     void clearPublicRenderParameters();
     
+    /**
+     * Retrieves the available private parameter names for the given window ID
+     * @param windowId
+     * @return
+     */
+    Set<String> getParameterNames(String windowId);
+    
+    /**
+     * Gets the values array for the given window ID and private parameter name
+     * @param windowId
+     * @param name
+     * @return
+     */
+    String[] getParameterValues(String windowId, String name);
+
+    /**
+     * Adds the specified private parameter if not already present, or updates the
+     * values for the parameter if it is already present.
+     * @param windowId
+     * @param name
+     * @param values
+     */
+    void setParameter(String windowId, String name, String[] values);
+    
+    /** 
+     * Removes the private parameter for the given window and name. Does nothing if the
+     * given parameter is not present.
+     * @param windowId
+     * @param name
+     */
+    void removeParameter(String windowId, String name);
+    
     String getCacheability();
     void setCacheability(String cacheLevel);
     

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/14800b56/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletContainerImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletContainerImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletContainerImpl.java
index 5c8128a..69b7c3f 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletContainerImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletContainerImpl.java
@@ -251,7 +251,7 @@ public class PortletContainerImpl implements PortletContainer
 
         String location = null;
         String logtxt = "Portlet action";
-        if (isRedirect) {
+        if (!isRedirect) {
            logtxt = "Portlet Ajax or Partial action";
         }
 

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/14800b56/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletRequestImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletRequestImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletRequestImpl.java
index 87ff0c0..ae30689 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletRequestImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletRequestImpl.java
@@ -1,711 +1,718 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pluto.container.impl;
-
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.ccpp.Profile;
-import javax.portlet.CacheControl;
-import javax.portlet.MimeResponse;
-import javax.portlet.PortalContext;
-import javax.portlet.PortletContext;
-import javax.portlet.PortletMode;
-import javax.portlet.PortletPreferences;
-import javax.portlet.PortletRequest;
-import javax.portlet.PortletSession;
-import javax.portlet.WindowState;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import org.apache.pluto.container.ContainerServices;
-import org.apache.pluto.container.PortletContainer;
-import org.apache.pluto.container.PortletEnvironmentService;
-import org.apache.pluto.container.PortletInvokerService;
-import org.apache.pluto.container.PortletRequestContext;
-import org.apache.pluto.container.PortletResponseContext;
-import org.apache.pluto.container.PortletWindow;
-import org.apache.pluto.container.om.portlet.CustomPortletMode;
-import org.apache.pluto.container.om.portlet.PortletDefinition;
-import org.apache.pluto.container.om.portlet.SecurityRoleRef;
-import org.apache.pluto.container.om.portlet.Supports;
-import org.apache.pluto.container.util.ArgumentUtility;
-import org.apache.pluto.container.util.StringManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Abstract <code>javax.portlet.PortletRequest</code> implementation.
- * This class also implements InternalPortletRequest.
- *
- */
-public abstract class PortletRequestImpl implements PortletRequest
-{
-    public static final String ACCEPT_LANGUAGE = "Accept-Language";
-
-    private static final Logger LOG = LoggerFactory.getLogger(PortletRequestImpl.class);
-
-    private static final StringManager EXCEPTIONS =
-        StringManager.getManager(PortletRequestImpl.class.getPackage().getName());
-
-    private static final List<String> EMPTY_STRING_LIST = Collections.unmodifiableList(new ArrayList<String>(0));
-
-    // Private Member Variables ------------------------------------------------
-
-    /** The PortalContext within which this request is occuring. */
-    private final PortalContext portalContext;
-
-    private final PortletRequestContext requestContext;
-    private final PortletResponseContext responseContext;
-
-    /** The portlet session. */
-    private PortletSession portletSession;
-
-    /** Response content types. */
-    private ArrayList<String> contentTypes;
-
-    private PortletPreferences portletPreferences;
-
-    private Map<String, String[]> parameters;
-
-    private Map<String, String[]> requestProperties;
-    private List<String> requestPropertyNames;
-
-    private Cookie[] requestCookies;
-
-    private Map<String, String> userInfo;
-
-    private Profile ccppProfile;
-
-    private String contextPath;
-
-    private final String lifecyclePhase;
-
-    public PortletRequestImpl(PortletRequestContext requestContext, PortletResponseContext responseContext, String lifecyclePhase)
-    {
-        this.requestContext = requestContext;
-        this.responseContext = responseContext;
-        this.lifecyclePhase = lifecyclePhase;
-        this.portalContext = getPortletContainer().getContainerServices().getPortalContext();
-    }
-
-    private void retrieveRequestProperties()
-    {
-        Map<String, String[]> properties = requestContext.getProperties();
-        requestPropertyNames = new ArrayList<String>(properties.size());
-        requestProperties = new HashMap<String, String[]>(properties.size());
-        for (Map.Entry<String, String[]> entry : properties.entrySet())
-        {
-            requestPropertyNames.add(entry.getKey());
-            requestProperties.put(entry.getKey().toLowerCase(), entry.getValue());
-        }
-    }
-
-    private void checkInitParameterMap()
-    {
-        if (parameters == null)
-        {
-            parameters = initParameterMap();
-        }
-    }
-
-    protected static Map<String, String[]> cloneParameterMap(Map<String, String[]> map)
-    {
-        if (!map.isEmpty())
-        {
-            Map<String, String[]> result = new HashMap<String, String[]>(map.size());
-            for (Map.Entry<String,String[]> entry : map.entrySet())
-            {
-                if (entry.getValue() != null)
-                {
-                    result.put(entry.getKey(), entry.getValue().clone());
-                }
-            }
-            return Collections.unmodifiableMap(result);
-        }
-        return Collections.emptyMap();
-    }
-
-    protected Map<String, String[]> initParameterMap()
-    {
-        String[] values  = null;
-        Map<String, String[]> parameters = requestContext.getPrivateParameterMap();
-        Map<String, String[]> publicParameters = requestContext.getPublicParameterMap();
-        if (!publicParameters.isEmpty())
-        {
-            parameters = new HashMap<String, String[]>(parameters);
-            for (Map.Entry<String,String[]> entry : publicParameters.entrySet())
-            {
-                values = parameters.get(entry.getKey());
-                if (values == null)
-                {
-                    parameters.put(entry.getKey(), entry.getValue().clone());
-                }
-                else
-                {
-                    String[] copy = new String[values.length+entry.getValue().length];
-                    System.arraycopy(values, 0, copy, 0, values.length);
-                    System.arraycopy(entry.getValue(), 0, copy, values.length, entry.getValue().length);
-                    parameters.put(entry.getKey(), copy);
-                }
-            }
-        }
-        return parameters;
-    }
-
-    protected PortletRequestContext getRequestContext()
-    {
-        return requestContext;
-    }
-
-    protected PortletContext getPortletContext()
-    {
-        return requestContext.getPortletConfig().getPortletContext();
-    }
-
-    protected PortletWindow getPortletWindow()
-    {
-        return requestContext.getPortletWindow();
-    }
-
-    protected PortletContainer getPortletContainer()
-    {
-        return requestContext.getContainer();
-    }
-
-    protected HttpServletRequest getServletRequest()
-    {
-        return requestContext.getServletRequest();
-    }
-
-    protected String getMimeRequestProperty(String name, CacheControl cacheControl)
-    {
-        if (MimeResponse.ETAG.equals(name))
-        {
-            return cacheControl.getETag();
-        }
-        else if (MimeResponse.CACHE_SCOPE.equals(name))
-        {
-            return cacheControl.isPublicScope() ? MimeResponse.PUBLIC_SCOPE : MimeResponse.PRIVATE_SCOPE;
-        }
-        else if (MimeResponse.USE_CACHED_CONTENT.equals(name))
-        {
-            return cacheControl.useCachedContent() ? "true" : null;
-        }
-        else if (MimeResponse.EXPIRATION_CACHE.equals(name))
-        {
-            return Integer.toString(cacheControl.getExpirationTime());
-        }
-        return null;
-    }
-
-    // PortletRequest Impl -----------------------------------------------------
-
-    public Object getAttribute(String name)
-    {
-        ArgumentUtility.validateNotNull("attributeName", name);
-        if (name.equals(PortletRequest.LIFECYCLE_PHASE))
-        {
-            return lifecyclePhase;
-        }
-        else if (name.equals(PortletRequest.USER_INFO))
-        {
-            if (userInfo == null)
-            {
-                try
-                {
-                    userInfo = getPortletContainer().getContainerServices().getUserInfoService().getUserInfo(this, getPortletWindow());
-                }
-                catch (Exception e)
-                {
-                    userInfo = Collections.emptyMap();
-                }
-            }
-            return userInfo;
-        }
-        else if (name.equals(PortletInvokerService.REQUEST_CONTEXT))
-        {
-            return requestContext;
-        }
-        else if (name.equals(PortletInvokerService.RESPONSE_CONTEXT))
-        {
-            return responseContext;
-        }
-        else if (name.equals(PortletRequest.CCPP_PROFILE))
-        {
-            if (ccppProfile == null)
-            {
-                ccppProfile = getPortletContainer().getContainerServices().getCCPPProfileService().getCCPPProfile(getServletRequest());
-            }
-            return ccppProfile;
-        }
-        return requestContext.getAttribute(name);
-    }
-
-    public Enumeration<String> getAttributeNames()
-    {
-        return requestContext.getAttributeNames();
-    }
-
-    public String getAuthType()
-    {
-        return getServletRequest().getAuthType();
-    }
-
-    public String getContextPath()
-    {
-        if (contextPath == null)
-        {
-            contextPath = requestContext.getPortletWindow().getPortletDefinition().getApplication().getContextPath();
-        }
-
-        return contextPath;
-    }
-
-    public Cookie[] getCookies()
-    {
-        if (requestCookies == null)
-        {
-            requestCookies = requestContext.getCookies();
-            if (requestCookies == null)
-            {
-                requestCookies = new Cookie[0];
-            }
-        }
-        return requestCookies.length > 0 ? requestCookies.clone() : null;
-    }
-
-    public Locale getLocale()
-    {
-        return requestContext.getPreferredLocale();
-    }
-
-    @SuppressWarnings("unchecked")
-    public Enumeration<Locale> getLocales()
-    {
-        Locale preferredLocale = getLocale();
-        ArrayList<Locale> locales = new ArrayList<Locale>();
-        locales.add(preferredLocale);
-        for (Enumeration e = getServletRequest().getLocales(); e.hasMoreElements(); )
-        {
-            Locale locale = (Locale)e.nextElement();
-            if (!locale.equals(preferredLocale))
-            {
-                locales.add(locale);
-            }
-        }
-        return Collections.enumeration(locales);
-    }
-
-    public String getParameter(String name)
-    {
-        ArgumentUtility.validateNotNull("parameterName", name);
-        checkInitParameterMap();
-        String[] values = parameters.get(name);
-        return values != null && values.length > 0 ? values[0] : null;
-    }
-
-    public Map<String, String[]> getParameterMap()
-    {
-        checkInitParameterMap();
-        return cloneParameterMap(parameters);
-    }
-
-    public Enumeration<String> getParameterNames()
-    {
-        checkInitParameterMap();
-        return Collections.enumeration(parameters.keySet());
-    }
-
-    public String[] getParameterValues(String name)
-    {
-        ArgumentUtility.validateNotNull("parameterName", name);
-        checkInitParameterMap();
-        String[] values =  parameters.get(name);
-        return values != null ? values.clone() : null;
-    }
-
-    public PortalContext getPortalContext()
-    {
-        return portalContext;
-    }
-
-    public PortletMode getPortletMode()
-    {
-        return getPortletWindow().getPortletMode();
-    }
-
-    public PortletSession getPortletSession()
-    {
-        return getPortletSession(true);
-    }
-
-    /**
-     * Returns the portlet session.
-     * <p>
-     * Note that since portlet request instance is created everytime the portlet
-     * container receives an incoming request, the portlet session instance held
-     * by the request instance is also re-created for each incoming request.
-     * </p>
-     */
-    public PortletSession getPortletSession(boolean create)
-    {
-        if (LOG.isDebugEnabled())
-        {
-            LOG.debug("Retreiving portlet session (create=" + create + ")");
-        }
-        //
-        // It is critical that we don't retrieve the portlet session until the
-        //   cross context dispatch has been completed.  If we do then we risk
-        //   having a cached version which is invalid for the context within
-        //   which it exists.
-        //
-        if (getPortletContext() == null)
-        {
-            throw new IllegalStateException(
-                    EXCEPTIONS.getString("error.session.illegalState"));
-        }
-        //
-        // We must make sure that if the session has been invalidated (perhaps
-        //   through setMaxIntervalTimeout()) and the underlying request
-        //   returns null that we no longer use the cached version.
-        // We have to check (ourselves) if the session has exceeded its max
-        //   inactive interval. If so, we should invalidate the underlying
-        //   HttpSession and recreate a new one (if the create flag is set to
-        //   true) -- We just cannot depend on the implementation of
-        //   javax.servlet.http.HttpSession!
-        //
-        HttpSession httpSession = getServletRequest().getSession(create);
-        if (httpSession != null)
-        {
-            // HttpSession is not null does NOT mean that it is valid.
-            int maxInactiveInterval = httpSession.getMaxInactiveInterval();
-            long lastAccesstime = httpSession.getLastAccessedTime();//lastAccesstime checks added for PLUTO-436
-            if (maxInactiveInterval >= 0 && lastAccesstime > 0)
-            {    // < 0 => Never expires.
-                long maxInactiveTime = httpSession.getMaxInactiveInterval() * 1000L;
-                long currentInactiveTime = System.currentTimeMillis() - lastAccesstime;
-                if (currentInactiveTime > maxInactiveTime)
-                {
-                    if (LOG.isDebugEnabled())
-                    {
-                        LOG.debug("The underlying HttpSession is expired and "
-                                + "should be invalidated.");
-                    }
-                    httpSession.invalidate();
-                    httpSession = getServletRequest().getSession(create);
-                    //Added for PLUTO-436
-                    // a cached portletSession is no longer useable.
-                    // a new one will be created below.
-                    portletSession = null;
-                }
-            }
-        }
-        if (httpSession == null)
-        {
-            if (LOG.isDebugEnabled())
-            {
-                LOG.debug("The underlying HttpSession is not available: "
-                        + "no session will be returned.");
-            }
-            return null;
-        }
-        //
-        // If we reach here, we are sure that the underlying HttpSession is
-        //   available. If we haven't created and cached a portlet session
-        //   instance, we will create and cache one now.
-        //
-        if (portletSession == null)
-        {
-            if (LOG.isDebugEnabled())
-            {
-                LOG.debug("Creating new portlet session...");
-            }
-            final ContainerServices containerServices = getPortletContainer().getContainerServices();
-            final PortletEnvironmentService portletEnvironmentService = containerServices.getPortletEnvironmentService();
-
-            portletSession = portletEnvironmentService.createPortletSession(getPortletContext(), getPortletWindow(), httpSession);
-        }
-        return portletSession;
-    }
-
-    public PortletPreferences getPreferences()
-    {
-        if (portletPreferences == null)
-        {
-            portletPreferences = new PortletPreferencesImpl(
-                    getPortletContainer(),getPortletWindow(),
-                    this);
-        }
-        return portletPreferences;
-    }
-
-    public Map<String, String[]> getPrivateParameterMap()
-    {
-        return cloneParameterMap(requestContext.getPrivateParameterMap());
-    }
-
-    @SuppressWarnings("unchecked")
-    public Enumeration<String> getProperties(String name)
-    {
-        ArgumentUtility.validateNotNull("propertyName", name);
-
-        if(ACCEPT_LANGUAGE.equalsIgnoreCase(name))
-        {
-            Locale preferredLocale = getLocale();
-            ArrayList<String> locales = new ArrayList<String>();
-            locales.add(preferredLocale.toString());
-            for (Enumeration e = getServletRequest().getLocales(); e.hasMoreElements(); )
-            {
-                Locale locale = (Locale)e.nextElement();
-                if (!locale.equals(preferredLocale))
-                {
-                    locales.add(locale.toString());
-                }
-            }
-            return Collections.enumeration(locales);
-        }
-
-        if (requestProperties == null)
-        {
-            retrieveRequestProperties();
-        }
-        String[] properties = requestProperties.get(name.toLowerCase());
-        if (properties == null)
-        {
-            return Collections.enumeration(EMPTY_STRING_LIST);
-        }
-        return Collections.enumeration(Arrays.asList(properties));
-    }
-
-    public String getProperty(String name)
-    {
-        ArgumentUtility.validateNotNull("name", name);
-
-        if(ACCEPT_LANGUAGE.equalsIgnoreCase(name))
-        {
-            return getLocale().toString();
-        }
-
-        if (requestProperties == null)
-        {
-            retrieveRequestProperties();
-        }
-        String property = null;
-        String[] properties = requestProperties.get(name.toLowerCase());
-        if (properties != null && properties.length > 0)
-        {
-            property = properties[0];
-        }
-        return property;
-    }
-
-    public Enumeration<String> getPropertyNames()
-    {
-        if (requestProperties == null)
-        {
-            retrieveRequestProperties();
-        }
-        return Collections.enumeration(requestPropertyNames);
-    }
-
-    public Map<String, String[]> getPublicParameterMap()
-    {
-        return cloneParameterMap(requestContext.getPublicParameterMap());
-    }
-
-    public String getRemoteUser()
-    {
-        return getServletRequest().getRemoteUser();
-    }
-
-    public String getRequestedSessionId()
-    {
-        return getServletRequest().getRequestedSessionId();
-    }
-
-    public String getResponseContentType()
-    {
-        return getResponseContentTypes().nextElement();
-    }
-
-    public Enumeration<String> getResponseContentTypes()
-    {
-        if (contentTypes == null)
-        {
-            contentTypes = new ArrayList<String>();
-            PortletDefinition dd = getPortletWindow().getPortletDefinition();
-            for (Supports sup : dd.getSupports())
-            {
-                contentTypes.add(sup.getMimeType());
-            }
-            if (contentTypes.isEmpty())
-            {
-                contentTypes.add("text/html");
-            }
-        }
-        return Collections.enumeration(contentTypes);
-    }
-
-    public String getScheme()
-    {
-        return getServletRequest().getScheme();
-    }
-
-    public String getServerName()
-    {
-        return getServletRequest().getServerName();
-    }
-
-    public int getServerPort()
-    {
-        return getServletRequest().getServerPort();
-    }
-
-    public Principal getUserPrincipal()
-    {
-        return getServletRequest().getUserPrincipal();
-    }
-
-    public String getWindowID()
-    {
-        return getPortletWindow().getId().getStringId();
-    }
-
-    public WindowState getWindowState()
-    {
-        return getPortletWindow().getWindowState();
-    }
-
-    public boolean isPortletModeAllowed(PortletMode mode)
-    {
-        if(PortletMode.VIEW.equals(mode))
-        {
-            return true;
-        }
-
-        String modeName = mode.toString();
-
-        PortletDefinition dd = getPortletWindow().getPortletDefinition();
-
-        for (Supports sup : dd.getSupports())
-        {
-            for (String m : sup.getPortletModes())
-            {
-                if (m.equalsIgnoreCase(modeName))
-                {
-                    // check if a portlet managed mode which is always allowed.
-                    CustomPortletMode cpm = dd.getApplication().getCustomPortletMode(modeName);
-                    if (cpm != null && !cpm.isPortalManaged())
-                    {
-                        return true;
-                    }
-                    Enumeration<PortletMode> supportedModes = portalContext.getSupportedPortletModes();
-                    while (supportedModes.hasMoreElements())
-                    {
-                        if (supportedModes.nextElement().equals(mode))
-                        {
-                            return true;
-                        }
-                    }
-                    return false;
-                }
-            }
-        }
-        return false;
-    }
-
-    public boolean isRequestedSessionIdValid()
-    {
-        return getServletRequest().isRequestedSessionIdValid();
-    }
-
-    public boolean isSecure()
-    {
-        return getServletRequest().isSecure();
-    }
-
-    /**
-     * Determines whether a user is mapped to the specified role.  As specified
-     * in PLT-20-3, we must reference the &lt;security-role-ref&gt; mappings
-     * within the deployment descriptor. If no mapping is available, then, and
-     * only then, do we check use the actual role name specified against the web
-     * application deployment descriptor.
-     *
-     * @param roleName the name of the role
-     * @return true if it is determined the user has the given role.
-     */
-    public boolean isUserInRole(String roleName)
-    {
-        PortletDefinition def = getPortletWindow().getPortletDefinition();
-        String link = roleName;
-
-        for (SecurityRoleRef r : def.getSecurityRoleRefs())
-        {
-            if (r.getRoleName().equals(roleName))
-            {
-                if (r.getRoleLink() != null)
-                {
-                    link = r.getRoleLink();
-                }
-                break;
-            }
-        }
-        return getServletRequest().isUserInRole(link);
-    }
-
-    /**
-     * Determine whether or not the specified WindowState is allowed for this
-     * portlet.
-     *
-     * @param state the state in question
-     * @return true if the state is allowed.
-     */
-    public boolean isWindowStateAllowed(WindowState state)
-    {
-        for (Enumeration<WindowState> en = portalContext.getSupportedWindowStates();
-        en.hasMoreElements(); )
-        {
-            if (en.nextElement().toString().equalsIgnoreCase(state.toString()))
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public void setAttribute(String name, Object value)
-    {
-        ArgumentUtility.validateNotEmpty("name", name);
-        requestContext.setAttribute(name, value);
-    }
-
-    public void removeAttribute(String name)
-    {
-        ArgumentUtility.validateNotEmpty("name", name);
-        requestContext.setAttribute(name, null);
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.container.impl;
+
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.ccpp.Profile;
+import javax.portlet.CacheControl;
+import javax.portlet.MimeResponse;
+import javax.portlet.PortalContext;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
+import javax.portlet.WindowState;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.apache.pluto.container.ContainerServices;
+import org.apache.pluto.container.PortletContainer;
+import org.apache.pluto.container.PortletEnvironmentService;
+import org.apache.pluto.container.PortletInvokerService;
+import org.apache.pluto.container.PortletRequestContext;
+import org.apache.pluto.container.PortletResponseContext;
+import org.apache.pluto.container.PortletWindow;
+import org.apache.pluto.container.om.portlet.CustomPortletMode;
+import org.apache.pluto.container.om.portlet.PortletDefinition;
+import org.apache.pluto.container.om.portlet.SecurityRoleRef;
+import org.apache.pluto.container.om.portlet.Supports;
+import org.apache.pluto.container.util.ArgumentUtility;
+import org.apache.pluto.container.util.StringManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Abstract <code>javax.portlet.PortletRequest</code> implementation.
+ * This class also implements InternalPortletRequest.
+ *
+ */
+public abstract class PortletRequestImpl implements PortletRequest
+{
+    public static final String ACCEPT_LANGUAGE = "Accept-Language";
+
+    private static final Logger LOG = LoggerFactory.getLogger(PortletRequestImpl.class);
+    private static boolean isDebug = LOG.isDebugEnabled();
+
+    private static final StringManager EXCEPTIONS =
+        StringManager.getManager(PortletRequestImpl.class.getPackage().getName());
+
+    private static final List<String> EMPTY_STRING_LIST = Collections.unmodifiableList(new ArrayList<String>(0));
+
+    // Private Member Variables ------------------------------------------------
+
+    /** The PortalContext within which this request is occuring. */
+    private final PortalContext portalContext;
+
+    private final PortletRequestContext requestContext;
+    private final PortletResponseContext responseContext;
+
+    /** The portlet session. */
+    private PortletSession portletSession;
+
+    /** Response content types. */
+    private ArrayList<String> contentTypes;
+
+    private PortletPreferences portletPreferences;
+
+    private Map<String, String[]> parameters;
+
+    private Map<String, String[]> requestProperties;
+    private List<String> requestPropertyNames;
+
+    private Cookie[] requestCookies;
+
+    private Map<String, String> userInfo;
+
+    private Profile ccppProfile;
+
+    private String contextPath;
+
+    private final String lifecyclePhase;
+
+    public PortletRequestImpl(PortletRequestContext requestContext, PortletResponseContext responseContext, String lifecyclePhase)
+    {
+        this.requestContext = requestContext;
+        this.responseContext = responseContext;
+        this.lifecyclePhase = lifecyclePhase;
+        this.portalContext = getPortletContainer().getContainerServices().getPortalContext();
+    }
+
+    private void retrieveRequestProperties()
+    {
+        Map<String, String[]> properties = requestContext.getProperties();
+        requestPropertyNames = new ArrayList<String>(properties.size());
+        requestProperties = new HashMap<String, String[]>(properties.size());
+        for (Map.Entry<String, String[]> entry : properties.entrySet())
+        {
+            requestPropertyNames.add(entry.getKey());
+            requestProperties.put(entry.getKey().toLowerCase(), entry.getValue());
+        }
+    }
+
+    private void checkInitParameterMap()
+    {
+        if (parameters == null)
+        {
+            parameters = initParameterMap();
+        }
+    }
+
+    protected static Map<String, String[]> cloneParameterMap(Map<String, String[]> map)
+    {
+        if (!map.isEmpty())
+        {
+            Map<String, String[]> result = new HashMap<String, String[]>(map.size());
+            for (Map.Entry<String,String[]> entry : map.entrySet())
+            {
+                if (entry.getValue() != null)
+                {
+                    result.put(entry.getKey(), entry.getValue().clone());
+                }
+            }
+            return Collections.unmodifiableMap(result);
+        }
+        return Collections.emptyMap();
+    }
+
+    protected Map<String, String[]> initParameterMap()
+    {
+        String[] values  = null;
+        Map<String, String[]> parameters = requestContext.getPrivateParameterMap();
+        Map<String, String[]> publicParameters = requestContext.getPublicParameterMap();
+        if (!publicParameters.isEmpty())
+        {
+            parameters = new HashMap<String, String[]>(parameters);
+            for (Map.Entry<String,String[]> entry : publicParameters.entrySet())
+            {
+                values = parameters.get(entry.getKey());
+                if (values == null)
+                {
+                    parameters.put(entry.getKey(), entry.getValue().clone());
+                }
+                else
+                {
+                    String[] copy = new String[values.length+entry.getValue().length];
+                    System.arraycopy(values, 0, copy, 0, values.length);
+                    System.arraycopy(entry.getValue(), 0, copy, values.length, entry.getValue().length);
+                    parameters.put(entry.getKey(), copy);
+                }
+            }
+        }
+        if (isDebug) {
+           StringBuilder txt = new StringBuilder("initParameterMap Returning ");
+           txt.append(publicParameters.size()).append(" public and ")
+              .append(parameters.size()).append(" total parameters.");
+           LOG.debug(txt.toString());
+        }
+        return parameters;
+    }
+
+    protected PortletRequestContext getRequestContext()
+    {
+        return requestContext;
+    }
+
+    protected PortletContext getPortletContext()
+    {
+        return requestContext.getPortletConfig().getPortletContext();
+    }
+
+    protected PortletWindow getPortletWindow()
+    {
+        return requestContext.getPortletWindow();
+    }
+
+    protected PortletContainer getPortletContainer()
+    {
+        return requestContext.getContainer();
+    }
+
+    protected HttpServletRequest getServletRequest()
+    {
+        return requestContext.getServletRequest();
+    }
+
+    protected String getMimeRequestProperty(String name, CacheControl cacheControl)
+    {
+        if (MimeResponse.ETAG.equals(name))
+        {
+            return cacheControl.getETag();
+        }
+        else if (MimeResponse.CACHE_SCOPE.equals(name))
+        {
+            return cacheControl.isPublicScope() ? MimeResponse.PUBLIC_SCOPE : MimeResponse.PRIVATE_SCOPE;
+        }
+        else if (MimeResponse.USE_CACHED_CONTENT.equals(name))
+        {
+            return cacheControl.useCachedContent() ? "true" : null;
+        }
+        else if (MimeResponse.EXPIRATION_CACHE.equals(name))
+        {
+            return Integer.toString(cacheControl.getExpirationTime());
+        }
+        return null;
+    }
+
+    // PortletRequest Impl -----------------------------------------------------
+
+    public Object getAttribute(String name)
+    {
+        ArgumentUtility.validateNotNull("attributeName", name);
+        if (name.equals(PortletRequest.LIFECYCLE_PHASE))
+        {
+            return lifecyclePhase;
+        }
+        else if (name.equals(PortletRequest.USER_INFO))
+        {
+            if (userInfo == null)
+            {
+                try
+                {
+                    userInfo = getPortletContainer().getContainerServices().getUserInfoService().getUserInfo(this, getPortletWindow());
+                }
+                catch (Exception e)
+                {
+                    userInfo = Collections.emptyMap();
+                }
+            }
+            return userInfo;
+        }
+        else if (name.equals(PortletInvokerService.REQUEST_CONTEXT))
+        {
+            return requestContext;
+        }
+        else if (name.equals(PortletInvokerService.RESPONSE_CONTEXT))
+        {
+            return responseContext;
+        }
+        else if (name.equals(PortletRequest.CCPP_PROFILE))
+        {
+            if (ccppProfile == null)
+            {
+                ccppProfile = getPortletContainer().getContainerServices().getCCPPProfileService().getCCPPProfile(getServletRequest());
+            }
+            return ccppProfile;
+        }
+        return requestContext.getAttribute(name);
+    }
+
+    public Enumeration<String> getAttributeNames()
+    {
+        return requestContext.getAttributeNames();
+    }
+
+    public String getAuthType()
+    {
+        return getServletRequest().getAuthType();
+    }
+
+    public String getContextPath()
+    {
+        if (contextPath == null)
+        {
+            contextPath = requestContext.getPortletWindow().getPortletDefinition().getApplication().getContextPath();
+        }
+
+        return contextPath;
+    }
+
+    public Cookie[] getCookies()
+    {
+        if (requestCookies == null)
+        {
+            requestCookies = requestContext.getCookies();
+            if (requestCookies == null)
+            {
+                requestCookies = new Cookie[0];
+            }
+        }
+        return requestCookies.length > 0 ? requestCookies.clone() : null;
+    }
+
+    public Locale getLocale()
+    {
+        return requestContext.getPreferredLocale();
+    }
+
+    @SuppressWarnings("unchecked")
+    public Enumeration<Locale> getLocales()
+    {
+        Locale preferredLocale = getLocale();
+        ArrayList<Locale> locales = new ArrayList<Locale>();
+        locales.add(preferredLocale);
+        for (Enumeration e = getServletRequest().getLocales(); e.hasMoreElements(); )
+        {
+            Locale locale = (Locale)e.nextElement();
+            if (!locale.equals(preferredLocale))
+            {
+                locales.add(locale);
+            }
+        }
+        return Collections.enumeration(locales);
+    }
+
+    public String getParameter(String name)
+    {
+        ArgumentUtility.validateNotNull("parameterName", name);
+        checkInitParameterMap();
+        String[] values = parameters.get(name);
+        return values != null && values.length > 0 ? values[0] : null;
+    }
+
+    public Map<String, String[]> getParameterMap()
+    {
+        checkInitParameterMap();
+        return cloneParameterMap(parameters);
+    }
+
+    public Enumeration<String> getParameterNames()
+    {
+        checkInitParameterMap();
+        return Collections.enumeration(parameters.keySet());
+    }
+
+    public String[] getParameterValues(String name)
+    {
+        ArgumentUtility.validateNotNull("parameterName", name);
+        checkInitParameterMap();
+        String[] values =  parameters.get(name);
+        return values != null ? values.clone() : null;
+    }
+
+    public PortalContext getPortalContext()
+    {
+        return portalContext;
+    }
+
+    public PortletMode getPortletMode()
+    {
+        return getPortletWindow().getPortletMode();
+    }
+
+    public PortletSession getPortletSession()
+    {
+        return getPortletSession(true);
+    }
+
+    /**
+     * Returns the portlet session.
+     * <p>
+     * Note that since portlet request instance is created everytime the portlet
+     * container receives an incoming request, the portlet session instance held
+     * by the request instance is also re-created for each incoming request.
+     * </p>
+     */
+    public PortletSession getPortletSession(boolean create)
+    {
+        if (LOG.isDebugEnabled())
+        {
+            LOG.debug("Retreiving portlet session (create=" + create + ")");
+        }
+        //
+        // It is critical that we don't retrieve the portlet session until the
+        //   cross context dispatch has been completed.  If we do then we risk
+        //   having a cached version which is invalid for the context within
+        //   which it exists.
+        //
+        if (getPortletContext() == null)
+        {
+            throw new IllegalStateException(
+                    EXCEPTIONS.getString("error.session.illegalState"));
+        }
+        //
+        // We must make sure that if the session has been invalidated (perhaps
+        //   through setMaxIntervalTimeout()) and the underlying request
+        //   returns null that we no longer use the cached version.
+        // We have to check (ourselves) if the session has exceeded its max
+        //   inactive interval. If so, we should invalidate the underlying
+        //   HttpSession and recreate a new one (if the create flag is set to
+        //   true) -- We just cannot depend on the implementation of
+        //   javax.servlet.http.HttpSession!
+        //
+        HttpSession httpSession = getServletRequest().getSession(create);
+        if (httpSession != null)
+        {
+            // HttpSession is not null does NOT mean that it is valid.
+            int maxInactiveInterval = httpSession.getMaxInactiveInterval();
+            long lastAccesstime = httpSession.getLastAccessedTime();//lastAccesstime checks added for PLUTO-436
+            if (maxInactiveInterval >= 0 && lastAccesstime > 0)
+            {    // < 0 => Never expires.
+                long maxInactiveTime = httpSession.getMaxInactiveInterval() * 1000L;
+                long currentInactiveTime = System.currentTimeMillis() - lastAccesstime;
+                if (currentInactiveTime > maxInactiveTime)
+                {
+                    if (LOG.isDebugEnabled())
+                    {
+                        LOG.debug("The underlying HttpSession is expired and "
+                                + "should be invalidated.");
+                    }
+                    httpSession.invalidate();
+                    httpSession = getServletRequest().getSession(create);
+                    //Added for PLUTO-436
+                    // a cached portletSession is no longer useable.
+                    // a new one will be created below.
+                    portletSession = null;
+                }
+            }
+        }
+        if (httpSession == null)
+        {
+            if (LOG.isDebugEnabled())
+            {
+                LOG.debug("The underlying HttpSession is not available: "
+                        + "no session will be returned.");
+            }
+            return null;
+        }
+        //
+        // If we reach here, we are sure that the underlying HttpSession is
+        //   available. If we haven't created and cached a portlet session
+        //   instance, we will create and cache one now.
+        //
+        if (portletSession == null)
+        {
+            if (LOG.isDebugEnabled())
+            {
+                LOG.debug("Creating new portlet session...");
+            }
+            final ContainerServices containerServices = getPortletContainer().getContainerServices();
+            final PortletEnvironmentService portletEnvironmentService = containerServices.getPortletEnvironmentService();
+
+            portletSession = portletEnvironmentService.createPortletSession(getPortletContext(), getPortletWindow(), httpSession);
+        }
+        return portletSession;
+    }
+
+    public PortletPreferences getPreferences()
+    {
+        if (portletPreferences == null)
+        {
+            portletPreferences = new PortletPreferencesImpl(
+                    getPortletContainer(),getPortletWindow(),
+                    this);
+        }
+        return portletPreferences;
+    }
+
+    public Map<String, String[]> getPrivateParameterMap()
+    {
+        return cloneParameterMap(requestContext.getPrivateParameterMap());
+    }
+
+    @SuppressWarnings("unchecked")
+    public Enumeration<String> getProperties(String name)
+    {
+        ArgumentUtility.validateNotNull("propertyName", name);
+
+        if(ACCEPT_LANGUAGE.equalsIgnoreCase(name))
+        {
+            Locale preferredLocale = getLocale();
+            ArrayList<String> locales = new ArrayList<String>();
+            locales.add(preferredLocale.toString());
+            for (Enumeration e = getServletRequest().getLocales(); e.hasMoreElements(); )
+            {
+                Locale locale = (Locale)e.nextElement();
+                if (!locale.equals(preferredLocale))
+                {
+                    locales.add(locale.toString());
+                }
+            }
+            return Collections.enumeration(locales);
+        }
+
+        if (requestProperties == null)
+        {
+            retrieveRequestProperties();
+        }
+        String[] properties = requestProperties.get(name.toLowerCase());
+        if (properties == null)
+        {
+            return Collections.enumeration(EMPTY_STRING_LIST);
+        }
+        return Collections.enumeration(Arrays.asList(properties));
+    }
+
+    public String getProperty(String name)
+    {
+        ArgumentUtility.validateNotNull("name", name);
+
+        if(ACCEPT_LANGUAGE.equalsIgnoreCase(name))
+        {
+            return getLocale().toString();
+        }
+
+        if (requestProperties == null)
+        {
+            retrieveRequestProperties();
+        }
+        String property = null;
+        String[] properties = requestProperties.get(name.toLowerCase());
+        if (properties != null && properties.length > 0)
+        {
+            property = properties[0];
+        }
+        return property;
+    }
+
+    public Enumeration<String> getPropertyNames()
+    {
+        if (requestProperties == null)
+        {
+            retrieveRequestProperties();
+        }
+        return Collections.enumeration(requestPropertyNames);
+    }
+
+    public Map<String, String[]> getPublicParameterMap()
+    {
+        return cloneParameterMap(requestContext.getPublicParameterMap());
+    }
+
+    public String getRemoteUser()
+    {
+        return getServletRequest().getRemoteUser();
+    }
+
+    public String getRequestedSessionId()
+    {
+        return getServletRequest().getRequestedSessionId();
+    }
+
+    public String getResponseContentType()
+    {
+        return getResponseContentTypes().nextElement();
+    }
+
+    public Enumeration<String> getResponseContentTypes()
+    {
+        if (contentTypes == null)
+        {
+            contentTypes = new ArrayList<String>();
+            PortletDefinition dd = getPortletWindow().getPortletDefinition();
+            for (Supports sup : dd.getSupports())
+            {
+                contentTypes.add(sup.getMimeType());
+            }
+            if (contentTypes.isEmpty())
+            {
+                contentTypes.add("text/html");
+            }
+        }
+        return Collections.enumeration(contentTypes);
+    }
+
+    public String getScheme()
+    {
+        return getServletRequest().getScheme();
+    }
+
+    public String getServerName()
+    {
+        return getServletRequest().getServerName();
+    }
+
+    public int getServerPort()
+    {
+        return getServletRequest().getServerPort();
+    }
+
+    public Principal getUserPrincipal()
+    {
+        return getServletRequest().getUserPrincipal();
+    }
+
+    public String getWindowID()
+    {
+        return getPortletWindow().getId().getStringId();
+    }
+
+    public WindowState getWindowState()
+    {
+        return getPortletWindow().getWindowState();
+    }
+
+    public boolean isPortletModeAllowed(PortletMode mode)
+    {
+        if(PortletMode.VIEW.equals(mode))
+        {
+            return true;
+        }
+
+        String modeName = mode.toString();
+
+        PortletDefinition dd = getPortletWindow().getPortletDefinition();
+
+        for (Supports sup : dd.getSupports())
+        {
+            for (String m : sup.getPortletModes())
+            {
+                if (m.equalsIgnoreCase(modeName))
+                {
+                    // check if a portlet managed mode which is always allowed.
+                    CustomPortletMode cpm = dd.getApplication().getCustomPortletMode(modeName);
+                    if (cpm != null && !cpm.isPortalManaged())
+                    {
+                        return true;
+                    }
+                    Enumeration<PortletMode> supportedModes = portalContext.getSupportedPortletModes();
+                    while (supportedModes.hasMoreElements())
+                    {
+                        if (supportedModes.nextElement().equals(mode))
+                        {
+                            return true;
+                        }
+                    }
+                    return false;
+                }
+            }
+        }
+        return false;
+    }
+
+    public boolean isRequestedSessionIdValid()
+    {
+        return getServletRequest().isRequestedSessionIdValid();
+    }
+
+    public boolean isSecure()
+    {
+        return getServletRequest().isSecure();
+    }
+
+    /**
+     * Determines whether a user is mapped to the specified role.  As specified
+     * in PLT-20-3, we must reference the &lt;security-role-ref&gt; mappings
+     * within the deployment descriptor. If no mapping is available, then, and
+     * only then, do we check use the actual role name specified against the web
+     * application deployment descriptor.
+     *
+     * @param roleName the name of the role
+     * @return true if it is determined the user has the given role.
+     */
+    public boolean isUserInRole(String roleName)
+    {
+        PortletDefinition def = getPortletWindow().getPortletDefinition();
+        String link = roleName;
+
+        for (SecurityRoleRef r : def.getSecurityRoleRefs())
+        {
+            if (r.getRoleName().equals(roleName))
+            {
+                if (r.getRoleLink() != null)
+                {
+                    link = r.getRoleLink();
+                }
+                break;
+            }
+        }
+        return getServletRequest().isUserInRole(link);
+    }
+
+    /**
+     * Determine whether or not the specified WindowState is allowed for this
+     * portlet.
+     *
+     * @param state the state in question
+     * @return true if the state is allowed.
+     */
+    public boolean isWindowStateAllowed(WindowState state)
+    {
+        for (Enumeration<WindowState> en = portalContext.getSupportedWindowStates();
+        en.hasMoreElements(); )
+        {
+            if (en.nextElement().toString().equalsIgnoreCase(state.toString()))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public void setAttribute(String name, Object value)
+    {
+        ArgumentUtility.validateNotEmpty("name", name);
+        requestContext.setAttribute(name, value);
+    }
+
+    public void removeAttribute(String name)
+    {
+        ArgumentUtility.validateNotEmpty("name", name);
+        requestContext.setAttribute(name, null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/14800b56/pluto-container/src/main/java/org/apache/pluto/container/impl/StateAwareResponseImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/StateAwareResponseImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/StateAwareResponseImpl.java
index bf7e885..a6ead55 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/StateAwareResponseImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/StateAwareResponseImpl.java
@@ -48,43 +48,46 @@ import org.apache.pluto.container.util.ArgumentUtility;
 public abstract class StateAwareResponseImpl extends PortletResponseImpl implements StateAwareResponse
 {
    private final Logger LOGGER = LoggerFactory.getLogger(StateAwareResponseImpl.class);
+   private final boolean isDebug = LOGGER.isDebugEnabled();
    
     private PortletStateAwareResponseContext responseContext;
+    private final String windowId;
     
 	public StateAwareResponseImpl(PortletStateAwareResponseContext responseContext)
 	{
 		super(responseContext);
 		this.responseContext = responseContext;
+		this.windowId = responseContext.getPortletWindow().getId().getStringId();
 	}
 	
-    private boolean isPublicRenderParameter(String name)
-    {
-        List<String> publicRenderParameterNames = responseContext.getPortletWindow().getPortletDefinition().getSupportedPublicRenderParameters();
-        return publicRenderParameterNames.isEmpty() ? false : publicRenderParameterNames.contains(name);
-    }
-    
-   private QName getQNameForPRPName(String name) {
-      QName qn = null;
-      PortletDefinition pd = responseContext.getPortletWindow().getPortletDefinition();
-      PortletApplicationDefinition pad = pd.getApplication();
-      List<? extends PublicRenderParameter> prps = pad.getPublicRenderParameters();
-      for (PublicRenderParameter prp : prps) {
-         if (name.equals(prp.getIdentifier())) {
-            qn = prp.getQName();
-            if (qn == null) {
-               String ns = pad.getDefaultNamespace();
-               String lp = prp.getName();
-               if (lp != null) {
-                  qn = new QName(ns, lp);
-               } else {
-                  LOGGER.error("Error in descriptor for " + responseContext.getPortletWindow()
-                        + " - neither QName nor Name is defined");
-               }
-            }
-         }
-      }
-      return qn;
-   }
+//     private boolean isPublicRenderParameter(String name)
+//     {
+//         List<String> publicRenderParameterNames = responseContext.getPortletWindow().getPortletDefinition().getSupportedPublicRenderParameters();
+//         return publicRenderParameterNames.isEmpty() ? false : publicRenderParameterNames.contains(name);
+//     }
+//     
+//    private QName getQNameForPRPName(String name) {
+//       QName qn = null;
+//       PortletDefinition pd = responseContext.getPortletWindow().getPortletDefinition();
+//       PortletApplicationDefinition pad = pd.getApplication();
+//       List<? extends PublicRenderParameter> prps = pad.getPublicRenderParameters();
+//       for (PublicRenderParameter prp : prps) {
+//          if (name.equals(prp.getIdentifier())) {
+//             qn = prp.getQName();
+//             if (qn == null) {
+//                String ns = pad.getDefaultNamespace();
+//                String lp = prp.getName();
+//                if (lp != null) {
+//                   qn = new QName(ns, lp);
+//                } else {
+//                   LOGGER.error("Error in descriptor for " + responseContext.getPortletWindow()
+//                         + " - neither QName nor Name is defined");
+//                }
+//             }
+//          }
+//       }
+//       return qn;
+//    }
         
 	private static String[] cloneParameterValues(String[] values)
 	{
@@ -157,12 +160,11 @@ public abstract class StateAwareResponseImpl extends PortletResponseImpl impleme
     {
         ArgumentUtility.validateNotEmpty("name", name);
         checkSetStateChanged();
-        if (isPublicRenderParameter(name))
+        if (responseContext.isPublicRenderParameter(windowId, name))
         {
             responseContext.getRenderParameters().remove(name);
             
-            QName qn = getQNameForPRPName(name);
-            responseContext.removePublicRenderParameter(qn, name);
+            responseContext.removePublicRenderParameter(windowId, name);
         }
     }
 
@@ -250,16 +252,14 @@ public abstract class StateAwareResponseImpl extends PortletResponseImpl impleme
         checkSetStateChanged();
         
         responseContext.getRenderParameters().clear();
-        responseContext.clearPublicRenderParameters();
         for (Map.Entry<String,String[]> entry : parameters.entrySet())
         {
             String[] values = cloneParameterValues(entry.getValue());
             String key = entry.getKey();
             responseContext.getRenderParameters().put(key, values);
-            if (isPublicRenderParameter(key))
+            if (responseContext.isPublicRenderParameter(windowId, key))
             {
-                QName qn = getQNameForPRPName(key);
-                responseContext.addPublicRenderParameter(qn, key, values);
+                responseContext.addPublicRenderParameter(windowId, key, values);
             }
         }
     }
@@ -271,10 +271,9 @@ public abstract class StateAwareResponseImpl extends PortletResponseImpl impleme
         checkSetStateChanged();
         String[] values = new String[]{value};
         responseContext.getRenderParameters().put(key, values);
-        if (isPublicRenderParameter(key))
+        if (responseContext.isPublicRenderParameter(windowId, key))
         {
-            QName qn = getQNameForPRPName(key);
-            responseContext.addPublicRenderParameter(qn, key, values);
+            responseContext.addPublicRenderParameter(windowId, key, values);
         }
     }
     
@@ -289,10 +288,9 @@ public abstract class StateAwareResponseImpl extends PortletResponseImpl impleme
         }
         checkSetStateChanged();
         responseContext.getRenderParameters().put(key, values);
-        if (isPublicRenderParameter(key))
+        if (responseContext.isPublicRenderParameter(windowId, key))
         {
-            QName qn = getQNameForPRPName(key);
-            responseContext.addPublicRenderParameter(qn, key, values);
+            responseContext.addPublicRenderParameter(windowId, key, values);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/14800b56/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
index 560ddac..a9c75bf 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
@@ -18,8 +18,10 @@ package org.apache.pluto.driver.services.container;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -59,7 +61,17 @@ public abstract class PortletStateAwareResponseContextImpl extends PortletRespon
                                                 HttpServletResponse containerResponse, PortletWindow window)
     {
         super(container, containerRequest, containerResponse, window);
+        if (isDebug) {
+           LOGGER.debug("Creating PortletURLProviderImpl.");
+        }
+        
         this.portletURLProvider = new PortletURLProviderImpl(getPortalURL(), PortletURLProvider.TYPE.RENDER, window);
+        
+        if (isDebug) {
+           LOGGER.debug("Done! created PortletURLProviderImpl.");
+           String txt = portletURLProvider.logSomething();
+           LOGGER.debug("URL Provider said: " + txt);
+        }
     }
     
     protected PortletURLProvider getPortletURLProvider()
@@ -73,10 +85,22 @@ public abstract class PortletStateAwareResponseContextImpl extends PortletRespon
         if (!isClosed())
         {
             super.close();
+            if (isDebug) {
+               LOGGER.debug("Filtering the URL.");
+            }
             new PortletURLImpl(this, portletURLProvider).filterURL();
-            PortalURL url = portletURLProvider.apply();
-            PortalRequestContext.getContext(getServletRequest()).mergePortalURL(url, getPortletWindow().getId().getStringId());
-        }
+            if (isDebug) {
+               LOGGER.debug("Applying the changes.");
+            }
+           PortalURL url = portletURLProvider.apply();
+           if (isDebug) {
+              LOGGER.debug("Merging.");
+           }
+           PortalRequestContext.getContext(getServletRequest()).mergePortalURL(url, getPortletWindow().getId().getStringId());
+           if (isDebug) {
+              LOGGER.debug("exiting.");
+           }
+       }
     }
     
     @Override
@@ -147,7 +171,9 @@ public abstract class PortletStateAwareResponseContextImpl extends PortletRespon
              .append(", values = ").append(Arrays.toString(values));
           LOGGER.debug(txt.toString());
        }
-       portletURLProvider.addPublicRenderParameter(qn, identifier, values);
+       if (!isClosed()) {
+          portletURLProvider.addPublicRenderParameter(qn, identifier, values);
+       }
     }
 
     /* (non-Javadoc)
@@ -157,14 +183,102 @@ public abstract class PortletStateAwareResponseContextImpl extends PortletRespon
        if (isDebug) {
           LOGGER.debug("Remove PRP. QName = " + qn.toString());
        }
-       portletURLProvider.removePublicRenderParameter(qn, id);
+       if (!isClosed()) {
+          portletURLProvider.removePublicRenderParameter(qn, id);
+       }
+    }
+    
+    /**
+     * Add a public render parameter for given window ID and parameter name
+     *  
+     * @param qn           QName
+     * @param identifier   Identifier for PRP
+     * @param values       values array
+     */
+    public void addPublicRenderParameter(String windowId, String name, String[] values) {
+       if (!isClosed()) {
+          portletURLProvider.addPublicRenderParameter(windowId, name, values);
+       }
+    }
+    
+    /**
+     * Remove the PRP for the given window ID and parameter name
+     * 
+     * @param windowId
+     * @param name
+     */
+    public void removePublicRenderParameter(String windowId, String name) {
+       if (!isClosed()) {
+          portletURLProvider.removeParameter(windowId, name);
+       }
+    }
+    
+    /**
+     * Returns <code>true</code> if the given name representa a public render
+     * parameter for the given window.
+     * 
+     * @param windowId
+     * @param name
+     * @return
+     */
+    public boolean isPublicRenderParameter(String windowId, String name) {
+       boolean ret = false;
+       if (!isClosed()) {
+          ret = portletURLProvider.isPublicRenderParameter(windowId, name);
+       }
+       return ret;
+    }
+    
+    /**
+     * Retrieves the available private parameter names for the given window ID
+     * @param windowId
+     * @return
+     */
+    public Set<String> getParameterNames(String windowId) {
+       Set<String> pns = new HashSet<String>();
+       if (!isClosed()) {
+          pns = portletURLProvider.getParameterNames(windowId);
+       }
+       return pns;
+    }
+    
+    /**
+     * Gets the values array for the given window ID and private parameter name
+     * @param windowId
+     * @param name
+     * @return
+     */
+    public String[] getParameterValues(String windowId, String name) {
+       String[] vals = new String[0];
+       if (!isClosed()) {
+          vals = portletURLProvider.getParameterValues(windowId, name);
+       }
+       return vals;
     }
 
     /**
-     * Clear public render parameters except those marked for removal 
+     * Adds the specified private parameter if not already present, or updates the
+     * values for the parameter if it is already present.
+     * @param windowId
+     * @param name
+     * @param values
      */
-    public void clearPublicRenderParameters() {
-       portletURLProvider.clearPublicRenderParameters();
+    public void setParameter(String windowId, String name, String[] values) {
+       if (!isClosed()) {
+          portletURLProvider.setParameter(windowId, name, values);
+       }
+    }
+    
+    /** 
+     * Removes the private parameter for the given window and name. Does nothing if the
+     * given parameter is not present.
+     * @param windowId
+     * @param name
+     */
+    public void removeParameter(String windowId, String name) {
+       if (!isClosed()) {
+          portletURLProvider.removeParameter(windowId, name);
+       }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/14800b56/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
index e6aad68..8328e20 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
@@ -36,226 +36,285 @@ import javax.xml.namespace.QName;
 
 import org.apache.pluto.container.PortletURLProvider;
 import org.apache.pluto.container.PortletWindow;
+import org.apache.pluto.driver.services.portal.PublicRenderParameterMapper;
 import org.apache.pluto.driver.url.PortalURL;
 import org.apache.pluto.driver.url.PortalURL.URLType;
 import org.apache.pluto.driver.url.PortalURLParameter;
 import org.apache.pluto.driver.url.PortalURLPublicParameter;
+import org.apache.pluto.driver.url.PortletParameterFactory;
 
 /**
  *
  */
-public class PortletURLProviderImpl implements PortletURLProvider
-{
-    private final Logger LOGGER = LoggerFactory.getLogger(PortletURLProviderImpl.class);
-    private final boolean isDebug = LOGGER.isDebugEnabled();
-
-    private final PortalURL url;
-    private final TYPE type;
-    private final String window;
-    private PortletMode portletMode;
-    private WindowState windowState;
-    private String cacheLevel = ResourceURL.PAGE;     // default
-    private String resourceID;
-    private Map<String, String[]> renderParameters;
-    private Map<String, List<String>> properties;
-    
-    private final Set<PortalURLPublicParameter> prpSet = new HashSet<PortalURLPublicParameter>();
-    
-    /**
-     * Returns <code>true</code> if given parameter name is a public render parameter
-     * 
-     * @param name
-     */
-    private boolean isPRP(String name) {
-       boolean found = false;
-       for (PortalURLPublicParameter prp : prpSet) {
-          if (name.equals(prp.getName())) {
-             found = true;
-             break;
-          }
-       }
-       return found;
-    }
-
-    public PortletURLProviderImpl(PortalURL url, TYPE type, PortletWindow portletWindow)
-    {
-        this.url = url.clone();
-        this.type = type;
-        this.window = portletWindow.getId().getStringId();
-    }
-    
-    public PortalURL apply()
-    {
-        if (PortletURLProvider.TYPE.ACTION == type)
-        {
-           url.setTargetWindow(window);
-           url.setType(URLType.Action);
-        }
-        else if (PortletURLProvider.TYPE.RESOURCE == type)
-        {
-           url.setTargetWindow(window);
-           url.setType(URLType.Resource);
-           url.clearResourceParameters(window);
-        }
-        else
-        {
-            url.setTargetWindow(window);
-            url.setType(URLType.Render);
-            url.clearParameters(window);
-        }
-        if (portletMode != null)
-        {
-            url.setPortletMode(window, portletMode);
-        }
-        if (windowState != null)
-        {
-            url.setWindowState(window, windowState);
-        }
-        if (renderParameters != null)
-        {
-            for (Map.Entry<String,String[]> entry : renderParameters.entrySet())
-            {
-                if (!isPRP(entry.getKey()))
-                {
-                    url.addParameter(new PortalURLParameter(window, entry.getKey(), entry.getValue()));
-                }
+public class PortletURLProviderImpl implements PortletURLProvider {
+   private final Logger   LOGGER     = LoggerFactory.getLogger(PortletURLProviderImpl.class);
+   private final boolean  isDebug    = LOGGER.isDebugEnabled();
+
+   private final PortalURL                     url;
+   private final PublicRenderParameterMapper   prpMapper;
+   private final PortletParameterFactory       parmFactory;
+
+   private final TYPE                          type;
+   private final String                        window;
+   private PortletMode                         portletMode;
+   private WindowState                         windowState;
+   private String                              cacheLevel = ResourceURL.PAGE;                            // default
+   private String                              resourceID;
+   private Map<String, String[]>               renderParameters;
+   private Map<String, List<String>>           properties;
+
+   private final Set<PortalURLPublicParameter> prpSet     = new HashSet<PortalURLPublicParameter>();
+
+   public PortletURLProviderImpl(PortalURL url, TYPE type,
+         PortletWindow portletWindow) {
+      this.url = url.clone();
+      this.type = type;
+      this.window = portletWindow.getId().getStringId();
+
+      parmFactory = url.getPortletParameterFactory();
+      prpMapper = url.getPublicRenderParameterMapper();
+
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder("Constructed PortalURLProviderImpl. ");
+         txt.append("type=").append(type);
+         txt.append(", URL type=").append(url.getType());
+         txt.append(", target=").append(url.getTargetWindow());
+         LOGGER.debug(txt.toString());
+      }
+   }
+   
+   public String logSomething() {
+      LOGGER.debug("Here is a debug message from " + this.getClass().getCanonicalName());
+      LOGGER.warn("Here is a message from " + this.getClass().getCanonicalName());
+      LOGGER.error("Here is a 'debug' !string, how is that?");
+      StringBuilder txt = new StringBuilder();
+      txt.append("Info about logger. isDebug=").append(isDebug);
+      txt.append(", Name=").append(LOGGER.getName());
+      txt.append(", Root Logger Name=").append(LOGGER.ROOT_LOGGER_NAME);
+      return txt.toString();
+   }
+
+   /**
+    * Returns <code>true</code> if given parameter name is a public render
+    * parameter
+    * 
+    * @param name
+    */
+   private boolean isPRP(String name) {
+      boolean found = false;
+      for (PortalURLPublicParameter prp : prpSet) {
+         if (name.equals(prp.getName())) {
+            found = true;
+            break;
+         }
+      }
+      return found;
+   }
+
+   public PortalURL apply() {
+
+      url.setTargetWindow(window);
+      switch (type) {
+      case ACTION:
+         url.setType(URLType.Action);
+         break;
+      case RESOURCE:
+         url.setType(URLType.Resource);
+         url.clearResourceParameters(window);
+         url.setCacheability(ResourceURL.PAGE);
+         break;
+      default:
+         url.setType(URLType.Render);
+         url.clearParameters(window);
+      }
+
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder("apply URL values: ");
+         txt.append("type=").append(type);
+         txt.append(", URL type=").append(url.getType());
+         txt.append(", target=").append(url.getTargetWindow());
+         LOGGER.debug(txt.toString());
+      }
+      if (renderParameters != null) {
+         for (Map.Entry<String, String[]> entry : renderParameters.entrySet()) {
+            if (!isPRP(entry.getKey())) {
+               url.addParameter(new PortalURLParameter(window, entry.getKey(),
+                     entry.getValue()));
             }
-        }
-        for (PortalURLPublicParameter prp : prpSet) {
-           url.addPublicRenderParameter(prp);
-        }
-        url.setResourceID(resourceID);
-        url.setCacheability(cacheLevel);
-        return url;
-    }
-    
-    public TYPE getType()
-    {
-        return type;
-    }
-    
-    public void setPortletMode(PortletMode mode)
-    {
-        this.portletMode = mode;
-    }
-    
-    public PortletMode getPortletMode()
-    {
-        return portletMode;
-    }
-
-    public void setWindowState(WindowState state)
-    {
-        this.windowState = state;
-    }
-
-    public WindowState getWindowState()
-    {
-        return windowState;
-    }
-
-    public void setSecure(boolean secure) throws PortletSecurityException {
-        // ignore: not supported
-    }
-    
-    public boolean isSecure()
-    {
-        return false;
-    }
-    
-    public Map<String,String[]> getRenderParameters()
-    {
-        if (renderParameters == null)
-        {
-            renderParameters = new HashMap<String,String[]>();
-        }
-        return renderParameters;
-    }
-    
-    public String getCacheability()
-    {
-        return cacheLevel;
-    }
-
-    public void setCacheability(String cacheLevel)
-    {
-        this.cacheLevel = cacheLevel;
-    }
-
-    public String getResourceID()
-    {
-        return resourceID;
-    }
-
-    public void setResourceID(String resourceID)
-    {
-        this.resourceID = resourceID;
-    }
-    
-    public String toURL()
-    {
-        return toURL(false);
-    }
-
-    public String toURL(boolean absolute)
-    {
-        return apply().toURL(absolute);
-    }
-
-    public void write(Writer out, boolean escapeXML) throws IOException
-    {
-        String result = apply().toURL(false);
-        if (escapeXML)
-        {
-            result = result.replaceAll("&", "&amp;");
-            result = result.replaceAll("<", "&lt;");
-            result = result.replaceAll(">", "&gt;");
-            result = result.replaceAll("\'", "&#039;");
-            result = result.replaceAll("\"", "&#034;");
-        }
-        out.write(result);
-    }
-
-    public Map<String, List<String>> getProperties()
-    {
-        if (properties == null)
-        {
-            properties = new HashMap<String, List<String>>();
-        }
-        return properties;
-    }
-
-   /* (non-Javadoc)
-    * @see org.apache.pluto.container.PortletURLProvider#addPublicRenderParameter(javax.xml.namespace.QName, java.lang.String, java.lang.String[])
+         }
+      }
+      for (PortalURLPublicParameter prp : prpSet) {
+         url.addPublicRenderParameter(prp);
+      }
+      return url;
+   }
+
+   public TYPE getType() {
+      return type;
+   }
+
+   public void setPortletMode(PortletMode mode) {
+      url.setPortletMode(window, mode);
+   }
+
+   public PortletMode getPortletMode() {
+      return url.getPortletMode(window);
+   }
+
+   public void setWindowState(WindowState state) {
+      url.setWindowState(window, state);
+   }
+
+   public WindowState getWindowState() {
+      return url.getWindowState(window);
+   }
+
+   public void setSecure(boolean secure) throws PortletSecurityException {
+      // ignore: not supported
+   }
+
+   public boolean isSecure() {
+      return false;
+   }
+
+   public Map<String, String[]> getRenderParameters() {
+      if (renderParameters == null) {
+         renderParameters = new HashMap<String, String[]>();
+      }
+      return renderParameters;
+   }
+
+   public String getCacheability() {
+      return url.getCacheability();
+   }
+
+   public void setCacheability(String cacheLevel) {
+      url.setCacheability(cacheLevel);
+   }
+
+   public String getResourceID() {
+      return url.getResourceID();
+   }
+
+   public void setResourceID(String resourceID) {
+      url.setCacheability(resourceID);
+   }
+
+   public String toURL() {
+      return toURL(false);
+   }
+
+   public String toURL(boolean absolute) {
+      return apply().toURL(absolute);
+   }
+
+   public void write(Writer out, boolean escapeXML) throws IOException {
+      String result = apply().toURL(false);
+      if (escapeXML) {
+         result = result.replaceAll("&", "&amp;");
+         result = result.replaceAll("<", "&lt;");
+         result = result.replaceAll(">", "&gt;");
+         result = result.replaceAll("\'", "&#039;");
+         result = result.replaceAll("\"", "&#034;");
+      }
+      out.write(result);
+   }
+
+   public Map<String, List<String>> getProperties() {
+      if (properties == null) {
+         properties = new HashMap<String, List<String>>();
+      }
+      return properties;
+   }
+
+   /*
+    * (non-Javadoc)
+    * 
+    * @see
+    * org.apache.pluto.container.PortletURLProvider#addPublicRenderParameter
+    * (javax.xml.namespace.QName, java.lang.String, java.lang.String[])
     */
-   public void addPublicRenderParameter(QName qn, String identifier, String[] values) 
-   {
+   public void addPublicRenderParameter(QName qn, String identifier,
+         String[] values) {
       if (isDebug) {
          StringBuilder txt = new StringBuilder("Add PRP. QName = ");
-         txt.append(qn.toString())
-         .append(", ID = ").append(identifier)
-         .append(", values = ").append(Arrays.toString(values));
+         txt.append(qn.toString()).append(", ID = ").append(identifier)
+               .append(", values = ").append(Arrays.toString(values));
          LOGGER.debug(txt.toString());
       }
-      PortalURLPublicParameter pupp = new PortalURLPublicParameter(window, identifier, qn, values);
+      PortalURLPublicParameter pupp = new PortalURLPublicParameter(window,
+            identifier, qn, values);
       prpSet.add(pupp);
    }
 
-   /* (non-Javadoc)
-    * @see org.apache.pluto.container.PortletURLProvider#removePublicRenderParameter(javax.xml.namespace.QName)
+   /*
+    * (non-Javadoc)
+    * 
+    * @see
+    * org.apache.pluto.container.PortletURLProvider#removePublicRenderParameter
+    * (javax.xml.namespace.QName)
     */
-   public void removePublicRenderParameter(QName qn, String identifier) 
-   {
+   public void removePublicRenderParameter(QName qn, String identifier) {
       if (isDebug) {
          LOGGER.debug("Remove PRP. QName = " + qn.toString());
       }
-      PortalURLPublicParameter pupp = new PortalURLPublicParameter(window, identifier, qn);
+      PortalURLPublicParameter pupp = new PortalURLPublicParameter(window,
+            identifier, qn);
       pupp.setRemoved(true);
       prpSet.add(pupp);
    }
 
+   public void addPublicRenderParameter(String windowId, String name,
+         String[] values) {
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder("Add PRP. Window: ");
+         txt.append(windowId).append(", name: ").append(name)
+               .append(", values = ").append(Arrays.toString(values));
+         LOGGER.debug(txt.toString());
+      }
+      int index = prpMapper.getIndex(windowId, name);
+      if (index >= 0) {
+         prpMapper.setValues(index, values);
+      } else {
+         StringBuilder txt = new StringBuilder(
+               "Public render parameter for window: ");
+         txt.append(windowId).append(", name: ").append(name)
+               .append(" not found in mapper");
+         LOGGER.warn(txt.toString());
+      }
+   }
+
+   public void removePublicRenderParameter(String windowId, String name) {
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder("Remove PRP. Window: ");
+         txt.append(windowId).append(", name: ").append(name);
+         LOGGER.debug(txt.toString());
+      }
+      int index = prpMapper.getIndex(windowId, name);
+      if (index >= 0) {
+         prpMapper.setRemoved(index, true);
+      } else {
+         StringBuilder txt = new StringBuilder(
+               "Public render parameter for window: ");
+         txt.append(windowId).append(", name: ").append(name)
+               .append(" not found in mapper");
+         LOGGER.warn(txt.toString());
+      }
+   }
+
+   public boolean isPublicRenderParameter(String windowId, String name) {
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder(
+               "isPublicRenderParameter Window: ");
+         txt.append(windowId).append(", name: ").append(name);
+         LOGGER.debug(txt.toString());
+      }
+      int index = prpMapper.getIndex(windowId, name);
+      return (index >= 0);
+   }
+
    /**
-    * Clear public render parameters except those marked for removal 
+    * Clear public render parameters except those marked for removal
     */
    public void clearPublicRenderParameters() {
       for (PortalURLPublicParameter prp : prpSet) {
@@ -264,4 +323,24 @@ public class PortletURLProviderImpl implements PortletURLProvider
          }
       }
    }
+
+   public Set<String> getParameterNames(String windowId) {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public String[] getParameterValues(String windowId, String name) {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public void setParameter(String windowId, String name, String[] values) {
+      // TODO Auto-generated method stub
+
+   }
+
+   public void removeParameter(String windowId, String name) {
+      // TODO Auto-generated method stub
+
+   }
 }


[03/22] portals-pluto git commit: Worked on preparing parameters / URL for Action & Resource parameters

Posted by ms...@apache.org.
Worked on preparing parameters / URL for Action & Resource parameters


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/bc54af37
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/bc54af37
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/bc54af37

Branch: refs/heads/V3Prototype
Commit: bc54af376f9131e99ec8cb704fa5eb9a1925d9ec
Parents: f4fab01
Author: Scott Nicklous <ms...@apache.org>
Authored: Wed Feb 4 17:10:40 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Wed Feb 4 17:10:40 2015 +0100

----------------------------------------------------------------------
 .../driver/url/impl/PortalURLParserImpl.java    |  30 ++-
 .../driver/url/impl/RelativePortalURLImpl.java  |  22 --
 .../org/apache/pluto/driver/url/PortalURL.java  |   4 -
 .../pluto/driver/url/PortalURLParameter.java    | 237 ++++++++++++-------
 .../driver/url/PortalURLPublicParameter.java    |   3 +
 5 files changed, 175 insertions(+), 121 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/bc54af37/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
index d42828e..7643acb 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
@@ -71,8 +71,10 @@ public class PortalURLParserImpl implements PortalURLParser {
    private static final String PORTLET_MODE = "pm";
    private static final String VALUE_DELIM = "0x0";
 
-   private static final String AJAX_ACTION = "aa";      // new for portlet spec 3
-   private static final String PARTIAL_ACTION = "pa";   // new for portlet spec 3
+   private static final String AJAX_ACTION = "aa";       // new for portlet spec 3
+   private static final String PARTIAL_ACTION = "pa";    // new for portlet spec 3
+   private static final String ACTION_PARAM = "av";      // new for portlet spec 3
+   private static final String RESOURCE_PARAM = "rv";    // new for portlet spec 3
 
 
    //This is a list of characters that need to be encoded  to be protected
@@ -326,13 +328,26 @@ public class PortalURLParserImpl implements PortalURLParser {
                LOG.debug(dbgstr.toString());
             }
 
-
             // Portal URL parameter: portalURL.addParameter().
             if(type.equals(RENDER_PARAM)) {
                portalURL.addParameter(new PortalURLParameter(pid, paramName, paramValues));
                continue;
             }
 
+            // Portal URL parameter: portalURL.addParameter().
+            if(type.equals(ACTION_PARAM)) {
+               portalURL.addParameter(new PortalURLParameter(pid, paramName, paramValues, 
+                     PortalURLParameter.PARAM_TYPE_ACTION));
+               continue;
+            }
+
+            // Portal URL parameter: portalURL.addParameter().
+            if(type.equals(RESOURCE_PARAM)) {
+               portalURL.addParameter(new PortalURLParameter(pid, paramName, paramValues,
+                     PortalURLParameter.PARAM_TYPE_RESOURCE));
+               continue;
+            }
+
             //set private (Resource) parameter in portalURL
             if (type.equals(PRIVATE_RENDER_PARAM)){
                portalURL.getPrivateRenderParameters().put(paramName, paramValues);
@@ -486,7 +501,14 @@ public class PortalURLParserImpl implements PortalURLParser {
                && param.getValues().length > 0) {
             String valueString = encodeMultiValues(param.getValues());
             if (valueString.length() > 0) {
-               buffer.append("/").append(PREFIX).append(RENDER_PARAM)
+               String ptype = RENDER_PARAM;
+               if (param.getType().equals(PortalURLParameter.PARAM_TYPE_ACTION)) {
+                  ptype = ACTION_PARAM;
+               } else 
+                  if (param.getType().equals(PortalURLParameter.PARAM_TYPE_RESOURCE)) {
+                  ptype = RESOURCE_PARAM;
+               }
+              buffer.append("/").append(PREFIX).append(ptype)
                .append(String.valueOf(index)).append(DELIM).append(encodeCharacters(param.getName()))
                .append(VALUE_DELIM).append(valueString);
             }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/bc54af37/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
index 172f924..4c7c7d3 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
@@ -291,28 +291,6 @@ public class RelativePortalURLImpl implements PortalURL {
       portalURL.v3Map = new HashMap<String, Boolean>(v3Map);
       return portalURL;
    }
-   //JSR-286 methods
-
-   public void addPublicParameterCurrent(String name, String[] values){
-      for (int ii = 0; ii < prpMapper.getNumberOfGroups(); ii++) {
-         List<PortalURLPublicParameter> prps = prpMapper.getPublicParameterGroup(ii);
-         if (prps.get(0).getName().equals(name)) {
-            prpMapper.setValues(ii, values);
-         }
-      }
-   }
-
-   public Map<String, String[]> getPublicParameters() {
-      Map<String,String[]> tmp = new HashMap<String, String[]>();
-      if (prpMapper != null) {
-         for (int ind : prpMapper.getActiveIndexes()) {
-            String name = prpMapper.getPublicParameterGroup(ind).get(0).getName();
-            String[] vals = prpMapper.getValues(ind);
-            tmp.put(name, vals);
-         }
-      }
-      return tmp;
-   }
 
    public Map<String, String[]> getPrivateRenderParameters()
    {

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/bc54af37/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
index 3463cc1..37fafa6 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
@@ -95,10 +95,6 @@ public interface PortalURL extends Cloneable {
     public boolean isVersion3(String portletId);
 
     Collection<PortalURLParameter> getParameters();
-
-    public void addPublicParameterCurrent(String name, String[] values);
-
-    public Map<String, String[]> getPublicParameters();
     
     Map<String, String[]> getPrivateRenderParameters();
     

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/bc54af37/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLParameter.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLParameter.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLParameter.java
index af59c2e..e988478 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLParameter.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLParameter.java
@@ -16,6 +16,11 @@
  */
 package org.apache.pluto.driver.url;
 
+import java.util.HashSet;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * The portal URL parameter.
  * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
@@ -24,99 +29,149 @@ package org.apache.pluto.driver.url;
  * @since Sep 30, 2004
  */
 public class PortalURLParameter {
+   private final Logger LOGGER = LoggerFactory.getLogger(PortalURLParameter.class);
+
+   public final static String PARAM_TYPE_RENDER = "rp";
+   public final static String PARAM_TYPE_ACTION = "ap";
+   public final static String PARAM_TYPE_RESOURCE = "re";
+   public final static String PARAM_TYPE_PUBLIC = "sp";
+   
+   private final static HashSet<String> allowedTypes = new HashSet<String>();
+   {
+      allowedTypes.add(PARAM_TYPE_RENDER);
+      allowedTypes.add(PARAM_TYPE_ACTION);
+      allowedTypes.add(PARAM_TYPE_RESOURCE);
+   }
+
+   protected final String window;
+   protected final String name;
+   protected String[] values;
+   protected String type;
+
+   // Constructor for use by extending classes
+   protected PortalURLParameter(String window, String name) {
+      this.window = window;
+      this.name = name;
+      this.values = null;
+   }
+
+   // Create a new render parameter
+   public PortalURLParameter(String window, String name, String value) {
+      this.window = window;
+      this.name = name;
+      this.values = new String[]{value};
+      this.type = PARAM_TYPE_RENDER;
+   }
+
+   // Create a new parameter of specified type
+   public PortalURLParameter(String window, String name, String[] values) {
+      this.window = window;
+      this.name = name;
+      this.values = values;
+      this.type = PARAM_TYPE_RENDER;
+   }
+
+   // Create a new parameter of specified type
+   public PortalURLParameter(String window, String name, String value, String type) {
+      this.window = window;
+      this.name = name;
+      this.values = new String[]{value};
+      this.type = type;
+      if (!allowedTypes.contains(type)) {
+         LOGGER.warn("Parameter type: " + type + " is not in allowed set: " + allowedTypes.toString());
+      }
+   }
+
+   public PortalURLParameter(String window, String name, String[] values, String type) {
+      this.window = window;
+      this.name = name;
+      this.values = values;
+      this.type = type;
+      if (!allowedTypes.contains(type)) {
+         LOGGER.warn("Parameter type: " + type + " is not in allowed set: " + allowedTypes.toString());
+      }
+   }
+
+   public String getType() {
+      return type;
+   }
+
+   public void setType(String type) {
+      if (!allowedTypes.contains(type)) {
+         LOGGER.warn("Parameter type: " + type + " is not in allowed set: " + allowedTypes.toString());
+      }
+      this.type = type;
+   }
+   
+   public String getName() {
+      return name;
+   }
+
+   public String[] getValues() {
+      return values;
+   }
+
+   public void setValues(String[] values) {
+      this.values = values;
+   }
+
+   public String getWindowId() {
+      return window;
+   }
+
+   @Override
+   public PortalURLParameter clone() {
+      // shallow clone works because strings are immutable
+      return new PortalURLParameter(window, name, (values == null ? values : values.clone()));
+   }
+
+   /**
+    * For this class, "equals" means "refers to the same parameter". The parameter name & window
+    * are compared, the values are NOT compared. The combination of window ID and parameter name 
+    * must always be unique when the objects are used in collections. 
+    */
+   @Override
+   public boolean equals(Object o) {
+      boolean eq = false;
+      if (o instanceof PortalURLParameter) {
+         if (o == this) {
+            eq = true; 
+         } else {
+            PortalURLParameter pup = (PortalURLParameter) o;
+            if (equals(window, pup.window)) {
+               if (equals(name, pup.name)) {
+                  eq = true;
+               }
+            }
+         }
+      }
+      return eq;
+   }
 
+   @Override
+   public int hashCode() {
+      int hc = 17;
+      if (window != null) {
+         hc += 37*hc + window.hashCode();
+      }
+      if (name != null) {
+         hc += 37*hc + name.hashCode();
+      }
+      return hc;
+   }
 
-    protected final String window;
-    protected final String name;
-    protected String[] values;
-
-    public PortalURLParameter(String window, String name) {
-        this.window = window;
-        this.name = name;
-        this.values = null;
-    }
-
-    public PortalURLParameter(String window, String name, String value) {
-        this.window = window;
-        this.name = name;
-        this.values = new String[]{value};
-    }
-
-    public PortalURLParameter(String window, String name, String[] values) {
-        this.window = window;
-        this.name = name;
-        this.values = values;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public String[] getValues() {
-        return values;
-    }
-
-    public void setValues(String[] values) {
-        this.values = values;
-    }
-
-    public String getWindowId() {
-        return window;
-    }
-    
-    @Override
-    public PortalURLParameter clone() {
-       // shallow clone works because strings are immutable
-       return new PortalURLParameter(window, name, (values == null ? values : values.clone()));
-    }
-    
-    /**
-     * For this class, "equals" means "refers to the same parameter". The parameter name & window
-     * are compared, the values are NOT compared. The combination of window ID and parameter name 
-     * must always be unique when the objects are used in collections. 
-     */
-    @Override
-    public boolean equals(Object o) {
-       boolean eq = false;
-       if (o instanceof PortalURLParameter) {
-          if (o == this) {
-             eq = true; 
-          } else {
-             PortalURLParameter pup = (PortalURLParameter) o;
-             if (equals(window, pup.window)) {
-                if (equals(name, pup.name)) {
-                   eq = true;
-                }
-             }
-          }
-       }
-       return eq;
-    }
-    
-    @Override
-    public int hashCode() {
-       int hc = 17;
-       if (window != null) {
-          hc += 37*hc + window.hashCode();
-       }
-       if (name != null) {
-          hc += 37*hc + name.hashCode();
-       }
-       return hc;
-    }
-    
-    /**
-     * helper function for comparison. 
-     */
-    protected boolean equals(Object o1, Object o2) {
-       boolean eq = false;
-       if (o1 == o2) {
-          eq = true;
-       } else if (o1 != null && o2 != null) {
-          eq = o1.equals(o2);
-       }
-       return eq;
-    }
+   /**
+    * helper function for comparison. 
+    */
+   protected boolean equals(Object o1, Object o2) {
+      boolean eq = false;
+      if (o1 == o2) {
+         eq = true;
+      } else if (o1 != null && o2 != null) {
+         eq = o1.equals(o2);
+      }
+      return eq;
+   }
 
 }
 

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/bc54af37/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLPublicParameter.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLPublicParameter.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLPublicParameter.java
index a62eea3..e360264 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLPublicParameter.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLPublicParameter.java
@@ -50,6 +50,7 @@ public class PortalURLPublicParameter extends PortalURLParameter {
    public PortalURLPublicParameter(String window, String name, QName qname) {
       super(window, name);
       this.qname = qname;
+      this.type = PARAM_TYPE_PUBLIC;
    }
 
    /**
@@ -63,6 +64,7 @@ public class PortalURLPublicParameter extends PortalURLParameter {
       super(window, name, value);
       this.qname = qname;
       removed = false;
+      this.type = PARAM_TYPE_PUBLIC;
    }
 
    /**
@@ -76,6 +78,7 @@ public class PortalURLPublicParameter extends PortalURLParameter {
       super(window, name, values);
       this.qname = qname;
       removed = false;
+      this.type = PARAM_TYPE_PUBLIC;
    }
    
    /**


[18/22] portals-pluto git commit: Some repairs and clean up in the URL parser

Posted by ms...@apache.org.
Some repairs and clean up in the URL parser


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/58b0e19b
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/58b0e19b
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/58b0e19b

Branch: refs/heads/V3Prototype
Commit: 58b0e19bf4dfa368081ee75828e249ad58b0ac9a
Parents: 0b758a1
Author: Scott Nicklous <ms...@apache.org>
Authored: Fri Feb 13 12:18:48 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Fri Feb 13 12:18:48 2015 +0100

----------------------------------------------------------------------
 .../driver/url/impl/PortalURLParserImpl.java    | 128 +++++++++----------
 1 file changed, 61 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/58b0e19b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
index b7bef1d..9733be8 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
@@ -49,6 +49,7 @@ public class PortalURLParserImpl implements PortalURLParser {
 
    /** Logger. */
    private static final Logger LOG = LoggerFactory.getLogger(PortalURLParserImpl.class);
+   boolean isDebug = LOG.isDebugEnabled();
 
    /** The singleton parser instance. */
    private static final PortalURLParser PARSER = new PortalURLParserImpl();
@@ -71,7 +72,9 @@ public class PortalURLParserImpl implements PortalURLParser {
    // See RFC 3986 & URLEncoder documentation.
    private static final String VALUE_DELIM = ":";
    private static final String VALUE_NULL = ",";
+   private static final String VALUE_ARRAY_EMPTY = "@";
    private static final String DELIM = ";";
+   private static final String TOKEN_DELIM = "/";
 
    private static final String ACTION = "ac";
    private static final String RESOURCE = "rs";
@@ -83,23 +86,6 @@ public class PortalURLParserImpl implements PortalURLParser {
    private static final String RESOURCE_PARAM = "rv";    // new for portlet spec 3
 
 
-//    //This is a list of characters that need to be encoded  to be protected
-//    //The ? is necessary to protect URI's with a query portion that is being passed as a parameter
-//    private static final String[][] ENCODINGS = new String[][] {
-//       new String[] { "_",  "0x1" },
-//       new String[] { ".",  "0x2" },
-//       new String[] { "/",  "0x3" },
-//       new String[] { "\r", "0x4" },
-//       new String[] { "\n", "0x5" },
-//       new String[] { "<",  "0x6" },
-//       new String[] { ">",  "0x7" },
-//       new String[] { " ",  "0x8" },
-//       new String[] { "#",  "0x9" },
-//       new String[] { "?",  "0xa" },
-//       new String[] { "\\", "0xb" },
-//       new String[] { "%",  "0xc" },
-//    };
-
    // Constructor -------------------------------------------------------------
 
    /**
@@ -131,7 +117,7 @@ public class PortalURLParserImpl implements PortalURLParser {
       String contextPath = request.getContextPath();
       String servletName = request.getServletPath();
 
-      if (LOG.isDebugEnabled()) {
+      if (isDebug) {
          LOG.debug("Parsing. Context Path: " + contextPath + ", Servlet Name: " + servletName + ", Request URI: " + reqURI);
       }
 
@@ -148,22 +134,20 @@ public class PortalURLParserImpl implements PortalURLParser {
             pathInfo = servletName.substring(idx);
             servletName = servletName.substring(0, idx);
             portalURL = new RelativePortalURLImpl(urlBase, contextPath, servletName, this, request);
-            if (LOG.isDebugEnabled()) {
+            if (isDebug) {
                LOG.debug("Constructed new URL due to JSP processing. pathInfo: " + pathInfo);
             }
          }
       }
       
       // we want to work with the untranslated path info, so extract it from the URI.
-      // chop off query string and fragment identifier.
+      // chop off query string.
       String prefix = contextPath + servletName;
       int qi = reqURI.indexOf("?");
-      int hi = reqURI.indexOf("#");
-      int last = (qi > 0 && hi > 0) ? Math.min(qi, hi) : Math.max(qi, hi);
-      last = (last < 0) ? reqURI.length() : last;
-      pathInfo = reqURI.substring(prefix.length(), last);
+      qi = (qi < 0) ? reqURI.length() : qi;
+      pathInfo = reqURI.substring(prefix.length(), qi);
 
-      if (LOG.isDebugEnabled()) {
+      if (isDebug) {
          LOG.debug("Parsing request pathInfo: " + pathInfo);
       }
 
@@ -173,7 +157,7 @@ public class PortalURLParserImpl implements PortalURLParser {
          renderPath.append('/');
       }
 
-      int ind = pathInfo.indexOf("/" + PREFIX);
+      int ind = pathInfo.indexOf(TOKEN_DELIM + PREFIX);
       if (ind < 0) {
          // there are no parameters to process
          renderPath.append(urlDecode(pathInfo));
@@ -185,7 +169,7 @@ public class PortalURLParserImpl implements PortalURLParser {
       }
 
       portalURL.setRenderPath(renderPath.toString());
-      if (LOG.isDebugEnabled()) {
+      if (isDebug) {
          LOG.debug("Parse: renderPath: " + renderPath.toString() + ",  pathInfo: " + pathInfo);
       }
 
@@ -204,7 +188,7 @@ public class PortalURLParserImpl implements PortalURLParser {
       // Extract the version info for the portlets on the page and store in URL
       
       StringBuilder vstr = new StringBuilder();
-      if (LOG.isDebugEnabled()) {
+      if (isDebug) {
          vstr.append("Portlet Versions: ");
       }
       for (String pid : pids) {
@@ -212,21 +196,21 @@ public class PortalURLParserImpl implements PortalURLParser {
          try {
             String pv = dc.getPortletRegistryService().getPortletApplication(appName).getVersion();
             portalURL.setVersion(pid, pv);
-            if (LOG.isDebugEnabled()) {
+            if (isDebug) {
                vstr.append(pid).append(" = ").append(pv).append(", ");
             }
          } catch (Exception e) {
             LOG.error("Portlet application definition could not be retrieved for " + appName);
          }
       }
-      if (LOG.isDebugEnabled()) {
+      if (isDebug) {
          LOG.debug(vstr.toString());
       }
 
       // Tokenize the rest and process the tokens
       ArrayList<String> portletIds = new ArrayList<String>();
       if (pathInfo.length() > 2) {
-         String[] tokens = pathInfo.split("/" + PREFIX);
+         String[] tokens = pathInfo.split(TOKEN_DELIM + PREFIX);
          for (String t : tokens) {
 
             // vals contains the component values of the token after the type
@@ -324,7 +308,7 @@ public class PortalURLParserImpl implements PortalURLParser {
             // The remaining types deal with parameters, so extract the
             // parameter name and values.
             StringBuilder dbgstr = new StringBuilder();
-            if (LOG.isDebugEnabled()) {
+            if (isDebug) {
                dbgstr.append("Decoding parameter: window ID=").append(pid)
                      .append(", name/value=").append(vals[1]);
             }
@@ -338,10 +322,14 @@ public class PortalURLParserImpl implements PortalURLParser {
                }
             }
 
-            String[] pVals = values.split(VALUE_DELIM);
+            String[] pVals = values.split(VALUE_DELIM, -1);
             String[] paramValues = new String[0];
             String paramName = "";
+            boolean isEmptyArray = false;
             if (pVals.length > 1) {
+               if (pVals.length == 2 && pVals[1].equals(VALUE_ARRAY_EMPTY)) {
+                  isEmptyArray = true;
+               }
                for (int i = 0; i < pVals.length; i++){
                   if (pVals[i].equals(VALUE_NULL)) {
                      pVals[i] = null;
@@ -351,15 +339,20 @@ public class PortalURLParserImpl implements PortalURLParser {
                }
             }
             
-            if (pVals.length <= 1 || pVals[0] == null) {
+            if (pVals.length == 0 || pVals[0] == null) {
                LOG.warn("Bad parameter token: " + values);
             } else {
                paramName = pVals[0];
-               paramValues = Arrays.copyOfRange(pVals, 1, pVals.length);
+               if (isEmptyArray) {
+                  paramValues = new String[0];
+               } else {
+                  paramValues = Arrays.copyOfRange(pVals, 1, pVals.length);
+               }
             }
             
-            if (LOG.isDebugEnabled()) {
+            if (isDebug) {
                dbgstr.append(", paramName=").append(paramName);
+               dbgstr.append(", Values length=").append(paramValues.length);
                dbgstr.append(", paramValues=").append(Arrays.toString(paramValues));
                LOG.debug(dbgstr.toString());
             }
@@ -406,7 +399,7 @@ public class PortalURLParserImpl implements PortalURLParser {
          portalURL.handleServletRequestParams();
       }
       
-      if (LOG.isDebugEnabled()) {
+      if (isDebug) {
          LOG.debug("Found " + portletIds.size() + " IDs: " + Arrays.toString(portletIds.toArray()));
       }
 
@@ -429,7 +422,7 @@ public class PortalURLParserImpl implements PortalURLParser {
       portalURL.handleServletRequestParams();
 
       // Append the server URI and the servlet path.
-      buffer.append(portalURL.getServletPath().startsWith("/")?"":"/")
+      buffer.append(portalURL.getServletPath().startsWith(TOKEN_DELIM)?"":TOKEN_DELIM)
       .append(portalURL.getServletPath());
 
       // Start the pathInfo with the path to the render URL (page).
@@ -441,7 +434,7 @@ public class PortalURLParserImpl implements PortalURLParser {
       ArrayList<String> pids = new ArrayList<String>();
       for (String pid : portalURL.getPortletIds()) {
          pids.add(pid);
-         buffer.append("/").append(PREFIX).append(PORTLET_ID);
+         buffer.append(TOKEN_DELIM).append(PREFIX).append(PORTLET_ID);
          try {
             buffer.append(URLEncoder.encode(pid, "UTF-8"));
          } catch(Exception e) {
@@ -461,7 +454,7 @@ public class PortalURLParserImpl implements PortalURLParser {
                .append(Arrays.toString(pids.toArray()));
             LOG.warn(txt.toString());
          } else {
-            buffer.append("/");
+            buffer.append(TOKEN_DELIM);
             buffer.append(PREFIX).append(RESOURCE).append(String.valueOf(index));
          }
       }
@@ -477,7 +470,7 @@ public class PortalURLParserImpl implements PortalURLParser {
                .append(Arrays.toString(pids.toArray()));
             LOG.warn(txt.toString());
          } else {
-            buffer.append("/");
+            buffer.append(TOKEN_DELIM);
             buffer.append(PREFIX).append(RENDER).append(String.valueOf(index));
          }
       }
@@ -493,7 +486,7 @@ public class PortalURLParserImpl implements PortalURLParser {
                .append(Arrays.toString(pids.toArray()));
             LOG.warn(txt.toString());
          } else {
-            buffer.append("/");
+            buffer.append(TOKEN_DELIM);
             buffer.append(PREFIX).append(ACTION).append(String.valueOf(index));
          }
       }
@@ -501,12 +494,12 @@ public class PortalURLParserImpl implements PortalURLParser {
       String reswin = null;
       if (portalURL.getType() == URLType.Resource) {
          if (portalURL.getCacheability() != null) {
-            buffer.append("/");
+            buffer.append(TOKEN_DELIM);
             buffer.append(PREFIX).append(CACHE_LEVEL)
                   .append(urlEncode(portalURL.getCacheability()));
          }
          if (portalURL.getResourceID() != null) {
-            buffer.append("/");
+            buffer.append(TOKEN_DELIM);
             buffer.append(PREFIX).append(RESOURCE_ID)
                   .append(urlEncode(portalURL.getResourceID()));
          }
@@ -538,7 +531,7 @@ public class PortalURLParserImpl implements PortalURLParser {
                .append(", Portlet IDs in map: ").append(Arrays.toString(pids.toArray()));
             LOG.warn(txt.toString());
          } else {
-            buffer.append("/").append(PREFIX).append(PORTLET_MODE)
+            buffer.append(TOKEN_DELIM).append(PREFIX).append(PORTLET_MODE)
             .append(String.valueOf(index)).append(DELIM).append(urlEncode(pm.toString()));
          }
       }
@@ -559,7 +552,7 @@ public class PortalURLParserImpl implements PortalURLParser {
                .append(", Portlet IDs in map: ").append(Arrays.toString(pids.toArray()));
             LOG.warn(txt.toString());
          } else {
-            buffer.append("/").append(PREFIX).append(WINDOW_STATE)
+            buffer.append(TOKEN_DELIM).append(PREFIX).append(WINDOW_STATE)
             .append(String.valueOf(index)).append(DELIM).append(urlEncode(ws.toString()));
          }
       }
@@ -579,20 +572,17 @@ public class PortalURLParserImpl implements PortalURLParser {
          }
 
          // Encode render params as a part of the URL.
-         if (param.getName() != null && param.getValues() != null
-               && param.getValues().length > 0) {
+         if (param.getName() != null && param.getValues() != null) {
             String valueString = encodeMultiValues(param.getValues());
-            if (valueString.length() > 0) {
-               String ptype = RENDER_PARAM;
-               if (param.getType().equals(PortalURLParameter.PARAM_TYPE_ACTION)) {
-                  ptype = ACTION_PARAM;
-               } else if (param.getType().equals(PortalURLParameter.PARAM_TYPE_RESOURCE)) {
-                  ptype = RESOURCE_PARAM;
-               }
-               buffer.append("/").append(PREFIX).append(ptype)
-               .append(String.valueOf(index)).append(DELIM).append(urlEncode(param.getName()))
-               .append(VALUE_DELIM).append(valueString);
+            String ptype = RENDER_PARAM;
+            if (param.getType().equals(PortalURLParameter.PARAM_TYPE_ACTION)) {
+               ptype = ACTION_PARAM;
+            } else if (param.getType().equals(PortalURLParameter.PARAM_TYPE_RESOURCE)) {
+               ptype = RESOURCE_PARAM;
             }
+            buffer.append(TOKEN_DELIM).append(PREFIX).append(ptype)
+            .append(String.valueOf(index)).append(DELIM).append(urlEncode(param.getName()))
+            .append(VALUE_DELIM).append(valueString);
          }
       }
 
@@ -620,7 +610,7 @@ public class PortalURLParserImpl implements PortalURLParser {
             PortalURLPublicParameter prp = prplist.get(0);
             int index = pids.indexOf(prp.getWindowId());
             if (index >= 0) {
-               buffer.append("/").append(PREFIX).append(PUBLIC_RENDER_PARAM)
+               buffer.append(TOKEN_DELIM).append(PREFIX).append(PUBLIC_RENDER_PARAM)
                .append(String.valueOf(index)).append(DELIM)
                .append(String.valueOf(i)).append(DELIM)
                .append(urlEncode(prp.getName())).append(VALUE_DELIM)
@@ -680,14 +670,18 @@ public class PortalURLParserImpl implements PortalURLParser {
     */
    private String encodeMultiValues(String[] values) {
       StringBuilder buffer = new StringBuilder();
-      for (int i = 0; i < values.length; i++) {
-         if (values[i] == null) {
-            buffer.append(VALUE_NULL);
-         } else {
-            buffer.append(urlEncode(values[i]));
-         }
-         if (i + 1 < values.length) {
-            buffer.append(VALUE_DELIM);
+      if (values.length == 0) {
+         buffer.append(VALUE_ARRAY_EMPTY);
+      } else {
+         for (int i = 0; i < values.length; i++) {
+            if (values[i] == null) {
+               buffer.append(VALUE_NULL);
+            } else {
+               buffer.append(urlEncode(values[i]));
+            }
+            if (i + 1 < values.length) {
+               buffer.append(VALUE_DELIM);
+            }
          }
       }
       return buffer.toString();


[09/22] portals-pluto git commit: Some bug fixing in the parameer handling code.

Posted by ms...@apache.org.
Some bug fixing in the parameer handling code.


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/b28c3d6f
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/b28c3d6f
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/b28c3d6f

Branch: refs/heads/V3Prototype
Commit: b28c3d6fcf78fbe4f87a40025a92ed3e9b8d2d72
Parents: ee5b0bd
Author: Scott Nicklous <ms...@apache.org>
Authored: Mon Feb 9 16:38:45 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Mon Feb 9 16:38:45 2015 +0100

----------------------------------------------------------------------
 .../pluto/container/PortletRequestContext.java  | 130 ++++----
 .../container/PortletParameterFactory.java      | 192 -----------
 .../container/PortletRequestContextImpl.java    |   3 +-
 .../PortletStateAwareResponseContextImpl.java   |  16 +-
 .../container/PortletURLProviderImpl.java       |  29 +-
 .../driver/url/impl/PortalURLParserImpl.java    |  24 +-
 .../driver/url/impl/RelativePortalURLImpl.java  | 329 +++++++++++++------
 .../PublicRenderParameterQNameMapper.java       |  16 +-
 .../org/apache/pluto/driver/url/PortalURL.java  |  14 +
 .../pluto/driver/url/PortalURLParameter.java    |  23 +-
 .../driver/url/PortalURLPublicParameter.java    |  14 -
 .../driver/url/PortletParameterFactory.java     | 189 +++++++++++
 12 files changed, 560 insertions(+), 419 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b28c3d6f/pluto-container-api/src/main/java/org/apache/pluto/container/PortletRequestContext.java
----------------------------------------------------------------------
diff --git a/pluto-container-api/src/main/java/org/apache/pluto/container/PortletRequestContext.java b/pluto-container-api/src/main/java/org/apache/pluto/container/PortletRequestContext.java
index 8dd441f..8c6c781 100644
--- a/pluto-container-api/src/main/java/org/apache/pluto/container/PortletRequestContext.java
+++ b/pluto-container-api/src/main/java/org/apache/pluto/container/PortletRequestContext.java
@@ -1,65 +1,65 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pluto.container;
-
-import java.util.Enumeration;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.portlet.PortletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletRequest;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-
-/**
- * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
- * @version $Id$
- */
-public interface PortletRequestContext
-{
-    void init(PortletConfig portletConfig, ServletContext servletContext, HttpServletRequest servletRequest, HttpServletResponse servletResponse);
-    PortletContainer getContainer();
-    PortletConfig getPortletConfig();
-    ServletContext getServletContext();
-    HttpServletRequest getContainerRequest();
-    HttpServletResponse getContainerResponse();
-    HttpServletRequest getServletRequest();
-    HttpServletResponse getServletResponse();
-    PortletWindow getPortletWindow();
-    
-    Enumeration<String> getAttributeNames();
-    Object getAttribute(String name);
-    /**
-     * Get the attribute from the request. Generally only called by servlet code that has been dispatched
-     * to by a portlet (such as rendering a JSP).
-     * 
-     * @param name attribute name
-     * @param servletRequest The current servlet request
-     */
-    Object getAttribute(String name, ServletRequest servletRequest);
-    void setAttribute(String name, Object value);
-
-    Locale getPreferredLocale();
-    Cookie[] getCookies();
-    Map<String, String[]> getProperties();
-    
-    Map<String, String[]> getPrivateParameterMap();
-    Map<String, String[]> getPublicParameterMap();
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.container;
+
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.portlet.PortletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletRequest;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+
+/**
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id$
+ */
+public interface PortletRequestContext
+{
+    void init(PortletConfig portletConfig, ServletContext servletContext, HttpServletRequest servletRequest, HttpServletResponse servletResponse);
+    PortletContainer getContainer();
+    PortletConfig getPortletConfig();
+    ServletContext getServletContext();
+    HttpServletRequest getContainerRequest();
+    HttpServletResponse getContainerResponse();
+    HttpServletRequest getServletRequest();
+    HttpServletResponse getServletResponse();
+    PortletWindow getPortletWindow();
+    
+    Enumeration<String> getAttributeNames();
+    Object getAttribute(String name);
+    /**
+     * Get the attribute from the request. Generally only called by servlet code that has been dispatched
+     * to by a portlet (such as rendering a JSP).
+     * 
+     * @param name attribute name
+     * @param servletRequest The current servlet request
+     */
+    Object getAttribute(String name, ServletRequest servletRequest);
+    void setAttribute(String name, Object value);
+
+    Locale getPreferredLocale();
+    Cookie[] getCookies();
+    Map<String, String[]> getProperties();
+    
+    Map<String, String[]> getPrivateParameterMap();
+    Map<String, String[]> getPublicParameterMap();
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b28c3d6f/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletParameterFactory.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletParameterFactory.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletParameterFactory.java
deleted file mode 100644
index f163f93..0000000
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletParameterFactory.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.pluto.driver.services.container;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.pluto.driver.services.portal.PublicRenderParameterMapper;
-import org.apache.pluto.driver.url.PortalURL;
-import org.apache.pluto.driver.url.PortalURLParameter;
-import org.apache.pluto.driver.url.PortalURLPublicParameter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author Scott Nicklous
- * 
- * This class bridges between the URL parameter representation and the parameter
- * representation presented through the portlet API. It also bridges between the 
- * JSR 286 and the JSR 362 parameter handling APIs. 
- *
- */
-public class PortletParameterFactory {
-   private static final Logger LOGGER = LoggerFactory.getLogger(PortletParameterFactory.class);
-   private final static boolean isDebug = LOGGER.isDebugEnabled();
-   
-   PortalURL url;
-   
-   HashMap<String, ArrayList<PortalURLParameter>> wid2Render;
-   HashMap<String, ArrayList<PortalURLParameter>> wid2Action;
-   HashMap<String, ArrayList<PortalURLParameter>> wid2Resource;
-   
-   public PortletParameterFactory(PortalURL url) {
-      this.url = url;
-   }
-   
-   private void addParam(Map<String, ArrayList<PortalURLParameter>> map, PortalURLParameter parm) {
-      String wid = parm.getWindowId();
-      if (!map.keySet().contains(wid)) {
-         map.put(wid, new ArrayList<PortalURLParameter>());
-      }
-      map.get(wid).add(parm);
-   }
-   
-   /**
-    * process the URL parameters. Do this as late as possible so that 
-    * the servlet rquest parameters get handled properly.
-    */
-   private void processParams() {
-      wid2Render = new HashMap<String, ArrayList<PortalURLParameter>>();
-      wid2Action = new HashMap<String, ArrayList<PortalURLParameter>>();
-      wid2Resource = new HashMap<String, ArrayList<PortalURLParameter>>();
-      
-      //Make sure the servlet request parameters are processed
-      url.handleServletRequestParams();
-      
-      for (PortalURLParameter parm : url.getParameters()) {
-         if (parm.getType().equals(PortalURLParameter.PARAM_TYPE_ACTION)) {
-            addParam(wid2Action, parm);
-         } else if (parm.getType().equals(PortalURLParameter.PARAM_TYPE_RESOURCE)) {
-            addParam(wid2Resource, parm);
-         } else {
-            addParam(wid2Render, parm);
-         }
-      }
-
-   }
-
-   /**
-    * This V2.0 method returns the private parameters for the given window ID.
-    * In the case of a render URL, it returns only the private render parameters.
-    * 
-    * In the case of an action or resource URL, it returns the action or resource 
-    * parameters combined with the render parameters, with the action or resource
-    * parameters taking precedence.
-    * 
-    * Note that the  latter circumstance will only occur with V3.0 portlets.
-    *  
-    * @param windowId
-    * @return
-    */
-   public Map<String, String[]> getPrivateParameterMap(String windowId) {
-      HashMap<String, String[]> parameters = new HashMap<String, String[]>();
-      processParams();
-
-      // get the action or resource parameters
-      
-      if (wid2Action.containsKey(windowId)) {
-         for (PortalURLParameter parm : wid2Action.get(windowId)) {
-            parameters.put(parm.getName(), parm.getValues().clone());
-         }
-      } else if (wid2Resource.containsKey(windowId)) {
-         for (PortalURLParameter parm : wid2Resource.get(windowId)) {
-            parameters.put(parm.getName(), parm.getValues().clone());
-         }
-      }
-      
-      // Now merge in the render parameters
-      
-      if (wid2Render.containsKey(windowId)) {
-         for (PortalURLParameter parm : wid2Render.get(windowId)) {
-            if (parameters.containsKey(parm.getName())) {
-               ArrayList<String> vals = 
-                     new ArrayList<String>(Arrays.asList(parameters.get(parm.getName())));
-               vals.addAll(Arrays.asList(parm.getValues()));
-               parameters.put(parm.getName(), (String[])vals.toArray());
-            } else {
-               parameters.put(parm.getName(), parm.getValues().clone());
-            }
-         }
-      }
-
-      if (isDebug) {
-         StringBuffer sb = new StringBuffer();
-         sb.append("Dump private Parameter Map:");
-         for (String k : parameters.keySet()) {
-            sb.append("\nName: " + k + ", Values: ");
-            String sep = "";
-            for (String v : parameters.get(k)) {
-               sb.append(sep + v);
-               sep = ", ";
-            }
-         }
-         LOGGER.debug(sb.toString());
-      }
-      return parameters;
-   }
-   
-   /**
-    * Returns the active (= have been set) public render parameters for the
-    * given window ID.
-    *  
-    * @param windowId
-    * @return
-    */
-   public Map<String, String[]> getPublicParameterMap(String windowId) {
-      HashMap<String, String[]> parameters = new HashMap<String, String[]>();
-      
-      //Make sure the servlet request parameters are processed
-      url.handleServletRequestParams();
-
-      PublicRenderParameterMapper mapper = url.getPublicRenderParameterMapper();
-      
-      // get the active PRPs only
-      
-      List<PortalURLPublicParameter> prps = mapper.getPRPsForWindow(windowId, true);
-      for (PortalURLPublicParameter prp : prps) {
-         parameters.put(prp.getName(), prp.getValues().clone());
-      }
-      return parameters;
-   }
-
-   /**
-    * This is a V2 method to get the private render parameter map during
-    * a resource request.
-    * 
-    * @return
-    */
-   public Map<String, String[]> getResourceRenderParameterMap(String windowId) {
-      HashMap<String, String[]> parameters = new HashMap<String, String[]>();
-
-      processParams();
-      
-      if (wid2Render.containsKey(windowId)) {
-         for (PortalURLParameter parm : wid2Render.get(windowId)) {
-            parameters.put(parm.getName(), parm.getValues().clone());
-         }
-      }
-      
-      return parameters;
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b28c3d6f/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java
index 492d0fa..fa5f368 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java
@@ -35,6 +35,7 @@ import org.apache.pluto.container.PortletRequestContext;
 import org.apache.pluto.container.PortletWindow;
 import org.apache.pluto.driver.core.PortalRequestContext;
 import org.apache.pluto.driver.url.PortalURL;
+import org.apache.pluto.driver.url.PortletParameterFactory;
 
 /**
  * @version $Id$
@@ -65,7 +66,7 @@ public class PortletRequestContextImpl implements PortletRequestContext {
       this.window = window;
       this.url = PortalRequestContext.getContext(containerRequest)
             .createPortalURL();
-      this.paramFactory = new PortletParameterFactory(url);
+      this.paramFactory = url.getPortletParameterFactory();
    }
 
    protected boolean isReservedAttributeName(String name) {

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b28c3d6f/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
index d2077ba..560ddac 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
@@ -50,6 +50,7 @@ public abstract class PortletStateAwareResponseContextImpl extends PortletRespon
                 PortletStateAwareResponseContext
 {
     private final Logger LOGGER = LoggerFactory.getLogger(PortletStateAwareResponseContextImpl.class);
+    private final boolean isDebug = LOGGER.isDebugEnabled();
 
     private List<Event> events;
     private PortletURLProviderImpl portletURLProvider;
@@ -61,7 +62,7 @@ public abstract class PortletStateAwareResponseContextImpl extends PortletRespon
         this.portletURLProvider = new PortletURLProviderImpl(getPortalURL(), PortletURLProvider.TYPE.RENDER, window);
     }
     
-    protected PortletURLProvider getPorletURLProvider()
+    protected PortletURLProvider getPortletURLProvider()
     {
         return portletURLProvider;
     }
@@ -139,8 +140,13 @@ public abstract class PortletStateAwareResponseContextImpl extends PortletRespon
      * @see org.apache.pluto.container.PortletStateAwareResponseContext#addPublicRenderParameter(javax.xml.namespace.QName, java.lang.String, java.lang.String[])
      */
     public void addPublicRenderParameter(QName qn, String identifier, String[] values) {
-       LOGGER.debug("Add PRP. QName = " + qn.toString() + ", ID = " + identifier
-             + ", values = " + Arrays.toString(values));
+       if (isDebug) {
+          StringBuilder txt = new StringBuilder("Add PRP. QName = ");
+          txt.append(qn.toString())
+             .append(", ID = ").append(identifier)
+             .append(", values = ").append(Arrays.toString(values));
+          LOGGER.debug(txt.toString());
+       }
        portletURLProvider.addPublicRenderParameter(qn, identifier, values);
     }
 
@@ -148,7 +154,9 @@ public abstract class PortletStateAwareResponseContextImpl extends PortletRespon
      * @see org.apache.pluto.container.PortletStateAwareResponseContext#removePublicRenderParameter(javax.xml.namespace.QName, java.lang.String)
      */
     public void removePublicRenderParameter(QName qn, String id) {
-       LOGGER.debug("Remove PRP. QName = " + qn.toString());
+       if (isDebug) {
+          LOGGER.debug("Remove PRP. QName = " + qn.toString());
+       }
        portletURLProvider.removePublicRenderParameter(qn, id);
     }
 

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b28c3d6f/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
index 1d15c69..e6aad68 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
@@ -47,13 +47,14 @@ import org.apache.pluto.driver.url.PortalURLPublicParameter;
 public class PortletURLProviderImpl implements PortletURLProvider
 {
     private final Logger LOGGER = LoggerFactory.getLogger(PortletURLProviderImpl.class);
+    private final boolean isDebug = LOGGER.isDebugEnabled();
 
     private final PortalURL url;
     private final TYPE type;
     private final String window;
     private PortletMode portletMode;
     private WindowState windowState;
-    private String cacheLevel;
+    private String cacheLevel = ResourceURL.PAGE;     // default
     private String resourceID;
     private Map<String, String[]> renderParameters;
     private Map<String, List<String>> properties;
@@ -78,14 +79,13 @@ public class PortletURLProviderImpl implements PortletURLProvider
 
     public PortletURLProviderImpl(PortalURL url, TYPE type, PortletWindow portletWindow)
     {
-        this.url = url;
+        this.url = url.clone();
         this.type = type;
         this.window = portletWindow.getId().getStringId();
     }
     
     public PortalURL apply()
     {
-        PortalURL url = this.url.clone();
         if (PortletURLProvider.TYPE.ACTION == type)
         {
            url.setTargetWindow(window);
@@ -230,10 +230,15 @@ public class PortletURLProviderImpl implements PortletURLProvider
     */
    public void addPublicRenderParameter(QName qn, String identifier, String[] values) 
    {
-       LOGGER.debug("Add PRP. QName = " + qn.toString() + ", ID = " + identifier
-             + ", values = " + Arrays.toString(values));
-       PortalURLPublicParameter pupp = new PortalURLPublicParameter(window, identifier, qn, values);
-       prpSet.add(pupp);
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder("Add PRP. QName = ");
+         txt.append(qn.toString())
+         .append(", ID = ").append(identifier)
+         .append(", values = ").append(Arrays.toString(values));
+         LOGGER.debug(txt.toString());
+      }
+      PortalURLPublicParameter pupp = new PortalURLPublicParameter(window, identifier, qn, values);
+      prpSet.add(pupp);
    }
 
    /* (non-Javadoc)
@@ -241,10 +246,12 @@ public class PortletURLProviderImpl implements PortletURLProvider
     */
    public void removePublicRenderParameter(QName qn, String identifier) 
    {
-       LOGGER.debug("Remove PRP. QName = " + qn.toString());
-       PortalURLPublicParameter pupp = new PortalURLPublicParameter(window, identifier, qn);
-       pupp.setRemoved(true);
-       prpSet.add(pupp);
+      if (isDebug) {
+         LOGGER.debug("Remove PRP. QName = " + qn.toString());
+      }
+      PortalURLPublicParameter pupp = new PortalURLPublicParameter(window, identifier, qn);
+      pupp.setRemoved(true);
+      prpSet.add(pupp);
    }
 
    /**

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b28c3d6f/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
index 4253802..1a911fd 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
@@ -140,7 +140,7 @@ public class PortalURLParserImpl implements PortalURLParser {
       // Construct portal URL using info retrieved from servlet request.
       PortalURL portalURL =  new RelativePortalURLImpl(urlBase, contextPath, servletName, this, request);
 
-      // Support added for filter.  Should we seperate into a different impl?
+      // Support added for filter.  Should we separate into a different impl?
       String pathInfo = request.getPathInfo();
       if (pathInfo == null) {
          if(servletName.contains(".jsp") && !servletName.endsWith(".jsp")) {
@@ -330,19 +330,25 @@ public class PortalURLParserImpl implements PortalURLParser {
             }
 
             String[] pVals = values.split(VALUE_DELIM);
-            String[] paramValues = null;
-            String paramName = null;
-            if (pVals.length > 2) {
-               for (int i = 0; i < pVals.length;i++){
+            String[] paramValues = new String[0];
+            String paramName = "";
+            if (pVals.length > 1) {
+               for (int i = 0; i < pVals.length; i++){
                   if (pVals[i].equals(VALUE_NULL)) {
                      pVals[i] = null;
                   } else {
                      pVals[i] = urlDecode(pVals[i]);
                   }
                }
+            }
+            
+            if (pVals.length <= 1 || pVals[0] == null) {
+               LOG.warn("Bad parameter token: " + values);
+            } else {
                paramName = pVals[0];
                paramValues = Arrays.copyOfRange(pVals, 1, pVals.length);
             }
+            
             if (LOG.isDebugEnabled()) {
                dbgstr.append(", paramName=").append(paramName);
                dbgstr.append(", paramValues=").append(Arrays.toString(paramValues));
@@ -385,6 +391,12 @@ public class PortalURLParserImpl implements PortalURLParser {
          }
       }
 
+      // If we're dealing with a render request (with or without target portlet),
+      // we can parse the servlet request parameters directly.
+      if (portalURL.getType() == URLType.Render || portalURL.getType() == URLType.Portal) {
+         portalURL.handleServletRequestParams();
+      }
+      
       if (LOG.isDebugEnabled()) {
          LOG.debug("Found " + portletIds.size() + " IDs: " + Arrays.toString(portletIds.toArray()));
       }
@@ -582,7 +594,7 @@ public class PortalURLParserImpl implements PortalURLParser {
                buffer.append("/").append(PREFIX).append(PUBLIC_RENDER_PARAM)
                .append(String.valueOf(index)).append(DELIM)
                .append(String.valueOf(i)).append(DELIM)
-               .append(urlEncode(prp.getName()))
+               .append(urlEncode(prp.getName())).append(VALUE_DELIM)
                .append(valstr);
             } else {
                LOG.warn("window ID not on page for public render parameter: " + prp.toString());

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b28c3d6f/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
index e6926a2..2e107ce 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
@@ -21,7 +21,6 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -40,62 +39,79 @@ import org.apache.pluto.driver.url.PortalURL;
 import org.apache.pluto.driver.url.PortalURLParameter;
 import org.apache.pluto.driver.url.PortalURLPublicParameter;
 import org.apache.pluto.driver.url.PortalURLParser;
+import org.apache.pluto.driver.url.PortletParameterFactory;
 
 /**
  * The portal URL.
+ * 
  * @since 1.0
  */
 public class RelativePortalURLImpl implements PortalURL {
 
-   private static final Logger LOG = LoggerFactory.getLogger(RelativePortalURLImpl.class);
+   private static final Logger         LOG                = LoggerFactory
+                                                                .getLogger(RelativePortalURLImpl.class);
+   private static final boolean        isDebug            = LOG.isDebugEnabled();
 
-   private String urlBase;
-   private String servletPath;
-   private String renderPath;
-   private String cacheLevel;
-   private String resourceID;
+   private String                      urlBase;
+   private String                      servletPath;
+   private String                      renderPath;
+   private String                      cacheLevel;
+   private String                      resourceID;
 
-   private Map<String, String[]> privateRenderParameters = new HashMap<String, String[]>();
+   private boolean                     isClone            = false;
 
-   // provides the defined public render parameters and their relationships to one another for the current page 
-   private PublicRenderParameterMapper prpMapper = null;
-   
-   private HashSet<String> portletIds = new HashSet<String>();
-   private HashMap<String, String> versionMap = new HashMap<String, String>(); 
-   private HashMap<String, Boolean> v3Map = new HashMap<String, Boolean>(); 
+   // provides the defined public render parameters and their relationships to
+   // one another for the current page
+   private PublicRenderParameterMapper prpMapper          = null;
+
+   private HashSet<String>             portletIds         = new HashSet<String>();
+   private HashMap<String, String>     versionMap         = new HashMap<String, String>();
+   private HashMap<String, Boolean>    v3Map              = new HashMap<String, Boolean>();
 
    /**
-    * PortalURLParser used to construct the string
-    * representation of this portal url.
+    * PortalURLParser used to construct the string representation of this portal
+    * url.
     */
-   private PortalURLParser urlParser;
-   
+   private PortalURLParser             urlParser;
+
    // The servlet request for delyed parsing of the servlet parameters
-   HttpServletRequest servletRequest;
+   HttpServletRequest                  servletRequest;
    // marks whether the servlet request parameters have been processed.
-   boolean reqParamsProcessed = false;
+   boolean                             reqParamsProcessed = false;
 
    /** The window states: key is the window ID, value is WindowState. */
-   private Map<String, WindowState> windowStates = new HashMap<String, WindowState>();
+   private Map<String, WindowState>    windowStates       = new HashMap<String, WindowState>();
 
-   private Map<String, PortletMode> portletModes = new HashMap<String, PortletMode>();
+   private Map<String, PortletMode>    portletModes       = new HashMap<String, PortletMode>();
 
    /** Parameters of the portlet windows. */
-   private HashSet<PortalURLParameter> parameters = new HashSet<PortalURLParameter>();
-   
+   private HashSet<PortalURLParameter> parameters         = new HashSet<PortalURLParameter>();
+
    // Target window & type of URL
-   URLType type = URLType.Portal;      // initially just addresses the portal in general
-   String targetWindow = null;
+   URLType                             type               = URLType.Portal;                             // initially
+                                                                                                         // just
+                                                                                                         // addresses
+                                                                                                         // the
+                                                                                                         // portal
+                                                                                                         // in
+                                                                                                         // general
+   String                              targetWindow       = null;
 
    /**
     * Constructs a PortalURLImpl instance using customized port.
-    * @param urlBase      the absolute (protocol://domain:port) request url base
-    * @param contextPath  the servlet context path.
-    * @param servletName  the servlet name.
-    * @param urlParser    the {@link PortalURLParser} used to construct a string representation of the url.
+    * 
+    * @param urlBase
+    *           the absolute (protocol://domain:port) request url base
+    * @param contextPath
+    *           the servlet context path.
+    * @param servletName
+    *           the servlet name.
+    * @param urlParser
+    *           the {@link PortalURLParser} used to construct a string
+    *           representation of the url.
     */
-   public RelativePortalURLImpl(String urlBase, String contextPath, String servletName, 
-         PortalURLParser urlParser, HttpServletRequest req) {
+   public RelativePortalURLImpl(String urlBase, String contextPath,
+         String servletName, PortalURLParser urlParser, HttpServletRequest req) {
       this.urlBase = urlBase;
       StringBuffer buffer = new StringBuffer();
       buffer.append(contextPath);
@@ -107,59 +123,81 @@ public class RelativePortalURLImpl implements PortalURL {
 
    /**
     * Internal private constructor used by method <code>clone()</code>.
+    * 
     * @see #clone()
     */
    private RelativePortalURLImpl() {
       // Do nothing.
    }
-   
+
    // reading of the servlet request parameters is delayed until the first time
    // the parameters are read in order to allow a portlet to potentially set
    // the character encoding during processAction or serveResource.
-   
+
    public void handleServletRequestParams() {
-      if (!reqParamsProcessed && servletRequest != null 
-            && targetWindow != null && type != URLType.Portal) {
+      if (!reqParamsProcessed && servletRequest != null && targetWindow != null
+            && type != URLType.Portal) {
          reqParamsProcessed = true;
-         
+
          try {
-            servletRequest.setCharacterEncoding("UTF-8"); // in case it hasn't already been set
-         } catch(Exception e) {}
-         
-         Map<String, String []> parms = servletRequest.getParameterMap();
+            servletRequest.setCharacterEncoding("UTF-8"); // in case it hasn't
+                                                          // already been set
+         } catch (Exception e) {
+         }
+
+         Map<String, String[]> parms = servletRequest.getParameterMap();
          if (!parms.isEmpty()) {
-            
-            // choose the parameter type. Query or POST parameters always target the 
+
+            // choose the parameter type. Query or POST parameters always target
+            // the
             // target window, never the general page.
-            
+
             String ptype = PortalURLParameter.PARAM_TYPE_RENDER;
-            if (type == URLType.Action || type == URLType.AjaxAction 
+            if (type == URLType.Action || type == URLType.AjaxAction
                   || type == URLType.PartialAction) {
                ptype = PortalURLParameter.PARAM_TYPE_ACTION;
             } else if (type == URLType.Resource) {
                ptype = PortalURLParameter.PARAM_TYPE_RESOURCE;
             }
-            
-            // The semantics is a query or POST parameter overwrites a 
+
+            // The semantics is a query or POST parameter overwrites a
             // parameter of the same windowId, type and name encoded in the URL.
-            
+
             for (String parm : parms.keySet()) {
-               
-               // If it's a render request & target window is set, the parameter might be public
+
+               // If it's a render request & target window is set, the parameter
+               // might be public
                if (type == URLType.Render && targetWindow != null) {
                   int index = prpMapper.getIndex(targetWindow, parm);
-                  if (index >= 0 ) {
+                  if (index >= 0) {
                      prpMapper.setValues(index, parms.get(parm));
+                     if (isDebug) {
+                        StringBuilder txt = new StringBuilder(
+                              "Added public parameter: ");
+                        txt.append(parm).append(", Values: ")
+                              .append(Arrays.toString(parms.get(parm)));
+                        txt.append(", isClone: " + isClone);
+                        LOG.debug(txt.toString());
+                     }
                      continue;
                   }
                }
-               
+
                // handle private parameter
-               
-               PortalURLParameter pup = new PortalURLParameter(targetWindow, parm, parms.get(parm), ptype);
+
+               PortalURLParameter pup = new PortalURLParameter(targetWindow,
+                     parm, parms.get(parm), ptype);
                if (parameters.contains(pup)) {
-                  parameters.remove(pup);       // remove the old values
-                  parameters.add(pup);          // add the new values
+                  parameters.remove(pup); // remove the old values
+               }
+               parameters.add(pup); // add the new values
+               if (isDebug) {
+                  StringBuilder txt = new StringBuilder(
+                        "Added private parameter: ");
+                  txt.append(parm).append(", Values: ")
+                        .append(Arrays.toString(parms.get(parm)));
+                  txt.append(", isClone: " + isClone);
+                  LOG.debug(txt.toString());
                }
             }
          }
@@ -177,6 +215,17 @@ public class RelativePortalURLImpl implements PortalURL {
    }
 
    public void addParameter(PortalURLParameter param) {
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder(
+               "Setting public render parameter: ");
+         txt.append(" window ID: " + param.getWindowId());
+         txt.append(", Name: " + param.getName());
+         String vals = (param.getValues() == null) ? "null" : Arrays
+               .toString(param.getValues());
+         txt.append(", Values: " + vals);
+         txt.append(", isClone: " + isClone);
+         LOG.debug(txt.toString());
+      }
       parameters.add(param);
    }
 
@@ -206,7 +255,9 @@ public class RelativePortalURLImpl implements PortalURL {
 
    /**
     * Returns the window state of the specified window.
-    * @param windowId  the window ID.
+    * 
+    * @param windowId
+    *           the window ID.
     * @return the window state. Default to NORMAL.
     */
    public WindowState getWindowState(String windowId) {
@@ -219,8 +270,11 @@ public class RelativePortalURLImpl implements PortalURL {
 
    /**
     * Sets the window state of the specified window.
-    * @param windowId  the window ID.
-    * @param windowState  the window state.
+    * 
+    * @param windowId
+    *           the window ID.
+    * @param windowState
+    *           the window state.
     */
    public void setWindowState(String windowId, WindowState windowState) {
       this.windowStates.put(windowId, windowState);
@@ -228,38 +282,44 @@ public class RelativePortalURLImpl implements PortalURL {
 
    /**
     * Clear parameters of the specified window.
-    * @param windowId  the window ID.
+    * 
+    * @param windowId
+    *           the window ID.
     */
    public void clearParameters(String windowId) {
+      HashSet<PortalURLParameter> rem = new HashSet<PortalURLParameter>();
       for (PortalURLParameter p : parameters) {
          if (p.getWindowId().equals(windowId)) {
-            parameters.remove(p);
+            rem.add(p);
          }
       }
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder("clearParameters Removing ");
+         txt.append(rem.size()).append(" elements.");
+         LOG.debug(txt.toString());
+      }
+      parameters.removeAll(rem);
    }
 
-   public void setCacheability(String cacheLevel)
-   {
+   public void setCacheability(String cacheLevel) {
       this.cacheLevel = cacheLevel;
    }
 
-   public String getCacheability()
-   {
+   public String getCacheability() {
       return cacheLevel;
    }
 
-   public void setResourceID(String resourceID)
-   {
+   public void setResourceID(String resourceID) {
       this.resourceID = resourceID;
    }
 
-   public String getResourceID()
-   {
+   public String getResourceID() {
       return resourceID;
    }
 
    /**
     * Converts to a string representing the portal URL.
+    * 
     * @deprecated use toURL(boolean absolute) instead
     * @return a string representing the portal URL.
     * @see PortalURLParserImpl#toString(org.apache.pluto.driver.url.PortalURL)
@@ -270,14 +330,13 @@ public class RelativePortalURLImpl implements PortalURL {
 
    /**
     * Converts to a string representing the portal URL.
+    * 
     * @return a string representing the portal URL.
     * @see PortalURLParserImpl#toString(org.apache.pluto.driver.url.PortalURL)
     */
-   public String toURL(boolean absolute)
-   {
+   public String toURL(boolean absolute) {
       String result = urlParser.toString(this);
-      if (absolute)
-      {
+      if (absolute) {
          return urlBase + result;
       }
       return result;
@@ -285,6 +344,7 @@ public class RelativePortalURLImpl implements PortalURL {
 
    /**
     * Returns the server URI (protocol, name, port).
+    * 
     * @return the server URI portion of the portal URL.
     * @deprecated
     */
@@ -295,6 +355,7 @@ public class RelativePortalURLImpl implements PortalURL {
 
    /**
     * Returns the servlet path (context path + servlet name).
+    * 
     * @return the servlet path.
     */
    public String getServletPath() {
@@ -303,13 +364,13 @@ public class RelativePortalURLImpl implements PortalURL {
 
    /**
     * Clone a copy of itself.
+    * 
     * @return a copy of itself.
     */
    public synchronized PortalURL clone() {
       RelativePortalURLImpl portalURL = new RelativePortalURLImpl();
       portalURL.servletPath = this.servletPath;
       portalURL.parameters = new HashSet<PortalURLParameter>(parameters);
-      portalURL.privateRenderParameters = new HashMap<String, String[]>(privateRenderParameters);
       portalURL.portletModes = new HashMap<String, PortletMode>(portletModes);
       portalURL.windowStates = new HashMap<String, WindowState>(windowStates);
       portalURL.cacheLevel = cacheLevel;
@@ -324,27 +385,28 @@ public class RelativePortalURLImpl implements PortalURL {
       portalURL.reqParamsProcessed = reqParamsProcessed;
       portalURL.type = type;
       portalURL.targetWindow = targetWindow;
+      portalURL.isClone = true;
       return portalURL;
    }
 
-
    public PageConfig getPageConfig(ServletContext servletContext) {
       String requestedPageId = getRenderPath();
-      if (LOG.isDebugEnabled()) {
+      if (isDebug) {
          LOG.debug("Requested Page: " + requestedPageId);
       }
-      
-      DriverConfiguration dc =  ((DriverConfiguration) servletContext.getAttribute(AttributeKeys.DRIVER_CONFIG));
+
+      DriverConfiguration dc = ((DriverConfiguration) servletContext
+            .getAttribute(AttributeKeys.DRIVER_CONFIG));
       PageConfig paco = dc.getPageConfig(requestedPageId);
       if (prpMapper == null && requestedPageId == null && paco != null) {
          // Make sure we get a prp mapper for the default page
-         prpMapper = dc.getPublicRenderParameterService().getPRPMapper(paco.getName());
+         prpMapper = dc.getPublicRenderParameterService().getPRPMapper(
+               paco.getName());
       }
       return paco;
    }
 
-   public synchronized void merge(PortalURL url, String windowId)
-   {
+   public synchronized void merge(PortalURL url, String windowId) {
       type = url.getType();
       targetWindow = url.getTargetWindow();
       setPortletMode(windowId, url.getPortletMode(windowId));
@@ -352,11 +414,10 @@ public class RelativePortalURLImpl implements PortalURL {
       setCacheability(url.getCacheability());
       setResourceID(url.getResourceID());
       clearParameters(windowId);
-      for (PortalURLParameter param : url.getParameters())
-      {
-         if (windowId.equals(param.getWindowId()))
-         {
-            addParameter(new PortalURLParameter(param.getWindowId(), param.getName(), param.getValues()));
+      for (PortalURLParameter param : url.getParameters()) {
+         if (windowId.equals(param.getWindowId())) {
+            addParameter(new PortalURLParameter(param.getWindowId(),
+                  param.getName(), param.getValues()));
          }
       }
       PublicRenderParameterMapper prpm = url.getPublicRenderParameterMapper();
@@ -371,6 +432,15 @@ public class RelativePortalURLImpl implements PortalURL {
    }
 
    public void addPublicRenderParameter(PortalURLPublicParameter pup) {
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder(
+               "Setting public render parameter: ");
+         txt.append(" window ID: " + pup.getWindowId());
+         txt.append(", Name: " + pup.getName());
+         txt.append(", QName: " + pup.getQName());
+         txt.append(", Values: " + Arrays.toString(pup.getValues()));
+         LOG.debug(txt.toString());
+      }
       int ind = prpMapper.getIndex(pup);
       if (ind >= 0) {
          if (pup.isRemoved()) {
@@ -379,7 +449,8 @@ public class RelativePortalURLImpl implements PortalURL {
             prpMapper.setValues(ind, pup.getValues());
          }
       } else {
-         StringBuilder txt = new StringBuilder("Public render parameter is not contained in mapper.");
+         StringBuilder txt = new StringBuilder(
+               "Public render parameter is not contained in mapper.");
          txt.append(" window ID: " + pup.getWindowId());
          txt.append(", Name: " + pup.getName());
          txt.append(", QName: " + pup.getQName());
@@ -398,8 +469,9 @@ public class RelativePortalURLImpl implements PortalURL {
 
    public void setPortletIds(Collection<String> portletIds) {
       this.portletIds.addAll(portletIds);
-      if (LOG.isDebugEnabled()) {
-         LOG.debug("Stored " + this.portletIds.size() + " IDs: " + Arrays.toString(this.portletIds.toArray()));
+      if (isDebug) {
+         LOG.debug("Stored " + this.portletIds.size() + " IDs: "
+               + Arrays.toString(this.portletIds.toArray()));
       }
    }
 
@@ -420,43 +492,102 @@ public class RelativePortalURLImpl implements PortalURL {
       return v3Map.get(portletId);
    }
 
-   /* (non-Javadoc)
-    * @see org.apache.pluto.driver.url.PortalURL#setType(org.apache.pluto.driver.url.PortalURL.URLType)
+   /*
+    * (non-Javadoc)
+    * 
+    * @see
+    * org.apache.pluto.driver.url.PortalURL#setType(org.apache.pluto.driver.
+    * url.PortalURL.URLType)
     */
    public void setType(URLType type) {
       this.type = type;
    }
 
-   /* (non-Javadoc)
+   /*
+    * (non-Javadoc)
+    * 
     * @see org.apache.pluto.driver.url.PortalURL#getType()
     */
    public URLType getType() {
       return type;
    }
 
-   /* (non-Javadoc)
-    * @see org.apache.pluto.driver.url.PortalURL#setTargetWindow(java.lang.String)
+   /*
+    * (non-Javadoc)
+    * 
+    * @see
+    * org.apache.pluto.driver.url.PortalURL#setTargetWindow(java.lang.String)
     */
    public void setTargetWindow(String windowId) {
       targetWindow = windowId;
    }
 
-   /* (non-Javadoc)
+   /*
+    * (non-Javadoc)
+    * 
     * @see org.apache.pluto.driver.url.PortalURL#getTargetWindow()
     */
    public String getTargetWindow() {
       return targetWindow;
    }
 
-   /* (non-Javadoc)
-    * @see org.apache.pluto.driver.url.PortalURL#clearResourceParameters(java.lang.String)
+   /*
+    * (non-Javadoc)
+    * 
+    * @see
+    * org.apache.pluto.driver.url.PortalURL#clearResourceParameters(java.lang
+    * .String)
     */
    public void clearResourceParameters(String window) {
+      HashSet<PortalURLParameter> rem = new HashSet<PortalURLParameter>();
       for (PortalURLParameter pup : parameters) {
-         if (pup.getType().equals(PortalURLParameter.PARAM_TYPE_RESOURCE) 
+         if (pup.getType().equals(PortalURLParameter.PARAM_TYPE_RESOURCE)
                && pup.getWindowId().equals(window)) {
-            parameters.remove(pup);
+            rem.add(pup);
          }
       }
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder("clearResourceParameters Removing ");
+         txt.append(rem.size()).append(" elements.");
+         LOG.debug(txt.toString());
+      }
+      parameters.removeAll(rem);
+   }
+
+   public PortletParameterFactory getPortletParameterFactory() {
+      return new PortletParameterFactory(this);
+   }
+
+   public void removeParameter(PortalURLParameter param) {
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder(
+               "Removing private render parameter: ");
+         txt.append(" window ID: " + param.getWindowId());
+         txt.append(", Name: " + param.getName());
+         txt.append(", Values: " + Arrays.toString(param.getValues()));
+         if (!parameters.contains(param)) {
+            txt.append(", Not in parameter set!");
+         }
+         LOG.debug(txt.toString());
+      }
+      parameters.remove(param);
+   }
+
+   public void removePublicRenderParameter(PortalURLPublicParameter param) {
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder(
+               "Removing public render parameter: ");
+         txt.append(" window ID: " + param.getWindowId());
+         txt.append(", Name: " + param.getName());
+         txt.append(", QName: " + param.getQName());
+         txt.append(", Values: " + Arrays.toString(param.getValues()));
+         LOG.debug(txt.toString());
+      }
+      int index = prpMapper.getIndex(param);
+      if (index >= 0) {
+         prpMapper.setRemoved(index, true);
+      } else {
+         LOG.warn("Public parameter not found in PRP mapper.");
+      }
    }
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b28c3d6f/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PublicRenderParameterQNameMapper.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PublicRenderParameterQNameMapper.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PublicRenderParameterQNameMapper.java
index 41c5030..ab1dcc7 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PublicRenderParameterQNameMapper.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PublicRenderParameterQNameMapper.java
@@ -48,6 +48,7 @@ import org.apache.pluto.container.om.portlet.PublicRenderParameter;
  */
 public class PublicRenderParameterQNameMapper implements PublicRenderParameterMapper {
    private final Logger LOGGER = LoggerFactory.getLogger(PublicRenderParameterQNameMapper.class);
+   private final boolean isTrace = LOGGER.isTraceEnabled();
  
    // Set of all public render parameters on the page
    private final ArrayList<PortalURLPublicParameter> prpList = new ArrayList<PortalURLPublicParameter>();
@@ -64,7 +65,6 @@ public class PublicRenderParameterQNameMapper implements PublicRenderParameterMa
       LOGGER.debug("Setting up the PRP mapper. There are " + pids.size() + " portlets to process.");
 
       StringBuilder dbgstr = new StringBuilder(1024);
-      boolean isTrace = LOGGER.isTraceEnabled();
       for (String pid : pids) {
          if (isTrace) {
             dbgstr.append("\n  Processing portlet id = " + pid);
@@ -171,7 +171,7 @@ public class PublicRenderParameterQNameMapper implements PublicRenderParameterMa
          p.setValues(vals);
          oprps.add(p);
       }
-      if (LOGGER.isTraceEnabled()) {
+      if (isTrace) {
          LOGGER.trace("For index: " + index + ", QName = " + qn + ", group size = "
                 + oprps.size());
       }
@@ -185,7 +185,9 @@ public class PublicRenderParameterQNameMapper implements PublicRenderParameterMa
    public int getIndex(PortalURLPublicParameter prp) {
       int ind =  qnList.indexOf(prp.getQName());
       if (ind < 0) {
-         LOGGER.warn("PRP Qname " + prp.getQName() + " not found in " + qnList.toString());
+         if (isTrace) {
+            LOGGER.trace("PRP Qname " + prp.getQName() + " not found in " + qnList.toString());
+         }
       }
       return ind;
    }
@@ -194,7 +196,9 @@ public class PublicRenderParameterQNameMapper implements PublicRenderParameterMa
       PortalURLPublicParameter tmpPRP = new PortalURLPublicParameter(windowId, identifier, null);
       int ind = prpList.indexOf(tmpPRP);
       if (ind < 0) {
-         LOGGER.warn("Public render parameter with window ID = " + windowId + ", ID = " + identifier + " could not be found.");
+         if (isTrace) {
+            LOGGER.trace("Public render parameter with window ID = " + windowId + ", ID = " + identifier + " could not be found.");
+         }
       } else {
          QName qn = prpList.get(ind).getQName();
          ind = qnList.indexOf(qn);
@@ -260,7 +264,7 @@ public class PublicRenderParameterQNameMapper implements PublicRenderParameterMa
          dbgstr.append(prefix + prp.getWindowId());
          prefix = ", ";
       }
-      if (LOGGER.isTraceEnabled()) {
+      if (isTrace) {
 //          LOGGER.trace(dbgstr.toString());       // fills log with entries.
       }
       return prpm;
@@ -282,7 +286,7 @@ public class PublicRenderParameterQNameMapper implements PublicRenderParameterMa
             }
          }
       }
-      if (LOGGER.isTraceEnabled()) {
+      if (isTrace) {
          LOGGER.trace("For window " + wid + " there are " + prps.size() + " parameters. " + dbgstr.toString());
       }
       return prps;

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b28c3d6f/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
index 60d1032..6f1e7b4 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
@@ -44,6 +44,8 @@ public interface PortalURL extends Cloneable {
       Portal;
    }
    
+   public PortletParameterFactory getPortletParameterFactory();
+   
    /**
     * Sets the URL type
     * @param type
@@ -73,6 +75,18 @@ public interface PortalURL extends Cloneable {
    String getRenderPath();
 
    void addParameter(PortalURLParameter param);
+   
+   /**
+    * Removes the given parameter
+    * @param param
+    */
+   public void removeParameter(PortalURLParameter param);
+   
+   /**
+    * Removes the given public render parameter
+    * @param param
+    */
+   public void removePublicRenderParameter(PortalURLPublicParameter param);
 
    /**
     * Adds a new public render parameter.

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b28c3d6f/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLParameter.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLParameter.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLParameter.java
index 6477cc6..d2e7ca0 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLParameter.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLParameter.java
@@ -48,21 +48,13 @@ public class PortalURLParameter {
    protected String[] values;
    protected String type;
 
-   // Constructor for use by extending classes
+   // Constructors for use by extending classes
    protected PortalURLParameter(String window, String name) {
       this.window = window;
       this.name = name;
       this.values = null;
    }
 
-   // Create a new render parameter
-   public PortalURLParameter(String window, String name, String value) {
-      this.window = window;
-      this.name = name;
-      this.values = new String[]{value};
-      this.type = PARAM_TYPE_RENDER;
-   }
-
    // Create a new parameter of specified type
    public PortalURLParameter(String window, String name, String[] values) {
       this.window = window;
@@ -71,17 +63,6 @@ public class PortalURLParameter {
       this.type = PARAM_TYPE_RENDER;
    }
 
-   // Create a new parameter of specified type
-   public PortalURLParameter(String window, String name, String value, String type) {
-      this.window = window;
-      this.name = name;
-      this.values = new String[]{value};
-      this.type = type;
-      if (!allowedTypes.contains(type)) {
-         LOGGER.warn("Parameter type: " + type + " is not in allowed set: " + allowedTypes.toString());
-      }
-   }
-
    public PortalURLParameter(String window, String name, String[] values, String type) {
       this.window = window;
       this.name = name;
@@ -122,7 +103,7 @@ public class PortalURLParameter {
    @Override
    public PortalURLParameter clone() {
       // shallow clone works because strings are immutable
-      return new PortalURLParameter(window, name, (values == null ? values : values.clone()));
+      return new PortalURLParameter(window, name, (values == null ? values : values.clone()), type);
    }
 
    /**

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b28c3d6f/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLPublicParameter.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLPublicParameter.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLPublicParameter.java
index e360264..19e4b26 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLPublicParameter.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLPublicParameter.java
@@ -54,20 +54,6 @@ public class PortalURLPublicParameter extends PortalURLParameter {
    }
 
    /**
-    * Constructor with single value
-    * @param window
-    * @param name
-    * @param qname
-    * @param value
-    */
-   public PortalURLPublicParameter(String window, String name, QName qname, String value) {
-      super(window, name, value);
-      this.qname = qname;
-      removed = false;
-      this.type = PARAM_TYPE_PUBLIC;
-   }
-
-   /**
     * Constructor with multiple values
     * @param window
     * @param name

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b28c3d6f/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java
new file mode 100644
index 0000000..3ef681b
--- /dev/null
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java
@@ -0,0 +1,189 @@
+/*  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.pluto.driver.url;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.pluto.driver.services.portal.PublicRenderParameterMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Scott Nicklous
+ * 
+ * This class bridges between the URL parameter representation and the parameter
+ * representation presented through the portlet API. It also bridges between the 
+ * JSR 286 and the JSR 362 parameter handling APIs. 
+ *
+ */
+public class PortletParameterFactory {
+   private static final Logger LOGGER = LoggerFactory.getLogger(PortletParameterFactory.class);
+   private final static boolean isDebug = LOGGER.isDebugEnabled();
+   
+   PortalURL url;
+   
+   HashMap<String, ArrayList<PortalURLParameter>> wid2Render;
+   HashMap<String, ArrayList<PortalURLParameter>> wid2Action;
+   HashMap<String, ArrayList<PortalURLParameter>> wid2Resource;
+   
+   public PortletParameterFactory(PortalURL url) {
+      this.url = url;
+   }
+   
+   private void addParam(Map<String, ArrayList<PortalURLParameter>> map, PortalURLParameter parm) {
+      String wid = parm.getWindowId();
+      if (!map.keySet().contains(wid)) {
+         map.put(wid, new ArrayList<PortalURLParameter>());
+      }
+      map.get(wid).add(parm);
+   }
+   
+   /**
+    * process the URL parameters. Do this as late as possible so that 
+    * the servlet rquest parameters get handled properly.
+    */
+   private void processParams() {
+      wid2Render = new HashMap<String, ArrayList<PortalURLParameter>>();
+      wid2Action = new HashMap<String, ArrayList<PortalURLParameter>>();
+      wid2Resource = new HashMap<String, ArrayList<PortalURLParameter>>();
+      
+      //Make sure the servlet request parameters are processed
+      url.handleServletRequestParams();
+      
+      for (PortalURLParameter parm : url.getParameters()) {
+         if (parm.getType().equals(PortalURLParameter.PARAM_TYPE_ACTION)) {
+            addParam(wid2Action, parm);
+         } else if (parm.getType().equals(PortalURLParameter.PARAM_TYPE_RESOURCE)) {
+            addParam(wid2Resource, parm);
+         } else {
+            addParam(wid2Render, parm);
+         }
+      }
+
+   }
+
+   /**
+    * This V2.0 method returns the private parameters for the given window ID.
+    * In the case of a render URL, it returns only the private render parameters.
+    * 
+    * In the case of an action or resource URL, it returns the action or resource 
+    * parameters combined with the render parameters, with the action or resource
+    * parameters taking precedence.
+    * 
+    * Note that the  latter circumstance will only occur with V3.0 portlets.
+    *  
+    * @param windowId
+    * @return
+    */
+   public Map<String, String[]> getPrivateParameterMap(String windowId) {
+      HashMap<String, String[]> parameters = new HashMap<String, String[]>();
+      processParams();
+
+      // get the action or resource parameters
+      
+      if (wid2Action.containsKey(windowId)) {
+         for (PortalURLParameter parm : wid2Action.get(windowId)) {
+            parameters.put(parm.getName(), parm.getValues().clone());
+         }
+      } else if (wid2Resource.containsKey(windowId)) {
+         for (PortalURLParameter parm : wid2Resource.get(windowId)) {
+            parameters.put(parm.getName(), parm.getValues().clone());
+         }
+      }
+      
+      // Now merge in the render parameters
+      
+      if (wid2Render.containsKey(windowId)) {
+         for (PortalURLParameter parm : wid2Render.get(windowId)) {
+            if (parameters.containsKey(parm.getName())) {
+               ArrayList<String> vals = 
+                     new ArrayList<String>(Arrays.asList(parameters.get(parm.getName())));
+               vals.addAll(Arrays.asList(parm.getValues()));
+               parameters.put(parm.getName(), vals.toArray(new String[0]));
+            } else {
+               parameters.put(parm.getName(), parm.getValues().clone());
+            }
+         }
+      }
+
+      if (isDebug) {
+         StringBuffer sb = new StringBuffer();
+         sb.append("Dump private Parameter Map:");
+         for (String k : parameters.keySet()) {
+            sb.append("\nName: " + k + ", Values: ");
+            String sep = "";
+            for (String v : parameters.get(k)) {
+               sb.append(sep + v);
+               sep = ", ";
+            }
+         }
+         LOGGER.debug(sb.toString());
+      }
+      return parameters;
+   }
+   
+   /**
+    * Returns the active (= have been set) public render parameters for the
+    * given window ID.
+    *  
+    * @param windowId
+    * @return
+    */
+   public Map<String, String[]> getPublicParameterMap(String windowId) {
+      HashMap<String, String[]> parameters = new HashMap<String, String[]>();
+      
+      //Make sure the servlet request parameters are processed
+      url.handleServletRequestParams();
+
+      PublicRenderParameterMapper mapper = url.getPublicRenderParameterMapper();
+      
+      // get the active PRPs only
+      
+      List<PortalURLPublicParameter> prps = mapper.getPRPsForWindow(windowId, true);
+      for (PortalURLPublicParameter prp : prps) {
+         parameters.put(prp.getName(), prp.getValues().clone());
+      }
+      return parameters;
+   }
+
+   /**
+    * This is a V2 method to get the private render parameter map during
+    * a resource request.
+    * 
+    * @return
+    */
+   public Map<String, String[]> getResourceRenderParameterMap(String windowId) {
+      HashMap<String, String[]> parameters = new HashMap<String, String[]>();
+
+      processParams();
+      
+      if (wid2Render.containsKey(windowId)) {
+         for (PortalURLParameter parm : wid2Render.get(windowId)) {
+            parameters.put(parm.getName(), parm.getValues().clone());
+         }
+      }
+      
+      return parameters;
+   }
+
+}


[05/22] portals-pluto git commit: Added some additional tracing to the demo portlets

Posted by ms...@apache.org.
Added some additional tracing to the demo portlets


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/aabd8d95
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/aabd8d95
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/aabd8d95

Branch: refs/heads/V3Prototype
Commit: aabd8d95ad607dfe582ff0c96b7b7ae7a9b95b3a
Parents: 60205ca
Author: Scott Nicklous <ms...@apache.org>
Authored: Thu Feb 5 16:58:11 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Thu Feb 5 16:58:11 2015 +0100

----------------------------------------------------------------------
 .../java/basic/portlet/ColorSelPortlet.java     | 37 +++++++++++++++-----
 .../src/main/java/basic/portlet/Constants.java  |  3 --
 .../java/basic/portlet/MessageBoxPortlet.java   |  4 ++-
 .../src/main/webapp/WEB-INF/portlet.xml         |  2 +-
 4 files changed, 32 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/aabd8d95/PortletHubDemo/src/main/java/basic/portlet/ColorSelPortlet.java
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/java/basic/portlet/ColorSelPortlet.java b/PortletHubDemo/src/main/java/basic/portlet/ColorSelPortlet.java
index c6447dc..102d2d5 100644
--- a/PortletHubDemo/src/main/java/basic/portlet/ColorSelPortlet.java
+++ b/PortletHubDemo/src/main/java/basic/portlet/ColorSelPortlet.java
@@ -21,6 +21,9 @@ package basic.portlet;
 import static basic.portlet.Constants.*;
 
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.logging.Logger;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
@@ -40,12 +43,16 @@ import javax.xml.namespace.QName;
 public class ColorSelPortlet extends GenericPortlet {
 
    // Set up logging
+   private static final String LOG_CLASS = ColorSelPortlet.class.getName();
+   private final Logger logger = Logger.getLogger(LOG_CLASS);
+
    // private static final String LOG_CLASS = ColorSelPortlet.class.getName();
    // private final Logger logger = Logger.getLogger(LOG_CLASS);
 
    protected void doView(RenderRequest req, RenderResponse resp)
          throws PortletException, IOException {
 
+      logger.fine("Doing view.");
       
       resp.setContentType("text/html");
 
@@ -85,20 +92,32 @@ public class ColorSelPortlet extends GenericPortlet {
          resp.setRenderParameter(PARAM_FG_COLOR, vals);
       }
       
-      String val = req.getParameter(PARAM_SUBTYPE);
-      if (val != null) {
-         resp.setRenderParameter(PARAM_SUBTYPE, val);
+      String subType = req.getParameter(PARAM_SUBTYPE);
+      if (subType != null) {
+         resp.setRenderParameter(PARAM_SUBTYPE, subType);
       }
       
-      val = req.getParameter(PARAM_MSG_INPUT);
-      if (val != null) {
-         resp.setRenderParameter(PARAM_MSG_INPUT, val);
+      String text = req.getParameter(PARAM_MSG_INPUT);
+      if (text != null) {
+         resp.setRenderParameter(PARAM_MSG_INPUT, text);
       }
       
-      String msg = val + DELIM + clr;
-      QName qn = new QName(EVENT_NAMESPACE, EVENT_NAME);
-      resp.setEvent(qn, msg);
+      String msg = text + DELIM + clr;
+
+      // there should only be one publishing event, so take the first QName
+      Enumeration<QName> eqn = getPublishingEventQNames();
+      if (eqn.hasMoreElements()) {
+         QName qn = eqn.nextElement(); 
+         resp.setEvent(qn, msg);
+         logger.fine("Firing event with QName: " + qn.toString());
+      } else {
+         logger.warning("No publishing event QName available. Check portlet deployment descriptor.");
+      }
       
+      StringBuilder sb = new StringBuilder("Color: ").append(Arrays.toString(vals));
+      sb.append(", Submission type: ").append(subType);
+      sb.append(", Text: ").append(text);
+      logger.fine(sb.toString());
    }
 
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/aabd8d95/PortletHubDemo/src/main/java/basic/portlet/Constants.java
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/java/basic/portlet/Constants.java b/PortletHubDemo/src/main/java/basic/portlet/Constants.java
index fad97d7..e36609c 100644
--- a/PortletHubDemo/src/main/java/basic/portlet/Constants.java
+++ b/PortletHubDemo/src/main/java/basic/portlet/Constants.java
@@ -46,8 +46,5 @@ public class Constants {
    public final static String PARAM_NUM_MSGS = "numMsgs";
    public final static String ATTRIB_MSGS = "msgs";
    
-   public final static String EVENT_NAMESPACE = "http://www.apache.org/portals/pluto/pub-render-params/ResourcePortlet";
-   public final static String EVENT_NAME = "Message";
-   
    public final static String DELIM = ";%;";
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/aabd8d95/PortletHubDemo/src/main/java/basic/portlet/MessageBoxPortlet.java
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/java/basic/portlet/MessageBoxPortlet.java b/PortletHubDemo/src/main/java/basic/portlet/MessageBoxPortlet.java
index f8363b0..4fb730a 100644
--- a/PortletHubDemo/src/main/java/basic/portlet/MessageBoxPortlet.java
+++ b/PortletHubDemo/src/main/java/basic/portlet/MessageBoxPortlet.java
@@ -103,7 +103,7 @@ public class MessageBoxPortlet extends GenericPortlet {
          msgs.clear();
       }
       
-      logger.fine("MBP: Processing message event. Current # messages = " + msgs.size());
+      logger.fine("Processing message event. Current # messages = " + msgs.size());
 
       try {
          // Both pieces of info are transported in a delimted string rather than 
@@ -161,6 +161,8 @@ public class MessageBoxPortlet extends GenericPortlet {
          writer.write(msg);
       }
 
+      int n = msgs.size();
+      logger.fine("Served messages. latest message: " + (n > 0 ? msgs.get(n-1) : "null"));
    }
 
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/aabd8d95/PortletHubDemo/src/main/webapp/WEB-INF/portlet.xml
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/webapp/WEB-INF/portlet.xml b/PortletHubDemo/src/main/webapp/WEB-INF/portlet.xml
index f81145e..9a516e3 100644
--- a/PortletHubDemo/src/main/webapp/WEB-INF/portlet.xml
+++ b/PortletHubDemo/src/main/webapp/WEB-INF/portlet.xml
@@ -1,6 +1,6 @@
 <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_3_0.xsd" 
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
-           xmlns:rp="http://www.apache.org/portals/pluto/pub-render-params/ResourcePortlet"
+             xmlns:rp="http://www.apache.org/portals/pluto/pub-render-params/ResourcePortlet"
              xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_3_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_3_0.xsd" 
              version="3.0"
     		id="ph.resource.portlet">


[19/22] portals-pluto git commit: Fix for removePublicRenderParameter method

Posted by ms...@apache.org.
Fix for removePublicRenderParameter method


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/40d76d3d
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/40d76d3d
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/40d76d3d

Branch: refs/heads/V3Prototype
Commit: 40d76d3dba4bd4b77b9751bd583d8e18cd34a37b
Parents: 58b0e19
Author: Scott Nicklous <ms...@apache.org>
Authored: Sun Feb 15 10:36:39 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Sun Feb 15 10:38:21 2015 +0100

----------------------------------------------------------------------
 .../services/container/PortletStateAwareResponseContextImpl.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/40d76d3d/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
index 32cda45..a58d7cc 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
@@ -174,7 +174,7 @@ public abstract class PortletStateAwareResponseContextImpl extends PortletRespon
      */
     public void removePublicRenderParameter(String windowId, String name) {
        if (!isClosed()) {
-          portletURLProvider.removeParameter(windowId, name);
+          portletURLProvider.removePublicRenderParameter(windowId, name);
        }
     }
     


[04/22] portals-pluto git commit: deactivated multipart support for the driver servlet. Changed all forms in the demo portlets to use enctype='application/x-www-form-urlencoded' encoding.

Posted by ms...@apache.org.
deactivated multipart support for the driver servlet. Changed all forms in
the demo portlets to use enctype='application/x-www-form-urlencoded'
encoding.


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/60205ca1
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/60205ca1
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/60205ca1

Branch: refs/heads/V3Prototype
Commit: 60205ca184d8878aeab0c3edc1a50e3c9659f7e5
Parents: bc54af3
Author: Scott Nicklous <ms...@apache.org>
Authored: Thu Feb 5 07:44:09 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Thu Feb 5 07:44:09 2015 +0100

----------------------------------------------------------------------
 PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-csp.jsp | 2 +-
 PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-isp.jsp | 2 +-
 PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-ivp.jsp | 2 +-
 PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-pap.jsp | 2 +-
 PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-csp.jsp  | 2 +-
 PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-isp.jsp  | 2 +-
 PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-ivp.jsp  | 2 +-
 PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-mbp.jsp  | 2 +-
 pluto-portal/src/main/webapp/WEB-INF/web.xml            | 2 ++
 9 files changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/60205ca1/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-csp.jsp
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-csp.jsp b/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-csp.jsp
index 11c0475..173d6a4 100644
--- a/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-csp.jsp
+++ b/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-csp.jsp
@@ -42,7 +42,7 @@ limitations under the License.
       }
 %>
 
-<form onsubmit='return false;' enctype='multipart/form-data'>
+<form onsubmit='return false;' enctype='application/x-www-form-urlencoded'>
   <table><tr>
      <td align='left'>Enter background color (public param):</td>
      <td>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/60205ca1/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-isp.jsp
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-isp.jsp b/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-isp.jsp
index 2efd1f2..73ecced 100644
--- a/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-isp.jsp
+++ b/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-isp.jsp
@@ -24,7 +24,7 @@ limitations under the License.
 
 
 <h3>Image Selector</h3><hr/>
-<FORM id='<portlet:namespace/>-setParams' onsubmit='return false;' enctype='multipart/form-data'>
+<FORM id='<portlet:namespace/>-setParams' onsubmit='return false;' enctype='application/x-www-form-urlencoded'>
    <table><tr><td align='left'>
    Selection type (private param):
    </td><td>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/60205ca1/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-ivp.jsp
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-ivp.jsp b/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-ivp.jsp
index 68aa575..9719718 100644
--- a/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-ivp.jsp
+++ b/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-ivp.jsp
@@ -27,7 +27,7 @@ limitations under the License.
 <div id=<portlet:namespace/>-counter style='float:right; font-size:250%; color:#0B0;'>1</div>
 </div><div style='clear:both;'><hr/>
       
-<FORM id='<portlet:namespace/>-setParams'  onsubmit='return false;' enctype='multipart/form-data'>
+<FORM id='<portlet:namespace/>-setParams'  onsubmit='return false;' enctype='application/x-www-form-urlencoded'>
    <table><tr><td align='left'>
    Cacheability setting:
    </td><td>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/60205ca1/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-pap.jsp
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-pap.jsp b/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-pap.jsp
index c9ccb8b..8cf3957 100644
--- a/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-pap.jsp
+++ b/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-pap.jsp
@@ -33,7 +33,7 @@ limitations under the License.
 <h3>Partial Action Portlet</h3>
 <hr/>
 <p>This portlet exercises the Partial Action execution path.</p>
-<form onsubmit='return false;' enctype='multipart/form-data'><input id='<portlet:namespace/>-doPA' type='submit' name='action' value='Do Partial Action' /></form>
+<form onsubmit='return false;' enctype='application/x-www-form-urlencoded'><input id='<portlet:namespace/>-doPA' type='submit' name='action' value='Do Partial Action' /></form>
 <div id='<portlet:namespace/>-responseDiv' style="<%=style.toString()%>"></div>
    
 <script>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/60205ca1/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-csp.jsp
----------------------------------------------------------------------
diff --git a/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-csp.jsp b/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-csp.jsp
index 11c0475..173d6a4 100644
--- a/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-csp.jsp
+++ b/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-csp.jsp
@@ -42,7 +42,7 @@ limitations under the License.
       }
 %>
 
-<form onsubmit='return false;' enctype='multipart/form-data'>
+<form onsubmit='return false;' enctype='application/x-www-form-urlencoded'>
   <table><tr>
      <td align='left'>Enter background color (public param):</td>
      <td>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/60205ca1/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-isp.jsp
----------------------------------------------------------------------
diff --git a/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-isp.jsp b/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-isp.jsp
index ed90d92..c558bcc 100644
--- a/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-isp.jsp
+++ b/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-isp.jsp
@@ -24,7 +24,7 @@ limitations under the License.
 
 
 <h3>Image Selector</h3><hr/>
-<FORM id='<portlet:namespace/>-setParams' onsubmit='return false;' enctype='multipart/form-data'>
+<FORM id='<portlet:namespace/>-setParams' onsubmit='return false;' enctype='application/x-www-form-urlencoded'>
    <table><tr><td align='left'>
    Selection type (private param):
    </td><td>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/60205ca1/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-ivp.jsp
----------------------------------------------------------------------
diff --git a/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-ivp.jsp b/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-ivp.jsp
index 68aa575..9719718 100644
--- a/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-ivp.jsp
+++ b/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-ivp.jsp
@@ -27,7 +27,7 @@ limitations under the License.
 <div id=<portlet:namespace/>-counter style='float:right; font-size:250%; color:#0B0;'>1</div>
 </div><div style='clear:both;'><hr/>
       
-<FORM id='<portlet:namespace/>-setParams'  onsubmit='return false;' enctype='multipart/form-data'>
+<FORM id='<portlet:namespace/>-setParams'  onsubmit='return false;' enctype='application/x-www-form-urlencoded'>
    <table><tr><td align='left'>
    Cacheability setting:
    </td><td>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/60205ca1/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-mbp.jsp
----------------------------------------------------------------------
diff --git a/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-mbp.jsp b/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-mbp.jsp
index 5e85af0..6e5ff8a 100644
--- a/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-mbp.jsp
+++ b/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-mbp.jsp
@@ -33,7 +33,7 @@ limitations under the License.
 <div style='clear:both;'>
 <div style='float:left;'><h3>Message Box Portlet</h3></div>
 <div style='float:right;'>
-<form   onsubmit='return false;'><input id='<portlet:namespace/>-clear' type='submit' name='action' value='clear' /></form>
+<form   onsubmit='return false;' enctype='application/x-www-form-urlencoded'><input id='<portlet:namespace/>-clear' type='submit' name='action' value='clear' /></form>
 </div>
 </div><div style='clear:both;'><hr/>
 <p>Messages that arrive via events from other portlets are displayed in this box.</p>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/60205ca1/pluto-portal/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/pluto-portal/src/main/webapp/WEB-INF/web.xml b/pluto-portal/src/main/webapp/WEB-INF/web.xml
index aecfa28..7db86e3 100644
--- a/pluto-portal/src/main/webapp/WEB-INF/web.xml
+++ b/pluto-portal/src/main/webapp/WEB-INF/web.xml
@@ -55,11 +55,13 @@ limitations under the License.
     <display-name>Pluto Portal Driver</display-name>
     <servlet-name>plutoPortalDriver</servlet-name>
     <servlet-class>org.apache.pluto.driver.PortalDriverServlet</servlet-class>
+<!--  we'll probably want to implement multipart support in a different manner.   
     <multipart-config>
         <max-file-size>10485760</max-file-size>
         <max-request-size>20971520</max-request-size>
         <file-size-threshold>5242880</file-size-threshold>
     </multipart-config>
+-->
   </servlet>
 
   <servlet>


[20/22] portals-pluto git commit: Some restructuring & clean up work

Posted by ms...@apache.org.
Some restructuring & clean up work


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/aef314f7
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/aef314f7
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/aef314f7

Branch: refs/heads/V3Prototype
Commit: aef314f75b82533ed38e799922f576a19cd4daa3
Parents: 40d76d3
Author: Scott Nicklous <ms...@apache.org>
Authored: Sun Feb 15 22:28:24 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Sun Feb 15 22:28:24 2015 +0100

----------------------------------------------------------------------
 .../pluto/container/PortletURLProvider.java     |   5 -
 .../container/PortletURLProviderImpl.java       | 188 +++-------------
 .../driver/url/impl/RelativePortalURLImpl.java  | 218 +++++++------------
 .../pluto/driver/core/PortalRequestContext.java |   8 -
 .../org/apache/pluto/driver/url/PortalURL.java  |   9 -
 .../driver/url/PortletParameterFactory.java     | 169 ++++++++++++++
 6 files changed, 275 insertions(+), 322 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/aef314f7/pluto-container-api/src/main/java/org/apache/pluto/container/PortletURLProvider.java
----------------------------------------------------------------------
diff --git a/pluto-container-api/src/main/java/org/apache/pluto/container/PortletURLProvider.java b/pluto-container-api/src/main/java/org/apache/pluto/container/PortletURLProvider.java
index 330ad1a..ae211ca 100644
--- a/pluto-container-api/src/main/java/org/apache/pluto/container/PortletURLProvider.java
+++ b/pluto-container-api/src/main/java/org/apache/pluto/container/PortletURLProvider.java
@@ -86,11 +86,6 @@ public interface PortletURLProvider {
      * @return
      */
     boolean isPublicRenderParameter(String windowId, String name);
-   
-    /**
-     * Clears public render parameters except those that are marked for removal.
-     */
-    void clearPublicRenderParameters();
     
     /**
      * Retrieves the available private parameter names for the given window ID

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/aef314f7/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
index 5b42263..81bdedf 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
@@ -20,7 +20,6 @@ import java.io.IOException;
 import java.io.Writer;
 import java.util.Arrays;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -40,6 +39,7 @@ import org.apache.pluto.driver.url.PortalURL;
 import org.apache.pluto.driver.url.PortalURL.URLType;
 import org.apache.pluto.driver.url.PortalURLParameter;
 import org.apache.pluto.driver.url.PortalURLPublicParameter;
+import org.apache.pluto.driver.url.PortletParameterFactory;
 
 /**
  *
@@ -48,23 +48,14 @@ public class PortletURLProviderImpl implements PortletURLProvider {
    private static final Logger   LOGGER     = LoggerFactory.getLogger(PortletURLProviderImpl.class);
    private static final boolean  isDebug    = LOGGER.isDebugEnabled();
    private static final boolean  isTrace    = LOGGER.isTraceEnabled();
-   
-   private final static HashMap<PortalURL.URLType, String> urlTypeMap  = 
-         new HashMap<PortalURL.URLType, String>();
-   static {
-      urlTypeMap.put(URLType.Action, PortalURLParameter.PARAM_TYPE_ACTION);
-      urlTypeMap.put(URLType.Render, PortalURLParameter.PARAM_TYPE_RENDER);
-      urlTypeMap.put(URLType.Resource, PortalURLParameter.PARAM_TYPE_RESOURCE);
-   }
 
    private final PortalURL                     url;
+   private final PortletParameterFactory     paramFactory;
 
    private final TYPE                          type;
    private final String                        window;
    private Map<String, List<String>>           properties;
 
-   private final Set<PortalURLPublicParameter> prpSet     = new HashSet<PortalURLPublicParameter>();
-
    // Hack: called to force class loading in Container thread
    protected static final void load() {
       if (isDebug) {
@@ -77,6 +68,7 @@ public class PortletURLProviderImpl implements PortletURLProvider {
       this.url = url.clone();
       this.type = type;
       this.window = portletWindow.getId().getStringId();
+      this.paramFactory = url.getPortletParameterFactory();
 
       if (isDebug) {
          StringBuilder txt = new StringBuilder("Constructing PortalURLProviderImpl. ");
@@ -237,175 +229,53 @@ public class PortletURLProviderImpl implements PortletURLProvider {
       return properties;
    }
 
+   /* (non-Javadoc)
+    * @see org.apache.pluto.container.PortletURLProvider#addPublicRenderParameter(java.lang.String, java.lang.String, java.lang.String[])
+    */
    public void addPublicRenderParameter(String windowId, String name, String[] values) {
-      PublicRenderParameterMapper prpMapper = url.getPublicRenderParameterMapper();
-      if (isDebug) {
-         StringBuilder txt = new StringBuilder("Add PRP. Window: ");
-         txt.append(windowId).append(", name: ").append(name)
-               .append(", values = ").append(Arrays.toString(values));
-         LOGGER.debug(txt.toString());
-      }
-      int index = prpMapper.getIndex(windowId, name);
-      if (index >= 0) {
-         prpMapper.setValues(index, values);
-      } else {
-         StringBuilder txt = new StringBuilder(
-               "Public render parameter for window: ");
-         txt.append(windowId).append(", name: ").append(name)
-               .append(" not found in mapper");
-         LOGGER.warn(txt.toString());
-      }
+      paramFactory.addPublicRenderParameter(windowId, name, values);
    }
 
+   /* (non-Javadoc)
+    * @see org.apache.pluto.container.PortletURLProvider#removePublicRenderParameter(java.lang.String, java.lang.String)
+    */
    public void removePublicRenderParameter(String windowId, String name) {
-      PublicRenderParameterMapper prpMapper = url.getPublicRenderParameterMapper();
-      if (isDebug) {
-         StringBuilder txt = new StringBuilder("Remove PRP. Window: ");
-         txt.append(windowId).append(", name: ").append(name);
-         LOGGER.debug(txt.toString());
-      }
-      int index = prpMapper.getIndex(windowId, name);
-      if (index >= 0) {
-         prpMapper.setRemoved(index, true);
-      } else {
-         StringBuilder txt = new StringBuilder("Public render parameter for window: ");
-         txt.append(windowId).append(", name: ").append(name)
-            .append(" not found in mapper");
-         LOGGER.warn(txt.toString());
-      }
+      paramFactory.removePublicRenderParameter(windowId, name);
    }
 
+   /* (non-Javadoc)
+    * @see org.apache.pluto.container.PortletURLProvider#isPublicRenderParameter(java.lang.String, java.lang.String)
+    */
    public boolean isPublicRenderParameter(String windowId, String name) {
-      PublicRenderParameterMapper prpMapper = url.getPublicRenderParameterMapper();
-      if (isDebug) {
-         StringBuilder txt = new StringBuilder(
-               "isPublicRenderParameter Window: ");
-         txt.append(windowId).append(", name: ").append(name);
-         LOGGER.debug(txt.toString());
-      }
-      int index = prpMapper.getIndex(windowId, name);
-      return (index >= 0);
+      return paramFactory.isPublicRenderParameter(windowId, name);
    }
 
-   /**
-    * Clear public render parameters except those marked for removal
+   /* (non-Javadoc)
+    * @see org.apache.pluto.container.PortletURLProvider#getPrivateParameterNames(java.lang.String)
     */
-   public void clearPublicRenderParameters() {
-      for (PortalURLPublicParameter prp : prpSet) {
-         if (!prp.isRemoved()) {
-            prpSet.remove(prp);
-         }
-      }
-   }
-
-   // This method is for V2 compatibility. It always returns the private 
-   // parameter names for the active URL type - Render parameters for a render URL,
-   // Action parameters for an action URL, and resouce parameters for a Resource URL.
    public Set<String> getPrivateParameterNames(String windowId) {
-      HashSet<String> names = new HashSet<String>();
-      String type = urlTypeMap.get(url.getType());
-      
-      for (PortalURLParameter p : url.getParameters()) {
-         if (p.getWindowId().equals(windowId) && p.getType().equals(type)) {
-            names.add(p.getName());
-         }
-      }
-
-      if (isDebug) {
-         StringBuilder txt = new StringBuilder();
-         txt.append("Window ID: ").append(windowId);
-         txt.append(", URL / Parameter type: ").append(type);
-         txt.append(", names: ").append(names.toString());
-         LOGGER.debug(txt.toString());
-      }
-
-      return names;
+      return paramFactory.getPrivateParameterNames(windowId);
    }
 
-   // This method is for V2 compatibility. It always returns the private 
-   // parameter values for the active URL type - Render parameters for a render URL,
-   // Action parameters for an action URL, and resouce parameters for a Resource URL.
+   /* (non-Javadoc)
+    * @see org.apache.pluto.container.PortletURLProvider#getParameterValues(java.lang.String, java.lang.String)
+    */
    public String[] getParameterValues(String windowId, String name) {
-      PublicRenderParameterMapper prpMapper = url.getPublicRenderParameterMapper();
-      String type = urlTypeMap.get(url.getType());
-      String[] vals = null;
-      
-      if (isDebug) {
-         StringBuilder txt = new StringBuilder("Setting ");
-         txt.append("name: ").append(name);
-         txt.append(", URL / Parameter type: ").append(type);
-         txt.append(", window ID: ").append(windowId);
-         LOGGER.debug(txt.toString());
-      }
-      
-      if (isPublicRenderParameter(windowId, name)) {
-         int index = prpMapper.getIndex(windowId, name);
-         if (index >= 0) {
-            vals = prpMapper.getValues(index).clone();
-         } else {
-            LOGGER.debug("Public render parameter name not found in index.");
-         }
-      } else {
-         for (PortalURLParameter p : url.getParameters()) {
-            if (p.getWindowId().equals(windowId)
-               && p.getName().equals(name) && p.getType().equals(type)) {
-               vals = p.getValues().clone();
-            }
-         }
-      }
-      
-      return vals;
+      return paramFactory.getParameterValues(windowId, name);
    }
 
-   /**
-    * Sets a parameter. This method sets a parameter
-    * of type corresponding to the URL type - Action parameter for an Action URL, etc.
-    * V2 compatibility method.
+   /* (non-Javadoc)
+    * @see org.apache.pluto.container.PortletURLProvider#setParameter(java.lang.String, java.lang.String, java.lang.String[])
     */
    public void setParameter(String windowId, String name, String[] values) {
-      String type = urlTypeMap.get(url.getType());
-      
-      if (isDebug) {
-         StringBuilder txt = new StringBuilder("Setting ");
-         txt.append("name: ").append(name);
-         txt.append(", values: ").append(Arrays.toString(values));
-         txt.append(", type: ").append(type);
-         txt.append(", window ID: ").append(windowId);
-         LOGGER.debug(txt.toString());
-      }
-      
-      if (url.getType() == URLType.Render && isPublicRenderParameter(windowId, name)) {
-         addPublicRenderParameter(windowId, name, values);
-      } else {
-         if (urlTypeMap.containsKey(url.getType())) {
-            PortalURLParameter pup = new PortalURLParameter(windowId, name, values, type);
-            url.setParameter(pup);
-         } else {
-            LOGGER.warn("Unsupported URL / Parameter type: " + url.getType());
-         }
-      }
+      paramFactory.setParameter(windowId, name, values);
    }
 
-   /**
-    * Remove parameter. If the parameter is a public render parameter, 
-    * an <code>IllegalArgumentException</code> is thrown. This method removes a parameter
-    * of type corresponding to the URL type - Action parameter for an Action URL, etc. 
-    * (V3 Spec errata)
+   /* (non-Javadoc)
+    * @see org.apache.pluto.container.PortletURLProvider#removeParameter(java.lang.String, java.lang.String)
     */
    public void removeParameter(String windowId, String name) {
-      String type = urlTypeMap.get(url.getType());
-      if (isDebug) {
-         StringBuilder txt = new StringBuilder("Removing ");
-         txt.append("name: ").append(name);
-         txt.append(", type: ").append(type);
-         txt.append(", window ID: ").append(windowId);
-         LOGGER.debug(txt.toString());
-      }
-      if (isPublicRenderParameter(windowId, name)) {
-         throw new IllegalArgumentException("Cannot set a public render parameter to null. Parameter name: " + name);
-      } else {
-         PortalURLParameter pup = new PortalURLParameter(windowId, name, null, type);
-         url.removeParameter(pup);
-      }
+      paramFactory.removeParameter(windowId, name);
    }
+
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/aef314f7/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
index 1655bf0..74a67a0 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
@@ -212,49 +212,6 @@ public class RelativePortalURLImpl implements PortalURL {
       return renderPath;
    }
 
-   protected void addParameter(PortalURLParameter param) {
-      if (isDebug) {
-         StringBuilder txt = new StringBuilder(
-               "Adding private parameter: ");
-         txt.append(" window ID: " + param.getWindowId());
-         txt.append(", Name: " + param.getName());
-         String vals = (param.getValues() == null) 
-               ? "null" : Arrays.toString(param.getValues());
-         txt.append(", Values: " + vals);
-         txt.append(", Type: " + param.getType());
-         txt.append(", Clone ID: " + cloneId);
-         LOG.debug(txt.toString());
-      }
-      
-      // If present, remove old value before adding new
-      if (parameters.contains(param)) {
-         parameters.remove(param);
-      }
-      parameters.add(param);
-   }
-
-   public void setParameter(PortalURLParameter param) {
-      handleServletRequestParams();
-      if (isDebug) {
-         StringBuilder txt = new StringBuilder(
-               "Setting private parameter: ");
-         txt.append(" window ID: " + param.getWindowId());
-         txt.append(", Name: " + param.getName());
-         String vals = (param.getValues() == null) 
-               ? "null" : Arrays.toString(param.getValues());
-         txt.append(", Values: " + vals);
-         txt.append(", Type: " + param.getType());
-         txt.append(", Clone ID: " + cloneId);
-         LOG.debug(txt.toString());
-      }
-      
-      // If present, remove old value before adding new
-      if (parameters.contains(param)) {
-         parameters.remove(param);
-      }
-      parameters.add(param);
-   }
-
    public Collection<PortalURLParameter> getParameters() {
       handleServletRequestParams();
       return parameters;
@@ -307,27 +264,6 @@ public class RelativePortalURLImpl implements PortalURL {
       this.windowStates.put(windowId, windowState);
    }
 
-   /**
-    * Clear parameters of the specified window.
-    * 
-    * @param windowId
-    *           the window ID.
-    */
-   public void clearParameters(String windowId) {
-      HashSet<PortalURLParameter> rem = new HashSet<PortalURLParameter>();
-      for (PortalURLParameter p : parameters) {
-         if (p.getWindowId().equals(windowId)) {
-            rem.add(p);
-         }
-      }
-      if (isDebug) {
-         StringBuilder txt = new StringBuilder("Removing ");
-         txt.append(rem.size()).append(" elements. Window ID: ").append(windowId);
-         LOG.debug(txt.toString());
-      }
-      parameters.removeAll(rem);
-   }
-
    public void setCacheability(String cacheLevel) {
       this.cacheLevel = cacheLevel;
    }
@@ -431,7 +367,7 @@ public class RelativePortalURLImpl implements PortalURL {
 
       portalURL.cloneId = ++cloneCtr;
 
-      if (isDebug) {
+      if (isTrace) {
          long tid = Thread.currentThread().getId();
          StringBuilder txt = new StringBuilder();
          txt.append("Created clone ID= ").append(portalURL.cloneId);
@@ -444,7 +380,7 @@ public class RelativePortalURLImpl implements PortalURL {
 
    public PageConfig getPageConfig(ServletContext servletContext) {
       String requestedPageId = getRenderPath();
-      if (isDebug) {
+      if (isTrace) {
          LOG.debug("Requested Page: " + requestedPageId);
       }
 
@@ -459,82 +395,9 @@ public class RelativePortalURLImpl implements PortalURL {
       return paco;
    }
 
-   public synchronized void merge(PortalURL url, String windowId) {
-      if (isDebug) {
-         if (url.getClass().isInstance(this)) {
-            long tid = Thread.currentThread().getId();
-            RelativePortalURLImpl turl = (RelativePortalURLImpl) url;
-            StringBuilder txt = new StringBuilder();
-            txt.append("Merging URL with clone ID= ").append(turl.cloneId);
-            txt.append(" into URL with clone ID= ").append(cloneId);
-            txt.append(". ThreadId=").append(tid);
-            LOG.debug(txt.toString());
-         }
-      }
-      type = url.getType();
-      targetWindow = url.getTargetWindow();
-      setPortletMode(windowId, url.getPortletMode(windowId));
-      setWindowState(windowId, url.getWindowState(windowId));
-      setCacheability(url.getCacheability());
-      setResourceID(url.getResourceID());
-      clearParameters(windowId);
-      for (PortalURLParameter param : url.getParameters()) {
-         if (windowId.equals(param.getWindowId())) {
-            addParameter(param.clone());
-         }
-      }
-      PublicRenderParameterMapper prpm = url.getPublicRenderParameterMapper();
-      List<Integer> activePrps = prpm.getActiveIndexes();
-      for (int ii = 0; ii < prpm.getNumberOfGroups(); ii++) {
-         if (activePrps.contains(ii)) {
-            prpMapper.setValues(ii, prpm.getValues(ii));
-         } else {
-            prpMapper.setRemoved(ii, true);
-         }
-      }
-   }
-
-   public void addPublicRenderParameter(PortalURLPublicParameter pup) {
-      handleServletRequestParams();
-      if (isDebug) {
-         StringBuilder txt = new StringBuilder(
-               "Setting public render parameter: ");
-         txt.append(" window ID: " + pup.getWindowId());
-         txt.append(", Name: " + pup.getName());
-         txt.append(", QName: " + pup.getQName());
-         txt.append(", Values: " + Arrays.toString(pup.getValues()));
-         LOG.debug(txt.toString());
-      }
-      int ind = prpMapper.getIndex(pup);
-      if (ind >= 0) {
-         if (pup.isRemoved()) {
-            prpMapper.setRemoved(ind, true);
-         } else {
-            prpMapper.setValues(ind, pup.getValues());
-         }
-      } else {
-         StringBuilder txt = new StringBuilder(
-               "Public render parameter is not contained in mapper.");
-         txt.append(" window ID: " + pup.getWindowId());
-         txt.append(", Name: " + pup.getName());
-         txt.append(", QName: " + pup.getQName());
-         txt.append(", Values: " + Arrays.toString(pup.getValues()));
-         LOG.warn(txt.toString());
-      }
-   }
-
-   public void setPublicRenderParameterMapper(PublicRenderParameterMapper prpm) {
-      prpMapper = prpm;
-   }
-
-   public PublicRenderParameterMapper getPublicRenderParameterMapper() {
-      handleServletRequestParams();
-      return prpMapper;
-   }
-
    public void setPortletIds(Collection<String> portletIds) {
       this.portletIds.addAll(portletIds);
-      if (isDebug) {
+      if (isTrace) {
          LOG.debug("Stored " + this.portletIds.size() + " IDs: "
                + Arrays.toString(this.portletIds.toArray()));
       }
@@ -613,6 +476,27 @@ public class RelativePortalURLImpl implements PortalURL {
       return targetWindow;
    }
 
+   /**
+    * Clear parameters of the specified window.
+    * 
+    * @param windowId
+    *           the window ID.
+    */
+   public void clearParameters(String windowId) {
+      HashSet<PortalURLParameter> rem = new HashSet<PortalURLParameter>();
+      for (PortalURLParameter p : parameters) {
+         if (p.getWindowId().equals(windowId)) {
+            rem.add(p);
+         }
+      }
+      if (isTrace) {
+         StringBuilder txt = new StringBuilder("Removing ");
+         txt.append(rem.size()).append(" elements. Window ID: ").append(windowId);
+         LOG.debug(txt.toString());
+      }
+      parameters.removeAll(rem);
+   }
+
    /*
     * (non-Javadoc)
     * 
@@ -629,7 +513,7 @@ public class RelativePortalURLImpl implements PortalURL {
             rem.add(pup);
          }
       }
-      if (isDebug) {
+      if (isTrace) {
          StringBuilder txt = new StringBuilder("Removing ");
          txt.append(rem.size()).append(" elements. Window ID: ").append(window);
          LOG.debug(txt.toString());
@@ -637,11 +521,63 @@ public class RelativePortalURLImpl implements PortalURL {
       parameters.removeAll(rem);
    }
 
+   protected void addParameter(PortalURLParameter param) {
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder(
+               "Adding private parameter: ");
+         txt.append(" window ID: " + param.getWindowId());
+         txt.append(", Name: " + param.getName());
+         String vals = (param.getValues() == null) 
+               ? "null" : Arrays.toString(param.getValues());
+         txt.append(", Values: " + vals);
+         txt.append(", Type: " + param.getType());
+         txt.append(", Clone ID: " + cloneId);
+         LOG.debug(txt.toString());
+      }
+      
+      // If present, remove old value before adding new
+      if (parameters.contains(param)) {
+         parameters.remove(param);
+      }
+      parameters.add(param);
+   }
+
+   public void setParameter(PortalURLParameter param) {
+      handleServletRequestParams();
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder(
+               "Setting private parameter: ");
+         txt.append(" window ID: " + param.getWindowId());
+         txt.append(", Name: " + param.getName());
+         String vals = (param.getValues() == null) 
+               ? "null" : Arrays.toString(param.getValues());
+         txt.append(", Values: " + vals);
+         txt.append(", Type: " + param.getType());
+         txt.append(", Clone ID: " + cloneId);
+         LOG.debug(txt.toString());
+      }
+      
+      // If present, remove old value before adding new
+      if (parameters.contains(param)) {
+         parameters.remove(param);
+      }
+      parameters.add(param);
+   }
+
    public PortletParameterFactory getPortletParameterFactory() {
       handleServletRequestParams();
       return new PortletParameterFactory(this);
    }
 
+   public void setPublicRenderParameterMapper(PublicRenderParameterMapper prpm) {
+      prpMapper = prpm;
+   }
+
+   public PublicRenderParameterMapper getPublicRenderParameterMapper() {
+      handleServletRequestParams();
+      return prpMapper;
+   }
+
    public void removeParameter(PortalURLParameter param) {
       handleServletRequestParams();
       if (isDebug) {

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/aef314f7/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalRequestContext.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalRequestContext.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalRequestContext.java
index 4be17d2..fab553b 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalRequestContext.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalRequestContext.java
@@ -132,14 +132,6 @@ public class PortalRequestContext {
 
     public synchronized void mergePortalURL(PortalURL portalURL, String windowId){
        requestedPortalURL = portalURL;
-//         if (requestedPortalURL == null)
-//         {
-//             requestedPortalURL = portalURL;
-//         }
-//         else
-//         {
-//             requestedPortalURL.merge(portalURL, windowId);
-//         }
     }
 
 	public ServletContext getServletContext() {

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/aef314f7/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
index caa123c..20a3b9b 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
@@ -89,13 +89,6 @@ public interface PortalURL extends Cloneable {
    public void removePublicRenderParameter(PortalURLPublicParameter param);
 
    /**
-    * Adds a new public render parameter.
-    * 
-    * @param pup
-    */
-   public void addPublicRenderParameter(PortalURLPublicParameter pup);
-
-   /**
     * Add the PRP mapper for the page being processed
     * @param prpm
     */
@@ -180,8 +173,6 @@ public interface PortalURL extends Cloneable {
    void setResourceID(String resourceID);
    String getResourceID();
 
-   void merge(PortalURL url, String windowId);
-
    /**
     * @param window
     */

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/aef314f7/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java
index dbcb7ec..a872478 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java
@@ -24,6 +24,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.pluto.driver.services.portal.PublicRenderParameterMapper;
 import org.apache.pluto.driver.url.PortalURL.URLType;
@@ -55,6 +56,14 @@ public class PortletParameterFactory {
       actionTypes.add(URLType.PartialAction);
    }
    
+   private final static HashMap<PortalURL.URLType, String> urlTypeMap  = 
+         new HashMap<PortalURL.URLType, String>();
+   static {
+      urlTypeMap.put(URLType.Action, PortalURLParameter.PARAM_TYPE_ACTION);
+      urlTypeMap.put(URLType.Render, PortalURLParameter.PARAM_TYPE_RENDER);
+      urlTypeMap.put(URLType.Resource, PortalURLParameter.PARAM_TYPE_RESOURCE);
+   }
+   
    public PortletParameterFactory(PortalURL url) {
       this.url = url;
    }
@@ -198,4 +207,164 @@ public class PortletParameterFactory {
       return parameters;
    }
 
+   public void addPublicRenderParameter(String windowId, String name, String[] values) {
+      PublicRenderParameterMapper prpMapper = url.getPublicRenderParameterMapper();
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder("Add PRP. Window: ");
+         txt.append(windowId).append(", name: ").append(name)
+               .append(", values = ").append(Arrays.toString(values));
+         LOGGER.debug(txt.toString());
+      }
+      int index = prpMapper.getIndex(windowId, name);
+      if (index >= 0) {
+         prpMapper.setValues(index, values);
+      } else {
+         StringBuilder txt = new StringBuilder(
+               "Public render parameter for window: ");
+         txt.append(windowId).append(", name: ").append(name)
+               .append(" not found in mapper");
+         LOGGER.warn(txt.toString());
+      }
+   }
+
+   public void removePublicRenderParameter(String windowId, String name) {
+      PublicRenderParameterMapper prpMapper = url.getPublicRenderParameterMapper();
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder("Remove PRP. Window: ");
+         txt.append(windowId).append(", name: ").append(name);
+         LOGGER.debug(txt.toString());
+      }
+      int index = prpMapper.getIndex(windowId, name);
+      if (index >= 0) {
+         prpMapper.setRemoved(index, true);
+      } else {
+         StringBuilder txt = new StringBuilder("Public render parameter for window: ");
+         txt.append(windowId).append(", name: ").append(name)
+            .append(" not found in mapper");
+         LOGGER.warn(txt.toString());
+      }
+   }
+
+   public boolean isPublicRenderParameter(String windowId, String name) {
+      PublicRenderParameterMapper prpMapper = url.getPublicRenderParameterMapper();
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder(
+               "isPublicRenderParameter Window: ");
+         txt.append(windowId).append(", name: ").append(name);
+         LOGGER.debug(txt.toString());
+      }
+      int index = prpMapper.getIndex(windowId, name);
+      return (index >= 0);
+   }
+
+   // This method is for V2 compatibility. It always returns the private 
+   // parameter names for the active URL type - Render parameters for a render URL,
+   // Action parameters for an action URL, and resouce parameters for a Resource URL.
+   public Set<String> getPrivateParameterNames(String windowId) {
+      HashSet<String> names = new HashSet<String>();
+      String type = urlTypeMap.get(url.getType());
+      
+      for (PortalURLParameter p : url.getParameters()) {
+         if (p.getWindowId().equals(windowId) && p.getType().equals(type)) {
+            names.add(p.getName());
+         }
+      }
+
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder();
+         txt.append("Window ID: ").append(windowId);
+         txt.append(", URL / Parameter type: ").append(type);
+         txt.append(", names: ").append(names.toString());
+         LOGGER.debug(txt.toString());
+      }
+
+      return names;
+   }
+
+   // This method is for V2 compatibility. It always returns the private 
+   // parameter values for the active URL type - Render parameters for a render URL,
+   // Action parameters for an action URL, and resouce parameters for a Resource URL.
+   public String[] getParameterValues(String windowId, String name) {
+      PublicRenderParameterMapper prpMapper = url.getPublicRenderParameterMapper();
+      String type = urlTypeMap.get(url.getType());
+      String[] vals = null;
+      
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder("Setting ");
+         txt.append("name: ").append(name);
+         txt.append(", URL / Parameter type: ").append(type);
+         txt.append(", window ID: ").append(windowId);
+         LOGGER.debug(txt.toString());
+      }
+      
+      if (isPublicRenderParameter(windowId, name)) {
+         int index = prpMapper.getIndex(windowId, name);
+         if (index >= 0) {
+            vals = prpMapper.getValues(index).clone();
+         } else {
+            LOGGER.debug("Public render parameter name not found in index.");
+         }
+      } else {
+         for (PortalURLParameter p : url.getParameters()) {
+            if (p.getWindowId().equals(windowId)
+               && p.getName().equals(name) && p.getType().equals(type)) {
+               vals = p.getValues().clone();
+            }
+         }
+      }
+      
+      return vals;
+   }
+
+   /**
+    * Sets a parameter. This method sets a parameter
+    * of type corresponding to the URL type - Action parameter for an Action URL, etc.
+    * V2 compatibility method.
+    */
+   public void setParameter(String windowId, String name, String[] values) {
+      String type = urlTypeMap.get(url.getType());
+      
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder("Setting ");
+         txt.append("name: ").append(name);
+         txt.append(", values: ").append(Arrays.toString(values));
+         txt.append(", type: ").append(type);
+         txt.append(", window ID: ").append(windowId);
+         LOGGER.debug(txt.toString());
+      }
+      
+      if (url.getType() == URLType.Render && isPublicRenderParameter(windowId, name)) {
+         addPublicRenderParameter(windowId, name, values);
+      } else {
+         if (urlTypeMap.containsKey(url.getType())) {
+            PortalURLParameter pup = new PortalURLParameter(windowId, name, values, type);
+            url.setParameter(pup);
+         } else {
+            LOGGER.warn("Unsupported URL / Parameter type: " + url.getType());
+         }
+      }
+   }
+
+   /**
+    * Remove parameter. If the parameter is a public render parameter, 
+    * an <code>IllegalArgumentException</code> is thrown. This method removes a parameter
+    * of type corresponding to the URL type - Action parameter for an Action URL, etc. 
+    * (V3 Spec errata)
+    */
+   public void removeParameter(String windowId, String name) {
+      String type = urlTypeMap.get(url.getType());
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder("Removing ");
+         txt.append("name: ").append(name);
+         txt.append(", type: ").append(type);
+         txt.append(", window ID: ").append(windowId);
+         LOGGER.debug(txt.toString());
+      }
+      if (isPublicRenderParameter(windowId, name)) {
+         throw new IllegalArgumentException("Cannot set a public render parameter to null. Parameter name: " + name);
+      } else {
+         PortalURLParameter pup = new PortalURLParameter(windowId, name, null, type);
+         url.removeParameter(pup);
+      }
+   }
 }


[13/22] portals-pluto git commit: Fixes & more traces

Posted by ms...@apache.org.
Fixes & more traces


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/fe4eb001
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/fe4eb001
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/fe4eb001

Branch: refs/heads/V3Prototype
Commit: fe4eb0016bbd7146d21bac467d2f743a635e7d6a
Parents: 53a16bc
Author: Scott Nicklous <ms...@apache.org>
Authored: Tue Feb 10 23:31:11 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Tue Feb 10 23:31:11 2015 +0100

----------------------------------------------------------------------
 .../container/PortletRequestContextImpl.java    |  5 ++++
 .../PortletStateAwareResponseContextImpl.java   | 31 ++++++++++----------
 .../container/PortletURLProviderImpl.java       | 22 ++++++--------
 3 files changed, 30 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/fe4eb001/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java
index fa5f368..df0e4e7 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java
@@ -52,6 +52,11 @@ public class PortletRequestContextImpl implements PortletRequestContext {
    private PortletConfig       portletConfig;
    private ServletContext      servletContext;
    private Cookie              cookies[];
+   
+   // Nasty trick to make sure the URL provider is loaded first by the container classloader
+   static {
+      PortletURLProviderImpl.load();
+   }
 
    protected PortletWindow       window;
    protected PortletParameterFactory paramFactory;

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/fe4eb001/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
index a9c75bf..84a2d15 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
@@ -61,16 +61,10 @@ public abstract class PortletStateAwareResponseContextImpl extends PortletRespon
                                                 HttpServletResponse containerResponse, PortletWindow window)
     {
         super(container, containerRequest, containerResponse, window);
-        if (isDebug) {
-           LOGGER.debug("Creating PortletURLProviderImpl.");
-        }
-        
         this.portletURLProvider = new PortletURLProviderImpl(getPortalURL(), PortletURLProvider.TYPE.RENDER, window);
         
         if (isDebug) {
-           LOGGER.debug("Done! created PortletURLProviderImpl.");
-           String txt = portletURLProvider.logSomething();
-           LOGGER.debug("URL Provider said: " + txt);
+           LOGGER.debug("Initialized.");
         }
     }
     
@@ -84,19 +78,26 @@ public abstract class PortletStateAwareResponseContextImpl extends PortletRespon
     {
         if (!isClosed())
         {
-            super.close();
-            if (isDebug) {
-               LOGGER.debug("Filtering the URL.");
-            }
-            new PortletURLImpl(this, portletURLProvider).filterURL();
-            if (isDebug) {
-               LOGGER.debug("Applying the changes.");
-            }
+           super.close();
+
+           if (isDebug) {
+              LOGGER.debug("Filtering the URL.");
+           }
+
+           new PortletURLImpl(this, portletURLProvider).filterURL();
+
+           if (isDebug) {
+              LOGGER.debug("Applying the changes.");
+           }
+
            PortalURL url = portletURLProvider.apply();
+           
            if (isDebug) {
               LOGGER.debug("Merging.");
            }
+           
            PortalRequestContext.getContext(getServletRequest()).mergePortalURL(url, getPortletWindow().getId().getStringId());
+           
            if (isDebug) {
               LOGGER.debug("exiting.");
            }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/fe4eb001/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
index 8328e20..8a31c14 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
@@ -47,8 +47,8 @@ import org.apache.pluto.driver.url.PortletParameterFactory;
  *
  */
 public class PortletURLProviderImpl implements PortletURLProvider {
-   private final Logger   LOGGER     = LoggerFactory.getLogger(PortletURLProviderImpl.class);
-   private final boolean  isDebug    = LOGGER.isDebugEnabled();
+   private static final Logger   LOGGER     = LoggerFactory.getLogger(PortletURLProviderImpl.class);
+   private static final boolean  isDebug    = LOGGER.isDebugEnabled();
 
    private final PortalURL                     url;
    private final PublicRenderParameterMapper   prpMapper;
@@ -65,6 +65,13 @@ public class PortletURLProviderImpl implements PortletURLProvider {
 
    private final Set<PortalURLPublicParameter> prpSet     = new HashSet<PortalURLPublicParameter>();
 
+   // Hack: called to force class loading in Container thread
+   protected static final void load() {
+      if (isDebug) {
+         LOGGER.debug("Loaded.");
+      }
+   };
+   
    public PortletURLProviderImpl(PortalURL url, TYPE type,
          PortletWindow portletWindow) {
       this.url = url.clone();
@@ -82,17 +89,6 @@ public class PortletURLProviderImpl implements PortletURLProvider {
          LOGGER.debug(txt.toString());
       }
    }
-   
-   public String logSomething() {
-      LOGGER.debug("Here is a debug message from " + this.getClass().getCanonicalName());
-      LOGGER.warn("Here is a message from " + this.getClass().getCanonicalName());
-      LOGGER.error("Here is a 'debug' !string, how is that?");
-      StringBuilder txt = new StringBuilder();
-      txt.append("Info about logger. isDebug=").append(isDebug);
-      txt.append(", Name=").append(LOGGER.getName());
-      txt.append(", Root Logger Name=").append(LOGGER.ROOT_LOGGER_NAME);
-      return txt.toString();
-   }
 
    /**
     * Returns <code>true</code> if given parameter name is a public render


[07/22] portals-pluto git commit: Worked on URL preparations for new parameter handling

Posted by ms...@apache.org.
Worked on URL preparations for new parameter handling


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/64c07496
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/64c07496
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/64c07496

Branch: refs/heads/V3Prototype
Commit: 64c0749658875b51ebfd4727b9aae921578d72c3
Parents: 727abbe
Author: Scott Nicklous <ms...@apache.org>
Authored: Sat Feb 7 22:02:24 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Sat Feb 7 22:02:24 2015 +0100

----------------------------------------------------------------------
 .../container/PortletURLProviderImpl.java       |  14 +-
 .../driver/url/impl/PortalURLParserImpl.java    |  70 ++-
 .../driver/url/impl/RelativePortalURLImpl.java  | 161 ++++---
 .../apache/pluto/driver/PortalDriverFilter.java |  11 +-
 .../pluto/driver/PortalDriverServlet.java       | 425 +++++++++----------
 .../org/apache/pluto/driver/url/PortalURL.java  | 254 +++++------
 .../pluto/driver/url/PortalURLParameter.java    |   3 +
 7 files changed, 508 insertions(+), 430 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/64c07496/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
index fc5c564..73244b9 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
@@ -37,6 +37,7 @@ import javax.xml.namespace.QName;
 import org.apache.pluto.container.PortletURLProvider;
 import org.apache.pluto.container.PortletWindow;
 import org.apache.pluto.driver.url.PortalURL;
+import org.apache.pluto.driver.url.PortalURL.URLType;
 import org.apache.pluto.driver.url.PortalURLParameter;
 import org.apache.pluto.driver.url.PortalURLPublicParameter;
 
@@ -87,14 +88,13 @@ public class PortletURLProviderImpl implements PortletURLProvider
         PortalURL url = this.url.clone();
         if (PortletURLProvider.TYPE.ACTION == type)
         {
-            url.setActionWindow(window);
-            url.setResourceWindow(null);
-            url.clearParameters(window);
+           url.setTargetWindow(window);
+           url.setType(URLType.Action);
         }
         else if (PortletURLProvider.TYPE.RESOURCE == type)
         {
-            url.setActionWindow(null);
-            url.setResourceWindow(window);
+           url.setTargetWindow(window);
+           url.setType(URLType.Resource);
             if (!ResourceURL.FULL.equals(cacheLevel))
             {
                 for (PortalURLParameter parm : url.getParameters())
@@ -109,8 +109,8 @@ public class PortletURLProviderImpl implements PortletURLProvider
         }
         else
         {
-            url.setResourceWindow(null);
-            url.setActionWindow(null);
+            url.setTargetWindow(window);
+            url.setType(URLType.Render);
             url.clearParameters(window);
         }
         if (portletMode != null)

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/64c07496/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
index 7643acb..6bc7a24 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
@@ -38,6 +38,7 @@ import org.apache.pluto.driver.config.DriverConfiguration;
 import org.apache.pluto.driver.services.portal.PortletWindowConfig;
 import org.apache.pluto.driver.services.portal.PublicRenderParameterMapper;
 import org.apache.pluto.driver.url.PortalURL;
+import org.apache.pluto.driver.url.PortalURL.URLType;
 import org.apache.pluto.driver.url.PortalURLParameter;
 import org.apache.pluto.driver.url.PortalURLParser;
 import org.apache.pluto.driver.url.PortalURLPublicParameter;
@@ -60,8 +61,6 @@ public class PortalURLParserImpl implements PortalURLParser {
    private static final String PREFIX = "__";
    private static final String DELIM = "_";
    private static final String PORTLET_ID = "pd";
-   private static final String ACTION = "ac";
-   private static final String RESOURCE = "rs";
    private static final String RESOURCE_ID = "ri";
    private static final String CACHE_LEVEL = "cl";
    private static final String RENDER_PARAM = "rp";
@@ -71,8 +70,12 @@ public class PortalURLParserImpl implements PortalURLParser {
    private static final String PORTLET_MODE = "pm";
    private static final String VALUE_DELIM = "0x0";
 
+   private static final String ACTION = "ac";
+   private static final String RESOURCE = "rs";
    private static final String AJAX_ACTION = "aa";       // new for portlet spec 3
    private static final String PARTIAL_ACTION = "pa";    // new for portlet spec 3
+   private static final String RENDER = "re";            // new for portlet spec 3
+   
    private static final String ACTION_PARAM = "av";      // new for portlet spec 3
    private static final String RESOURCE_PARAM = "rv";    // new for portlet spec 3
 
@@ -130,7 +133,7 @@ public class PortalURLParserImpl implements PortalURLParser {
 
       String urlBase = request.getScheme()+"://" + request.getServerName() + ":" + request.getServerPort();
       // Construct portal URL using info retrieved from servlet request.
-      PortalURL portalURL =  new RelativePortalURLImpl(urlBase, contextPath, servletName, this);
+      PortalURL portalURL =  new RelativePortalURLImpl(urlBase, contextPath, servletName, this, request);
 
       // Support added for filter.  Should we seperate into a different impl?
       String pathInfo = request.getPathInfo();
@@ -139,7 +142,7 @@ public class PortalURLParserImpl implements PortalURLParser {
             int idx = servletName.indexOf(".jsp")+".jsp".length();
             pathInfo = servletName.substring(idx);
             servletName = servletName.substring(0, idx);
-            portalURL = new RelativePortalURLImpl(urlBase, contextPath, servletName, this);
+            portalURL = new RelativePortalURLImpl(urlBase, contextPath, servletName, this, request);
          } else {
             return portalURL;
          }
@@ -259,25 +262,36 @@ public class PortalURLParserImpl implements PortalURLParser {
 
             // Resource window definition: portalURL.setResourceWindow().
             if (type.equals(RESOURCE)) {
-               portalURL.setResourceWindow(pid);
+               portalURL.setTargetWindow(pid);
+               portalURL.setType(URLType.Resource);
+               continue;
+            }
+
+            // Render window definition: portalURL.setResourceWindow().
+            if (type.equals(RENDER)) {
+               portalURL.setTargetWindow(pid);
+               portalURL.setType(URLType.Render);
                continue;
             }
 
             // Action window definition: portalURL.setActionWindow().
             if (type.equals(ACTION)) {
-               portalURL.setActionWindow(pid);
+               portalURL.setTargetWindow(pid);
+               portalURL.setType(URLType.Action);
                continue;
             }
 
-            // Action window definition: portalURL.setActionWindow().
+            // Ajax Action window definition: portalURL.setActionWindow().
             if (type.equals(AJAX_ACTION)) {
-               portalURL.setAjaxActionWindow(pid);
+               portalURL.setTargetWindow(pid);
+               portalURL.setType(URLType.AjaxAction);
                continue;
             }
 
-            // Action window definition: portalURL.setActionWindow().
+            // Partial Action window definition: portalURL.setActionWindow().
             if (type.equals(PARTIAL_ACTION)) {
-               portalURL.setPartialActionWindow(pid);
+               portalURL.setTargetWindow(pid);
+               portalURL.setType(URLType.PartialAction);
                continue;
             }
 
@@ -387,6 +401,7 @@ public class PortalURLParserImpl implements PortalURLParser {
    public String toString(PortalURL portalURL) {
 
       StringBuilder buffer = new StringBuilder();
+      String targetWindow = portalURL.getTargetWindow();
 
       // Append the server URI and the servlet path.
       buffer.append(portalURL.getServletPath().startsWith("/")?"":"/")
@@ -406,27 +421,39 @@ public class PortalURLParserImpl implements PortalURLParser {
       }
 
       //Append the resource window definition, if it exists.
-      if (portalURL.getResourceWindow() != null) {
-         int index = pids.indexOf(portalURL.getResourceWindow());
+      if (portalURL.getType() == URLType.Resource) {
+         int index = pids.indexOf(targetWindow);
          if (index < 0) {
-            LOG.warn("resource window not found in portlet ID list. PID = " + portalURL.getResourceWindow());
+            LOG.warn("resource window not found in portlet ID list. PID = " + targetWindow);
          } else {
             buffer.append("/");
             buffer.append(PREFIX).append(RESOURCE).append(String.valueOf(index));
          }
       }
+
+      //Append the render window definition, if it exists.
+      if (portalURL.getType() == URLType.Render) {
+         int index = pids.indexOf(targetWindow);
+         if (index < 0) {
+            LOG.warn("render window not found in portlet ID list. PID = " + targetWindow);
+         } else {
+            buffer.append("/");
+            buffer.append(PREFIX).append(RENDER).append(String.valueOf(index));
+         }
+      }
+      
       // Append the action window definition, if it exists.
-      if (portalURL.getActionWindow() != null) {
-         int index = pids.indexOf(portalURL.getActionWindow());
+      if (portalURL.getType() == URLType.Action) {
+         int index = pids.indexOf(targetWindow);
          if (index < 0) {
-            LOG.warn("Action window not found in portlet ID list. PID = " + portalURL.getActionWindow());
+            LOG.warn("Action window not found in portlet ID list. PID = " + targetWindow);
          } else {
             buffer.append("/");
             buffer.append(PREFIX).append(ACTION).append(String.valueOf(index));
          }
       }
 
-      if (portalURL.getResourceWindow() != null)
+      if (portalURL.getType() == URLType.Resource)
       {
          if (portalURL.getCacheability() != null)
          {
@@ -480,10 +507,9 @@ public class PortalURLParserImpl implements PortalURLParser {
          }
 
          // Encode action params in the query appended at the end of the URL.
-         if (portalURL.getActionWindow() != null
-               && portalURL.getActionWindow().equals(param.getWindowId())
-               || (portalURL.getResourceWindow() != null
-               && portalURL.getResourceWindow().equals(param.getWindowId()))) {
+         if (targetWindow.equals(param.getWindowId()) &&
+               (portalURL.getType() == URLType.Action
+               || portalURL.getType() == URLType.Resource)) {
             for (int i = 0; i < param.getValues().length; i++) {
                // FIX for PLUTO-247
                if ( firstParam ) {
@@ -518,7 +544,7 @@ public class PortalURLParserImpl implements PortalURLParser {
       encode(buffer);
 
       // Add the private render parameters
-      if (portalURL.getResourceWindow() != null)
+      if (portalURL.getType() == URLType.Resource)
       {
          Map<String, String[]> privateParamList = portalURL.getPrivateRenderParameters();
          if (privateParamList!=null){

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/64c07496/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
index 4c7c7d3..0cba184 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
@@ -28,6 +28,7 @@ import java.util.Map;
 import javax.portlet.PortletMode;
 import javax.portlet.WindowState;
 import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -51,10 +52,6 @@ public class RelativePortalURLImpl implements PortalURL {
    private String urlBase;
    private String servletPath;
    private String renderPath;
-   private String actionWindow;
-   private String ajaxActionWindow;
-   private String partialActionWindow;
-   private String resourceWindow;
    private String cacheLevel;
    private String resourceID;
 
@@ -72,6 +69,11 @@ public class RelativePortalURLImpl implements PortalURL {
     * representation of this portal url.
     */
    private PortalURLParser urlParser;
+   
+   // The servlet request for delyed parsing of the servlet parameters
+   HttpServletRequest servletRequest;
+   // marks whether the servlet request parameters have been processed.
+   boolean reqParamsProcessed = false;
 
    /** The window states: key is the window ID, value is WindowState. */
    private Map<String, WindowState> windowStates = new HashMap<String, WindowState>();
@@ -79,7 +81,11 @@ public class RelativePortalURLImpl implements PortalURL {
    private Map<String, PortletMode> portletModes = new HashMap<String, PortletMode>();
 
    /** Parameters of the portlet windows. */
-   private Map<String, PortalURLParameter> parameters = new HashMap<String, PortalURLParameter>();
+   private HashSet<PortalURLParameter> parameters = new HashSet<PortalURLParameter>();
+   
+   // Target window & type of URL
+   URLType type = URLType.Portal;      // initially just addresses the portal in general
+   String targetWindow = null;
 
    /**
     * Constructs a PortalURLImpl instance using customized port.
@@ -88,13 +94,15 @@ public class RelativePortalURLImpl implements PortalURL {
     * @param servletName  the servlet name.
     * @param urlParser    the {@link PortalURLParser} used to construct a string representation of the url.
     */
-   public RelativePortalURLImpl(String urlBase, String contextPath, String servletName, PortalURLParser urlParser) {
+   public RelativePortalURLImpl(String urlBase, String contextPath, String servletName, 
+         PortalURLParser urlParser, HttpServletRequest req) {
       this.urlBase = urlBase;
       StringBuffer buffer = new StringBuffer();
       buffer.append(contextPath);
       buffer.append(servletName);
       servletPath = buffer.toString();
       this.urlParser = urlParser;
+      this.servletRequest = req;
    }
 
    /**
@@ -104,6 +112,59 @@ public class RelativePortalURLImpl implements PortalURL {
    private RelativePortalURLImpl() {
       // Do nothing.
    }
+   
+   // reading of the servlet request parameters is delayed until the first time
+   // the parameters are read in order to allow a portlet to potentially set
+   // the character encoding during processAction or serveResource.
+   
+   private void handleReqParams() {
+      if (!reqParamsProcessed && servletRequest != null 
+            && targetWindow != null && type != URLType.Portal) {
+         reqParamsProcessed = true;
+         
+         try {
+            servletRequest.setCharacterEncoding("UTF-8"); // in case it hasn't already been set
+         } catch(Exception e) {}
+         
+         Map<String, String []> parms = servletRequest.getParameterMap();
+         if (!parms.isEmpty()) {
+            
+            // choose the parameter type. Query or POST parameters always target the 
+            // target window, never the general page.
+            
+            String ptype = PortalURLParameter.PARAM_TYPE_RENDER;
+            if (type == URLType.Action || type == URLType.AjaxAction 
+                  || type == URLType.PartialAction) {
+               ptype = PortalURLParameter.PARAM_TYPE_ACTION;
+            } else if (type == URLType.Resource) {
+               ptype = PortalURLParameter.PARAM_TYPE_RESOURCE;
+            }
+            
+            // The semantics is a query or POST parameter overwrites a 
+            // parameter of the same windowId, type and name encoded in the URL.
+            
+            for (String parm : parms.keySet()) {
+               
+               // If it's a render request & target window is set, the parameter might be public
+               if (type == URLType.Render && targetWindow != null) {
+                  int index = prpMapper.getIndex(targetWindow, parm);
+                  if (index >= 0 ) {
+                     prpMapper.setValues(index, parms.get(parm));
+                     continue;
+                  }
+               }
+               
+               // handle private parameter
+               
+               PortalURLParameter pup = new PortalURLParameter(targetWindow, parm, parms.get(parm), ptype);
+               if (parameters.contains(pup)) {
+                  parameters.remove(pup);       // remove the old values
+                  parameters.add(pup);          // add the new values
+               }
+            }
+         }
+      }
+   }
 
    // Public Methods ----------------------------------------------------------
 
@@ -116,35 +177,12 @@ public class RelativePortalURLImpl implements PortalURL {
    }
 
    public void addParameter(PortalURLParameter param) {
-      parameters.put(param.getWindowId() + param.getName(), param);
+      parameters.add(param);
    }
 
    public Collection<PortalURLParameter> getParameters() {
-      return parameters.values();
-   }
-
-   public void setActionWindow(String actionWindow) {
-      this.actionWindow = actionWindow;
-   }
-
-   public String getActionWindow() {
-      return actionWindow;
-   }
-
-   public void setAjaxActionWindow(String window) {
-      this.ajaxActionWindow = window;
-   }
-
-   public String getAjaxActionWindow() {
-      return ajaxActionWindow;
-   }
-
-   public void setPartialActionWindow(String window) {
-      this.partialActionWindow = window;
-   }
-
-   public String getPartialActionWindow() {
-      return partialActionWindow;
+      handleReqParams();
+      return parameters;
    }
 
    public Map<String, PortletMode> getPortletModes() {
@@ -194,13 +232,9 @@ public class RelativePortalURLImpl implements PortalURL {
     * @param windowId  the window ID.
     */
    public void clearParameters(String windowId) {
-      for (Iterator<Map.Entry<String, PortalURLParameter>> it = parameters.entrySet().iterator(); it.hasNext(); ) {
-         Map.Entry<String, PortalURLParameter> entry = it.next();
-         PortalURLParameter param = entry.getValue();
-         if (param.getWindowId()!=null){
-            if (param.getWindowId().equals(windowId)) {
-               it.remove();
-            }
+      for (PortalURLParameter p : parameters) {
+         if (p.getWindowId().equals(windowId)) {
+            parameters.remove(p);
          }
       }
    }
@@ -275,25 +309,28 @@ public class RelativePortalURLImpl implements PortalURL {
    public synchronized PortalURL clone() {
       RelativePortalURLImpl portalURL = new RelativePortalURLImpl();
       portalURL.servletPath = this.servletPath;
-      portalURL.parameters = new HashMap<String, PortalURLParameter>(parameters);
+      portalURL.parameters = new HashSet<PortalURLParameter>(parameters);
       portalURL.privateRenderParameters = new HashMap<String, String[]>(privateRenderParameters);
       portalURL.portletModes = new HashMap<String, PortletMode>(portletModes);
       portalURL.windowStates = new HashMap<String, WindowState>(windowStates);
       portalURL.cacheLevel = cacheLevel;
       portalURL.resourceID = resourceID;
       portalURL.renderPath = renderPath;
-      portalURL.actionWindow = actionWindow;
       portalURL.urlParser = urlParser;
-      portalURL.resourceWindow = resourceWindow;
       portalURL.prpMapper = (prpMapper == null) ? null : prpMapper.clone();
       portalURL.portletIds = new HashSet<String>(portletIds);
       portalURL.versionMap = new HashMap<String, String>(versionMap);
       portalURL.v3Map = new HashMap<String, Boolean>(v3Map);
+      portalURL.servletRequest = servletRequest;
+      portalURL.reqParamsProcessed = reqParamsProcessed;
+      portalURL.type = type;
+      portalURL.targetWindow = targetWindow;
       return portalURL;
    }
 
    public Map<String, String[]> getPrivateRenderParameters()
    {
+      handleReqParams();
       return privateRenderParameters;
    }
 
@@ -313,18 +350,10 @@ public class RelativePortalURLImpl implements PortalURL {
       return paco;
    }
 
-   public String getResourceWindow() {
-      return resourceWindow;
-   }
-
-   public void setResourceWindow(String resourceWindow) {
-      this.resourceWindow = resourceWindow;
-   }
-
    public synchronized void merge(PortalURL url, String windowId)
    {
-      actionWindow = url.getActionWindow();
-      resourceWindow = url.getResourceWindow();
+      type = url.getType();
+      targetWindow = url.getTargetWindow();
       setPortletMode(windowId, url.getPortletMode(windowId));
       setWindowState(windowId, url.getWindowState(windowId));
       setCacheability(url.getCacheability());
@@ -397,4 +426,32 @@ public class RelativePortalURLImpl implements PortalURL {
    public boolean isVersion3(String portletId) {
       return v3Map.get(portletId);
    }
+
+   /* (non-Javadoc)
+    * @see org.apache.pluto.driver.url.PortalURL#setType(org.apache.pluto.driver.url.PortalURL.URLType)
+    */
+   public void setType(URLType type) {
+      this.type = type;
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.pluto.driver.url.PortalURL#getType()
+    */
+   public URLType getType() {
+      return type;
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.pluto.driver.url.PortalURL#setTargetWindow(java.lang.String)
+    */
+   public void setTargetWindow(String windowId) {
+      targetWindow = windowId;
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.pluto.driver.url.PortalURL#getTargetWindow()
+    */
+   public String getTargetWindow() {
+      return targetWindow;
+   }
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/64c07496/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverFilter.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverFilter.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverFilter.java
index 510246a..ca5a834 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverFilter.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverFilter.java
@@ -24,6 +24,7 @@ import org.apache.pluto.driver.core.PortalRequestContext;
 import org.apache.pluto.driver.core.PortletWindowImpl;
 import org.apache.pluto.driver.services.portal.PortletWindowConfig;
 import org.apache.pluto.driver.url.PortalURL;
+import org.apache.pluto.driver.url.PortalURL.URLType;
 
 import javax.portlet.PortletException;
 import javax.servlet.Filter;
@@ -35,6 +36,7 @@ import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+
 import java.io.IOException;
 
 /**
@@ -151,12 +153,11 @@ public class PortalDriverFilter implements Filter {
             new PortalRequestContext(getServletContext(), request, response);
 
         PortalURL portalURL = portalRequestContext.getRequestedPortalURL();
-        String actionWindowId = portalURL.getActionWindow();
 
-        PortletWindowConfig actionWindowConfig =
-            actionWindowId == null
-                ? null
-                : PortletWindowConfig.fromId(actionWindowId);
+        PortletWindowConfig actionWindowConfig = null;
+        if (portalURL.getType() == URLType.Action) {
+           actionWindowConfig = PortletWindowConfig.fromId(portalURL.getTargetWindow());
+        }
 
         // Action window config will only exist if there is an action request.
         if (actionWindowConfig != null) {

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/64c07496/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
index 041c950..8de18c3 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
@@ -1,5 +1,5 @@
 /*
-  * Licensed to the Apache Software Foundation (ASF) under one or more
+ * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
@@ -35,7 +35,9 @@ import org.apache.pluto.driver.core.PortalRequestContext;
 import org.apache.pluto.driver.core.PortletWindowImpl;
 import org.apache.pluto.driver.services.portal.PageConfig;
 import org.apache.pluto.driver.services.portal.PortletWindowConfig;
+import org.apache.pluto.driver.services.portal.RenderConfigService;
 import org.apache.pluto.driver.url.PortalURL;
+import org.apache.pluto.driver.url.PortalURL.URLType;
 import org.apache.pluto.driver.util.PageState;
 
 /**
@@ -47,228 +49,201 @@ import org.apache.pluto.driver.util.PageState;
  */
 public class PortalDriverServlet extends HttpServlet {
 
-    /** Internal Logger. */
-    private static final Logger LOG = LoggerFactory.getLogger(PortalDriverServlet.class);    
-    
-    /** The Portal Driver sServlet Context */
-    private ServletContext servletContext = null;
-    
-    public static final String DEFAULT_PAGE_URI =
-    		"/WEB-INF/themes/pluto-default-theme.jsp";
-    
-    /** The portlet container to which we will forward all portlet requests. */
-    protected PortletContainer container = null;
-
-    /** Character encoding and content type of the response */
-    private String contentType = "";
-
-    // HttpServlet Impl --------------------------------------------------------
-    
-    public String getServletInfo() {
-        return "Pluto Portal Driver Servlet";
-    }
-    
-    /**
-     * Initialize the Portal Driver. This method retrieves the portlet container
-     * instance from the servlet context scope.
-     * @see PortletContainer
-     */
-    public void init() {
-        servletContext = getServletContext();
-        container = (PortletContainer) servletContext.getAttribute(
-        		AttributeKeys.PORTLET_CONTAINER);        
-        String charset = getServletConfig().getInitParameter("charset");
-        if (charset != null && charset.length() > 0) {
-            contentType = "text/html; charset=" + charset;
-        }
-
-    }
-    
-    /**
-     * Handle all requests. All POST requests are passed to this method.
-     * @param request  the incoming HttpServletRequest.
-     * @param response  the incoming HttpServletResponse.
-     * @throws ServletException  if an internal error occurs.
-     * @throws IOException  if an error occurs writing to the response.
-     */
-    public void doGet(HttpServletRequest request, HttpServletResponse response)
-          throws ServletException, IOException {
-       if (LOG.isDebugEnabled()) {
-          LOG.debug("Start of PortalDriverServlet.doGet() to process portlet request . . .");
-       }
-
-       if ( contentType != "" ) {
-          response.setContentType( contentType );
-       }
-
-       PortalRequestContext portalRequestContext =
-             new PortalRequestContext(getServletContext(), request, response);
-
-       PortalURL portalURL = null;
-
-       try {
-          portalURL = portalRequestContext.getRequestedPortalURL();
-       } catch(Exception ex) {
-          String msg = "Cannot handle request for portal URL. Problem: "  + ex.getMessage();
-          LOG.error(msg, ex);
-          throw new ServletException(msg, ex);
-       }
-
-       String ajaxActionWindowId = portalURL.getAjaxActionWindow();
-       String partialActionWindowId = portalURL.getPartialActionWindow();
-       String actionWindowId = portalURL.getActionWindow();
-       String resourceWindowId = portalURL.getResourceWindow();
-
-       PortletWindowConfig windowConfig = null;
-
-       // Action window config will only exist if there is an action request.
-       if (actionWindowId != null) {
-          windowConfig = PortletWindowConfig.fromId(actionWindowId);
-          PortletWindowImpl portletWindow = new PortletWindowImpl(container,
-                windowConfig, portalURL);
-          if (LOG.isDebugEnabled()) {
-             LOG.debug("Processing action request for window: "
-                   + portletWindow.getId().getStringId());
-          }
-          try {
-             container.doAction(portletWindow, request, response, true);
-          } catch (PortletContainerException ex) {
-             LOG.error(ex.getMessage(), ex);
-             throw new ServletException(ex);
-          } catch (PortletException ex) {
-             LOG.error(ex.getMessage(), ex);
-             throw new ServletException(ex);
-          }
-          if (LOG.isDebugEnabled()) {
-             LOG.debug("Action request processed.\n\n");
-          }
-       }
-       
-       // Ajax Action request
-       else if (ajaxActionWindowId != null) {
-          windowConfig = PortletWindowConfig.fromId(ajaxActionWindowId);
-          PortletWindowImpl portletWindow = new PortletWindowImpl(container,
-                windowConfig, portalURL);
-          if (LOG.isDebugEnabled()) {
-             LOG.debug("Processing Ajax Action request for window: "
-                   + portletWindow.getId().getStringId());
-          }
-          try {
-             container.doAction(portletWindow, request, response, false);
-             response.setContentType("application/json");
-             PageState ps = new PageState(request);
-             Writer writer = response.getWriter();
-             String jsondata = ps.toJSONString();
-             LOG.debug("Ajax Action: returning new page state to client: " + jsondata);
-             writer.write(jsondata);
-          } catch (PortletContainerException ex) {
-             LOG.error(ex.getMessage(), ex);
-             throw new ServletException(ex);
-          } catch (PortletException ex) {
-             LOG.error(ex.getMessage(), ex);
-             throw new ServletException(ex);
-          }
-          if (LOG.isDebugEnabled()) {
-             LOG.debug("Ajax Action request processed.\n\n");
-          }
-       }
-       
-       // Partial Action request
-       else if (partialActionWindowId != null) {
-          windowConfig = PortletWindowConfig.fromId(partialActionWindowId);
-          PortletWindowImpl portletWindow = new PortletWindowImpl(container,
-                windowConfig, portalURL);
-          if (LOG.isDebugEnabled()) {
-             LOG.debug("Processing Partial Action request for window: "
-                   + portletWindow.getId().getStringId());
-          }
-          try {
-             container.doAction(portletWindow, request, response, false);
-             
-             // The page state is made available to the ResourceRequest by passing 
-             // it through all layers, which allows for special case processing at
-             // some points.
-             
-             PageState ps = new PageState(request);
-             String jsondata = ps.toJSONString();
-             if (LOG.isDebugEnabled()) {
-                LOG.debug("Partial Action: dump page state:\n" + jsondata);
-             }
-             
-             container.doServeResource(portletWindow, request, response, jsondata);
-          } catch (PortletContainerException ex) {
-             LOG.error(ex.getMessage(), ex);
-             throw new ServletException(ex);
-          } catch (PortletException ex) {
-             LOG.error(ex.getMessage(), ex);
-             throw new ServletException(ex);
-          }
-          if (LOG.isDebugEnabled()) {
-             LOG.debug("Partial Action request processed.\n\n");
-          }
-       }
-       
-       //Resource request
-       else if (resourceWindowId != null) {
-          windowConfig = PortletWindowConfig.fromId(resourceWindowId);
-          PortletWindowImpl portletWindow = new PortletWindowImpl(container,
-                windowConfig, portalURL);
-          if (LOG.isDebugEnabled()) {
-             LOG.debug("Processing resource Serving request for window: "
-                   + portletWindow.getId().getStringId());
-          }
-          try {
-             container.doServeResource(portletWindow, request, response, null);
-          } catch (PortletContainerException ex) {
-             LOG.error(ex.getMessage(), ex);
-             throw new ServletException(ex);
-          } catch (PortletException ex) {
-             LOG.error(ex.getMessage(), ex);
-             throw new ServletException(ex);
-          }
-          if (LOG.isDebugEnabled()) {
-             LOG.debug("Resource serving request processed.\n\n");
-          }
-       }
-       
-       // Otherwise (actionWindowConfig == null), handle the render request.
-       else {
-          if (LOG.isDebugEnabled()) {
-             LOG.debug("Processing render request.");
-          }
-          PageConfig pageConfig = portalURL.getPageConfig(servletContext);
-          if (pageConfig == null)
-          {
-             String renderPath = (portalURL == null ? "" : portalURL.getRenderPath());
-             String msg = "PageConfig for render path [" + renderPath + "] could not be found.";
-             LOG.error(msg);
-             throw new ServletException(msg);
-          }
-
-          request.setAttribute(AttributeKeys.CURRENT_PAGE, pageConfig);
-          String uri = (pageConfig.getUri() != null)
-                ? pageConfig.getUri() : DEFAULT_PAGE_URI;
-                if (LOG.isDebugEnabled()) {
-                   LOG.debug("Dispatching to: " + uri);
-                }
-                RequestDispatcher dispatcher = request.getRequestDispatcher(uri);
-                dispatcher.forward(request, response);
-                if (LOG.isDebugEnabled()) {
-                   LOG.debug("Render request processed.\n\n");
-                }
-       }
-    }
-
-    /**
-     * Pass all POST requests to {@link #doGet(HttpServletRequest, HttpServletResponse)}.
-     * @param request  the incoming servlet request.
-     * @param response  the incoming servlet response.
-     * @throws ServletException if an exception occurs.
-     * @throws IOException if an exception occurs writing to the response.
-     */
-    public void doPost(HttpServletRequest request, HttpServletResponse response)
-    throws ServletException, IOException {
-        doGet(request, response);
-    }
+   private static final long   serialVersionUID = 1L;
+
+   /** Internal Logger. */
+   private static final Logger LOG              = LoggerFactory
+                                                      .getLogger(PortalDriverServlet.class);
+
+   /** The Portal Driver sServlet Context */
+   private ServletContext      servletContext   = null;
+
+   public static final String  DEFAULT_PAGE_URI = "/WEB-INF/themes/pluto-default-theme.jsp";
+
+   /** The portlet container to which we will forward all portlet requests. */
+   protected PortletContainer  container        = null;
+
+   /** Character encoding and content type of the response */
+   private String              contentType      = "";
+
+   // HttpServlet Impl --------------------------------------------------------
+
+   public String getServletInfo() {
+      return "Pluto Portal Driver Servlet";
+   }
+
+   /**
+    * Initialize the Portal Driver. This method retrieves the portlet container
+    * instance from the servlet context scope.
+    * 
+    * @see PortletContainer
+    */
+   public void init() {
+      servletContext = getServletContext();
+      container = (PortletContainer) servletContext
+            .getAttribute(AttributeKeys.PORTLET_CONTAINER);
+      String charset = getServletConfig().getInitParameter("charset");
+      if (charset != null && charset.length() > 0) {
+         contentType = "text/html; charset=" + charset;
+      }
+
+   }
+
+   /**
+    * Handle all requests. All POST requests are passed to this method.
+    * 
+    * @param request
+    *           the incoming HttpServletRequest.
+    * @param response
+    *           the incoming HttpServletResponse.
+    * @throws ServletException
+    *            if an internal error occurs.
+    * @throws IOException
+    *            if an error occurs writing to the response.
+    */
+   public void doGet(HttpServletRequest request, HttpServletResponse response)
+         throws ServletException, IOException {
+      if (LOG.isDebugEnabled()) {
+         LOG.debug("Start of PortalDriverServlet.doGet() to process portlet request . . .");
+      }
+
+      if (contentType != "") {
+         response.setContentType(contentType);
+      }
+
+      PortalRequestContext portalRequestContext = new PortalRequestContext(
+            getServletContext(), request, response);
+
+      PortalURL portalURL = null;
+
+      try {
+         portalURL = portalRequestContext.getRequestedPortalURL();
+      } catch (Exception ex) {
+         String msg = "Cannot handle request for portal URL. Problem: "
+               + ex.getMessage();
+         LOG.error(msg, ex);
+         throw new ServletException(msg, ex);
+      }
+
+      String targetWindow = portalURL.getTargetWindow();
+
+      // Handle Action, Ajax Action, Partial Action, & Resource requests.
+      // Render requests handled subsequently.
+
+      if (targetWindow != null && portalURL.getType() != URLType.Render
+            && portalURL.getType() != URLType.Portal) {
+
+         String reqType = portalURL.getType().toString();
+         PortletWindowConfig windowConfig = PortletWindowConfig.fromId(targetWindow);
+         PortletWindowImpl portletWindow = new PortletWindowImpl(container,
+               windowConfig, portalURL);
+
+         if (LOG.isDebugEnabled()) {
+            LOG.debug("Processing " + reqType + " request for window: "
+                  + portletWindow.getId().getStringId());
+         }
+
+         try {
+            PageState ps;
+            String jsondata;
+            switch (portalURL.getType()) {
+               case Action:
+                  container.doAction(portletWindow, request, response, true);
+                  break;
+               case AjaxAction:
+                  container.doAction(portletWindow, request, response, false);
+                  response.setContentType("application/json");
+                  ps = new PageState(request);
+                  Writer writer = response.getWriter();
+                  jsondata = ps.toJSONString();
+                  LOG.debug("Ajax Action: returning new page state to client: "
+                        + jsondata);
+                  writer.write(jsondata);
+                  break;
+               case PartialAction:
+                  container.doAction(portletWindow, request, response, false);
+
+                  // The page state is made available to the ResourceRequest by
+                  // passing
+                  // it through all layers, which allows for special case
+                  // processing at
+                  // some points.
+
+                  ps = new PageState(request);
+                  jsondata = ps.toJSONString();
+                  if (LOG.isDebugEnabled()) {
+                     LOG.debug("Partial Action: dump page state:\n" + jsondata);
+                  }
+
+                  container.doServeResource(portletWindow, request, response,
+                        jsondata);
+                  break;
+               case Resource:
+                  container.doServeResource(portletWindow, request, response,
+                        null);
+                  break;
+               default:
+                  LOG.warn("Unknown request: " + reqType);
+            }
+         } catch (PortletContainerException ex) {
+            LOG.error(ex.getMessage(), ex);
+            throw new ServletException(ex);
+         } catch (PortletException ex) {
+            LOG.error(ex.getMessage(), ex);
+            throw new ServletException(ex);
+         }
+         if (LOG.isDebugEnabled()) {
+            LOG.debug(reqType + " request processed.\n\n");
+         }
+
+      }
+
+      // Otherwise, handle the render request.
+      else {
+         if (LOG.isDebugEnabled()) {
+            LOG.debug("Processing render request.");
+         }
+
+         PageConfig pageConfig = portalURL.getPageConfig(servletContext);
+
+         if (pageConfig == null) {
+            String renderPath = (portalURL == null ? "" : portalURL.getRenderPath());
+            String msg = "PageConfig for render path [" + renderPath + "] could not be found.";
+            LOG.error(msg);
+            throw new ServletException(msg);
+         }
+
+         request.setAttribute(AttributeKeys.CURRENT_PAGE, pageConfig);
+         String uri = (pageConfig.getUri() != null) ? pageConfig.getUri() : DEFAULT_PAGE_URI;
+         
+         if (LOG.isDebugEnabled()) {
+            LOG.debug("Dispatching to: " + uri);
+         }
+         
+         RequestDispatcher dispatcher = request.getRequestDispatcher(uri);
+         dispatcher.forward(request, response);
+         
+         if (LOG.isDebugEnabled()) {
+            LOG.debug("Render request processed.\n\n");
+         }
+      }
+   }
+
+   /**
+    * Pass all POST requests to
+    * {@link #doGet(HttpServletRequest, HttpServletResponse)}.
+    * 
+    * @param request
+    *           the incoming servlet request.
+    * @param response
+    *           the incoming servlet response.
+    * @throws ServletException
+    *            if an exception occurs.
+    * @throws IOException
+    *            if an exception occurs writing to the response.
+    */
+   public void doPost(HttpServletRequest request, HttpServletResponse response)
+         throws ServletException, IOException {
+      doGet(request, response);
+   }
 }
-

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/64c07496/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
index 37fafa6..48a122c 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
@@ -34,123 +34,139 @@ import org.apache.pluto.driver.services.portal.PublicRenderParameterMapper;
  * To change this template use File | Settings | File Templates.
  */
 public interface PortalURL extends Cloneable {
-    void setRenderPath(String renderPath);
-
-    String getRenderPath();
-
-    void addParameter(PortalURLParameter param);
-    
-    /**
-     * Adds a new public render parameter.
-     * 
-     * @param pup
-     */
-    public void addPublicRenderParameter(PortalURLPublicParameter pup);
-    
-    /**
-     * Add the PRP mapper for the page being processed
-     * @param prpm
-     */
-    public void setPublicRenderParameterMapper(PublicRenderParameterMapper prpm);
-    
-    /**
-     * get the PRP mapper for the page being processed
-     * @return
-     */
-    public PublicRenderParameterMapper getPublicRenderParameterMapper();
-    
-    /**
-     * Stores the portlet window IDs for the portlets on the page
-     * 
-     * @param portletIds
-     */
-    public void setPortletIds(Collection<String> portletIds);
-    
-    /**
-     * Returns the portlet Ids for the portlets on the page
-     * 
-     * @return
-     */
-    public Collection<String> getPortletIds();
-    
-    /**
-     * Sets the version for the given portlet ID
-     * @param portletId
-     * @param version
-     */
-    public void setVersion(String portletId, String version);
-    
-    /**
-     * gets the version for the given portlet ID
-     * @param portletId
-     * @return
-     */
-    public String getVersion(String portletId);
-    
-    /**
-     * Returns <code>true</code> if the given portlet ID refers to a version 3 portlet
-     * @param portletId
-     * @return
-     */
-    public boolean isVersion3(String portletId);
-
-    Collection<PortalURLParameter> getParameters();
-    
-    Map<String, String[]> getPrivateRenderParameters();
-    
-    void setActionWindow(String actionWindow);
-
-    String getActionWindow();
-    
-    // Ajax action & partial action for portlet spec 3
-    
-    void setAjaxActionWindow(String window);
-
-    String getAjaxActionWindow();
-    
-    void setPartialActionWindow(String window);
-
-    String getPartialActionWindow();
-
-    Map<String, PortletMode> getPortletModes();
-
-    PortletMode getPortletMode(String windowId);
-
-    void setPortletMode(String windowId, PortletMode portletMode);
-
-    Map<String, WindowState> getWindowStates();
-
-    WindowState getWindowState(String windowId);
-
-    void setWindowState(String windowId, WindowState windowState);
-
-    void clearParameters(String windowId);
-
-    /**
-     * 
-     * @deprecated use toURL(boolean) instead
-     */
-    String toString();
-    
-    String toURL(boolean absolute);
-
-    String getServerURI();
-
-    String getServletPath();
-
-    PortalURL clone();
-
-    String getResourceWindow();
-
-	void setResourceWindow(String window);
-
-	PageConfig getPageConfig(ServletContext servletContext);
-	
-	void setCacheability(String cacheLevel);
-	String getCacheability();
-	
-	void setResourceID(String resourceID);
-	String getResourceID();
-	
-	void merge(PortalURL url, String windowId);	
+
+   enum URLType {
+      Render,
+      Action,
+      Resource,
+      AjaxAction,
+      PartialAction,
+      Portal;
+   }
+   
+   /**
+    * Sets the URL type
+    * @param type
+    */
+   public void setType(URLType type);
+   
+   /**
+    * Returns the URL Type
+    * @return
+    */
+   public URLType getType();
+   
+   /**
+    * Sets the target window ID for this URL
+    * @param windowId
+    */
+   public void setTargetWindow(String windowId);
+   
+   /**
+    * returns the target window. May be null.
+    * @return
+    */
+   public String getTargetWindow();
+
+   void setRenderPath(String renderPath);
+
+   String getRenderPath();
+
+   void addParameter(PortalURLParameter param);
+
+   /**
+    * Adds a new public render parameter.
+    * 
+    * @param pup
+    */
+   public void addPublicRenderParameter(PortalURLPublicParameter pup);
+
+   /**
+    * Add the PRP mapper for the page being processed
+    * @param prpm
+    */
+   public void setPublicRenderParameterMapper(PublicRenderParameterMapper prpm);
+
+   /**
+    * get the PRP mapper for the page being processed
+    * @return
+    */
+   public PublicRenderParameterMapper getPublicRenderParameterMapper();
+
+   /**
+    * Stores the portlet window IDs for the portlets on the page
+    * 
+    * @param portletIds
+    */
+   public void setPortletIds(Collection<String> portletIds);
+
+   /**
+    * Returns the portlet Ids for the portlets on the page
+    * 
+    * @return
+    */
+   public Collection<String> getPortletIds();
+
+   /**
+    * Sets the version for the given portlet ID
+    * @param portletId
+    * @param version
+    */
+   public void setVersion(String portletId, String version);
+
+   /**
+    * gets the version for the given portlet ID
+    * @param portletId
+    * @return
+    */
+   public String getVersion(String portletId);
+
+   /**
+    * Returns <code>true</code> if the given portlet ID refers to a version 3 portlet
+    * @param portletId
+    * @return
+    */
+   public boolean isVersion3(String portletId);
+
+   Collection<PortalURLParameter> getParameters();
+
+   Map<String, String[]> getPrivateRenderParameters();
+
+   Map<String, PortletMode> getPortletModes();
+
+   PortletMode getPortletMode(String windowId);
+
+   void setPortletMode(String windowId, PortletMode portletMode);
+
+   Map<String, WindowState> getWindowStates();
+
+   WindowState getWindowState(String windowId);
+
+   void setWindowState(String windowId, WindowState windowState);
+
+   void clearParameters(String windowId);
+
+   /**
+    * 
+    * @deprecated use toURL(boolean) instead
+    */
+   String toString();
+
+   String toURL(boolean absolute);
+
+   String getServerURI();
+
+   String getServletPath();
+
+   PortalURL clone();
+
+   PageConfig getPageConfig(ServletContext servletContext);
+
+   void setCacheability(String cacheLevel);
+   String getCacheability();
+
+   void setResourceID(String resourceID);
+   String getResourceID();
+
+   void merge(PortalURL url, String windowId);	
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/64c07496/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLParameter.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLParameter.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLParameter.java
index 46277b6..6477cc6 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLParameter.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLParameter.java
@@ -159,6 +159,9 @@ public class PortalURLParameter {
       if (name != null) {
          hc += 37*hc + name.hashCode();
       }
+      if (type != null) {
+         hc += 37*hc + type.hashCode();
+      }
       return hc;
    }
 


[14/22] portals-pluto git commit: Adapted StateAwareResponseImpl & PortletUrlImpl to updated infrastructure.

Posted by ms...@apache.org.
Adapted StateAwareResponseImpl & PortletUrlImpl to updated infrastructure.


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/b46bff8b
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/b46bff8b
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/b46bff8b

Branch: refs/heads/V3Prototype
Commit: b46bff8b40e29f4a8b3b646a580b128f2d39e50f
Parents: fe4eb00
Author: Scott Nicklous <ms...@apache.org>
Authored: Wed Feb 11 16:49:49 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Wed Feb 11 16:49:49 2015 +0100

----------------------------------------------------------------------
 .../PortletStateAwareResponseContext.java       |  23 +-
 .../pluto/container/PortletURLProvider.java     |  23 +-
 .../pluto/container/impl/PortletURLImpl.java    | 197 +++-------
 .../container/impl/StateAwareResponseImpl.java  | 385 +++++++------------
 .../container/PortletRequestContextImpl.java    |   3 +
 .../PortletStateAwareResponseContextImpl.java   |  40 +-
 .../container/PortletURLProviderImpl.java       | 247 ++++++------
 .../driver/url/impl/PortalURLParserImpl.java    |  12 +-
 .../driver/url/impl/RelativePortalURLImpl.java  |  89 ++++-
 .../portal/PublicRenderParameterMapper.java     |   2 +-
 .../PublicRenderParameterQNameMapper.java       |   6 +-
 .../org/apache/pluto/driver/url/PortalURL.java  |   9 +-
 .../driver/url/PortletParameterFactory.java     |   6 -
 .../java/javax/portlet/StateAwareResponse.java  | 128 ++++--
 14 files changed, 528 insertions(+), 642 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b46bff8b/pluto-container-api/src/main/java/org/apache/pluto/container/PortletStateAwareResponseContext.java
----------------------------------------------------------------------
diff --git a/pluto-container-api/src/main/java/org/apache/pluto/container/PortletStateAwareResponseContext.java b/pluto-container-api/src/main/java/org/apache/pluto/container/PortletStateAwareResponseContext.java
index c89354c..aea640c 100644
--- a/pluto-container-api/src/main/java/org/apache/pluto/container/PortletStateAwareResponseContext.java
+++ b/pluto-container-api/src/main/java/org/apache/pluto/container/PortletStateAwareResponseContext.java
@@ -17,13 +17,11 @@
 package org.apache.pluto.container;
 
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 
 import javax.portlet.Event;
 import javax.portlet.PortletMode;
 import javax.portlet.WindowState;
-import javax.xml.namespace.QName;
 
 /**
  * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
@@ -35,29 +33,10 @@ public interface PortletStateAwareResponseContext extends PortletResponseContext
     void setPortletMode(PortletMode portletMode);
     WindowState getWindowState();
     void setWindowState(WindowState windowState);
-    Map<String, String[]> getRenderParameters();
     EventProvider getEventProvider();
     List<Event> getEvents();
     
     /**
-     * Add a public render parameter including QName to allow for use of
-     * PRP mapping algorithm.
-     *  
-     * @param qn           QName
-     * @param identifier   Identifier for PRP
-     * @param values       values array
-     */
-    void addPublicRenderParameter(QName qn, String identifier, String[] values);
-    
-    /**
-     * Remove the PRP referred to by the QName
-     * 
-     * @param qn
-     * @param identifier   Identifier for PRP
-     */
-    void removePublicRenderParameter(QName qn, String identifier);
-    
-    /**
      * Add a public render parameter for given window ID and parameter name
      *  
      * @param qn           QName
@@ -89,7 +68,7 @@ public interface PortletStateAwareResponseContext extends PortletResponseContext
      * @param windowId
      * @return
      */
-    Set<String> getParameterNames(String windowId);
+    Set<String> getPrivateParameterNames(String windowId);
     
     /**
      * Gets the values array for the given window ID and private parameter name

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b46bff8b/pluto-container-api/src/main/java/org/apache/pluto/container/PortletURLProvider.java
----------------------------------------------------------------------
diff --git a/pluto-container-api/src/main/java/org/apache/pluto/container/PortletURLProvider.java b/pluto-container-api/src/main/java/org/apache/pluto/container/PortletURLProvider.java
index 11b0bb6..330ad1a 100644
--- a/pluto-container-api/src/main/java/org/apache/pluto/container/PortletURLProvider.java
+++ b/pluto-container-api/src/main/java/org/apache/pluto/container/PortletURLProvider.java
@@ -25,7 +25,6 @@ import java.util.Set;
 import javax.portlet.PortletMode;
 import javax.portlet.PortletSecurityException;
 import javax.portlet.WindowState;
-import javax.xml.namespace.QName;
 
 /**
  * Defines the interface used by the portlet container to create Portlet URLs.
@@ -60,26 +59,6 @@ public interface PortletURLProvider {
 
     void setSecure(boolean secure) throws PortletSecurityException;
     boolean isSecure();
-
-    Map<String, String[]> getRenderParameters();
-    
-    /**
-     * Add a public render parameter including QName to allow for use of
-     * PRP mapping algorithm.
-     *  
-     * @param qn           QName
-     * @param identifier   Identifier for PRP
-     * @param values       values array
-     */
-    void addPublicRenderParameter(QName qn, String identifier, String[] values);
-    
-    /**
-     * Remove the PRP referred to by the QName
-     * 
-     * @param qn
-     * @param identifier   Identifier for PRP
-     */
-    void removePublicRenderParameter(QName qn, String identifier);
     
     /**
      * Add a public render parameter for given window ID and parameter name
@@ -118,7 +97,7 @@ public interface PortletURLProvider {
      * @param windowId
      * @return
      */
-    Set<String> getParameterNames(String windowId);
+    Set<String> getPrivateParameterNames(String windowId);
     
     /**
      * Gets the values array for the given window ID and private parameter name

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b46bff8b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletURLImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletURLImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletURLImpl.java
index 0312103..1505bd5 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletURLImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletURLImpl.java
@@ -24,6 +24,7 @@ import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -56,7 +57,8 @@ import org.apache.pluto.container.util.ArgumentUtility;
  * @since 2.0
  */
 public class PortletURLImpl implements PortletURL, ResourceURL {
-    private final Logger LOGGER = LoggerFactory.getLogger(PortletURLImpl.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(PortletURLImpl.class);
+    private static final boolean isDebug = LOGGER.isDebugEnabled();
 
     private PortletResponseContext responseContext;
     private PortalContext portalContext;
@@ -64,13 +66,28 @@ public class PortletURLImpl implements PortletURL, ResourceURL {
     private String cacheLevel = ResourceURL.PAGE;
     private boolean filtering;
     private boolean renderURL;
+    private final String windowId;
+
+    // Called to force class loading in Container thread
+    public static final void load() {
+       if (isDebug) {
+          LOGGER.debug("Loaded.");
+       }
+    };
     
     public PortletURLImpl(PortletResponseContext responseContext, PortletURLProvider urlProvider)
     {
         this.responseContext = responseContext;
         this.portalContext = responseContext.getContainer().getContainerServices().getPortalContext();
+        this.windowId = responseContext.getPortletWindow().getId().getStringId();
         this.urlProvider = urlProvider;
         renderURL = PortletURLProvider.TYPE.RENDER == urlProvider.getType();
+        if (isDebug) {
+           StringBuilder txt = new StringBuilder();
+           txt.append("URL provider type=").append(urlProvider.getType());
+           txt.append(", isRender=").append(renderURL);
+           LOGGER.debug(txt.toString());
+        }
     }
     
     public PortletURLImpl(PortletMimeResponseContext responseContext, PortletURLProvider.TYPE type)
@@ -138,68 +155,6 @@ public class PortletURLImpl implements PortletURL, ResourceURL {
         return false;
     }
     
-    private boolean isPublicRenderParameter(String name)
-    {
-        List<String> publicRenderParameterNames = responseContext.getPortletWindow().getPortletDefinition().getSupportedPublicRenderParameters();
-        return publicRenderParameterNames.isEmpty() ? false : publicRenderParameterNames.contains(name);
-    }
-    
-   private QName getQNameForPRPName(String name) {
-      QName qn = null;
-      PortletDefinition pd = responseContext.getPortletWindow().getPortletDefinition();
-      PortletApplicationDefinition pad = pd.getApplication();
-      List<? extends PublicRenderParameter> prps = pad.getPublicRenderParameters();
-      for (PublicRenderParameter prp : prps) {
-         if (name.equals(prp.getIdentifier())) {
-            qn = prp.getQName();
-            if (qn == null) {
-               String ns = pad.getDefaultNamespace();
-               String lp = prp.getName();
-               if (lp != null) {
-                  qn = new QName(ns, lp);
-               } else {
-                  LOGGER.error("Error in descriptor for " + responseContext.getPortletWindow()
-                        + " - neither QName nor Name is defined");
-               }
-            }
-         }
-      }
-      return qn;
-   }
-        
-    private static String[] cloneParameterValues(String[] values)
-    {
-        int count = 0;
-        for (String s : values)
-        {
-            if (s != null)
-            {
-                count++;
-            }
-        }
-        if (count == 0)
-        {
-            return null;
-        }
-        else if (count < values.length)
-        {
-            String[] copy = new String[count];
-            count = 0;
-            for (String s : values)
-            {
-                if (s != null)
-                {
-                    copy[count++] = s;
-                }
-            }
-            return copy;
-        }
-        else
-        {
-            return values.clone();
-        }
-    }
-    
     public void filterURL()
     {
         if (filtering)
@@ -254,101 +209,59 @@ public class PortletURLImpl implements PortletURL, ResourceURL {
 
     public Map<String, String[]> getParameterMap()
     {
-        Map<String, String[]> parameters = urlProvider.getRenderParameters();
-        if (parameters.isEmpty())
-        {
-            parameters = Collections.emptyMap();
-        }
-        else
-        {
-            parameters = new HashMap<String,String[]>(parameters);
-            for (Map.Entry<String,String[]> entry : parameters.entrySet())
-            {
-                entry.setValue(entry.getValue().clone());
-            }
-        }
-        return parameters;
+       Map<String, String[]> parameters = new HashMap<String, String[]>();
+       Set<String> names = urlProvider.getPrivateParameterNames(windowId);
+       for (String name : names) {
+          String[] vals = urlProvider.getParameterValues(windowId, name);
+          parameters.put(name, vals);
+       }
+       return parameters;
     }
 
     public void setParameter(String name, String value)
     {
         ArgumentUtility.validateNotEmpty("name", name);
-        ArgumentUtility.validateNotNull("value", value);
-        String[] values = new String[]{value};
-        urlProvider.getRenderParameters().put(name, values);
-        if (renderURL && isPublicRenderParameter(name))
-        {
-            QName qn = getQNameForPRPName(name);
-            urlProvider.addPublicRenderParameter(qn, name, values);
+        if (value == null) {
+           urlProvider.removeParameter(windowId, name);
+        } else {
+           String[] values = new String[] { value };
+           urlProvider.setParameter(windowId, name, values);
         }
     }
 
-    public void setParameter(String name, String[] values)
+    public void setParameter(String name, String... values)
     {
         ArgumentUtility.validateNotEmpty("name", name);
         ArgumentUtility.validateNotNull("values", values);
-        values = cloneParameterValues(values);
-        if (values == null )            
-        {
-            throw new IllegalStateException("Illegal Argument: values array is empty or contains only null values");
-        }
-        urlProvider.getRenderParameters().put(name, values);
-        if (renderURL && isPublicRenderParameter(name))
-        {
-            QName qn = getQNameForPRPName(name);
-            urlProvider.addPublicRenderParameter(qn, name, values);
+        if (values == null) {
+           urlProvider.removeParameter(windowId, name);
+        } else {
+           urlProvider.setParameter(windowId, name, values.clone());
         }
     }
 
     public void setParameters(Map<String, String[]> parameters)
     {
         ArgumentUtility.validateNotNull("parameters", parameters);
-        
+
         // validate map first
-        boolean emptyValuesArray;
-        for (Map.Entry<? extends Object, ? extends Object> entry : parameters.entrySet())
-        {
-            if (entry.getKey() == null || entry.getValue() == null)
-            {
-                throw new IllegalArgumentException("parameters map contains a null key or value entry");
-            }
-            if (!(entry.getKey() instanceof String))
-            {
-                throw new IllegalArgumentException("parameters map contains a key which is not of type String");
-            }
-            if (!(entry.getValue() instanceof String[]))
-            {
-                throw new IllegalArgumentException("parameters map contains a value which is not of type String[]");
-            }
-            emptyValuesArray = true;
-            for (String s : (String[])entry.getValue())
-            {
-                if (s != null)
-                {
-                    emptyValuesArray = false;
-                    break;
-                }
-            }
-            if (emptyValuesArray)
-            {
-                throw new IllegalStateException("parameters map contains a values array which is empty or contains only null values");
-            }
+        for (String key : parameters.keySet()) {
+           String[] vals = parameters.get(key);
+           if (key == null || vals == null) {
+              throw new IllegalArgumentException("parameters map contains a null key or values array");
+           }
         }
-        urlProvider.getRenderParameters().clear();
-        if (renderURL)
-        {
-            urlProvider.clearPublicRenderParameters();
+
+        // Remove the parameters that are gone
+        Set<String> currNames = urlProvider.getPrivateParameterNames(windowId);
+        currNames.removeAll(parameters.keySet());
+        for (String name : currNames) {
+           urlProvider.removeParameter(windowId, name);
         }
-        for (Map.Entry<String,String[]> entry : parameters.entrySet())
-        {
-            String[] values = cloneParameterValues(entry.getValue());
-            String key = entry.getKey();
-            urlProvider.getRenderParameters().put(key, values);
-            if (renderURL && isPublicRenderParameter(key))
-            {
-                QName qn = getQNameForPRPName(key);
-                urlProvider.addPublicRenderParameter(qn, key, values);
-            }
+        
+        // Now set the new values
+        for (String key : parameters.keySet()) {
+           urlProvider.setParameter(windowId, key, parameters.get(key));
         }
     }
 
@@ -439,13 +352,7 @@ public class PortletURLImpl implements PortletURL, ResourceURL {
     public void removePublicRenderParameter(String name)
     {
         ArgumentUtility.validateNotEmpty("name", name);
-        if (isPublicRenderParameter(name))
-        {
-            urlProvider.getRenderParameters().remove(name);
-            
-            QName qn = getQNameForPRPName(name);
-            urlProvider.removePublicRenderParameter(qn, name);
-        }
+        urlProvider.removePublicRenderParameter(windowId, name);
     }
 
     // ResourceURL impl ------------------------------------------------------------    

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b46bff8b/pluto-container/src/main/java/org/apache/pluto/container/impl/StateAwareResponseImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/StateAwareResponseImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/StateAwareResponseImpl.java
index a6ead55..e57fb3b 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/StateAwareResponseImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/StateAwareResponseImpl.java
@@ -19,8 +19,8 @@ package org.apache.pluto.container.impl;
 import java.io.Serializable;
 import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -35,262 +35,153 @@ import javax.xml.namespace.QName;
 
 import org.apache.pluto.container.PortletStateAwareResponseContext;
 import org.apache.pluto.container.PortletWindow;
-import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
-import org.apache.pluto.container.om.portlet.PortletDefinition;
-import org.apache.pluto.container.om.portlet.PublicRenderParameter;
 import org.apache.pluto.container.util.ArgumentUtility;
 
 /**
  * Implementation of JSR-286 <code>StateAwareResponse</code>.
- *
+ * 
  * @since 2.0
  */
-public abstract class StateAwareResponseImpl extends PortletResponseImpl implements StateAwareResponse
-{
-   private final Logger LOGGER = LoggerFactory.getLogger(StateAwareResponseImpl.class);
+public abstract class StateAwareResponseImpl extends PortletResponseImpl
+      implements StateAwareResponse {
+   private final Logger  LOGGER  = LoggerFactory.getLogger(StateAwareResponseImpl.class);
+   @SuppressWarnings("unused")
    private final boolean isDebug = LOGGER.isDebugEnabled();
-   
-    private PortletStateAwareResponseContext responseContext;
-    private final String windowId;
-    
-	public StateAwareResponseImpl(PortletStateAwareResponseContext responseContext)
-	{
-		super(responseContext);
-		this.responseContext = responseContext;
-		this.windowId = responseContext.getPortletWindow().getId().getStringId();
-	}
-	
-//     private boolean isPublicRenderParameter(String name)
-//     {
-//         List<String> publicRenderParameterNames = responseContext.getPortletWindow().getPortletDefinition().getSupportedPublicRenderParameters();
-//         return publicRenderParameterNames.isEmpty() ? false : publicRenderParameterNames.contains(name);
-//     }
-//     
-//    private QName getQNameForPRPName(String name) {
-//       QName qn = null;
-//       PortletDefinition pd = responseContext.getPortletWindow().getPortletDefinition();
-//       PortletApplicationDefinition pad = pd.getApplication();
-//       List<? extends PublicRenderParameter> prps = pad.getPublicRenderParameters();
-//       for (PublicRenderParameter prp : prps) {
-//          if (name.equals(prp.getIdentifier())) {
-//             qn = prp.getQName();
-//             if (qn == null) {
-//                String ns = pad.getDefaultNamespace();
-//                String lp = prp.getName();
-//                if (lp != null) {
-//                   qn = new QName(ns, lp);
-//                } else {
-//                   LOGGER.error("Error in descriptor for " + responseContext.getPortletWindow()
-//                         + " - neither QName nor Name is defined");
-//                }
-//             }
-//          }
-//       }
-//       return qn;
-//    }
-        
-	private static String[] cloneParameterValues(String[] values)
-	{
-	    int count = 0;
-	    for (String s : values)
-	    {
-	        if (s != null)
-	        {
-	            count++;
-	        }
-	    }
-	    if (count == 0)
-	    {
-	        return null;
-	    }
-	    else if (count < values.length)
-	    {
-	        String[] copy = new String[count];
-	        count = 0;
-	        for (String s : values)
-	        {
-	            if (s != null)
-	            {
-	                copy[count++] = s;
-	            }
-	        }
-	        return copy;
-	    }
-	    else
-	    {
-	        return values.clone();
-	    }
-	}
-	
-	protected abstract void checkSetStateChanged();
-	
-    protected boolean isWindowStateAllowed(WindowState state)
-    {
-        Enumeration<WindowState> supportedStates = getPortalContext().getSupportedWindowStates();
-        while (supportedStates.hasMoreElements()) {
-            if (supportedStates.nextElement().equals(state))
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-    
-    public PortletMode getPortletMode()
-    {
-        return responseContext.getPortletMode();
-    }
 
-    public Map<String, String[]> getRenderParameterMap()
-    {
-        Map<String, String[]> parameters = new HashMap<String, String[]>(responseContext.getRenderParameters());
-        for (Map.Entry<String,String[]> entry : parameters.entrySet())
-        {
-            entry.setValue(entry.getValue().clone());
-        }
-        return parameters;
-    }
-    
-    public WindowState getWindowState()
-    {
-        return responseContext.getWindowState();
-    }
-    
-    public void removePublicRenderParameter(String name)
-    {
-        ArgumentUtility.validateNotEmpty("name", name);
-        checkSetStateChanged();
-        if (responseContext.isPublicRenderParameter(windowId, name))
-        {
-            responseContext.getRenderParameters().remove(name);
-            
-            responseContext.removePublicRenderParameter(windowId, name);
-        }
-    }
+   private PortletStateAwareResponseContext responseContext;
+   private final String                     windowId;
+
+   public StateAwareResponseImpl(PortletStateAwareResponseContext responseContext) {
+      super(responseContext);
+      this.responseContext = responseContext;
+      this.windowId = responseContext.getPortletWindow().getId().getStringId();
+   }
+
+   protected abstract void checkSetStateChanged();
+
+   protected boolean isWindowStateAllowed(WindowState state) {
+      Enumeration<WindowState> supportedStates = getPortalContext()
+            .getSupportedWindowStates();
+      while (supportedStates.hasMoreElements()) {
+         if (supportedStates.nextElement().equals(state)) {
+            return true;
+         }
+      }
+      return false;
+   }
+
+   public PortletMode getPortletMode() {
+      return responseContext.getPortletMode();
+   }
+
+   public Map<String, String[]> getRenderParameterMap() {
+      Map<String, String[]> parameters = new HashMap<String, String[]>();
+      Set<String> names = responseContext.getPrivateParameterNames(windowId);
+      for (String name : names) {
+         String[] vals = responseContext.getParameterValues(windowId, name);
+         parameters.put(name, vals);
+      }
+      return parameters;
+   }
+
+   public WindowState getWindowState() {
+      return responseContext.getWindowState();
+   }
+
+   public void removePublicRenderParameter(String name) {
+      ArgumentUtility.validateNotEmpty("name", name);
+      checkSetStateChanged();
+      responseContext.removePublicRenderParameter(windowId, name);
+   }
+
+   public void setEvent(QName qname, Serializable value) {
+      ArgumentUtility.validateNotNull("qname", qname);
+      Event event = responseContext.getEventProvider()
+            .createEvent(qname, value);
+      if (event != null) {
+         responseContext.getEvents().add(event);
+      }
+   }
+
+   public void setEvent(String name, Serializable value) {
+      PortletWindow window = getPortletWindow();
+      String defaultNamespace;
+      defaultNamespace = window.getPortletDefinition().getApplication()
+            .getDefaultNamespace();
+      QName qname = new QName(defaultNamespace, name);
+      setEvent(qname, value);
+   }
+
+   public void setPortletMode(PortletMode portletMode)
+         throws PortletModeException {
+      ArgumentUtility.validateNotNull("portletMode", portletMode);
+      if (isPortletModeAllowed(portletMode)) {
+         checkSetStateChanged();
+         responseContext.setPortletMode(portletMode);
+      } else {
+         throw new PortletModeException("Can't set this PortletMode",
+               portletMode);
+      }
+   }
+
+   public void setWindowState(WindowState windowState)
+         throws WindowStateException {
+      ArgumentUtility.validateNotNull("windowState", windowState);
+      if (isWindowStateAllowed(windowState)) {
+         checkSetStateChanged();
+         responseContext.setWindowState(windowState);
+      } else {
+         throw new WindowStateException("Can't set this WindowState",
+               windowState);
+      }
+   }
+
+   public void setRenderParameters(java.util.Map<String, String[]> parameters) {
+      ArgumentUtility.validateNotNull("parameters", parameters);
 
-	public void setEvent(QName qname, Serializable value)
-	{
-        ArgumentUtility.validateNotNull("qname", qname);
-        Event event = responseContext.getEventProvider().createEvent(qname, value);
-        if (event != null)
-        {
-            responseContext.getEvents().add(event);
-        }
-	}
+      // validate map first
+      for (String key : parameters.keySet()) {
+         String[] vals = parameters.get(key);
+         if (key == null || vals == null) {
+            throw new IllegalArgumentException("parameters map contains a null key or values array");
+         }
+      }
+      
+      // Throws exception if state change no longer allowed (for example, after a forward)
+      checkSetStateChanged();
 
-	public void setEvent(String name, Serializable value)
-	{
-	    PortletWindow window = getPortletWindow();
-        String defaultNamespace;
-        defaultNamespace = window.getPortletDefinition().getApplication().getDefaultNamespace();
-        QName qname = new QName(defaultNamespace, name);
-        setEvent(qname, value);
-	}
+      // Remove the parameters that are gone
+      Set<String> currNames = responseContext.getPrivateParameterNames(windowId);
+      currNames.removeAll(parameters.keySet());
+      for (String name : currNames) {
+         responseContext.removeParameter(windowId, name);
+      }
+      
+      // Now set the new values
+      for (String key : parameters.keySet()) {
+         responseContext.setParameter(windowId, key, parameters.get(key));
+      }
+   }
 
-    public void setPortletMode(PortletMode portletMode) throws PortletModeException 
-    {
-        ArgumentUtility.validateNotNull("portletMode", portletMode);
-        if (isPortletModeAllowed(portletMode))
-        {
-            checkSetStateChanged();
-            responseContext.setPortletMode(portletMode);
-        }
-        else 
-        {
-            throw new PortletModeException("Can't set this PortletMode", portletMode);
-        }
-    }
+   public void setRenderParameter(String key, String value) {
+      ArgumentUtility.validateNotEmpty("key", key);
+      checkSetStateChanged();
+      if (value == null) {
+         responseContext.removeParameter(windowId, key);
+      } else {
+         String[] values = new String[] { value };
+         responseContext.setParameter(windowId, key, values);
+      }
+   }
 
-    public void setWindowState(WindowState windowState) throws WindowStateException
-    {
-        ArgumentUtility.validateNotNull("windowState", windowState);
-        if (isWindowStateAllowed(windowState))
-        {
-            checkSetStateChanged();
-            responseContext.setWindowState(windowState);
-        }
-        else 
-        {
-            throw new WindowStateException("Can't set this WindowState", windowState);
-        }
-    }
-	    
-    public void setRenderParameters(java.util.Map<String, String[]> parameters)
-    {
-        ArgumentUtility.validateNotNull("parameters", parameters);
-        
-        // validate map first
-        boolean emptyValuesArray;
-        for (Map.Entry<? extends Object, ? extends Object> entry : parameters.entrySet())
-        {
-            if (entry.getKey() == null || entry.getValue() == null)
-            {
-                throw new IllegalArgumentException("parameters map contains a null key or value entry");
-            }
-            if (!(entry.getKey() instanceof String))
-            {
-                throw new IllegalArgumentException("parameters map contains a key which is not of type String");
-            }
-            if (!(entry.getValue() instanceof String[]))
-            {
-                throw new IllegalArgumentException("parameters map contains a value which is not of type String[]");
-            }
-            emptyValuesArray = true;
-            for (String s : (String[])entry.getValue())
-            {
-                if (s != null)
-                {
-                    emptyValuesArray = false;
-                    break;
-                }
-            }
-            if (emptyValuesArray)
-            {
-                throw new IllegalStateException("parameters map contains a values array which is empty or contains only null values");
-            }
-        }
-        checkSetStateChanged();
-        
-        responseContext.getRenderParameters().clear();
-        for (Map.Entry<String,String[]> entry : parameters.entrySet())
-        {
-            String[] values = cloneParameterValues(entry.getValue());
-            String key = entry.getKey();
-            responseContext.getRenderParameters().put(key, values);
-            if (responseContext.isPublicRenderParameter(windowId, key))
-            {
-                responseContext.addPublicRenderParameter(windowId, key, values);
-            }
-        }
-    }
-    
-    public void setRenderParameter(String key, String value)
-    {
-        ArgumentUtility.validateNotEmpty("key", key);
-        ArgumentUtility.validateNotNull("value", value);
-        checkSetStateChanged();
-        String[] values = new String[]{value};
-        responseContext.getRenderParameters().put(key, values);
-        if (responseContext.isPublicRenderParameter(windowId, key))
-        {
-            responseContext.addPublicRenderParameter(windowId, key, values);
-        }
-    }
-    
-    public void setRenderParameter(String key, String[] values)
-    {
-        ArgumentUtility.validateNotEmpty("key", key);
-        ArgumentUtility.validateNotNull("values", values);
-        values = cloneParameterValues(values);
-        if (values == null )            
-        {
-            throw new IllegalStateException("Illegal Argument: values array is empty or contains only null values");
-        }
-        checkSetStateChanged();
-        responseContext.getRenderParameters().put(key, values);
-        if (responseContext.isPublicRenderParameter(windowId, key))
-        {
-            responseContext.addPublicRenderParameter(windowId, key, values);
-        }
-    }
+   public void setRenderParameter(String key, String... values) {
+      ArgumentUtility.validateNotEmpty("key", key);
+      ArgumentUtility.validateNotNull("values", values);
+      checkSetStateChanged();
+      if (values == null) {
+         responseContext.removeParameter(windowId, key);
+      } else {
+         responseContext.setParameter(windowId, key, values.clone());
+      }
+   }
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b46bff8b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java
index df0e4e7..ebb86e6 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java
@@ -33,6 +33,7 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.pluto.container.PortletContainer;
 import org.apache.pluto.container.PortletRequestContext;
 import org.apache.pluto.container.PortletWindow;
+import org.apache.pluto.container.impl.PortletURLImpl;
 import org.apache.pluto.driver.core.PortalRequestContext;
 import org.apache.pluto.driver.url.PortalURL;
 import org.apache.pluto.driver.url.PortletParameterFactory;
@@ -54,8 +55,10 @@ public class PortletRequestContextImpl implements PortletRequestContext {
    private Cookie              cookies[];
    
    // Nasty trick to make sure the URL provider is loaded first by the container classloader
+   // so that the logs from these classes land in the Pluto log file.
    static {
       PortletURLProviderImpl.load();
+      PortletURLImpl.load();
    }
 
    protected PortletWindow       window;

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b46bff8b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
index 84a2d15..32cda45 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
@@ -17,10 +17,8 @@
 package org.apache.pluto.driver.services.container;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 
 import org.slf4j.Logger;
@@ -31,7 +29,6 @@ import javax.portlet.PortletMode;
 import javax.portlet.WindowState;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import javax.xml.namespace.QName;
 
 import org.apache.pluto.container.EventProvider;
 import org.apache.pluto.container.PortletContainer;
@@ -42,7 +39,6 @@ import org.apache.pluto.container.driver.PlutoServices;
 import org.apache.pluto.container.impl.PortletURLImpl;
 import org.apache.pluto.driver.core.PortalRequestContext;
 import org.apache.pluto.driver.url.PortalURL;
-import org.apache.pluto.driver.url.PortalURLPublicParameter;
 
 /**
  * @version $Id$
@@ -130,11 +126,6 @@ public abstract class PortletStateAwareResponseContextImpl extends PortletRespon
         return isClosed() ? null : portletURLProvider.getPortletMode();
     }
 
-    public Map<String, String[]> getRenderParameters()
-    {
-        return isClosed() ? null : portletURLProvider.getRenderParameters();
-    }
-
     public WindowState getWindowState()
     {
         return isClosed() ? null : portletURLProvider.getWindowState();
@@ -161,33 +152,6 @@ public abstract class PortletStateAwareResponseContextImpl extends PortletRespon
         return isClosed() ? null : new EventProviderImpl(getPortletWindow(), PlutoServices.getServices().getPortletRegistryService());
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.pluto.container.PortletStateAwareResponseContext#addPublicRenderParameter(javax.xml.namespace.QName, java.lang.String, java.lang.String[])
-     */
-    public void addPublicRenderParameter(QName qn, String identifier, String[] values) {
-       if (isDebug) {
-          StringBuilder txt = new StringBuilder("Add PRP. QName = ");
-          txt.append(qn.toString())
-             .append(", ID = ").append(identifier)
-             .append(", values = ").append(Arrays.toString(values));
-          LOGGER.debug(txt.toString());
-       }
-       if (!isClosed()) {
-          portletURLProvider.addPublicRenderParameter(qn, identifier, values);
-       }
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.pluto.container.PortletStateAwareResponseContext#removePublicRenderParameter(javax.xml.namespace.QName, java.lang.String)
-     */
-    public void removePublicRenderParameter(QName qn, String id) {
-       if (isDebug) {
-          LOGGER.debug("Remove PRP. QName = " + qn.toString());
-       }
-       if (!isClosed()) {
-          portletURLProvider.removePublicRenderParameter(qn, id);
-       }
-    }
     
     /**
      * Add a public render parameter for given window ID and parameter name
@@ -235,10 +199,10 @@ public abstract class PortletStateAwareResponseContextImpl extends PortletRespon
      * @param windowId
      * @return
      */
-    public Set<String> getParameterNames(String windowId) {
+    public Set<String> getPrivateParameterNames(String windowId) {
        Set<String> pns = new HashSet<String>();
        if (!isClosed()) {
-          pns = portletURLProvider.getParameterNames(windowId);
+          pns = portletURLProvider.getPrivateParameterNames(windowId);
        }
        return pns;
     }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b46bff8b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
index 8a31c14..a576644 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
@@ -32,7 +32,6 @@ import javax.portlet.PortletMode;
 import javax.portlet.PortletSecurityException;
 import javax.portlet.ResourceURL;
 import javax.portlet.WindowState;
-import javax.xml.namespace.QName;
 
 import org.apache.pluto.container.PortletURLProvider;
 import org.apache.pluto.container.PortletWindow;
@@ -41,7 +40,6 @@ import org.apache.pluto.driver.url.PortalURL;
 import org.apache.pluto.driver.url.PortalURL.URLType;
 import org.apache.pluto.driver.url.PortalURLParameter;
 import org.apache.pluto.driver.url.PortalURLPublicParameter;
-import org.apache.pluto.driver.url.PortletParameterFactory;
 
 /**
  *
@@ -49,18 +47,20 @@ import org.apache.pluto.driver.url.PortletParameterFactory;
 public class PortletURLProviderImpl implements PortletURLProvider {
    private static final Logger   LOGGER     = LoggerFactory.getLogger(PortletURLProviderImpl.class);
    private static final boolean  isDebug    = LOGGER.isDebugEnabled();
+   private static final boolean  isTrace    = LOGGER.isTraceEnabled();
+   
+   private final static HashMap<PortalURL.URLType, String> urlTypeMap  = 
+         new HashMap<PortalURL.URLType, String>();
+   static {
+      urlTypeMap.put(URLType.Action, PortalURLParameter.PARAM_TYPE_ACTION);
+      urlTypeMap.put(URLType.Render, PortalURLParameter.PARAM_TYPE_RENDER);
+      urlTypeMap.put(URLType.Resource, PortalURLParameter.PARAM_TYPE_RESOURCE);
+   }
 
    private final PortalURL                     url;
-   private final PublicRenderParameterMapper   prpMapper;
-   private final PortletParameterFactory       parmFactory;
 
    private final TYPE                          type;
    private final String                        window;
-   private PortletMode                         portletMode;
-   private WindowState                         windowState;
-   private String                              cacheLevel = ResourceURL.PAGE;                            // default
-   private String                              resourceID;
-   private Map<String, String[]>               renderParameters;
    private Map<String, List<String>>           properties;
 
    private final Set<PortalURLPublicParameter> prpSet     = new HashSet<PortalURLPublicParameter>();
@@ -78,52 +78,40 @@ public class PortletURLProviderImpl implements PortletURLProvider {
       this.type = type;
       this.window = portletWindow.getId().getStringId();
 
-      parmFactory = url.getPortletParameterFactory();
-      prpMapper = url.getPublicRenderParameterMapper();
-
       if (isDebug) {
-         StringBuilder txt = new StringBuilder("Constructed PortalURLProviderImpl. ");
+         StringBuilder txt = new StringBuilder("Constructing PortalURLProviderImpl. ");
          txt.append("type=").append(type);
          txt.append(", URL type=").append(url.getType());
-         txt.append(", target=").append(url.getTargetWindow());
+         txt.append(", target=").append(window);
+         txt.append(", URL target=").append(url.getTargetWindow());
          LOGGER.debug(txt.toString());
       }
-   }
-
-   /**
-    * Returns <code>true</code> if given parameter name is a public render
-    * parameter
-    * 
-    * @param name
-    */
-   private boolean isPRP(String name) {
-      boolean found = false;
-      for (PortalURLPublicParameter prp : prpSet) {
-         if (name.equals(prp.getName())) {
-            found = true;
-            break;
-         }
-      }
-      return found;
-   }
-
-   public PortalURL apply() {
-
-      url.setTargetWindow(window);
+      
+      this.url.setTargetWindow(window);
       switch (type) {
       case ACTION:
-         url.setType(URLType.Action);
+         this.url.setType(URLType.Action);
          break;
       case RESOURCE:
-         url.setType(URLType.Resource);
-         url.clearResourceParameters(window);
-         url.setCacheability(ResourceURL.PAGE);
+         this.url.setType(URLType.Resource);
+         this.url.clearResourceParameters(window);
+         this.url.setCacheability(ResourceURL.PAGE);
          break;
       default:
-         url.setType(URLType.Render);
-         url.clearParameters(window);
+         this.url.setType(URLType.Render);
+         this.url.clearParameters(window);
       }
 
+      if (isTrace) {
+         StringBuilder txt = new StringBuilder("Constructed PortalURLProviderImpl, set type. ");
+         txt.append("new URL type=").append(this.url.getType());
+         LOGGER.debug(txt.toString());
+      }
+
+   }
+
+   public PortalURL apply() {
+
       if (isDebug) {
          StringBuilder txt = new StringBuilder("apply URL values: ");
          txt.append("type=").append(type);
@@ -131,17 +119,6 @@ public class PortletURLProviderImpl implements PortletURLProvider {
          txt.append(", target=").append(url.getTargetWindow());
          LOGGER.debug(txt.toString());
       }
-      if (renderParameters != null) {
-         for (Map.Entry<String, String[]> entry : renderParameters.entrySet()) {
-            if (!isPRP(entry.getKey())) {
-               url.addParameter(new PortalURLParameter(window, entry.getKey(),
-                     entry.getValue()));
-            }
-         }
-      }
-      for (PortalURLPublicParameter prp : prpSet) {
-         url.addPublicRenderParameter(prp);
-      }
       return url;
    }
 
@@ -173,13 +150,6 @@ public class PortletURLProviderImpl implements PortletURLProvider {
       return false;
    }
 
-   public Map<String, String[]> getRenderParameters() {
-      if (renderParameters == null) {
-         renderParameters = new HashMap<String, String[]>();
-      }
-      return renderParameters;
-   }
-
    public String getCacheability() {
       return url.getCacheability();
    }
@@ -223,45 +193,8 @@ public class PortletURLProviderImpl implements PortletURLProvider {
       return properties;
    }
 
-   /*
-    * (non-Javadoc)
-    * 
-    * @see
-    * org.apache.pluto.container.PortletURLProvider#addPublicRenderParameter
-    * (javax.xml.namespace.QName, java.lang.String, java.lang.String[])
-    */
-   public void addPublicRenderParameter(QName qn, String identifier,
-         String[] values) {
-      if (isDebug) {
-         StringBuilder txt = new StringBuilder("Add PRP. QName = ");
-         txt.append(qn.toString()).append(", ID = ").append(identifier)
-               .append(", values = ").append(Arrays.toString(values));
-         LOGGER.debug(txt.toString());
-      }
-      PortalURLPublicParameter pupp = new PortalURLPublicParameter(window,
-            identifier, qn, values);
-      prpSet.add(pupp);
-   }
-
-   /*
-    * (non-Javadoc)
-    * 
-    * @see
-    * org.apache.pluto.container.PortletURLProvider#removePublicRenderParameter
-    * (javax.xml.namespace.QName)
-    */
-   public void removePublicRenderParameter(QName qn, String identifier) {
-      if (isDebug) {
-         LOGGER.debug("Remove PRP. QName = " + qn.toString());
-      }
-      PortalURLPublicParameter pupp = new PortalURLPublicParameter(window,
-            identifier, qn);
-      pupp.setRemoved(true);
-      prpSet.add(pupp);
-   }
-
-   public void addPublicRenderParameter(String windowId, String name,
-         String[] values) {
+   public void addPublicRenderParameter(String windowId, String name, String[] values) {
+      PublicRenderParameterMapper prpMapper = url.getPublicRenderParameterMapper();
       if (isDebug) {
          StringBuilder txt = new StringBuilder("Add PRP. Window: ");
          txt.append(windowId).append(", name: ").append(name)
@@ -281,6 +214,7 @@ public class PortletURLProviderImpl implements PortletURLProvider {
    }
 
    public void removePublicRenderParameter(String windowId, String name) {
+      PublicRenderParameterMapper prpMapper = url.getPublicRenderParameterMapper();
       if (isDebug) {
          StringBuilder txt = new StringBuilder("Remove PRP. Window: ");
          txt.append(windowId).append(", name: ").append(name);
@@ -290,15 +224,15 @@ public class PortletURLProviderImpl implements PortletURLProvider {
       if (index >= 0) {
          prpMapper.setRemoved(index, true);
       } else {
-         StringBuilder txt = new StringBuilder(
-               "Public render parameter for window: ");
+         StringBuilder txt = new StringBuilder("Public render parameter for window: ");
          txt.append(windowId).append(", name: ").append(name)
-               .append(" not found in mapper");
+            .append(" not found in mapper");
          LOGGER.warn(txt.toString());
       }
    }
 
    public boolean isPublicRenderParameter(String windowId, String name) {
+      PublicRenderParameterMapper prpMapper = url.getPublicRenderParameterMapper();
       if (isDebug) {
          StringBuilder txt = new StringBuilder(
                "isPublicRenderParameter Window: ");
@@ -320,23 +254,114 @@ public class PortletURLProviderImpl implements PortletURLProvider {
       }
    }
 
-   public Set<String> getParameterNames(String windowId) {
-      // TODO Auto-generated method stub
-      return null;
+   // This method is for V2 compatibility. It always returns the private 
+   // parameter names for the active URL type - Render parameters for a render URL,
+   // Action parameters for an action URL, and resouce parameters for a Resource URL.
+   public Set<String> getPrivateParameterNames(String windowId) {
+      HashSet<String> names = new HashSet<String>();
+      String type = urlTypeMap.get(url.getType());
+      
+      for (PortalURLParameter p : url.getParameters()) {
+         if (p.getWindowId().equals(windowId) && p.getType().equals(type)) {
+            names.add(p.getName());
+         }
+      }
+
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder();
+         txt.append("Window ID: ").append(windowId);
+         txt.append(", URL / Parameter type: ").append(type);
+         txt.append(", names: ").append(names.toString());
+         LOGGER.debug(txt.toString());
+      }
+
+      return names;
    }
 
+   // This method is for V2 compatibility. It always returns the private 
+   // parameter values for the active URL type - Render parameters for a render URL,
+   // Action parameters for an action URL, and resouce parameters for a Resource URL.
    public String[] getParameterValues(String windowId, String name) {
-      // TODO Auto-generated method stub
-      return null;
+      PublicRenderParameterMapper prpMapper = url.getPublicRenderParameterMapper();
+      String type = urlTypeMap.get(url.getType());
+      String[] vals = null;
+      
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder("Setting ");
+         txt.append("name: ").append(name);
+         txt.append(", URL / Parameter type: ").append(type);
+         txt.append(", window ID: ").append(windowId);
+         LOGGER.debug(txt.toString());
+      }
+      
+      if (isPublicRenderParameter(windowId, name)) {
+         int index = prpMapper.getIndex(windowId, name);
+         if (index >= 0) {
+            vals = prpMapper.getValues(index).clone();
+         } else {
+            LOGGER.debug("Public render parameter name not found in index.");
+         }
+      } else {
+         for (PortalURLParameter p : url.getParameters()) {
+            if (p.getWindowId().equals(windowId)
+               && p.getName().equals(name) && p.getType().equals(type)) {
+               vals = p.getValues().clone();
+            }
+         }
+      }
+      
+      return vals;
    }
 
+   /**
+    * Sets a parameter. This method sets a parameter
+    * of type corresponding to the URL type - Action parameter for an Action URL, etc.
+    * V2 compatibility method.
+    */
    public void setParameter(String windowId, String name, String[] values) {
-      // TODO Auto-generated method stub
-
+      String type = urlTypeMap.get(url.getType());
+      
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder("Setting ");
+         txt.append("name: ").append(name);
+         txt.append(", values: ").append(Arrays.toString(values));
+         txt.append(", type: ").append(type);
+         txt.append(", window ID: ").append(windowId);
+         LOGGER.debug(txt.toString());
+      }
+      
+      if (url.getType() == URLType.Render && isPublicRenderParameter(windowId, name)) {
+         addPublicRenderParameter(windowId, name, values);
+      } else {
+         if (urlTypeMap.containsKey(url.getType())) {
+            PortalURLParameter pup = new PortalURLParameter(windowId, name, values, type);
+            url.setParameter(pup);
+         } else {
+            LOGGER.warn("Unsupported URL / Parameter type: " + url.getType());
+         }
+      }
    }
 
+   /**
+    * Remove parameter. If the parameter is a public render parameter, 
+    * an <code>IllegalArgumentException</code> is thrown. This method removes a parameter
+    * of type corresponding to the URL type - Action parameter for an Action URL, etc. 
+    * (V3 Spec errata)
+    */
    public void removeParameter(String windowId, String name) {
-      // TODO Auto-generated method stub
-
+      String type = urlTypeMap.get(url.getType());
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder("Removing ");
+         txt.append("name: ").append(name);
+         txt.append(", type: ").append(type);
+         txt.append(", window ID: ").append(windowId);
+         LOGGER.debug(txt.toString());
+      }
+      if (isPublicRenderParameter(windowId, name)) {
+         throw new IllegalArgumentException("Cannot set a public render parameter to null. Parameter name: " + name);
+      } else {
+         PortalURLParameter pup = new PortalURLParameter(windowId, name, null, type);
+         url.removeParameter(pup);
+      }
    }
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b46bff8b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
index 1a911fd..7e62bd1 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
@@ -138,7 +138,7 @@ public class PortalURLParserImpl implements PortalURLParser {
 
       String urlBase = request.getScheme()+"://" + request.getServerName() + ":" + request.getServerPort();
       // Construct portal URL using info retrieved from servlet request.
-      PortalURL portalURL =  new RelativePortalURLImpl(urlBase, contextPath, servletName, this, request);
+      RelativePortalURLImpl portalURL =  new RelativePortalURLImpl(urlBase, contextPath, servletName, this, request);
 
       // Support added for filter.  Should we separate into a different impl?
       String pathInfo = request.getPathInfo();
@@ -411,7 +411,7 @@ public class PortalURLParserImpl implements PortalURLParser {
     * @param portalURL  the portal URL to convert.
     * @return a URL string representing the portal URL.
     */
-   public String toString(PortalURL portalURL) {
+   public String toString(RelativePortalURLImpl portalURL) {
 
       StringBuilder buffer = new StringBuilder();
       String targetWindow = portalURL.getTargetWindow();
@@ -689,6 +689,14 @@ public class PortalURLParserImpl implements PortalURLParser {
       return buffer.toString();
    }
 
+   /**
+    * This parser is completely married to the URL impl anyway, so let it
+    * blow up if someone tries to use a different URL impl.
+    */
+   public String toString(PortalURL portalURL) {
+      return toString((RelativePortalURLImpl) portalURL);
+   }
+
 //    /**
 //     * Encode special characters contained in the string value.
 //     * @param string  the string value to encode.

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b46bff8b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
index 2d022bb..b93e493 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
@@ -48,9 +48,9 @@ import org.apache.pluto.driver.url.PortletParameterFactory;
  */
 public class RelativePortalURLImpl implements PortalURL {
 
-   private static final Logger         LOG                = LoggerFactory
-                                                                .getLogger(RelativePortalURLImpl.class);
-   private static final boolean        isDebug            = LOG.isDebugEnabled();
+   private static final Logger   LOG      = LoggerFactory.getLogger(RelativePortalURLImpl.class);
+   private static final boolean  isDebug  = LOG.isDebugEnabled();
+   private static final boolean  isTrace  = LOG.isTraceEnabled();
 
    private String                      urlBase;
    private String                      servletPath;
@@ -131,7 +131,7 @@ public class RelativePortalURLImpl implements PortalURL {
    // the parameters are read in order to allow a portlet to potentially set
    // the character encoding during processAction or serveResource.
 
-   public void handleServletRequestParams() {
+   protected void handleServletRequestParams() {
       if (!reqParamsProcessed && servletRequest != null && targetWindow != null
             && type != URLType.Portal) {
          reqParamsProcessed = true;
@@ -209,23 +209,51 @@ public class RelativePortalURLImpl implements PortalURL {
       return renderPath;
    }
 
-   public void addParameter(PortalURLParameter param) {
+   protected void addParameter(PortalURLParameter param) {
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder(
+               "Adding private parameter: ");
+         txt.append(" window ID: " + param.getWindowId());
+         txt.append(", Name: " + param.getName());
+         String vals = (param.getValues() == null) 
+               ? "null" : Arrays.toString(param.getValues());
+         txt.append(", Values: " + vals);
+         txt.append(", Type: " + param.getType());
+         txt.append(", Clone ID: " + cloneId);
+         LOG.debug(txt.toString());
+      }
+      
+      // If present, remove old value before adding new
+      if (parameters.contains(param)) {
+         parameters.remove(param);
+      }
+      parameters.add(param);
+   }
+
+   public void setParameter(PortalURLParameter param) {
+      handleServletRequestParams();
       if (isDebug) {
          StringBuilder txt = new StringBuilder(
                "Setting private parameter: ");
          txt.append(" window ID: " + param.getWindowId());
          txt.append(", Name: " + param.getName());
-         String vals = (param.getValues() == null) ? "null" : Arrays
-               .toString(param.getValues());
+         String vals = (param.getValues() == null) 
+               ? "null" : Arrays.toString(param.getValues());
          txt.append(", Values: " + vals);
          txt.append(", Type: " + param.getType());
          txt.append(", Clone ID: " + cloneId);
          LOG.debug(txt.toString());
       }
+      
+      // If present, remove old value before adding new
+      if (parameters.contains(param)) {
+         parameters.remove(param);
+      }
       parameters.add(param);
    }
 
    public Collection<PortalURLParameter> getParameters() {
+      handleServletRequestParams();
       return parameters;
    }
 
@@ -365,23 +393,34 @@ public class RelativePortalURLImpl implements PortalURL {
     */
    public synchronized PortalURL clone() {
       RelativePortalURLImpl portalURL = new RelativePortalURLImpl();
+
+      portalURL.urlBase = this.urlBase;
       portalURL.servletPath = this.servletPath;
-      portalURL.parameters = new HashSet<PortalURLParameter>(parameters);
-      portalURL.portletModes = new HashMap<String, PortletMode>(portletModes);
-      portalURL.windowStates = new HashMap<String, WindowState>(windowStates);
+      portalURL.renderPath = renderPath;
       portalURL.cacheLevel = cacheLevel;
       portalURL.resourceID = resourceID;
-      portalURL.renderPath = renderPath;
-      portalURL.urlParser = urlParser;
+
       portalURL.prpMapper = (prpMapper == null) ? null : prpMapper.clone();
       portalURL.portletIds = new HashSet<String>(portletIds);
       portalURL.versionMap = new HashMap<String, String>(versionMap);
       portalURL.v3Map = new HashMap<String, Boolean>(v3Map);
+
+      portalURL.urlParser = urlParser;
       portalURL.servletRequest = servletRequest;
       portalURL.reqParamsProcessed = reqParamsProcessed;
+
+      portalURL.windowStates = new HashMap<String, WindowState>(windowStates);
+      portalURL.portletModes = new HashMap<String, PortletMode>(portletModes);
+
+      for (PortalURLParameter p : parameters) {
+         portalURL.parameters.add(p.clone());
+      }
+
       portalURL.type = type;
       portalURL.targetWindow = targetWindow;
+
       portalURL.cloneId = ++cloneCtr;
+
       if (isDebug) {
          long tid = Thread.currentThread().getId();
          StringBuilder txt = new StringBuilder();
@@ -431,8 +470,7 @@ public class RelativePortalURLImpl implements PortalURL {
       clearParameters(windowId);
       for (PortalURLParameter param : url.getParameters()) {
          if (windowId.equals(param.getWindowId())) {
-            addParameter(new PortalURLParameter(param.getWindowId(),
-                  param.getName(), param.getValues()));
+            addParameter(param.clone());
          }
       }
       PublicRenderParameterMapper prpm = url.getPublicRenderParameterMapper();
@@ -447,6 +485,7 @@ public class RelativePortalURLImpl implements PortalURL {
    }
 
    public void addPublicRenderParameter(PortalURLPublicParameter pup) {
+      handleServletRequestParams();
       if (isDebug) {
          StringBuilder txt = new StringBuilder(
                "Setting public render parameter: ");
@@ -479,6 +518,7 @@ public class RelativePortalURLImpl implements PortalURL {
    }
 
    public PublicRenderParameterMapper getPublicRenderParameterMapper() {
+      handleServletRequestParams();
       return prpMapper;
    }
 
@@ -515,6 +555,15 @@ public class RelativePortalURLImpl implements PortalURL {
     * url.PortalURL.URLType)
     */
    public void setType(URLType type) {
+      if (isTrace) {
+         long tid = Thread.currentThread().getId();
+         StringBuilder txt = new StringBuilder();
+         txt.append("old type= ").append(this.type);
+         txt.append(", new type= ").append(type);
+         txt.append(", clone ID= ").append(cloneId);
+         txt.append(". ThreadId=").append(tid);
+         LOG.debug(txt.toString());
+      }
       this.type = type;
    }
 
@@ -524,6 +573,14 @@ public class RelativePortalURLImpl implements PortalURL {
     * @see org.apache.pluto.driver.url.PortalURL#getType()
     */
    public URLType getType() {
+      if (isTrace) {
+         long tid = Thread.currentThread().getId();
+         StringBuilder txt = new StringBuilder();
+         txt.append("type= ").append(this.type);
+         txt.append(", clone ID= ").append(cloneId);
+         txt.append(". ThreadId=").append(tid);
+         LOG.debug(txt.toString());
+      }
       return type;
    }
 
@@ -554,6 +611,7 @@ public class RelativePortalURLImpl implements PortalURL {
     * .String)
     */
    public void clearResourceParameters(String window) {
+      handleServletRequestParams();
       HashSet<PortalURLParameter> rem = new HashSet<PortalURLParameter>();
       for (PortalURLParameter pup : parameters) {
          if (pup.getType().equals(PortalURLParameter.PARAM_TYPE_RESOURCE)
@@ -570,10 +628,12 @@ public class RelativePortalURLImpl implements PortalURL {
    }
 
    public PortletParameterFactory getPortletParameterFactory() {
+      handleServletRequestParams();
       return new PortletParameterFactory(this);
    }
 
    public void removeParameter(PortalURLParameter param) {
+      handleServletRequestParams();
       if (isDebug) {
          StringBuilder txt = new StringBuilder(
                "Removing private render parameter: ");
@@ -589,6 +649,7 @@ public class RelativePortalURLImpl implements PortalURL {
    }
 
    public void removePublicRenderParameter(PortalURLPublicParameter param) {
+      handleServletRequestParams();
       if (isDebug) {
          StringBuilder txt = new StringBuilder(
                "Removing public render parameter: ");

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b46bff8b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PublicRenderParameterMapper.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PublicRenderParameterMapper.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PublicRenderParameterMapper.java
index 1d82e6b..7f45f5f 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PublicRenderParameterMapper.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PublicRenderParameterMapper.java
@@ -115,7 +115,7 @@ public interface PublicRenderParameterMapper {
 
    /**
     * Gets the string value array that is set for all the public render parameters within  
-    * the group specified by the index.
+    * the group specified by the index. Returns null if the PRP is marked as removed.
     * 
     * @param index      Group index
     * @return           String array 

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b46bff8b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PublicRenderParameterQNameMapper.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PublicRenderParameterQNameMapper.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PublicRenderParameterQNameMapper.java
index ab1dcc7..056944f 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PublicRenderParameterQNameMapper.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PublicRenderParameterQNameMapper.java
@@ -218,8 +218,12 @@ public class PublicRenderParameterQNameMapper implements PublicRenderParameterMa
    }
 
    public String[] getValues(int index) {
+      String[] vals = null;
       List<PortalURLPublicParameter> oprps = qn2PRP.get(qnList.get(index));
-      return oprps.get(0).getValues().clone();
+      if (!oprps.get(0).isRemoved()) {
+         vals = oprps.get(0).getValues().clone();
+      }
+      return vals;
    }
 
    public void setRemoved(int index, boolean removed) {

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b46bff8b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
index 6f1e7b4..caa123c 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
@@ -74,7 +74,7 @@ public interface PortalURL extends Cloneable {
 
    String getRenderPath();
 
-   void addParameter(PortalURLParameter param);
+   void setParameter(PortalURLParameter param);
    
    /**
     * Removes the given parameter
@@ -141,13 +141,6 @@ public interface PortalURL extends Cloneable {
     * @return
     */
    public boolean isVersion3(String portletId);
-   
-   /**
-    *  To allow delayed reading of the servlet request parameters until the first time
-    *  the parameters are read in order to allow a portlet to potentially set   
-    *  the character encoding during processAction or serveResource.            
-    */
-   public void handleServletRequestParams();
 
    Collection<PortalURLParameter> getParameters();
 

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b46bff8b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java
index fd63474..be49fec 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java
@@ -67,9 +67,6 @@ public class PortletParameterFactory {
       wid2Action = new HashMap<String, ArrayList<PortalURLParameter>>();
       wid2Resource = new HashMap<String, ArrayList<PortalURLParameter>>();
       
-      //Make sure the servlet request parameters are processed
-      url.handleServletRequestParams();
-      
       for (PortalURLParameter parm : url.getParameters()) {
          if (parm.getType().equals(PortalURLParameter.PARAM_TYPE_ACTION)) {
             addParam(wid2Action, parm);
@@ -151,9 +148,6 @@ public class PortletParameterFactory {
     */
    public Map<String, String[]> getPublicParameterMap(String windowId) {
       HashMap<String, String[]> parameters = new HashMap<String, String[]>();
-      
-      //Make sure the servlet request parameters are processed
-      url.handleServletRequestParams();
 
       PublicRenderParameterMapper mapper = url.getPublicRenderParameterMapper();
       

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/b46bff8b/portlet-api/src/main/java/javax/portlet/StateAwareResponse.java
----------------------------------------------------------------------
diff --git a/portlet-api/src/main/java/javax/portlet/StateAwareResponse.java b/portlet-api/src/main/java/javax/portlet/StateAwareResponse.java
index 3cb87f0..f1de4d4 100644
--- a/portlet-api/src/main/java/javax/portlet/StateAwareResponse.java
+++ b/portlet-api/src/main/java/javax/portlet/StateAwareResponse.java
@@ -25,11 +25,16 @@
 package javax.portlet;
 
 /**
- * The <CODE>StateAwareResponse</CODE> represents a response that can modify
- * state information or send events.<BR>
- * It extends the PortletResponse interface.
+ * <div class="changed_modified_3_0">The
+ * <CODE>StateAwareResponse</CODE> represents a response that can modify
+ * portlet state information or send events.
+ * <p>
+ * If the portlet state is modified through this interface, the changes take
+ * effect for subsequent portlet render phase processing. 
+ * </div>
  * 
  * @since 2.0
+ * @see PortletState
  * @see PortletResponse
  */
 public interface StateAwareResponse extends PortletResponse {
@@ -98,10 +103,11 @@ public interface StateAwareResponse extends PortletResponse {
 	public void setPortletMode(PortletMode portletMode)
 			throws PortletModeException;
 
-	/**
-     * Sets a parameter map for the render request.
-     * <p>
-     * All previously set render parameters are cleared.
+
+   /**
+    * <span class="changed_modified_3_0">Sets</span> 
+    * a parameter map for the render request.
+    * <div class="changed_deleted_3_0">
      * <p>
      * These parameters will be accessible in all sub-sequent render calls via
      * the <code>PortletRequest.getParameter</code> call until a new request
@@ -112,36 +118,71 @@ public interface StateAwareResponse extends PortletResponse {
      * <p>
      * The portlet should not modify the map any further after calling
      * this method.
+    * </div> 
+    * <div class="changed_added_3_0"> 
+    * <p>
+    * This method can be used to set both public and private render parameters. 
+    * <p>
+    * These parameters will be accessible in all subsequent render calls via the
+    * PortletRequest.getParameter call until a new request is targeted to the portlet.
+    * <p>
+    * Any previously set private render parameter that is not contained in the new map
+    * is removed. However, public render parameters cannot be removed by excluding
+    * them from the map. Public render parameters that are not included in the map
+    * remain unchanged.
+    * <p>
+    * The given parameters do not need to be encoded prior to calling this method.
+    * <p>
+    * The portlet should not modify the map any further after calling this method.
+    * </div>
      * 
      * @param parameters
-     *            Map containing parameter names for the render phase as keys
-     *            and parameter values as map values. The keys in the parameter
-     *            map must be of type String. The values in the parameter map
-     *            must be of type String array (<code>String[]</code>).
+    * <span class="changed_modified_3_0">
+    * Map containing parameter names for the render phase as keys and
+    * parameter values as map values. The keys in the parameter map must be of type
+    * String and may not be null or the empty string (""). The values in the parameter
+    * map must be of type String array (<code>String[]</code>). 
+    * The values array may not be null;
+    * however, the values array elements may be null.
+    * </span>
      * 
      * @exception java.lang.IllegalArgumentException
+    * <span class="changed_modified_3_0">
      *                if parameters is <code>null</code>, if any of the
      *                keys in the Map are <code>null</code>, if any of
-     *                the keys is not a String, or if any of the values is not a
-     *                String array.
+    *                the keys is not a String, or if any of the values is not a
+    *                String array. 
+    * </span>
      * @exception java.lang.IllegalStateException
      *                if the method is invoked after <code>sendRedirect</code>
      *                has been called.
+    *                
+    * @deprecated As of version 3.0. Use {@link #getRenderParameters()} instead.
      */
 
+   @Deprecated
 	public void setRenderParameters(java.util.Map<String, String[]> parameters);
 
 	/**
-     * Sets a String parameter for the render request.
+    * <span class="changed_modified_3_0">Sets</span> 
+    * a String parameter for the render request.
      * <p>
-     * These parameters will be accessible in all sub-sequent render calls via
-     * the <code>PortletRequest.getParameter</code> call until a request is
+    * <span class="changed_modified_3_0"> 
+    * These parameters will be accessible in all subsequent render calls 
+    * until an action or render request is
      * targeted to the portlet.
+    * </span>
      * <p>
      * This method replaces all parameters with the given key.
      * <p>
      * The given parameter do not need to be encoded prior to calling this
      * method.
+    * <p>
+    * <span class="changed_added_3_0"> 
+    * A parameter value of <code>null</code> indicates that this
+    * parameter should be removed. 
+    * However, an empty string value ("") is allowed.
+    * </span>
      * 
      * @param key
      *            key of the render parameter
@@ -149,25 +190,43 @@ public interface StateAwareResponse extends PortletResponse {
      *            value of the render parameter
      * 
      * @exception java.lang.IllegalArgumentException
-     *                if key is <code>null</code>.
+    *                if key is <code>null</code>;
+    * <span class="changed_added_3_0"> 
+    *                if an attempt is made to set a public render parameter to <code>null</code>.
+    * </span>                 
      * @exception java.lang.IllegalStateException
      *                if the method is invoked after <code>sendRedirect</code>
      *                has been called.
+    *                
+    * @deprecated As of version 3.0. Use {@link #getRenderParameters()} instead.
      */
 
+   @Deprecated
 	public void setRenderParameter(String key, String value);
 
 	/**
-     * Sets a String array parameter for the render request.
+    * <span class="changed_modified_3_0">Sets
+    * a multi-valued String</span> parameter for the render request.
      * <p>
-     * These parameters will be accessible in all sub-sequent render calls via
-     * the <code>PortletRequest.getParameter</code> call until a request is
+    * <span class="changed_added_3_0"> 
+    * These parameters will be accessible in all subsequent render calls 
+    * until an action or render request is
      * targeted to the portlet.
+    * </span>
      * <p>
-     * This method replaces all parameters with the given key.
+    * This method replaces all parameter values with the given key.
      * <p>
      * The given parameter do not need to be encoded prior to calling this
      * method.
+    * <p>
+    * <span class="changed_added_3_0"> 
+    * A values parameter of <code>null</code> indicates that this
+    * parameter should be removed. 
+    * </span>
+    * <p>
+    * <span class="changed_added_3_0"> 
+    * If the values parameter is not null, elements of the array may be null. 
+    * </span>
      * 
      * @param key
      *            key of the render parameter
@@ -175,13 +234,20 @@ public interface StateAwareResponse extends PortletResponse {
      *            values of the render parameter
      * 
      * @exception java.lang.IllegalArgumentException
-     *                if key or value are <code>null</code>.
+    *                if name is <code>null</code>; 
+    * <span class="changed_added_3_0"> 
+    *                if an element of the values array is <code>null</code>; 
+    *                if an attempt is made to set a public render parameter to <code>null</code>. 
+    * </span>
      * @exception java.lang.IllegalStateException
      *                if the method is invoked after <code>sendRedirect</code>
      *                has been called.
+    *                
+    * @deprecated As of version 3.0. Use {@link #getRenderParameters()} instead.
      */
 
-	public void setRenderParameter(String key, String[] values);
+   @Deprecated
+   public void setRenderParameter(String key, String... values);
 
 	/**
      * Publishes an Event with the given payload.
@@ -236,10 +302,15 @@ public interface StateAwareResponse extends PortletResponse {
 
 
 	/**
-     * Returns a <code>Map</code> of the render parameters currently set on
+    * <span class="changed_modified_3_0">Returns</span> a <code>Map</code> of the render parameters currently set on
      * this response.
      * <p>
-     * The values in the returned <code>Map</code> are from type String array (<code>String[]</code>).
+    * The values in the returned <code>Map</code> are of type String array (<code>String[]</code>).
+    * <p class="changed_added_3_0">
+    * The contents of the returned map are immutable in the sense that modifying the map does not directly 
+    * affect the render parameters. In order to set the parameters using the modified map, 
+    * the {@link StateAwareResponse#setRenderParameters(Map)} method must be used.
+    * </p>
      * <p>
      * If no parameters exist this method returns an empty <code>Map</code>.
      * 
@@ -249,8 +320,11 @@ public interface StateAwareResponse extends PortletResponse {
      *         parameter values as map values, or an empty <code>Map</code> if
      *         no parameters exist. The keys in the parameter map are of type
      *         String. The values in the parameter map are of type String array (<code>String[]</code>).
+    *         
+    * @deprecated As of version 3.0. Use {@link #getRenderParameters()} instead.
      */
 
+   @Deprecated
 	public java.util.Map<String, String[]> getRenderParameterMap();
 
 	/**
@@ -287,6 +361,10 @@ public interface StateAwareResponse extends PortletResponse {
 	 * @exception  java.lang.IllegalArgumentException 
 	 *                            if name is <code>null</code>.
 	 * @since 2.0
+    * 
+    * @deprecated As of version 3.0. Use {@link #getRenderParameters()} instead.
 	 */
+   
+   @Deprecated
 	public void removePublicRenderParameter(String name);
 }


[15/22] portals-pluto git commit: Some fixes for parameter handling problems

Posted by ms...@apache.org.
Some fixes for parameter handling problems


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/bac65740
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/bac65740
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/bac65740

Branch: refs/heads/V3Prototype
Commit: bac6574077c9e72629b2f5b5cc4c563b9e2ebb1d
Parents: b46bff8
Author: Scott Nicklous <ms...@apache.org>
Authored: Wed Feb 11 20:00:19 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Wed Feb 11 20:00:19 2015 +0100

----------------------------------------------------------------------
 .../container/impl/ResourceRequestImpl.java     |  5 ++-
 .../container/PortletURLProviderImpl.java       | 28 +++++++++++++++-
 .../driver/url/impl/RelativePortalURLImpl.java  |  2 +-
 .../driver/url/PortletParameterFactory.java     | 35 ++++++++++++++------
 4 files changed, 54 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/bac65740/pluto-container/src/main/java/org/apache/pluto/container/impl/ResourceRequestImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/ResourceRequestImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/ResourceRequestImpl.java
index 4d87575..b6863ee 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/ResourceRequestImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/ResourceRequestImpl.java
@@ -102,16 +102,15 @@ public class ResourceRequestImpl extends ClientDataRequestImpl implements Resour
       if (LOG.isDebugEnabled()) {
          Map<String, String[]> pmap = super.getParameterMap();
          StringBuffer txt = new StringBuffer(1024);
-         txt.append("Resource Request parameter map dump:\n");
+         txt.append("Resource Request parameter map dump:");
          for (String n : pmap.keySet()) {
-            txt.append("Name: " + n + ", Values: ");
+            txt.append("\nName: " + n + ", Values: ");
             String[] vals = pmap.get(n);
             String sep = "";
             for (String v : vals) {
                txt.append(sep + v);
                sep = ", ";
             }
-            txt.append("\n");
          }
          LOG.debug(txt.toString());
       }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/bac65740/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
index a576644..44e890d 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
@@ -86,7 +86,20 @@ public class PortletURLProviderImpl implements PortletURLProvider {
          txt.append(", URL target=").append(url.getTargetWindow());
          LOGGER.debug(txt.toString());
       }
-      
+
+      if (isTrace) {
+         StringBuilder txt = new StringBuilder("Before clearing parameters for window: ");
+         txt.append(window);
+         for (PortalURLParameter p : this.url.getParameters()) {
+            if (p.getWindowId().equals(window)) {
+               txt.append("\nName: ").append(p.getName());
+               txt.append(", Type: ").append(p.getType());
+               txt.append(", Values: ").append(Arrays.toString(p.getValues()));
+            }
+         }
+         LOGGER.debug(txt.toString());
+      }
+
       this.url.setTargetWindow(window);
       switch (type) {
       case ACTION:
@@ -119,6 +132,19 @@ public class PortletURLProviderImpl implements PortletURLProvider {
          txt.append(", target=").append(url.getTargetWindow());
          LOGGER.debug(txt.toString());
       }
+      
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder("URL Parameters for window: ");
+         txt.append(window);
+         for (PortalURLParameter p : url.getParameters()) {
+            if (p.getWindowId().equals(window)) {
+               txt.append("\nName: ").append(p.getName());
+               txt.append(", Type: ").append(p.getType());
+               txt.append(", Values: ").append(Arrays.toString(p.getValues()));
+            }
+         }
+         LOGGER.debug(txt.toString());
+      }
       return url;
    }
 

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/bac65740/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
index b93e493..90d2c3b 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
@@ -190,7 +190,7 @@ public class RelativePortalURLImpl implements PortalURL {
                if (isDebug) {
                   StringBuilder txt = new StringBuilder("Added private parameter: ");
                   txt.append(parm).append(", Values: ").append(Arrays.toString(parms.get(parm)));
-                  txt.append(parm).append(", Type: ").append(ptype);
+                  txt.append(", Type: ").append(ptype);
                   txt.append(", Clone ID: " + cloneId);
                   LOG.debug(txt.toString());
                }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/bac65740/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java
index be49fec..dbcb7ec 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortletParameterFactory.java
@@ -21,10 +21,12 @@ package org.apache.pluto.driver.url;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 
 import org.apache.pluto.driver.services.portal.PublicRenderParameterMapper;
+import org.apache.pluto.driver.url.PortalURL.URLType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -46,6 +48,13 @@ public class PortletParameterFactory {
    HashMap<String, ArrayList<PortalURLParameter>> wid2Action;
    HashMap<String, ArrayList<PortalURLParameter>> wid2Resource;
    
+   static final HashSet<PortalURL.URLType> actionTypes = new HashSet<PortalURL.URLType>();
+   static {
+      actionTypes.add(URLType.Action);
+      actionTypes.add(URLType.AjaxAction);
+      actionTypes.add(URLType.PartialAction);
+   }
+   
    public PortletParameterFactory(PortalURL url) {
       this.url = url;
    }
@@ -95,6 +104,8 @@ public class PortletParameterFactory {
    public Map<String, String[]> getPrivateParameterMap(String windowId) {
       HashMap<String, String[]> parameters = new HashMap<String, String[]>();
       processParams();
+      
+      boolean isV3 = url.isVersion3(windowId);
 
       // get the action or resource parameters
       
@@ -108,17 +119,19 @@ public class PortletParameterFactory {
          }
       }
       
-      // Now merge in the render parameters
-      
-      if (wid2Render.containsKey(windowId)) {
-         for (PortalURLParameter parm : wid2Render.get(windowId)) {
-            if (parameters.containsKey(parm.getName())) {
-               ArrayList<String> vals = 
-                     new ArrayList<String>(Arrays.asList(parameters.get(parm.getName())));
-               vals.addAll(Arrays.asList(parm.getValues()));
-               parameters.put(parm.getName(), vals.toArray(new String[0]));
-            } else {
-               parameters.put(parm.getName(), parm.getValues().clone());
+      // Now merge in the render parameters if we're not dealing with a V2 action
+
+      if (isV3 || !actionTypes.contains(url.getType())) {
+         if (wid2Render.containsKey(windowId)) {
+            for (PortalURLParameter parm : wid2Render.get(windowId)) {
+               if (parameters.containsKey(parm.getName())) {
+                  ArrayList<String> vals = 
+                        new ArrayList<String>(Arrays.asList(parameters.get(parm.getName())));
+                  vals.addAll(Arrays.asList(parm.getValues()));
+                  parameters.put(parm.getName(), vals.toArray(new String[0]));
+               } else {
+                  parameters.put(parm.getName(), parm.getValues().clone());
+               }
             }
          }
       }


[21/22] portals-pluto git commit: Bug fix; remove unused code

Posted by ms...@apache.org.
Bug fix; remove unused code


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/11bb397a
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/11bb397a
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/11bb397a

Branch: refs/heads/V3Prototype
Commit: 11bb397ad048d3c6145f8e1aef76f87f9f4b349c
Parents: aef314f
Author: Scott Nicklous <ms...@apache.org>
Authored: Mon Feb 16 08:54:01 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Mon Feb 16 08:54:01 2015 +0100

----------------------------------------------------------------------
 .../container/PortletURLProviderImpl.java       |  2 +-
 .../driver/url/impl/RelativePortalURLImpl.java  | 21 +-------------------
 .../org/apache/pluto/driver/url/PortalURL.java  |  6 ------
 3 files changed, 2 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/11bb397a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
index 81bdedf..92bcd3d 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
@@ -68,7 +68,7 @@ public class PortletURLProviderImpl implements PortletURLProvider {
       this.url = url.clone();
       this.type = type;
       this.window = portletWindow.getId().getStringId();
-      this.paramFactory = url.getPortletParameterFactory();
+      this.paramFactory = this.url.getPortletParameterFactory();
 
       if (isDebug) {
          StringBuilder txt = new StringBuilder("Constructing PortalURLProviderImpl. ");

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/11bb397a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
index 74a67a0..d9df81d 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
@@ -505,7 +505,6 @@ public class RelativePortalURLImpl implements PortalURL {
     * .String)
     */
    public void clearResourceParameters(String window) {
-      handleServletRequestParams();
       HashSet<PortalURLParameter> rem = new HashSet<PortalURLParameter>();
       for (PortalURLParameter pup : parameters) {
          if (pup.getType().equals(PortalURLParameter.PARAM_TYPE_RESOURCE)
@@ -521,6 +520,7 @@ public class RelativePortalURLImpl implements PortalURL {
       parameters.removeAll(rem);
    }
 
+   // used by parser when parsing URL parameter strings
    protected void addParameter(PortalURLParameter param) {
       if (isDebug) {
          StringBuilder txt = new StringBuilder(
@@ -593,23 +593,4 @@ public class RelativePortalURLImpl implements PortalURL {
       }
       parameters.remove(param);
    }
-
-   public void removePublicRenderParameter(PortalURLPublicParameter param) {
-      handleServletRequestParams();
-      if (isDebug) {
-         StringBuilder txt = new StringBuilder(
-               "Removing public render parameter: ");
-         txt.append(" window ID: " + param.getWindowId());
-         txt.append(", Name: " + param.getName());
-         txt.append(", QName: " + param.getQName());
-         txt.append(", Values: " + Arrays.toString(param.getValues()));
-         LOG.debug(txt.toString());
-      }
-      int index = prpMapper.getIndex(param);
-      if (index >= 0) {
-         prpMapper.setRemoved(index, true);
-      } else {
-         LOG.warn("Public parameter not found in PRP mapper.");
-      }
-   }
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/11bb397a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
index 20a3b9b..5d30540 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
@@ -81,12 +81,6 @@ public interface PortalURL extends Cloneable {
     * @param param
     */
    public void removeParameter(PortalURLParameter param);
-   
-   /**
-    * Removes the given public render parameter
-    * @param param
-    */
-   public void removePublicRenderParameter(PortalURLPublicParameter param);
 
    /**
     * Add the PRP mapper for the page being processed


[08/22] portals-pluto git commit: more preparations for new parameer handling

Posted by ms...@apache.org.
more preparations for new parameer handling


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/ee5b0bdf
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/ee5b0bdf
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/ee5b0bdf

Branch: refs/heads/V3Prototype
Commit: ee5b0bdf7f9bcf562ea26ce0718a53a72f76ef68
Parents: 64c0749
Author: Scott Nicklous <ms...@apache.org>
Authored: Sun Feb 8 23:23:53 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Sun Feb 8 23:23:53 2015 +0100

----------------------------------------------------------------------
 .../container/PortletParameterFactory.java      | 137 +++++--
 .../container/PortletRequestContextImpl.java    |  14 +-
 .../PortletResourceRequestContextImpl.java      |   2 +-
 .../container/PortletURLProviderImpl.java       |  12 +-
 .../driver/url/impl/PortalURLParserImpl.java    | 370 ++++++++++---------
 .../driver/url/impl/RelativePortalURLImpl.java  |  21 +-
 .../org/apache/pluto/driver/url/PortalURL.java  |  16 +-
 7 files changed, 338 insertions(+), 234 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/ee5b0bdf/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletParameterFactory.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletParameterFactory.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletParameterFactory.java
index 45cc15c..f163f93 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletParameterFactory.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletParameterFactory.java
@@ -18,6 +18,8 @@
 
 package org.apache.pluto.driver.services.container;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -43,44 +45,90 @@ public class PortletParameterFactory {
    
    PortalURL url;
    
+   HashMap<String, ArrayList<PortalURLParameter>> wid2Render;
+   HashMap<String, ArrayList<PortalURLParameter>> wid2Action;
+   HashMap<String, ArrayList<PortalURLParameter>> wid2Resource;
+   
    public PortletParameterFactory(PortalURL url) {
       this.url = url;
    }
+   
+   private void addParam(Map<String, ArrayList<PortalURLParameter>> map, PortalURLParameter parm) {
+      String wid = parm.getWindowId();
+      if (!map.keySet().contains(wid)) {
+         map.put(wid, new ArrayList<PortalURLParameter>());
+      }
+      map.get(wid).add(parm);
+   }
+   
+   /**
+    * process the URL parameters. Do this as late as possible so that 
+    * the servlet rquest parameters get handled properly.
+    */
+   private void processParams() {
+      wid2Render = new HashMap<String, ArrayList<PortalURLParameter>>();
+      wid2Action = new HashMap<String, ArrayList<PortalURLParameter>>();
+      wid2Resource = new HashMap<String, ArrayList<PortalURLParameter>>();
+      
+      //Make sure the servlet request parameters are processed
+      url.handleServletRequestParams();
+      
+      for (PortalURLParameter parm : url.getParameters()) {
+         if (parm.getType().equals(PortalURLParameter.PARAM_TYPE_ACTION)) {
+            addParam(wid2Action, parm);
+         } else if (parm.getType().equals(PortalURLParameter.PARAM_TYPE_RESOURCE)) {
+            addParam(wid2Resource, parm);
+         } else {
+            addParam(wid2Render, parm);
+         }
+      }
+
+   }
 
+   /**
+    * This V2.0 method returns the private parameters for the given window ID.
+    * In the case of a render URL, it returns only the private render parameters.
+    * 
+    * In the case of an action or resource URL, it returns the action or resource 
+    * parameters combined with the render parameters, with the action or resource
+    * parameters taking precedence.
+    * 
+    * Note that the  latter circumstance will only occur with V3.0 portlets.
+    *  
+    * @param windowId
+    * @return
+    */
    public Map<String, String[]> getPrivateParameterMap(String windowId) {
       HashMap<String, String[]> parameters = new HashMap<String, String[]>();
-//       if (useRequestParameters) {
-//          parameters.putAll(servletRequest.getParameterMap());
-//       }
-//       for (Map.Entry<String, String[]> entry : getPrivateRenderParameterMap()
-//             .entrySet()) {
-//          String[] values = parameters.get(entry.getKey());
-//          if (values == null) {
-//             parameters.put(entry.getKey(), entry.getValue());
-//          } else {
-//             String[] copy = new String[values.length + entry.getValue().length];
-//             System.arraycopy(values, 0, copy, 0, values.length);
-//             System.arraycopy(entry.getValue(), 0, copy, values.length,
-//                   entry.getValue().length);
-//             parameters.put(entry.getKey(), copy);
-//          }
-//       }
-      for (PortalURLParameter parm : url.getParameters()) {
-         if (windowId.equals(parm.getWindowId()) 
-               && PortalURLParameter.PARAM_TYPE_RENDER.equals(parm.getType())) {
-            String[] values = parameters.get(parm.getName());
-            if (values == null) {
-               parameters.put(parm.getName(), parm.getValues());
+      processParams();
+
+      // get the action or resource parameters
+      
+      if (wid2Action.containsKey(windowId)) {
+         for (PortalURLParameter parm : wid2Action.get(windowId)) {
+            parameters.put(parm.getName(), parm.getValues().clone());
+         }
+      } else if (wid2Resource.containsKey(windowId)) {
+         for (PortalURLParameter parm : wid2Resource.get(windowId)) {
+            parameters.put(parm.getName(), parm.getValues().clone());
+         }
+      }
+      
+      // Now merge in the render parameters
+      
+      if (wid2Render.containsKey(windowId)) {
+         for (PortalURLParameter parm : wid2Render.get(windowId)) {
+            if (parameters.containsKey(parm.getName())) {
+               ArrayList<String> vals = 
+                     new ArrayList<String>(Arrays.asList(parameters.get(parm.getName())));
+               vals.addAll(Arrays.asList(parm.getValues()));
+               parameters.put(parm.getName(), (String[])vals.toArray());
             } else {
-               String[] copy = new String[values.length
-                     + parm.getValues().length];
-               System.arraycopy(values, 0, copy, 0, values.length);
-               System.arraycopy(parm.getValues(), 0, copy, values.length,
-                     parm.getValues().length);
-               parameters.put(parm.getName(), copy);
+               parameters.put(parm.getName(), parm.getValues().clone());
             }
          }
       }
+
       if (isDebug) {
          StringBuffer sb = new StringBuffer();
          sb.append("Dump private Parameter Map:");
@@ -97,10 +145,23 @@ public class PortletParameterFactory {
       return parameters;
    }
    
+   /**
+    * Returns the active (= have been set) public render parameters for the
+    * given window ID.
+    *  
+    * @param windowId
+    * @return
+    */
    public Map<String, String[]> getPublicParameterMap(String windowId) {
       HashMap<String, String[]> parameters = new HashMap<String, String[]>();
+      
+      //Make sure the servlet request parameters are processed
+      url.handleServletRequestParams();
+
       PublicRenderParameterMapper mapper = url.getPublicRenderParameterMapper();
+      
       // get the active PRPs only
+      
       List<PortalURLPublicParameter> prps = mapper.getPRPsForWindow(windowId, true);
       for (PortalURLPublicParameter prp : prps) {
          parameters.put(prp.getName(), prp.getValues().clone());
@@ -108,4 +169,24 @@ public class PortletParameterFactory {
       return parameters;
    }
 
+   /**
+    * This is a V2 method to get the private render parameter map during
+    * a resource request.
+    * 
+    * @return
+    */
+   public Map<String, String[]> getResourceRenderParameterMap(String windowId) {
+      HashMap<String, String[]> parameters = new HashMap<String, String[]>();
+
+      processParams();
+      
+      if (wid2Render.containsKey(windowId)) {
+         for (PortalURLParameter parm : wid2Render.get(windowId)) {
+            parameters.put(parm.getName(), parm.getValues().clone());
+         }
+      }
+      
+      return parameters;
+   }
+
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/ee5b0bdf/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java
index 67b3bba..492d0fa 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java
@@ -23,9 +23,6 @@ import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
 
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
 import javax.portlet.PortletConfig;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletRequest;
@@ -38,29 +35,25 @@ import org.apache.pluto.container.PortletRequestContext;
 import org.apache.pluto.container.PortletWindow;
 import org.apache.pluto.driver.core.PortalRequestContext;
 import org.apache.pluto.driver.url.PortalURL;
-import org.apache.pluto.driver.url.PortalURLParameter;
 
 /**
  * @version $Id$
  *
  */
 public class PortletRequestContextImpl implements PortletRequestContext {
-   private static final String LOG_CLASS = PortletRequestContextImpl.class
-                                               .getName();
-   private final Logger        LOGGER    = Logger.getLogger(LOG_CLASS);
 
    private PortletContainer    container;
    private HttpServletRequest  containerRequest;
    private HttpServletResponse containerResponse;
    private HttpServletRequest  servletRequest;
    private HttpServletResponse servletResponse;
-   private PortletWindow       window;
    private PortalURL           url;
-   private PortletParameterFactory paramFactory;
    private PortletConfig       portletConfig;
    private ServletContext      servletContext;
    private Cookie              cookies[];
-   private boolean             useRequestParameters;
+
+   protected PortletWindow       window;
+   protected PortletParameterFactory paramFactory;
 
    public PortletRequestContextImpl(PortletContainer container,
          HttpServletRequest containerRequest,
@@ -70,7 +63,6 @@ public class PortletRequestContextImpl implements PortletRequestContext {
       this.containerRequest = containerRequest;
       this.containerResponse = containerResponse;
       this.window = window;
-      this.useRequestParameters = useRequestParameters;
       this.url = PortalRequestContext.getContext(containerRequest)
             .createPortalURL();
       this.paramFactory = new PortletParameterFactory(url);

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/ee5b0bdf/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletResourceRequestContextImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletResourceRequestContextImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletResourceRequestContextImpl.java
index 97bce7c..50c5d32 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletResourceRequestContextImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletResourceRequestContextImpl.java
@@ -52,7 +52,7 @@ public class PortletResourceRequestContextImpl extends PortletRequestContextImpl
 
     public Map<String, String[]> getPrivateRenderParameterMap()
     {
-        return getPortalURL().getPrivateRenderParameters();
+        return paramFactory.getResourceRenderParameterMap(window.getId().getStringId());
     }
 
     public String getResourceID()

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/ee5b0bdf/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
index 73244b9..1d15c69 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
@@ -95,17 +95,7 @@ public class PortletURLProviderImpl implements PortletURLProvider
         {
            url.setTargetWindow(window);
            url.setType(URLType.Resource);
-            if (!ResourceURL.FULL.equals(cacheLevel))
-            {
-                for (PortalURLParameter parm : url.getParameters())
-                {
-                    if (window.equals(parm.getWindowId()))
-                    {
-                        url.getPrivateRenderParameters().put(parm.getName(), parm.getValues());
-                    }                            
-                }
-            }
-            url.clearParameters(window);
+           url.clearResourceParameters(window);
         }
         else
         {

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/ee5b0bdf/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
index 6bc7a24..4253802 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
@@ -16,17 +16,17 @@
  */
 package org.apache.pluto.driver.url.impl;
 
-import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Iterator;
+import java.util.HashSet;
 import java.util.List;
-import java.util.Map;
+import java.util.Set;
 
 import javax.portlet.PortletMode;
+import javax.portlet.ResourceURL;
 import javax.portlet.WindowState;
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
@@ -64,11 +64,16 @@ public class PortalURLParserImpl implements PortalURLParser {
    private static final String RESOURCE_ID = "ri";
    private static final String CACHE_LEVEL = "cl";
    private static final String RENDER_PARAM = "rp";
-   private static final String PRIVATE_RENDER_PARAM = "pr";
    private static final String PUBLIC_RENDER_PARAM = "sp";
    private static final String WINDOW_STATE = "ws";
    private static final String PORTLET_MODE = "pm";
-   private static final String VALUE_DELIM = "0x0";
+   
+   // The delimiter & special chars for the value encoding are chosen
+   // from the URL reserved delimiter characters that ARE ENCODED by the URLEncoder
+   // so that they will not appear encoded parameter names or values.
+   // See RFC 3986 & URLEncoder documentation.
+   private static final String VALUE_DELIM = ":";
+   private static final String VALUE_NULL = ",";
 
    private static final String ACTION = "ac";
    private static final String RESOURCE = "rs";
@@ -80,22 +85,22 @@ public class PortalURLParserImpl implements PortalURLParser {
    private static final String RESOURCE_PARAM = "rv";    // new for portlet spec 3
 
 
-   //This is a list of characters that need to be encoded  to be protected
-   //The ? is necessary to protect URI's with a query portion that is being passed as a parameter
-   private static final String[][] ENCODINGS = new String[][] {
-      new String[] { "_",  "0x1" },
-      new String[] { ".",  "0x2" },
-      new String[] { "/",  "0x3" },
-      new String[] { "\r", "0x4" },
-      new String[] { "\n", "0x5" },
-      new String[] { "<",  "0x6" },
-      new String[] { ">",  "0x7" },
-      new String[] { " ",  "0x8" },
-      new String[] { "#",  "0x9" },
-      new String[] { "?",  "0xa" },
-      new String[] { "\\", "0xb" },
-      new String[] { "%",  "0xc" },
-   };
+//    //This is a list of characters that need to be encoded  to be protected
+//    //The ? is necessary to protect URI's with a query portion that is being passed as a parameter
+//    private static final String[][] ENCODINGS = new String[][] {
+//       new String[] { "_",  "0x1" },
+//       new String[] { ".",  "0x2" },
+//       new String[] { "/",  "0x3" },
+//       new String[] { "\r", "0x4" },
+//       new String[] { "\n", "0x5" },
+//       new String[] { "<",  "0x6" },
+//       new String[] { ">",  "0x7" },
+//       new String[] { " ",  "0x8" },
+//       new String[] { "#",  "0x9" },
+//       new String[] { "?",  "0xa" },
+//       new String[] { "\\", "0xb" },
+//       new String[] { "%",  "0xc" },
+//    };
 
    // Constructor -------------------------------------------------------------
 
@@ -222,9 +227,9 @@ public class PortalURLParserImpl implements PortalURLParser {
                type = t.substring(0, 2);
                val = t.substring(2);
                vals = val.split(DELIM);
-               for (int ii = 0; ii < vals.length; ii++) {
-                  vals[ii] = decodeCharacters(vals[ii]);
-               }
+//                for (int ii = 0; ii < vals.length; ii++) {
+//                   vals[ii] = decodeCharacters(vals[ii]);
+//                }
             }
 
             // If the first value is numeric, attempt to dereference the index to obtain the portlet ID.
@@ -242,21 +247,21 @@ public class PortalURLParserImpl implements PortalURLParser {
                }
             }
 
-            // Get the portlet IDs & reference numbers
+            // Get the portlet IDs & reference numbers. The portlet IDs are URL encoded.
             if (type.equals(PORTLET_ID)) {
-               portletIds.add(Integer.parseInt(vals[1]), vals[0]);
+               portletIds.add(Integer.parseInt(vals[1]), urlDecode(vals[0]));
                continue;
             } 
 
             // Cacheability definition: portalURL.setCacheability().
             if (type.equals(CACHE_LEVEL)) {
-               portalURL.setCacheability(vals[0]);
+               portalURL.setCacheability(urlDecode(vals[0]));
                continue;
             }
 
             // ResourceID definition: portalURL.setResourceID().
             if (type.equals(RESOURCE_ID)) {
-               portalURL.setResourceID(vals[0]);
+               portalURL.setResourceID(urlDecode(vals[0]));
                continue;
             }
 
@@ -297,19 +302,23 @@ public class PortalURLParserImpl implements PortalURLParser {
 
             // Window state definition: portalURL.setWindowState().
             if (type.equals(WINDOW_STATE)) {
-               portalURL.setWindowState(pid, new WindowState(vals[1]));
+               portalURL.setWindowState(pid, new WindowState(urlDecode(vals[1])));
                continue;
             }
 
             // Portlet mode definition: portalURL.setPortletMode().
             if (type.equals(PORTLET_MODE)) {
-               portalURL.setPortletMode(pid, new PortletMode(vals[1]));
+               portalURL.setPortletMode(pid, new PortletMode(urlDecode(vals[1])));
                continue;
             }
 
             // The remaining types deal with parameters, so extract the
             // parameter name and values.
-            StringBuilder dbgstr = new StringBuilder("Decoding parameter: window ID=" + pid + ", name/value=" + vals[1]);
+            StringBuilder dbgstr = new StringBuilder();
+            if (LOG.isDebugEnabled()) {
+               dbgstr.append("Decoding parameter: window ID=").append(pid)
+                     .append(", name/value=").append(vals[1]);
+            }
 
             String values = vals[1];
             if (type.equals(PUBLIC_RENDER_PARAM)) {
@@ -322,23 +331,21 @@ public class PortalURLParserImpl implements PortalURLParser {
 
             String[] pVals = values.split(VALUE_DELIM);
             String[] paramValues = null;
-            if (pVals.length > 1) {
-               paramValues = new String[pVals.length-1];
-            }
-            for (int i = 0; i < pVals.length;i++){
-               try {
-                  pVals[i] = URLDecoder.decode(pVals[i], "UTF-8");
-                  if (i > 0) {            // 1st value is the parameter name
-                     paramValues[i-1] = pVals[i];
+            String paramName = null;
+            if (pVals.length > 2) {
+               for (int i = 0; i < pVals.length;i++){
+                  if (pVals[i].equals(VALUE_NULL)) {
+                     pVals[i] = null;
+                  } else {
+                     pVals[i] = urlDecode(pVals[i]);
                   }
-               } catch (UnsupportedEncodingException e) {
-                  LOG.warn(e.getMessage(),e);
                }
+               paramName = pVals[0];
+               paramValues = Arrays.copyOfRange(pVals, 1, pVals.length);
             }
-            String paramName = pVals[0];
-            dbgstr.append(", paramName=").append(paramName);
-            dbgstr.append(", paramValues=").append(Arrays.toString(paramValues));
             if (LOG.isDebugEnabled()) {
+               dbgstr.append(", paramName=").append(paramName);
+               dbgstr.append(", paramValues=").append(Arrays.toString(paramValues));
                LOG.debug(dbgstr.toString());
             }
 
@@ -362,12 +369,6 @@ public class PortalURLParserImpl implements PortalURLParser {
                continue;
             }
 
-            //set private (Resource) parameter in portalURL
-            if (type.equals(PRIVATE_RENDER_PARAM)){
-               portalURL.getPrivateRenderParameters().put(paramName, paramValues);
-               continue;
-            }
-
             //set public parameter in portalURL
             if (type.equals(PUBLIC_RENDER_PARAM)){
                PublicRenderParameterMapper mapper = portalURL.getPublicRenderParameterMapper();
@@ -402,6 +403,9 @@ public class PortalURLParserImpl implements PortalURLParser {
 
       StringBuilder buffer = new StringBuilder();
       String targetWindow = portalURL.getTargetWindow();
+      
+      // Make sure the servlet parameters have been processed
+      portalURL.handleServletRequestParams();
 
       // Append the server URI and the servlet path.
       buffer.append(portalURL.getServletPath().startsWith("/")?"":"/")
@@ -416,8 +420,13 @@ public class PortalURLParserImpl implements PortalURLParser {
       ArrayList<String> pids = new ArrayList<String>();
       for (String pid : portalURL.getPortletIds()) {
          pids.add(pid);
-         buffer.append("/").append(PREFIX).append(PORTLET_ID)
-         .append(encodeCharacters(pid)).append(DELIM).append(String.valueOf(pids.indexOf(pid)));
+         buffer.append("/").append(PREFIX).append(PORTLET_ID);
+         try {
+            buffer.append(URLEncoder.encode(pid, "UTF-8"));
+         } catch(Exception e) {
+            LOG.warn("Could not encode pid=" + pid);
+         }
+         buffer.append(DELIM).append(String.valueOf(pids.indexOf(pid)));
       }
 
       //Append the resource window definition, if it exists.
@@ -453,22 +462,38 @@ public class PortalURLParserImpl implements PortalURLParser {
          }
       }
 
-      if (portalURL.getType() == URLType.Resource)
-      {
-         if (portalURL.getCacheability() != null)
-         {
+      String reswin = null;
+      if (portalURL.getType() == URLType.Resource) {
+         if (portalURL.getCacheability() != null) {
             buffer.append("/");
-            buffer.append(PREFIX).append(CACHE_LEVEL).append(encodeCharacters(portalURL.getCacheability()));
+            buffer.append(PREFIX).append(CACHE_LEVEL)
+                  .append(urlEncode(portalURL.getCacheability()));
          }
-         if (portalURL.getResourceID() != null)
-         {
+         if (portalURL.getResourceID() != null) {
             buffer.append("/");
-            buffer.append(PREFIX).append(RESOURCE_ID).append(encodeCharacters(portalURL.getResourceID()));
+            buffer.append(PREFIX).append(RESOURCE_ID)
+                  .append(urlEncode(portalURL.getResourceID()));
+         }
+         
+         // if cacheability = FULL, we're done. For PORTLET, set
+         // the resource window so that the only the state for the
+         // target portlet is set.
+         
+         if (portalURL.getCacheability().equals(ResourceURL.FULL)) {
+            return buffer.toString();
+         } else if (portalURL.getCacheability().equals(ResourceURL.PORTLET)) {
+            reswin = portalURL.getTargetWindow();
          }
       }
 
       // Append portlet mode definitions.
       for (String pid : portalURL.getPortletModes().keySet()) {
+         
+         // special handling for Cacheability = PORTLET
+         if (reswin != null && !reswin.equals(pid)) {
+            continue;
+         }
+         
          int index = pids.indexOf(pid);
          PortletMode pm = portalURL.getPortletMode(pid);
          if (index < 0) {
@@ -476,29 +501,35 @@ public class PortalURLParserImpl implements PortalURLParser {
             LOG.warn("portlet IDs in map: " + Arrays.toString(pids.toArray()));
          } else {
             buffer.append("/").append(PREFIX).append(PORTLET_MODE)
-            .append(String.valueOf(index)).append(DELIM).append(encodeCharacters(pm.toString()));
+            .append(String.valueOf(index)).append(DELIM).append(urlEncode(pm.toString()));
          }
       }
 
       // Append window state definitions.
       for (String pid : portalURL.getWindowStates().keySet()) {
+
+         // special handling for Cacheability = PORTLET
+         if (reswin != null && !reswin.equals(pid)) {
+            continue;
+         }
+         
          int index = pids.indexOf(pid);
          WindowState ws = portalURL.getWindowState(pid);
          if (index < 0) {
             LOG.warn("Window not found in portlet ID list. PID = " + pid + ", WS = " + ws.toString());
          } else {
             buffer.append("/").append(PREFIX).append(WINDOW_STATE)
-            .append(String.valueOf(index)).append(DELIM).append(encodeCharacters(ws.toString()));
+            .append(String.valueOf(index)).append(DELIM).append(urlEncode(ws.toString()));
          }
       }
 
       // Append action and render parameters.
-      StringBuilder query = new StringBuilder("?");
-      boolean firstParam = true;
-      for (Iterator<PortalURLParameter> it = portalURL.getParameters().iterator();
-            it.hasNext(); ) {
+      for (PortalURLParameter param : portalURL.getParameters()) {
 
-         PortalURLParameter param = (PortalURLParameter) it.next();
+         // special handling for Cacheability = PORTLET
+         if (reswin != null && !reswin.equals(param.getWindowId())) {
+            continue;
+         }
 
          int index = pids.indexOf(param.getWindowId());
          if (index < 0) {
@@ -506,71 +537,42 @@ public class PortalURLParserImpl implements PortalURLParser {
             continue;
          }
 
-         // Encode action params in the query appended at the end of the URL.
-         if (targetWindow.equals(param.getWindowId()) &&
-               (portalURL.getType() == URLType.Action
-               || portalURL.getType() == URLType.Resource)) {
-            for (int i = 0; i < param.getValues().length; i++) {
-               // FIX for PLUTO-247
-               if ( firstParam ) {
-                  firstParam = false;
-               } else {
-                  query.append("&");
-               }
-               query.append(encodeQueryParam(param.getName())).append("=")
-               .append(encodeQueryParam(param.getValues()[i]));
-            }
-         }
-
          // Encode render params as a part of the URL.
-         else if (param.getValues() != null
+         if (param.getName() != null && param.getValues() != null
                && param.getValues().length > 0) {
             String valueString = encodeMultiValues(param.getValues());
             if (valueString.length() > 0) {
                String ptype = RENDER_PARAM;
                if (param.getType().equals(PortalURLParameter.PARAM_TYPE_ACTION)) {
                   ptype = ACTION_PARAM;
-               } else 
-                  if (param.getType().equals(PortalURLParameter.PARAM_TYPE_RESOURCE)) {
+               } else if (param.getType().equals(PortalURLParameter.PARAM_TYPE_RESOURCE)) {
                   ptype = RESOURCE_PARAM;
                }
-              buffer.append("/").append(PREFIX).append(ptype)
-               .append(String.valueOf(index)).append(DELIM).append(encodeCharacters(param.getName()))
+               buffer.append("/").append(PREFIX).append(ptype)
+               .append(String.valueOf(index)).append(DELIM).append(urlEncode(param.getName()))
                .append(VALUE_DELIM).append(valueString);
             }
          }
       }
 
-      encode(buffer);
-
-      // Add the private render parameters
-      if (portalURL.getType() == URLType.Resource)
-      {
-         Map<String, String[]> privateParamList = portalURL.getPrivateRenderParameters();
-         if (privateParamList!=null){
-            for (Iterator<String> iter = privateParamList.keySet().iterator();iter.hasNext();){
-               String paramname = (String)iter.next();
-               String[] tmp = privateParamList.get(paramname);
-               String valueString = encodeMultiValues(tmp);
-               if (valueString.length()>0){
-                  buffer.append("/").append(PREFIX).append(PRIVATE_RENDER_PARAM)
-                  .append(DELIM).append(encodeCharacters(paramname))
-                  .append(VALUE_DELIM).append(valueString);
-               }
-            }
-         }
-      }
-
       // Add the public render parameters, retaining the grouping information and 
-      // the parameter names for each portlet. The finished token looks like this:
-      //     /__sp<window reference>_<PRP group reference>_<name>0x0<val>0x0<val> ... etc
+      // the parameter names for each portlet. 
       PublicRenderParameterMapper mapper = portalURL.getPublicRenderParameterMapper();
-      for (int i : mapper.getActiveIndexes()) {
-         String[] values = mapper.getValues(i);
-         StringBuilder valstr = new StringBuilder();
-         for (String v : values) {
-            valstr.append(VALUE_DELIM).append(encodeCharacters(v));
+      List<Integer> activeIndexes = mapper.getActiveIndexes();
+
+      // special handling for Cacheability = PORTLET
+      if (reswin != null) {
+         List<PortalURLPublicParameter> pups = mapper.getPRPsForWindow(reswin, true);
+         activeIndexes = new ArrayList<Integer>();
+         for (PortalURLPublicParameter pup : pups) {
+            activeIndexes.add(mapper.getIndex(pup));
          }
+      }
+      
+      for (int i : activeIndexes) {
+         String[] values = mapper.getValues(i);
+         String valstr = encodeMultiValues(values);
+         
          // the values for the PRP group need only appear in the URL once
          List<PortalURLPublicParameter> prplist = mapper.getPublicParameterGroup(i);
          if (prplist.size() > 0) {
@@ -580,7 +582,7 @@ public class PortalURLParserImpl implements PortalURLParser {
                buffer.append("/").append(PREFIX).append(PUBLIC_RENDER_PARAM)
                .append(String.valueOf(index)).append(DELIM)
                .append(String.valueOf(i)).append(DELIM)
-               .append(encodeCharacters(prp.getName()))
+               .append(urlEncode(prp.getName()))
                .append(valstr);
             } else {
                LOG.warn("window ID not on page for public render parameter: " + prp.toString());
@@ -590,40 +592,68 @@ public class PortalURLParserImpl implements PortalURLParser {
       }
 
       // Construct the string representing the portal URL.
-      // Fix for PLUTO-247 - check if query string contains parameters
-      if ( query.length() > 1 ) {
-         return buffer.append(query).toString();
-      }
-
-      // Construct the string representing the portal URL.
       return buffer.toString();
    }
 
    // Private Encoding/Decoding Methods ---------------------------------------
 
-   private static void encode(StringBuilder url){
-      replaceChar(url,"|","%7C");
-      replaceChar(url,"\"","%22");
-   }
+//    private static void encode(StringBuilder url){
+//       replaceChar(url,"|","%7C");
+//       replaceChar(url,"\"","%22");
+//    }
+// 
+//    private static void replaceChar(StringBuilder url, String character, String change){
+//       boolean contains = url.toString().contains(character);
+//       while (contains){
+//          int index = url.indexOf(character);
+//          url.deleteCharAt(index);
+//          url.insert(index, change, 0, 3);
+//          contains = url.toString().contains(character);
+//       }
+//    }
+// 
+//    private String encodeQueryParam(String param) {
+//       try {
+//          return URLEncoder.encode(param, "UTF-8");
+//       }
+//       catch (UnsupportedEncodingException e) {
+//          // If this happens, we've got bigger problems.
+//          throw new RuntimeException(e);
+//       }
+//    }
 
-   private static void replaceChar(StringBuilder url, String character, String change){
-      boolean contains = url.toString().contains(character);
-      while (contains){
-         int index = url.indexOf(character);
-         url.deleteCharAt(index);
-         url.insert(index, change, 0, 3);
-         contains = url.toString().contains(character);
+   /**
+    * Wrapper for URLEncoder
+    * @param str
+    * @return
+    */
+   private String urlEncode(String str) {
+      String out = str;
+      if (str != null) {
+         try {
+            out = URLEncoder.encode(str, "UTF-8");
+         } catch(Exception e) {
+            LOG.warn("Error URL encoding string: " + str);
+         }
       }
+      return out;
    }
 
-   private String encodeQueryParam(String param) {
-      try {
-         return URLEncoder.encode(param, "UTF-8");
-      }
-      catch (UnsupportedEncodingException e) {
-         // If this happens, we've got bigger problems.
-         throw new RuntimeException(e);
+   /**
+    * Wrapper for URLDecoder
+    * @param str
+    * @return
+    */
+   private String urlDecode(String str) {
+      String out = str;
+      if (str != null) {
+         try {
+            out = URLDecoder.decode(str, "UTF-8");
+         } catch(Exception e) {
+            LOG.warn("Error URL decoding string: " + str);
+         }
       }
+      return out;
    }
 
    /**
@@ -635,45 +665,41 @@ public class PortalURLParserImpl implements PortalURLParser {
    private String encodeMultiValues(String[] values) {
       StringBuilder buffer = new StringBuilder();
       for (int i = 0; i < values.length; i++) {
-         // Do not operate on the array reference
-         String currentValue = values[i];
-         try {
-            if (currentValue != null)
-               currentValue = URLEncoder.encode(values[i], "UTF-8");
-         } catch (UnsupportedEncodingException e) {
-            LOG.warn(e.getMessage(),e);
+         if (values[i] == null) {
+            buffer.append(VALUE_NULL);
+         } else {
+            buffer.append(urlEncode(values[i]));
          }
-         buffer.append(currentValue != null ? currentValue : "");
          if (i + 1 < values.length) {
             buffer.append(VALUE_DELIM);
          }
       }
-      return encodeCharacters(buffer.toString());
-   }
-
-   /**
-    * Encode special characters contained in the string value.
-    * @param string  the string value to encode.
-    * @return the encoded string.
-    */
-   private String encodeCharacters(String string) {
-      for (int i = 0; i < ENCODINGS.length; i++) {
-         string = string.replace(ENCODINGS[i][0], ENCODINGS[i][1]);
-      }
-      return string;
+      return buffer.toString();
    }
 
-   /**
-    * Decode special characters contained in the string value.
-    * @param string  the string value to decode.
-    * @return the decoded string.
-    */
-   private String decodeCharacters(String string) {
-      for (int i = 0; i < ENCODINGS.length; i++) {
-         string = string.replace(ENCODINGS[i][1], ENCODINGS[i][0]);
-      }
-      return string;
-   }
+//    /**
+//     * Encode special characters contained in the string value.
+//     * @param string  the string value to encode.
+//     * @return the encoded string.
+//     */
+//    private String encodeCharacters(String string) {
+//       for (int i = 0; i < ENCODINGS.length; i++) {
+//          string = string.replace(ENCODINGS[i][0], ENCODINGS[i][1]);
+//       }
+//       return string;
+//    }
+// 
+//    /**
+//     * Decode special characters contained in the string value.
+//     * @param string  the string value to decode.
+//     * @return the decoded string.
+//     */
+//    private String decodeCharacters(String string) {
+//       for (int i = 0; i < ENCODINGS.length; i++) {
+//          string = string.replace(ENCODINGS[i][1], ENCODINGS[i][0]);
+//       }
+//       return string;
+//    }
 
 }
 

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/ee5b0bdf/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
index 0cba184..e6926a2 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
@@ -117,7 +117,7 @@ public class RelativePortalURLImpl implements PortalURL {
    // the parameters are read in order to allow a portlet to potentially set
    // the character encoding during processAction or serveResource.
    
-   private void handleReqParams() {
+   public void handleServletRequestParams() {
       if (!reqParamsProcessed && servletRequest != null 
             && targetWindow != null && type != URLType.Portal) {
          reqParamsProcessed = true;
@@ -181,7 +181,6 @@ public class RelativePortalURLImpl implements PortalURL {
    }
 
    public Collection<PortalURLParameter> getParameters() {
-      handleReqParams();
       return parameters;
    }
 
@@ -328,12 +327,6 @@ public class RelativePortalURLImpl implements PortalURL {
       return portalURL;
    }
 
-   public Map<String, String[]> getPrivateRenderParameters()
-   {
-      handleReqParams();
-      return privateRenderParameters;
-   }
-
 
    public PageConfig getPageConfig(ServletContext servletContext) {
       String requestedPageId = getRenderPath();
@@ -454,4 +447,16 @@ public class RelativePortalURLImpl implements PortalURL {
    public String getTargetWindow() {
       return targetWindow;
    }
+
+   /* (non-Javadoc)
+    * @see org.apache.pluto.driver.url.PortalURL#clearResourceParameters(java.lang.String)
+    */
+   public void clearResourceParameters(String window) {
+      for (PortalURLParameter pup : parameters) {
+         if (pup.getType().equals(PortalURLParameter.PARAM_TYPE_RESOURCE) 
+               && pup.getWindowId().equals(window)) {
+            parameters.remove(pup);
+         }
+      }
+   }
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/ee5b0bdf/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
index 48a122c..60d1032 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURL.java
@@ -127,11 +127,16 @@ public interface PortalURL extends Cloneable {
     * @return
     */
    public boolean isVersion3(String portletId);
+   
+   /**
+    *  To allow delayed reading of the servlet request parameters until the first time
+    *  the parameters are read in order to allow a portlet to potentially set   
+    *  the character encoding during processAction or serveResource.            
+    */
+   public void handleServletRequestParams();
 
    Collection<PortalURLParameter> getParameters();
 
-   Map<String, String[]> getPrivateRenderParameters();
-
    Map<String, PortletMode> getPortletModes();
 
    PortletMode getPortletMode(String windowId);
@@ -168,5 +173,10 @@ public interface PortalURL extends Cloneable {
    void setResourceID(String resourceID);
    String getResourceID();
 
-   void merge(PortalURL url, String windowId);	
+   void merge(PortalURL url, String windowId);
+
+   /**
+    * @param window
+    */
+   public void clearResourceParameters(String window);	
 }


[02/22] portals-pluto git commit: progress with merge

Posted by ms...@apache.org.
progress with merge


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/f4fab017
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/f4fab017
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/f4fab017

Branch: refs/heads/V3Prototype
Commit: f4fab017fc9b34fbccc64e0ae8f8759ad1b4caac
Parents: 8423118
Author: Scott Nicklous <ms...@apache.org>
Authored: Tue Feb 3 21:15:33 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Tue Feb 3 21:15:33 2015 +0100

----------------------------------------------------------------------
 .../container/impl/RenderResponseImpl.java      | 252 +++++++++----------
 .../src/main/java/javax/portlet/BaseURL.java    | 190 +++++++++++---
 .../portlet/filter/RenderResponseWrapper.java   |   4 +-
 3 files changed, 289 insertions(+), 157 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/f4fab017/pluto-container/src/main/java/org/apache/pluto/container/impl/RenderResponseImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/RenderResponseImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/RenderResponseImpl.java
index e369156..04b41ea 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/RenderResponseImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/RenderResponseImpl.java
@@ -1,126 +1,126 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pluto.container.impl;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import javax.portlet.PortletMode;
-import javax.portlet.RenderResponse;
-
-import org.apache.pluto.container.PortletRenderResponseContext;
-import org.apache.pluto.container.util.ArgumentUtility;
-
-
-/**
- * Implementation of the <code>javax.portlet.RenderResponse</code> interface.
- * 
- */
-public class RenderResponseImpl extends MimeResponseImpl implements RenderResponse
-{	
-    private PortletRenderResponseContext responseContext;
-    
-    public RenderResponseImpl(PortletRenderResponseContext responseContext)
-    {
-        super(responseContext);
-        this.responseContext = responseContext;
-    }
-    
-    /**
-     * Checks if the specified content type is valid (supported by the portlet).
-     * The specified content type should be a tripped mime type without any
-     * character encoding suffix.
-     * @param contentType  the content type to check.
-     * @return true if the content type is valid, false otherwise.
-     */
-    protected boolean isValidContentType(String contentType)
-    {
-        boolean valid = false;
-        for (String supportedType : getResponseContentTypes())
-        {
-            // Content type is supported by an exact match.
-            if (supportedType.equals(contentType))
-            {
-                valid = true;
-            }
-            // The supported type contains a wildcard.
-            else if (supportedType.indexOf("*") >= 0)
-            {
-                int index = supportedType.indexOf("/");
-                String supportedPrefix = supportedType.substring(0, index);
-                String supportedSuffix = supportedType.substring(index + 1);
-                index = contentType.indexOf("/");
-                String typePrefix = contentType.substring(0, index);
-                String typeSuffix = contentType.substring(index + 1);
-                // Check if the prefixes match AND the suffixes match.
-                if (supportedPrefix.equals("*") || supportedPrefix.equals(typePrefix))
-                {
-                    if (supportedSuffix.equals("*") || supportedSuffix.equals(typeSuffix))
-                    {
-                        valid = true;
-                    }
-                }
-            }
-        }
-        // Return the check result.
-        return valid;
-    }
-    
-    @Override
-    public void setContentType(String contentType)
-    {
-        ArgumentUtility.validateNotNull("contentType", contentType);
-        int index =contentType.indexOf(';');
-        if (index != -1)
-        {
-            contentType = contentType.substring(0, index);
-        }
-        contentType = contentType.trim();
-        if (!isValidContentType(contentType))
-        {
-            throw new IllegalArgumentException("Specified content type '" + contentType + "' is not supported.");
-        }
-        super.setContentType(contentType);
-    }
-    
-    public void setNextPossiblePortletModes(Collection<PortletMode> portletModes)
-    {
-        ArgumentUtility.validateNotNull("portletModes", portletModes);
-        if (portletModes.isEmpty())
-        {
-            throw new IllegalArgumentException("At least one possible PortletMode should be specified.");            
-        }
-        ArrayList<PortletMode> modes = new ArrayList<PortletMode>();
-        for (PortletMode mode : portletModes)
-        {
-            if (isPortletModeAllowed(mode))
-            {
-                modes.add(mode);
-            }
-        }
-        if (modes.isEmpty())
-        {
-            modes.add(getPortletWindow().getPortletMode());
-        }
-        responseContext.setNextPossiblePortletModes(modes);
-    }
-    
-    public void setTitle(String title)
-    {
-        responseContext.setTitle(title);
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.container.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.portlet.PortletMode;
+import javax.portlet.RenderResponse;
+
+import org.apache.pluto.container.PortletRenderResponseContext;
+import org.apache.pluto.container.util.ArgumentUtility;
+
+
+/**
+ * Implementation of the <code>javax.portlet.RenderResponse</code> interface.
+ * 
+ */
+public class RenderResponseImpl extends MimeResponseImpl implements RenderResponse
+{	
+    private PortletRenderResponseContext responseContext;
+    
+    public RenderResponseImpl(PortletRenderResponseContext responseContext)
+    {
+        super(responseContext);
+        this.responseContext = responseContext;
+    }
+    
+    /**
+     * Checks if the specified content type is valid (supported by the portlet).
+     * The specified content type should be a tripped mime type without any
+     * character encoding suffix.
+     * @param contentType  the content type to check.
+     * @return true if the content type is valid, false otherwise.
+     */
+    protected boolean isValidContentType(String contentType)
+    {
+        boolean valid = false;
+        for (String supportedType : getResponseContentTypes())
+        {
+            // Content type is supported by an exact match.
+            if (supportedType.equals(contentType))
+            {
+                valid = true;
+            }
+            // The supported type contains a wildcard.
+            else if (supportedType.indexOf("*") >= 0)
+            {
+                int index = supportedType.indexOf("/");
+                String supportedPrefix = supportedType.substring(0, index);
+                String supportedSuffix = supportedType.substring(index + 1);
+                index = contentType.indexOf("/");
+                String typePrefix = contentType.substring(0, index);
+                String typeSuffix = contentType.substring(index + 1);
+                // Check if the prefixes match AND the suffixes match.
+                if (supportedPrefix.equals("*") || supportedPrefix.equals(typePrefix))
+                {
+                    if (supportedSuffix.equals("*") || supportedSuffix.equals(typeSuffix))
+                    {
+                        valid = true;
+                    }
+                }
+            }
+        }
+        // Return the check result.
+        return valid;
+    }
+    
+    @Override
+    public void setContentType(String contentType)
+    {
+        ArgumentUtility.validateNotNull("contentType", contentType);
+        int index =contentType.indexOf(';');
+        if (index != -1)
+        {
+            contentType = contentType.substring(0, index);
+        }
+        contentType = contentType.trim();
+        if (!isValidContentType(contentType))
+        {
+            throw new IllegalArgumentException("Specified content type '" + contentType + "' is not supported.");
+        }
+        super.setContentType(contentType);
+    }
+    
+    public void setNextPossiblePortletModes(Collection<? extends PortletMode> portletModes)
+    {
+        ArgumentUtility.validateNotNull("portletModes", portletModes);
+        if (portletModes.isEmpty())
+        {
+            throw new IllegalArgumentException("At least one possible PortletMode should be specified.");            
+        }
+        ArrayList<PortletMode> modes = new ArrayList<PortletMode>();
+        for (PortletMode mode : portletModes)
+        {
+            if (isPortletModeAllowed(mode))
+            {
+                modes.add(mode);
+            }
+        }
+        if (modes.isEmpty())
+        {
+            modes.add(getPortletWindow().getPortletMode());
+        }
+        responseContext.setNextPossiblePortletModes(modes);
+    }
+    
+    public void setTitle(String title)
+    {
+        responseContext.setTitle(title);
+    }
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/f4fab017/portlet-api/src/main/java/javax/portlet/BaseURL.java
----------------------------------------------------------------------
diff --git a/portlet-api/src/main/java/javax/portlet/BaseURL.java b/portlet-api/src/main/java/javax/portlet/BaseURL.java
index 025e2c2..bb097bb 100644
--- a/portlet-api/src/main/java/javax/portlet/BaseURL.java
+++ b/portlet-api/src/main/java/javax/portlet/BaseURL.java
@@ -25,17 +25,47 @@
 package javax.portlet;
 
 /**
- * The <CODE>BaseURL</CODE> defines the basic capabilities
- * of a portlet URL pointing back to the portlet.
- *
+ * <div class="changed_modified_3_0">The
+ * <CODE>BaseURL</CODE> defines the basic capabilities of a portlet URL
+ * pointing back to the portlet.
+ * <p>
+ * If the portlet state is modified through this interface, the changes take
+ * effect when the URL containing the modifications is triggered.
+ * </div>
+ * @see   MutablePortletState
  * @since 2.0
  */
 public interface BaseURL {
 
     /**
-     * Sets the given String parameter to this URL. 
+    * <span class="changed_modified_3_0">Sets</span> 
+    * the given String parameter on this URL. 
      * <p>
-     * This method replaces all parameters with the given key.
+    * This method replaces all parameter values with the given key, 
+    * <span class="changed_added_3_0">as allowed 
+    * according to the rules for the URL.</span>
+    * <div class="changed_added_3_0"> 
+    * <ul>
+    * <li>
+    * <code>RenderURL</code> - Both public and private parameters can be set. 
+    * </li>
+    * <li>
+    * <code>ActionURL</code> - Action parameters (private parameters) are set as described. 
+    * Public render parameters 
+    * remain unchanged. If an action parameter has the same name as a public 
+    * render parameter, both the action parameter value and the public render parameter
+    * value will be available during processing of the action request.
+    * </li>
+    * <li>
+    * <code>ResourceURL</code> - Resource parameters are set. Public 
+    * and private render parameters that were attached to the URL when it was created 
+    * remain unchanged. 
+    * If a resource parameter has the same name as a public or private 
+    * render parameter, both the resource parameter value and the public or private 
+    * render parameter value will be available during processing of the resource request.
+    * </li>
+    * </ul>
+    * </div>
      * <p>
      * The <code>PortletURL</code> implementation 'x-www-form-urlencoded' encodes
      * all  parameter names and values. Developers should not encode them.
@@ -45,6 +75,10 @@ public interface BaseURL {
      * <p>
      * A parameter value of <code>null</code> indicates that this
      * parameter should be removed.
+    * <span class="changed_added_3_0">However, an empty string value ("") is allowed.</span>
+    * <p>
+    * <span class="changed_added_3_0">A public render parameter cannot be removed by 
+    * setting its value to <code>null</code>.</span>
      *
      * @param   name
      *          the parameter name
@@ -52,22 +86,60 @@ public interface BaseURL {
      *          the parameter value
      *
      * @exception  java.lang.IllegalArgumentException 
-     *                            if name is <code>null</code>.
+    *                            if name is <code>null</code>;
+    *                            <span class="changed_added_3_0">if an attempt is made to set a public 
+    *                            render parameter to <code>null</code>.</span> 
+    * @deprecated As of version 3.0. Use {@link PortletURL#getRenderParameters()},
+    * {@link ResourceURL#getResourceParameters()},
+    * or {@link ActionURL#getActionParameters()} as required.
      */
 
+   @Deprecated
     public void setParameter (String name, String value);
 
 
     /**
-     * Sets the given String array parameter to this URL. 
+    * <span class="changed_modified_3_0">Sets
+    * a multi-valued String parameter on</span> this URL. 
+    * <div class="changed_added_3_0"> 
      * <p>
-     * This method replaces all parameters with the given key.
+    * This method replaces all parameter values with the given key
+    * according to the rules for the URL. 
+    * <ul>
+    * <li>
+    * <code>RenderURL</code> - Both public and private parameters can be set. 
+    * </li>
+    * <li>
+    * <code>ActionURL</code> - Action parameters (private parameters) are set as described. 
+    * Public render parameters 
+    * remain unchanged. If an action parameter has the same name as a public 
+    * render parameter, both the action parameter value and the public render parameter
+    * value will be available during processing of the action request.
+    * </li>
+    * <li>
+    * <code>ResourceURL</code> - Resource parameters are set. Public 
+    * and private render parameters that were attached to the URL when it was created 
+    * remain unchanged. 
+    * If a resource parameter has the same name as a public or private 
+    * render parameter, both the resource parameter value and the public or private 
+    * render parameter value will be available during processing of the resource request.
+    * </li>
+    * </ul>
+    * </div>
      * <p>
      * The <code>PortletURL</code> implementation 'x-www-form-urlencoded' encodes
      * all  parameter names and values. Developers should not encode them.
      * <p>
      * A portlet container may prefix the attribute names internally 
      * in order to preserve a unique namespace for the portlet.
+    * <div class="changed_added_3_0"> 
+    * <p>
+    * A values parameter of <code>null</code> indicates that this
+    * parameter should be removed. 
+    * <p>
+    * If the values parameter is not null, no element of the values array may be null. 
+    * However, an empty string value ("") is allowed.
+    * </div>
      *
      * @param   name
      *          the parameter name
@@ -75,16 +147,56 @@ public interface BaseURL {
      *          the parameter values
      *
      * @exception  java.lang.IllegalArgumentException 
-     *                            if name is <code>null</code>.
+    *                            if name is <code>null</code>; 
+    *      <span class="changed_added_3_0">if an element of the values array is <code>null</code>; 
+    *      if an attempt is made to set a public render parameter to <code>null</code>.</span>
+    *       
+    * @deprecated As of version 3.0. Use {@link PortletURL#getRenderParameters()},
+    * {@link ResourceURL#getResourceParameters()},
+    * or {@link ActionURL#getActionParameters()} as required.
      */
 
-    public void setParameter (String name, String[] values);
+   @Deprecated
+   public void setParameter (String name, String... values);
 
 
     /**
-     * Sets a parameter map for this URL.
+    * <span class="changed_modified_3_0">Sets</span> 
+    * a parameter map for this URL.
      * <p>
-     * All previously set parameters are cleared.
+    * <span class="changed_deleted_3_0">All previously set parameters are cleared.</span>
+    * <div class="changed_added_3_0"> 
+    * <p> 
+    * This method can be used to set both public and private render parameters 
+    * according to the rules for the URL. 
+    * <ul>
+    * <li>
+    * <code>RenderURL</code> - Both public and private parameters can be set. 
+    * </li>
+    * <li>
+    * <code>ActionURL</code> - Action parameters are set. Public render parameters 
+    * remain unchanged. If an action parameter has the same name as a public 
+    * render parameter, both the action parameter value and the public render parameter
+    * value will be available during processing of the action request.
+    * </li>
+    * <li>
+    * <code>ResourceURL</code> - Resource parameters are set. Public 
+    * and private render parameters that were attached to the URL when it was created 
+    * remain unchanged. 
+    * If a resource parameter has the same name as a public or private 
+    * render parameter, both the resource parameter value and the public or private 
+    * render parameter value will be available during processing of the resource request.
+    * </li>
+    * </ul>
+    * <p>
+    * These parameters will be accessible through the portlet request initiated through
+    * the URL.
+    * <p>
+    * Any previously set private render parameter that is not contained in the new map
+    * is removed. However, public render parameters cannot be removed by excluding
+    * them from the map. Public render parameters that are not included in the map
+    * remain unchanged.
+    * </div>
      * <p>
      * The <code>PortletURL</code> implementation 'x-www-form-urlencoded' encodes
      * all  parameter names and values. Developers should not encode them.
@@ -92,26 +204,36 @@ public interface BaseURL {
      * A portlet container may prefix the attribute names internally, 
      * in order to preserve a unique namespace for the portlet.
      *
-     * @param  parameters   Map containing parameter names for 
-     *                      the render phase as 
-     *                      keys and parameter values as map 
-     *                      values. The keys in the parameter
-     *                      map must be of type String. The values 
-     *                      in the parameter map must be of type
-     *                      String array (<code>String[]</code>).
+    * @param parameters
+    * <span class="changed_modified_3_0">
+    * Map containing parameter names for the render phase as keys and
+    * parameter values as map values. The keys in the parameter map must be of type
+    * String and may not be null or the empty string (""). The values in the parameter
+    * map must be of type String array (<code>String[]</code>). 
+    * Neither the values array nor any of
+    * its elements may be null; however, the empty string ("") is allowed as an array element.
+    * </span>
      *
      * @exception   java.lang.IllegalArgumentException 
-     *                      if parameters is <code>null</code>, if
-     *                      any of the keys in the Map are <code>null</code>, 
-     *                      if any of the keys is not a String, or if any of 
-     *                      the values is not a String array.
+    *                <span class="changed_modified_3_0">
+    *                if parameters is <code>null</code>, if any of the
+    *                keys in the Map are <code>null</code>, if any of
+    *                the keys is not a String, if any of the values is not a
+    *                String array, or if any of the String array elements
+    *                are null. 
+    *                </span>
+    *                
+    * @deprecated As of version 3.0. Use {@link PortletURL#getRenderParameters()},
+    * {@link ResourceURL#getResourceParameters()},
+    * or {@link ActionURL#getActionParameters()} as required.
      */
 
+   @Deprecated
     public void setParameters(java.util.Map<String, String[]> parameters);
 
 
     /**
-     * Indicated the security setting for this URL. 
+    * Indicates the security setting for this URL. 
      * <p>
      * Secure set to <code>true</code> indicates that the portlet requests
      * a secure connection between the client and the portlet window for
@@ -148,13 +270,18 @@ public interface BaseURL {
     public String toString ();
     
     /** 
-     * Returns a <code>Map</code> of the parameters 
-     * currently set on this portlet URL via the 
-     * <code>setParameter</code> or <code>setParameters</code>
-     * methods.
+    * <span class="changed_modified_3_0">Returns</span> a
+    * <code>Map</code> of the parameters currently set on this portlet
+    * URL.
      * <p>
      * The values in the returned <code>Map</code> are from type
      * String array (<code>String[]</code>).
+    * <p class="changed_added_3_0">
+    * The contents of the returned map are immutable in the sense that modifying the map 
+    * does not directly affect the render parameters. In order to set the 
+    * parameters using the modified map, 
+    * the {@link BaseURL#setParameters(Map)} method must be used.
+    * </p>
      * <p>
      * If no parameters exist this method returns an empty <code>Map</code>.
      *             
@@ -165,8 +292,13 @@ public interface BaseURL {
      *             String array (<code>String[]</code>).
      *
      * @since 2.0
+    * 
+    * @deprecated As of version 3.0. Use {@link PortletURL#getRenderParameters()},
+    * {@link ResourceURL#getResourceParameters()},
+    * or {@link ActionURL#getActionParameters()} as required.
      */
 
+   @Deprecated
     public java.util.Map<String, String[]> getParameterMap();
 
     /**
@@ -180,7 +312,7 @@ public interface BaseURL {
      * non-escaped URLs use {@link #write(java.io.Writer, boolean)}.
      *  
      * @param out  the writer to write the portlet URL to
-     * @throws java.io.IOException  if an I/O error occured while writing the URL
+    * @throws java.io.IOException  if an I/O error occurred while writing the URL
      *
      * @since 2.0
      */

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/f4fab017/portlet-api/src/main/java/javax/portlet/filter/RenderResponseWrapper.java
----------------------------------------------------------------------
diff --git a/portlet-api/src/main/java/javax/portlet/filter/RenderResponseWrapper.java b/portlet-api/src/main/java/javax/portlet/filter/RenderResponseWrapper.java
index b39dda9..5bcb55d 100644
--- a/portlet-api/src/main/java/javax/portlet/filter/RenderResponseWrapper.java
+++ b/portlet-api/src/main/java/javax/portlet/filter/RenderResponseWrapper.java
@@ -176,10 +176,10 @@ public class RenderResponseWrapper extends PortletResponseWrapper implements Ren
     }
 
     /**
-     *  The default behavior of this method is to call 
+     *  <span class="changed_modified_3_0">The</span> default behavior of this method is to call 
      * <code>setNextPossiblePortletModes()</code> on the wrapped response object.
      */
-    public void setNextPossiblePortletModes(Collection<PortletMode> portletModes) {
+    public void setNextPossiblePortletModes(Collection<? extends PortletMode> portletModes) {
         response.setNextPossiblePortletModes(portletModes);
     }
 


[17/22] portals-pluto git commit: Bug fix in Map cloning method

Posted by ms...@apache.org.
Bug fix in Map cloning method


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/0b758a10
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/0b758a10
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/0b758a10

Branch: refs/heads/V3Prototype
Commit: 0b758a10f2ec58fe57484287d4779f938d2fd5a8
Parents: 9dc7bee
Author: Scott Nicklous <ms...@apache.org>
Authored: Fri Feb 13 00:41:26 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Fri Feb 13 00:41:26 2015 +0100

----------------------------------------------------------------------
 .../pluto/container/impl/PortletRequestImpl.java  | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/0b758a10/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletRequestImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletRequestImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletRequestImpl.java
index ae30689..04a2c96 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletRequestImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletRequestImpl.java
@@ -135,19 +135,11 @@ public abstract class PortletRequestImpl implements PortletRequest
 
     protected static Map<String, String[]> cloneParameterMap(Map<String, String[]> map)
     {
-        if (!map.isEmpty())
-        {
-            Map<String, String[]> result = new HashMap<String, String[]>(map.size());
-            for (Map.Entry<String,String[]> entry : map.entrySet())
-            {
-                if (entry.getValue() != null)
-                {
-                    result.put(entry.getKey(), entry.getValue().clone());
-                }
-            }
-            return Collections.unmodifiableMap(result);
-        }
-        return Collections.emptyMap();
+       Map<String, String[]> newMap = new HashMap<String, String[]>();
+       for (String pn : map.keySet()) {
+          newMap.put(pn, map.get(pn).clone());
+       }
+       return newMap;
     }
 
     protected Map<String, String[]> initParameterMap()


[16/22] portals-pluto git commit: Some bug fixes to get the basic JSR 286 parameter support woring on the modified infrastructure

Posted by ms...@apache.org.
Some bug fixes to get the basic JSR 286 parameter support woring on the modified infrastructure


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/9dc7bee1
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/9dc7bee1
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/9dc7bee1

Branch: refs/heads/V3Prototype
Commit: 9dc7bee188c06b8ba198e334c519f53b7637b47c
Parents: bac6574
Author: Scott Nicklous <ms...@apache.org>
Authored: Thu Feb 12 18:03:55 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Thu Feb 12 18:03:55 2015 +0100

----------------------------------------------------------------------
 .../container/impl/StateAwareResponseImpl.java  |   1 -
 .../container/EventCoordinationServiceImpl.java |   3 +-
 .../PortletMimeResponseContextImpl.java         | 432 +++++++-------
 .../container/PortletURLProviderImpl.java       |  20 +-
 .../driver/url/impl/PortalURLParserImpl.java    | 122 ++--
 .../driver/url/impl/RelativePortalURLImpl.java  |  10 +
 .../container/DefaultPortletInvokerService.java | 564 +++++++++----------
 .../pluto/driver/core/PortalRequestContext.java | 295 +++++-----
 .../PublicRenderParameterQNameMapper.java       |  10 +-
 9 files changed, 736 insertions(+), 721 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/9dc7bee1/pluto-container/src/main/java/org/apache/pluto/container/impl/StateAwareResponseImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/StateAwareResponseImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/StateAwareResponseImpl.java
index e57fb3b..122e57e 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/StateAwareResponseImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/StateAwareResponseImpl.java
@@ -176,7 +176,6 @@ public abstract class StateAwareResponseImpl extends PortletResponseImpl
 
    public void setRenderParameter(String key, String... values) {
       ArgumentUtility.validateNotEmpty("key", key);
-      ArgumentUtility.validateNotNull("values", values);
       checkSetStateChanged();
       if (values == null) {
          responseContext.removeParameter(windowId, key);

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/9dc7bee1/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/EventCoordinationServiceImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/EventCoordinationServiceImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/EventCoordinationServiceImpl.java
index e79b0d5..f34dcd9 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/EventCoordinationServiceImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/EventCoordinationServiceImpl.java
@@ -82,7 +82,8 @@ public class EventCoordinationServiceImpl implements EventCoordinationService
         DriverConfiguration driverConfig = (DriverConfiguration) containerServletContext
                 .getAttribute(AttributeKeys.DRIVER_CONFIG);
 
-        PortalURL portalURL = PortalURLParserImpl.getParser().parse(request);
+        // PortalURL portalURL = PortalURLParserImpl.getParser().parse(request);
+        PortalURL portalURL = PortalRequestContext.getContext(request).createPortalURL();
 
 //      Map<String, PortletWindowThread> portletWindowThreads = new HashMap<String, PortletWindowThread>();
 

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/9dc7bee1/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletMimeResponseContextImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletMimeResponseContextImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletMimeResponseContextImpl.java
index 08de9aa..a418988 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletMimeResponseContextImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletMimeResponseContextImpl.java
@@ -1,216 +1,216 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pluto.driver.services.container;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.util.Locale;
-
-import javax.portlet.CacheControl;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.pluto.container.PortletContainer;
-import org.apache.pluto.container.PortletMimeResponseContext;
-import org.apache.pluto.container.PortletURLProvider;
-import org.apache.pluto.container.PortletWindow;
-import org.apache.pluto.container.PortletURLProvider.TYPE;
-import org.apache.pluto.container.util.PrintWriterServletOutputStream;
-
-/**
- * @version $Id$
- *
- */
-public abstract class PortletMimeResponseContextImpl extends PortletResponseContextImpl implements PortletMimeResponseContext
-{
-    private static class CacheControlImpl implements CacheControl
-    {
-        private String eTag;
-        private int expirationTime;
-        private boolean publicScope;
-        private boolean cachedContent;
-        
-        public CacheControlImpl()
-        {
-        }
-
-        public boolean useCachedContent()
-        {
-            return cachedContent;
-        }
-
-        public String getETag()
-        {
-            return this.eTag;
-        }
-
-        public int getExpirationTime()
-        {
-            return expirationTime;
-        }
-
-        public boolean isPublicScope()
-        {
-            return publicScope;
-        }
-
-        public void setETag(String eTag)
-        {
-            this.eTag = eTag;
-        }
-
-        public void setExpirationTime(int expirationTime)
-        {
-            this.expirationTime = expirationTime;
-        }
-
-        public void setPublicScope(boolean publicScope)
-        {
-            this.publicScope = publicScope;
-        }
-
-        public void setUseCachedContent(boolean cachedContent)
-        {
-            this.cachedContent = cachedContent;
-        }
-    }
-    
-    private CacheControl cacheControl;
-    private OutputStream outputStream;
-    
-    public PortletMimeResponseContextImpl(PortletContainer container, HttpServletRequest containerRequest,
-                                          HttpServletResponse containerResponse, PortletWindow window)
-    {
-        super(container, containerRequest, containerResponse, window);
-    }
-    
-    public void close()
-    {
-        cacheControl = null;
-        outputStream = null;
-        super.close();
-    }
-
-    public void flushBuffer() throws IOException
-    {
-        if (!isClosed())
-        {
-            getServletResponse().flushBuffer();
-        }
-    }
-
-    public int getBufferSize()
-    {
-        return getServletResponse().getBufferSize();
-    }
-
-    public CacheControl getCacheControl()
-    {
-        if (isClosed())
-        {
-            return null;
-        }
-        if (cacheControl == null)
-        {
-            cacheControl = new CacheControlImpl();
-        }
-        return cacheControl;
-    }
-
-    public String getCharacterEncoding()
-    {
-        return isClosed() ? null : getServletResponse().getCharacterEncoding();
-    }
-
-    public String getContentType()
-    {
-        return isClosed() ? null : getServletResponse().getContentType();
-    }
-
-    public Locale getLocale()
-    {
-        return isClosed() ? null : getServletResponse().getLocale();
-    }
-
-    public OutputStream getOutputStream() throws IOException, IllegalStateException
-    {
-        if (isClosed())
-        {
-            return null;
-        }
-        if (outputStream == null)
-        {
-            try
-            {
-                outputStream = getServletResponse().getOutputStream();
-            }
-            catch (IllegalStateException e)
-            {
-                // handle situation where underlying ServletResponse its getWriter()
-                // has been called already anyway: return a wrapped PrintWriter in that case
-                outputStream = new PrintWriterServletOutputStream(getServletResponse().getWriter(),
-                                                                   getServletResponse().getCharacterEncoding());
-            }
-        }
-        return outputStream;
-    }
-
-    public PrintWriter getWriter() throws IOException, IllegalStateException
-    {
-        return isClosed() ? null : getServletResponse().getWriter();
-    }
-
-    public boolean isCommitted()
-    {
-        return getServletResponse().isCommitted();
-    }
-
-    public void reset()
-    {
-        getServletResponse().reset();
-    }
-
-    public void resetBuffer()
-    {
-        if (!isClosed())
-        {
-            getServletResponse().resetBuffer();
-        }
-    }
-
-    public void setBufferSize(int size)
-    {
-        if (!isClosed())
-        {
-            getServletResponse().setBufferSize(size);
-        }
-    }
-
-    public void setContentType(String contentType)
-    {
-        if (!isClosed())
-        {
-            getServletResponse().setContentType(contentType);
-        }
-    }
-
-    public PortletURLProvider getPortletURLProvider(TYPE type)
-    {
-        return isClosed() ? null : new PortletURLProviderImpl(getPortalURL(), type, getPortletWindow());
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.driver.services.container;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.util.Locale;
+
+import javax.portlet.CacheControl;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.pluto.container.PortletContainer;
+import org.apache.pluto.container.PortletMimeResponseContext;
+import org.apache.pluto.container.PortletURLProvider;
+import org.apache.pluto.container.PortletWindow;
+import org.apache.pluto.container.PortletURLProvider.TYPE;
+import org.apache.pluto.container.util.PrintWriterServletOutputStream;
+
+/**
+ * @version $Id$
+ *
+ */
+public abstract class PortletMimeResponseContextImpl extends PortletResponseContextImpl implements PortletMimeResponseContext
+{
+    private static class CacheControlImpl implements CacheControl
+    {
+        private String eTag;
+        private int expirationTime;
+        private boolean publicScope;
+        private boolean cachedContent;
+        
+        public CacheControlImpl()
+        {
+        }
+
+        public boolean useCachedContent()
+        {
+            return cachedContent;
+        }
+
+        public String getETag()
+        {
+            return this.eTag;
+        }
+
+        public int getExpirationTime()
+        {
+            return expirationTime;
+        }
+
+        public boolean isPublicScope()
+        {
+            return publicScope;
+        }
+
+        public void setETag(String eTag)
+        {
+            this.eTag = eTag;
+        }
+
+        public void setExpirationTime(int expirationTime)
+        {
+            this.expirationTime = expirationTime;
+        }
+
+        public void setPublicScope(boolean publicScope)
+        {
+            this.publicScope = publicScope;
+        }
+
+        public void setUseCachedContent(boolean cachedContent)
+        {
+            this.cachedContent = cachedContent;
+        }
+    }
+    
+    private CacheControl cacheControl;
+    private OutputStream outputStream;
+    
+    public PortletMimeResponseContextImpl(PortletContainer container, HttpServletRequest containerRequest,
+                                          HttpServletResponse containerResponse, PortletWindow window)
+    {
+        super(container, containerRequest, containerResponse, window);
+    }
+    
+    public void close()
+    {
+        cacheControl = null;
+        outputStream = null;
+        super.close();
+    }
+
+    public void flushBuffer() throws IOException
+    {
+        if (!isClosed())
+        {
+            getServletResponse().flushBuffer();
+        }
+    }
+
+    public int getBufferSize()
+    {
+        return getServletResponse().getBufferSize();
+    }
+
+    public CacheControl getCacheControl()
+    {
+        if (isClosed())
+        {
+            return null;
+        }
+        if (cacheControl == null)
+        {
+            cacheControl = new CacheControlImpl();
+        }
+        return cacheControl;
+    }
+
+    public String getCharacterEncoding()
+    {
+        return isClosed() ? null : getServletResponse().getCharacterEncoding();
+    }
+
+    public String getContentType()
+    {
+        return isClosed() ? null : getServletResponse().getContentType();
+    }
+
+    public Locale getLocale()
+    {
+        return isClosed() ? null : getServletResponse().getLocale();
+    }
+
+    public OutputStream getOutputStream() throws IOException, IllegalStateException
+    {
+        if (isClosed())
+        {
+            return null;
+        }
+        if (outputStream == null)
+        {
+            try
+            {
+                outputStream = getServletResponse().getOutputStream();
+            }
+            catch (IllegalStateException e)
+            {
+                // handle situation where underlying ServletResponse its getWriter()
+                // has been called already anyway: return a wrapped PrintWriter in that case
+                outputStream = new PrintWriterServletOutputStream(getServletResponse().getWriter(),
+                                                                   getServletResponse().getCharacterEncoding());
+            }
+        }
+        return outputStream;
+    }
+
+    public PrintWriter getWriter() throws IOException, IllegalStateException
+    {
+        return isClosed() ? null : getServletResponse().getWriter();
+    }
+
+    public boolean isCommitted()
+    {
+        return getServletResponse().isCommitted();
+    }
+
+    public void reset()
+    {
+        getServletResponse().reset();
+    }
+
+    public void resetBuffer()
+    {
+        if (!isClosed())
+        {
+            getServletResponse().resetBuffer();
+        }
+    }
+
+    public void setBufferSize(int size)
+    {
+        if (!isClosed())
+        {
+            getServletResponse().setBufferSize(size);
+        }
+    }
+
+    public void setContentType(String contentType)
+    {
+        if (!isClosed())
+        {
+            getServletResponse().setContentType(contentType);
+        }
+    }
+
+    public PortletURLProvider getPortletURLProvider(TYPE type)
+    {
+        return isClosed() ? null : new PortletURLProviderImpl(getPortalURL(), type, getPortletWindow());
+    }
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/9dc7bee1/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
index 44e890d..5b42263 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
@@ -87,7 +87,7 @@ public class PortletURLProviderImpl implements PortletURLProvider {
          LOGGER.debug(txt.toString());
       }
 
-      if (isTrace) {
+      if (isDebug) {
          StringBuilder txt = new StringBuilder("Before clearing parameters for window: ");
          txt.append(window);
          for (PortalURLParameter p : this.url.getParameters()) {
@@ -97,6 +97,15 @@ public class PortletURLProviderImpl implements PortletURLProvider {
                txt.append(", Values: ").append(Arrays.toString(p.getValues()));
             }
          }
+         txt.append("\nActive Public Render Parameters:");
+         PublicRenderParameterMapper mapper = this.url.getPublicRenderParameterMapper();
+         List<PortalURLPublicParameter> pups = mapper.getPRPsForWindow(window, false);
+         for (PortalURLPublicParameter p : pups) {
+            txt.append("\nName: ").append(p.getName());
+            txt.append(", Type: ").append(p.getType());
+            txt.append(", isRemoved: ").append(p.isRemoved());
+            txt.append(", Values: ").append(Arrays.toString(p.getValues()));
+         }
          LOGGER.debug(txt.toString());
       }
 
@@ -143,6 +152,15 @@ public class PortletURLProviderImpl implements PortletURLProvider {
                txt.append(", Values: ").append(Arrays.toString(p.getValues()));
             }
          }
+         txt.append("\nActive Public Render Parameters:");
+         PublicRenderParameterMapper mapper = this.url.getPublicRenderParameterMapper();
+         List<PortalURLPublicParameter> pups = mapper.getPRPsForWindow(window, false);
+         for (PortalURLPublicParameter p : pups) {
+            txt.append("\nName: ").append(p.getName());
+            txt.append(", Type: ").append(p.getType());
+            txt.append(", isRemoved: ").append(p.isRemoved());
+            txt.append(", Values: ").append(Arrays.toString(p.getValues()));
+         }
          LOGGER.debug(txt.toString());
       }
       return url;

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/9dc7bee1/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
index 7e62bd1..b7bef1d 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLParserImpl.java
@@ -21,9 +21,7 @@ import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
 import javax.portlet.PortletMode;
 import javax.portlet.ResourceURL;
@@ -59,7 +57,6 @@ public class PortalURLParserImpl implements PortalURLParser {
    // Constants used for Encoding/Decoding ------------------------------------
 
    private static final String PREFIX = "__";
-   private static final String DELIM = "_";
    private static final String PORTLET_ID = "pd";
    private static final String RESOURCE_ID = "ri";
    private static final String CACHE_LEVEL = "cl";
@@ -74,6 +71,7 @@ public class PortalURLParserImpl implements PortalURLParser {
    // See RFC 3986 & URLEncoder documentation.
    private static final String VALUE_DELIM = ":";
    private static final String VALUE_NULL = ",";
+   private static final String DELIM = ";";
 
    private static final String ACTION = "ac";
    private static final String RESOURCE = "rs";
@@ -129,12 +127,14 @@ public class PortalURLParserImpl implements PortalURLParser {
     */
    public PortalURL parse(HttpServletRequest request) {
 
+      String reqURI = request.getRequestURI();
+      String contextPath = request.getContextPath();
+      String servletName = request.getServletPath();
+
       if (LOG.isDebugEnabled()) {
-         LOG.debug("Parsing URL: " + request.getRequestURI());
+         LOG.debug("Parsing. Context Path: " + contextPath + ", Servlet Name: " + servletName + ", Request URI: " + reqURI);
       }
 
-      String contextPath = request.getContextPath();
-      String servletName = request.getServletPath();
 
       String urlBase = request.getScheme()+"://" + request.getServerName() + ":" + request.getServerPort();
       // Construct portal URL using info retrieved from servlet request.
@@ -148,10 +148,20 @@ public class PortalURLParserImpl implements PortalURLParser {
             pathInfo = servletName.substring(idx);
             servletName = servletName.substring(0, idx);
             portalURL = new RelativePortalURLImpl(urlBase, contextPath, servletName, this, request);
-         } else {
-            return portalURL;
+            if (LOG.isDebugEnabled()) {
+               LOG.debug("Constructed new URL due to JSP processing. pathInfo: " + pathInfo);
+            }
          }
       }
+      
+      // we want to work with the untranslated path info, so extract it from the URI.
+      // chop off query string and fragment identifier.
+      String prefix = contextPath + servletName;
+      int qi = reqURI.indexOf("?");
+      int hi = reqURI.indexOf("#");
+      int last = (qi > 0 && hi > 0) ? Math.min(qi, hi) : Math.max(qi, hi);
+      last = (last < 0) ? reqURI.length() : last;
+      pathInfo = reqURI.substring(prefix.length(), last);
 
       if (LOG.isDebugEnabled()) {
          LOG.debug("Parsing request pathInfo: " + pathInfo);
@@ -159,18 +169,18 @@ public class PortalURLParserImpl implements PortalURLParser {
 
       // Need to set the render path (= page) and PRP mapper before the rest of the URL is parsed
       StringBuilder renderPath = new StringBuilder();
-      if (pathInfo.charAt(0) != '/') {
+      if (pathInfo.length() > 0 && pathInfo.charAt(0) != '/') {
          renderPath.append('/');
       }
 
       int ind = pathInfo.indexOf("/" + PREFIX);
       if (ind < 0) {
          // there are no parameters to process
-         renderPath.append(pathInfo);
+         renderPath.append(urlDecode(pathInfo));
          pathInfo = "";
       } else {
          // parameters, etc. remain to be processed
-         renderPath.append(pathInfo.substring(0, ind));
+         renderPath.append(urlDecode(pathInfo.substring(0, ind)));
          pathInfo = pathInfo.substring(ind);
       }
 
@@ -183,10 +193,12 @@ public class PortalURLParserImpl implements PortalURLParser {
       
       ServletContext sc = request.getServletContext();
       DriverConfiguration dc = (DriverConfiguration) sc.getAttribute(AttributeKeys.DRIVER_CONFIG);
+      // special handling for default page
+      String rp = (renderPath.length() > 0) ? renderPath.toString() : null;
       PublicRenderParameterMapper prpm = dc.getPublicRenderParameterService()
-            .getPRPMapper(renderPath.toString());
+            .getPRPMapper(rp);
       portalURL.setPublicRenderParameterMapper(prpm);
-      Collection<String> pids = dc.getPageConfig(renderPath.toString()).getPortletIds();
+      Collection<String> pids = dc.getPageConfig(rp).getPortletIds();
       portalURL.setPortletIds(pids);
 
       // Extract the version info for the portlets on the page and store in URL
@@ -227,9 +239,6 @@ public class PortalURLParserImpl implements PortalURLParser {
                type = t.substring(0, 2);
                val = t.substring(2);
                vals = val.split(DELIM);
-//                for (int ii = 0; ii < vals.length; ii++) {
-//                   vals[ii] = decodeCharacters(vals[ii]);
-//                }
             }
 
             // If the first value is numeric, attempt to dereference the index to obtain the portlet ID.
@@ -445,7 +454,12 @@ public class PortalURLParserImpl implements PortalURLParser {
       if (portalURL.getType() == URLType.Resource) {
          int index = pids.indexOf(targetWindow);
          if (index < 0) {
-            LOG.warn("resource window not found in portlet ID list. PID = " + targetWindow);
+            StringBuilder txt = new StringBuilder();
+            txt.append("Resource Window not found in portlet ID list. PID = ")
+               .append(targetWindow)
+               .append(", Portlet IDs in map: ")
+               .append(Arrays.toString(pids.toArray()));
+            LOG.warn(txt.toString());
          } else {
             buffer.append("/");
             buffer.append(PREFIX).append(RESOURCE).append(String.valueOf(index));
@@ -456,7 +470,12 @@ public class PortalURLParserImpl implements PortalURLParser {
       if (portalURL.getType() == URLType.Render) {
          int index = pids.indexOf(targetWindow);
          if (index < 0) {
-            LOG.warn("render window not found in portlet ID list. PID = " + targetWindow);
+            StringBuilder txt = new StringBuilder();
+            txt.append("Render Window not found in portlet ID list. PID = ")
+               .append(targetWindow)
+               .append(", Portlet IDs in map: ")
+               .append(Arrays.toString(pids.toArray()));
+            LOG.warn(txt.toString());
          } else {
             buffer.append("/");
             buffer.append(PREFIX).append(RENDER).append(String.valueOf(index));
@@ -467,7 +486,12 @@ public class PortalURLParserImpl implements PortalURLParser {
       if (portalURL.getType() == URLType.Action) {
          int index = pids.indexOf(targetWindow);
          if (index < 0) {
-            LOG.warn("Action window not found in portlet ID list. PID = " + targetWindow);
+            StringBuilder txt = new StringBuilder();
+            txt.append("Action Window not found in portlet ID list. PID = ")
+               .append(targetWindow)
+               .append(", Portlet IDs in map: ")
+               .append(Arrays.toString(pids.toArray()));
+            LOG.warn(txt.toString());
          } else {
             buffer.append("/");
             buffer.append(PREFIX).append(ACTION).append(String.valueOf(index));
@@ -509,8 +533,10 @@ public class PortalURLParserImpl implements PortalURLParser {
          int index = pids.indexOf(pid);
          PortletMode pm = portalURL.getPortletMode(pid);
          if (index < 0) {
-            LOG.warn("Window not found in portlet ID list. PID = " + pid + ", PM = " + pm.toString());
-            LOG.warn("portlet IDs in map: " + Arrays.toString(pids.toArray()));
+            StringBuilder txt = new StringBuilder("Window not found in portlet ID list. PID = ");
+            txt.append(pid).append(", PM = ").append(pm.toString())
+               .append(", Portlet IDs in map: ").append(Arrays.toString(pids.toArray()));
+            LOG.warn(txt.toString());
          } else {
             buffer.append("/").append(PREFIX).append(PORTLET_MODE)
             .append(String.valueOf(index)).append(DELIM).append(urlEncode(pm.toString()));
@@ -528,7 +554,10 @@ public class PortalURLParserImpl implements PortalURLParser {
          int index = pids.indexOf(pid);
          WindowState ws = portalURL.getWindowState(pid);
          if (index < 0) {
-            LOG.warn("Window not found in portlet ID list. PID = " + pid + ", WS = " + ws.toString());
+            StringBuilder txt = new StringBuilder("Window not found in portlet ID list. PID = ");
+            txt.append(pid).append(", WS = ").append(ws.toString())
+               .append(", Portlet IDs in map: ").append(Arrays.toString(pids.toArray()));
+            LOG.warn(txt.toString());
          } else {
             buffer.append("/").append(PREFIX).append(WINDOW_STATE)
             .append(String.valueOf(index)).append(DELIM).append(urlEncode(ws.toString()));
@@ -609,31 +638,6 @@ public class PortalURLParserImpl implements PortalURLParser {
 
    // Private Encoding/Decoding Methods ---------------------------------------
 
-//    private static void encode(StringBuilder url){
-//       replaceChar(url,"|","%7C");
-//       replaceChar(url,"\"","%22");
-//    }
-// 
-//    private static void replaceChar(StringBuilder url, String character, String change){
-//       boolean contains = url.toString().contains(character);
-//       while (contains){
-//          int index = url.indexOf(character);
-//          url.deleteCharAt(index);
-//          url.insert(index, change, 0, 3);
-//          contains = url.toString().contains(character);
-//       }
-//    }
-// 
-//    private String encodeQueryParam(String param) {
-//       try {
-//          return URLEncoder.encode(param, "UTF-8");
-//       }
-//       catch (UnsupportedEncodingException e) {
-//          // If this happens, we've got bigger problems.
-//          throw new RuntimeException(e);
-//       }
-//    }
-
    /**
     * Wrapper for URLEncoder
     * @param str
@@ -697,29 +701,5 @@ public class PortalURLParserImpl implements PortalURLParser {
       return toString((RelativePortalURLImpl) portalURL);
    }
 
-//    /**
-//     * Encode special characters contained in the string value.
-//     * @param string  the string value to encode.
-//     * @return the encoded string.
-//     */
-//    private String encodeCharacters(String string) {
-//       for (int i = 0; i < ENCODINGS.length; i++) {
-//          string = string.replace(ENCODINGS[i][0], ENCODINGS[i][1]);
-//       }
-//       return string;
-//    }
-// 
-//    /**
-//     * Decode special characters contained in the string value.
-//     * @param string  the string value to decode.
-//     * @return the decoded string.
-//     */
-//    private String decodeCharacters(String string) {
-//       for (int i = 0; i < ENCODINGS.length; i++) {
-//          string = string.replace(ENCODINGS[i][1], ENCODINGS[i][0]);
-//       }
-//       return string;
-//    }
-
 }
 

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/9dc7bee1/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
index 90d2c3b..1655bf0 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
@@ -116,6 +116,9 @@ public class RelativePortalURLImpl implements PortalURL {
       this.urlParser = urlParser;
       this.servletRequest = req;
       this.cloneId = (++cloneCtr) + 10000;
+      if (isDebug) {
+         LOG.debug("Constructed URL, clone ID: " + cloneId);
+      }
    }
 
    /**
@@ -363,6 +366,13 @@ public class RelativePortalURLImpl implements PortalURL {
       if (absolute) {
          return urlBase + result;
       }
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder();
+         txt.append("Clone ID: ").append(cloneId)
+            .append(", absolute: ").append(absolute)
+            .append(", URL: ").append(result);
+         LOG.debug(txt.toString());
+      }
       return result;
    }
 

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/9dc7bee1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/container/DefaultPortletInvokerService.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/container/DefaultPortletInvokerService.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/container/DefaultPortletInvokerService.java
index 44d7619..30ddfaa 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/container/DefaultPortletInvokerService.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/container/DefaultPortletInvokerService.java
@@ -1,282 +1,282 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pluto.driver.container;
-
-import java.io.IOException;
-
-import javax.portlet.ActionRequest;
-import javax.portlet.ActionResponse;
-import javax.portlet.EventRequest;
-import javax.portlet.EventResponse;
-import javax.portlet.PortletException;
-import javax.portlet.PortletRequest;
-import javax.portlet.PortletResponse;
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-import javax.portlet.ResourceRequest;
-import javax.portlet.ResourceResponse;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.pluto.container.FilterManager;
-import org.apache.pluto.container.PortletContainerException;
-import org.apache.pluto.container.PortletInvokerService;
-import org.apache.pluto.container.PortletRequestContext;
-import org.apache.pluto.container.PortletWindow;
-import org.apache.pluto.container.driver.PortletContextService;
-import org.apache.pluto.container.driver.PortletServlet;
-import org.apache.pluto.container.util.StringManager;
-
-/**
- * Used internally to invoke/dispatch requests from the container to
- * the portlet application.
- *
- */
-public class DefaultPortletInvokerService implements PortletInvokerService {
-
-    /**
-     * Logger.
-     */
-    private static final Logger LOG = LoggerFactory.getLogger(DefaultPortletInvokerService.class);
-
-    /**
-     * Exception Messages.
-     */
-    private static final StringManager EXCEPTIONS = StringManager.getManager(
-            DefaultPortletInvokerService.class.getPackage().getName());
-
-    // Private Member Variables ------------------------------------------------
-
-    /** URI prefix of the portlet invoker servlet.
-     *  TODO: this is Pluto Portal Driver specific!
-     * */
-    private static final String PREFIX = "/PlutoInvoker/";
-
-    private PortletContextService portletContextService;
-
-    // Constructor -------------------------------------------------------------
-
-    /**
-     * Default Constructor.  Create a new invoker which
-     * is initialized for the given <code>PortletWindow</code>.
-     */
-    public DefaultPortletInvokerService(PortletContextService portletContextService) {
-        this.portletContextService = portletContextService;
-    }
-
-    // Public Methods ----------------------------------------------------------
-
-    /**
-     * Invoke the portlet with an action request.
-     *
-     * @param context request context used for the invocation
-     * @param request  action request used for the invocation.
-     * @param response action response used for the invocation.
-     * @see PortletServlet
-     * @see javax.portlet.Portlet#processAction(javax.portlet.ActionRequest,javax.portlet.ActionResponse)
-     */
-    public void action(PortletRequestContext context, ActionRequest request, ActionResponse response, FilterManager filterManager)
-    throws IOException, PortletException, PortletContainerException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Performing Action Invocation");
-        }
-        invoke(context, request, response, filterManager, PortletInvokerService.METHOD_ACTION);
-    }
-
-    /**
-     * Invoke the portlet with a render request.
-     *
-     * @param request  action request used for the invocation.
-     * @param response action response used for the invocation.
-     * @see PortletServlet
-     * @see javax.portlet.Portlet#render(javax.portlet.RenderRequest,javax.portlet.RenderResponse)
-     */
-    public void render(PortletRequestContext context, RenderRequest request, RenderResponse response, FilterManager filterManager)
-    throws IOException, PortletException, PortletContainerException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Performing Render Invocation");
-        }
-        invoke(context, request, response, filterManager, PortletInvokerService.METHOD_RENDER);
-    }
-
-    /**
-     * Invoke the portlet with a render request.
-     *
-     * @param request  action request used for the invocation.
-     * @param response action response used for the invocation.
-     * @see PortletServlet
-     * @see javax.portlet.Portlet#render(javax.portlet.RenderRequest,javax.portlet.RenderResponse)
-     */
-    public void event(PortletRequestContext context, EventRequest request, EventResponse response, FilterManager filterManager)
-    throws IOException, PortletException, PortletContainerException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Performing Render Invocation");
-        }
-        invoke(context, request, response, filterManager, PortletInvokerService.METHOD_EVENT);
-    }
-
-    /**
-     * Invoke the portlet with a resource request.
-     *
-     * @param request  resource request used for the invocation.
-     * @param response resource response used for the invocation.
-     * @see PortletServlet
-     * @see javax.portlet.Portlet#resource(javax.portlet.ResourceRequest,javax.portlet.ResourceResponse)
-     */
-    public void serveResource(PortletRequestContext context, ResourceRequest request, ResourceResponse response, FilterManager filterManager)
-    throws IOException, PortletException, PortletContainerException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Performing Resource Invocation");
-        }
-        invoke(context, request, response, filterManager, PortletInvokerService.METHOD_RESOURCE);
-    }
-
-    /**
-     * Invoke the portlet with a load request.
-     *
-     * @param request  action request used for the invocation.
-     * @param response action response used for the invocation.
-     * @see PortletServlet
-     */
-    public void load(PortletRequestContext context, PortletRequest request, PortletResponse response)
-    throws IOException, PortletException, PortletContainerException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Performing Load Invocation.");
-        }
-        invoke(context, request, response, PortletInvokerService.METHOD_LOAD);
-    }
-
-    public void admin(PortletRequestContext context, PortletRequest request, PortletResponse response)
-    throws IOException, PortletException, PortletContainerException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Performing Admin Invocation.");
-        }
-
-        invoke(context, request, response, PortletInvokerService.METHOD_ADMIN);
-    }
-
-    // Private Invoke Method ---------------------------------------------------
-
-    private final void invoke(PortletRequestContext context,
-            PortletRequest request,
-            PortletResponse response,
-            Integer methodID)
-    throws PortletException, IOException, PortletContainerException {
-
-        invoke(context, request, response, null, methodID);
-    }
-
-    /**
-     * Perform the invocation.
-     *
-     * @param request       portlet request
-     * @param response      portlet response
-     * @param portletWindow internal portlet window
-     * @param methodID      method identifier
-     * @throws PortletException if a portlet exception occurs.
-     * @throws IOException      if an error occurs writing to the response.
-     */
-    protected final void invoke(PortletRequestContext context,
-            PortletRequest request,
-            PortletResponse response,
-            FilterManager filterManager,
-            Integer methodID)
-    throws PortletException, IOException, PortletContainerException {
-
-        PortletWindow portletWindow = context.getPortletWindow();
-        String appName = portletWindow.getPortletDefinition().getApplication().getName();
-        ServletContext servletContext = portletContextService.getPortletContext(appName).getServletContext();
-
-        String uri =  PREFIX + portletWindow.getPortletDefinition().getPortletName();
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Dispatching to portlet servlet at: " + uri);
-        }
-
-        RequestDispatcher dispatcher = servletContext.getRequestDispatcher(uri);
-
-        if (dispatcher != null) {
-
-            HttpServletRequest containerRequest = context.getContainerRequest();
-            HttpServletResponse containerResponse = context.getContainerResponse();
-
-            try {
-
-                containerRequest.setAttribute(PortletInvokerService.METHOD_ID, methodID);
-                containerRequest.setAttribute(PortletInvokerService.PORTLET_REQUEST, request);
-                containerRequest.setAttribute(PortletInvokerService.PORTLET_RESPONSE, response);
-                containerRequest.setAttribute(PortletInvokerService.FILTER_MANAGER, filterManager);
-
-                if (methodID.equals(PortletInvokerService.METHOD_RESOURCE))
-                {
-                    dispatcher.forward(containerRequest, containerResponse);
-                }
-                else
-                {
-                    dispatcher.include(containerRequest, containerResponse);
-                }
-
-
-            } catch (javax.servlet.UnavailableException ex) {
-                int seconds = ex.isPermanent() ? -1 : ex.getUnavailableSeconds();
-                String message = EXCEPTIONS.getString(
-                        "error.portlet.invoker.unavailable",
-                        uri, new String[]{String.valueOf(seconds)}
-                );
-                if (LOG.isErrorEnabled()) {
-                    LOG.error(message, ex);
-                }
-                throw new javax.portlet.UnavailableException(
-                        message, seconds);
-
-            } catch (javax.servlet.ServletException ex) {
-                String message = EXCEPTIONS.getString("error.portlet.invoker");
-                if (LOG.isErrorEnabled()) {
-                    LOG.error(message);
-                }
-
-                if (ex.getRootCause() != null &&
-                        ex.getRootCause() instanceof PortletException) {
-                    throw (PortletException) ex.getRootCause();
-                } else if (ex.getRootCause() != null) {
-                    throw new PortletException(ex.getRootCause());
-                } else {
-                    throw new PortletException(ex);
-                }
-
-            } finally {
-                containerRequest.removeAttribute(PortletInvokerService.METHOD_ID);
-                containerRequest.removeAttribute(PortletInvokerService.PORTLET_REQUEST);
-                containerRequest.removeAttribute(PortletInvokerService.PORTLET_RESPONSE);
-                containerRequest.removeAttribute(PortletInvokerService.FILTER_MANAGER);
-            }
-        } else {
-            String msg = EXCEPTIONS.getString(
-                    "error.portlet.invoker.dispatcher",
-                    new String[]{servletContext.getServletContextName(), uri}
-            );
-            if (LOG.isErrorEnabled()) {
-                LOG.error(msg);
-            }
-            throw new PortletException(msg);
-        }
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.driver.container;
+
+import java.io.IOException;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.pluto.container.FilterManager;
+import org.apache.pluto.container.PortletContainerException;
+import org.apache.pluto.container.PortletInvokerService;
+import org.apache.pluto.container.PortletRequestContext;
+import org.apache.pluto.container.PortletWindow;
+import org.apache.pluto.container.driver.PortletContextService;
+import org.apache.pluto.container.driver.PortletServlet;
+import org.apache.pluto.container.util.StringManager;
+
+/**
+ * Used internally to invoke/dispatch requests from the container to
+ * the portlet application.
+ *
+ */
+public class DefaultPortletInvokerService implements PortletInvokerService {
+
+    /**
+     * Logger.
+     */
+    private static final Logger LOG = LoggerFactory.getLogger(DefaultPortletInvokerService.class);
+
+    /**
+     * Exception Messages.
+     */
+    private static final StringManager EXCEPTIONS = StringManager.getManager(
+            DefaultPortletInvokerService.class.getPackage().getName());
+
+    // Private Member Variables ------------------------------------------------
+
+    /** URI prefix of the portlet invoker servlet.
+     *  TODO: this is Pluto Portal Driver specific!
+     * */
+    private static final String PREFIX = "/PlutoInvoker/";
+
+    private PortletContextService portletContextService;
+
+    // Constructor -------------------------------------------------------------
+
+    /**
+     * Default Constructor.  Create a new invoker which
+     * is initialized for the given <code>PortletWindow</code>.
+     */
+    public DefaultPortletInvokerService(PortletContextService portletContextService) {
+        this.portletContextService = portletContextService;
+    }
+
+    // Public Methods ----------------------------------------------------------
+
+    /**
+     * Invoke the portlet with an action request.
+     *
+     * @param context request context used for the invocation
+     * @param request  action request used for the invocation.
+     * @param response action response used for the invocation.
+     * @see PortletServlet
+     * @see javax.portlet.Portlet#processAction(javax.portlet.ActionRequest,javax.portlet.ActionResponse)
+     */
+    public void action(PortletRequestContext context, ActionRequest request, ActionResponse response, FilterManager filterManager)
+    throws IOException, PortletException, PortletContainerException {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Performing Action Invocation");
+        }
+        invoke(context, request, response, filterManager, PortletInvokerService.METHOD_ACTION);
+    }
+
+    /**
+     * Invoke the portlet with a render request.
+     *
+     * @param request  action request used for the invocation.
+     * @param response action response used for the invocation.
+     * @see PortletServlet
+     * @see javax.portlet.Portlet#render(javax.portlet.RenderRequest,javax.portlet.RenderResponse)
+     */
+    public void render(PortletRequestContext context, RenderRequest request, RenderResponse response, FilterManager filterManager)
+    throws IOException, PortletException, PortletContainerException {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Performing Render Invocation");
+        }
+        invoke(context, request, response, filterManager, PortletInvokerService.METHOD_RENDER);
+    }
+
+    /**
+     * Invoke the portlet with a render request.
+     *
+     * @param request  action request used for the invocation.
+     * @param response action response used for the invocation.
+     * @see PortletServlet
+     * @see javax.portlet.Portlet#render(javax.portlet.RenderRequest,javax.portlet.RenderResponse)
+     */
+    public void event(PortletRequestContext context, EventRequest request, EventResponse response, FilterManager filterManager)
+    throws IOException, PortletException, PortletContainerException {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Performing Event Invocation");
+        }
+        invoke(context, request, response, filterManager, PortletInvokerService.METHOD_EVENT);
+    }
+
+    /**
+     * Invoke the portlet with a resource request.
+     *
+     * @param request  resource request used for the invocation.
+     * @param response resource response used for the invocation.
+     * @see PortletServlet
+     * @see javax.portlet.Portlet#resource(javax.portlet.ResourceRequest,javax.portlet.ResourceResponse)
+     */
+    public void serveResource(PortletRequestContext context, ResourceRequest request, ResourceResponse response, FilterManager filterManager)
+    throws IOException, PortletException, PortletContainerException {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Performing Resource Invocation");
+        }
+        invoke(context, request, response, filterManager, PortletInvokerService.METHOD_RESOURCE);
+    }
+
+    /**
+     * Invoke the portlet with a load request.
+     *
+     * @param request  action request used for the invocation.
+     * @param response action response used for the invocation.
+     * @see PortletServlet
+     */
+    public void load(PortletRequestContext context, PortletRequest request, PortletResponse response)
+    throws IOException, PortletException, PortletContainerException {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Performing Load Invocation.");
+        }
+        invoke(context, request, response, PortletInvokerService.METHOD_LOAD);
+    }
+
+    public void admin(PortletRequestContext context, PortletRequest request, PortletResponse response)
+    throws IOException, PortletException, PortletContainerException {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Performing Admin Invocation.");
+        }
+
+        invoke(context, request, response, PortletInvokerService.METHOD_ADMIN);
+    }
+
+    // Private Invoke Method ---------------------------------------------------
+
+    private final void invoke(PortletRequestContext context,
+            PortletRequest request,
+            PortletResponse response,
+            Integer methodID)
+    throws PortletException, IOException, PortletContainerException {
+
+        invoke(context, request, response, null, methodID);
+    }
+
+    /**
+     * Perform the invocation.
+     *
+     * @param request       portlet request
+     * @param response      portlet response
+     * @param portletWindow internal portlet window
+     * @param methodID      method identifier
+     * @throws PortletException if a portlet exception occurs.
+     * @throws IOException      if an error occurs writing to the response.
+     */
+    protected final void invoke(PortletRequestContext context,
+            PortletRequest request,
+            PortletResponse response,
+            FilterManager filterManager,
+            Integer methodID)
+    throws PortletException, IOException, PortletContainerException {
+
+        PortletWindow portletWindow = context.getPortletWindow();
+        String appName = portletWindow.getPortletDefinition().getApplication().getName();
+        ServletContext servletContext = portletContextService.getPortletContext(appName).getServletContext();
+
+        String uri =  PREFIX + portletWindow.getPortletDefinition().getPortletName();
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Dispatching to portlet servlet at: " + uri);
+        }
+
+        RequestDispatcher dispatcher = servletContext.getRequestDispatcher(uri);
+
+        if (dispatcher != null) {
+
+            HttpServletRequest containerRequest = context.getContainerRequest();
+            HttpServletResponse containerResponse = context.getContainerResponse();
+
+            try {
+
+                containerRequest.setAttribute(PortletInvokerService.METHOD_ID, methodID);
+                containerRequest.setAttribute(PortletInvokerService.PORTLET_REQUEST, request);
+                containerRequest.setAttribute(PortletInvokerService.PORTLET_RESPONSE, response);
+                containerRequest.setAttribute(PortletInvokerService.FILTER_MANAGER, filterManager);
+
+                if (methodID.equals(PortletInvokerService.METHOD_RESOURCE))
+                {
+                    dispatcher.forward(containerRequest, containerResponse);
+                }
+                else
+                {
+                    dispatcher.include(containerRequest, containerResponse);
+                }
+
+
+            } catch (javax.servlet.UnavailableException ex) {
+                int seconds = ex.isPermanent() ? -1 : ex.getUnavailableSeconds();
+                String message = EXCEPTIONS.getString(
+                        "error.portlet.invoker.unavailable",
+                        uri, new String[]{String.valueOf(seconds)}
+                );
+                if (LOG.isErrorEnabled()) {
+                    LOG.error(message, ex);
+                }
+                throw new javax.portlet.UnavailableException(
+                        message, seconds);
+
+            } catch (javax.servlet.ServletException ex) {
+                String message = EXCEPTIONS.getString("error.portlet.invoker");
+                if (LOG.isErrorEnabled()) {
+                    LOG.error(message);
+                }
+
+                if (ex.getRootCause() != null &&
+                        ex.getRootCause() instanceof PortletException) {
+                    throw (PortletException) ex.getRootCause();
+                } else if (ex.getRootCause() != null) {
+                    throw new PortletException(ex.getRootCause());
+                } else {
+                    throw new PortletException(ex);
+                }
+
+            } finally {
+                containerRequest.removeAttribute(PortletInvokerService.METHOD_ID);
+                containerRequest.removeAttribute(PortletInvokerService.PORTLET_REQUEST);
+                containerRequest.removeAttribute(PortletInvokerService.PORTLET_RESPONSE);
+                containerRequest.removeAttribute(PortletInvokerService.FILTER_MANAGER);
+            }
+        } else {
+            String msg = EXCEPTIONS.getString(
+                    "error.portlet.invoker.dispatcher",
+                    new String[]{servletContext.getServletContextName(), uri}
+            );
+            if (LOG.isErrorEnabled()) {
+                LOG.error(msg);
+            }
+            throw new PortletException(msg);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/9dc7bee1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalRequestContext.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalRequestContext.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalRequestContext.java
index 08391f1..4be17d2 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalRequestContext.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalRequestContext.java
@@ -1,147 +1,148 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pluto.driver.core;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.pluto.driver.AttributeKeys;
-import org.apache.pluto.driver.config.DriverConfiguration;
-import org.apache.pluto.driver.url.PortalURL;
-import org.apache.pluto.driver.url.PortalURLParser;
-
-/**
- * Defines the context of the currentl portal request.
- * Allows for the retrieval of the original request
- * and response throughout the lifetime of the request.
- *
- * Provides a consistent interface for parsing/creating
- * PortalURLs to the outside world.
- *
- */
-public class PortalRequestContext {
-
-    /** Internal Logger. */
-    private static final Logger LOG = LoggerFactory.getLogger(PortalRequestContext.class);
-
-    /**
-     * The attribute key to bind the portal environment instance to servlet
-     * request.
-     */
-    private final static String REQUEST_KEY =
-            PortalRequestContext.class.getName();
-
-    /** The servletContext of execution. **/
-    private ServletContext servletContext;
-
-    /** The incoming servlet request. */
-    private HttpServletRequest request;
-
-    /** The incoming servlet response. */
-    private HttpServletResponse response;
-
-    /** The requested portal URL. */
-    private PortalURL requestedPortalURL;
-
-
-    // Constructor -------------------------------------------------------------
-
-    /**
-     * Creates a PortalRequestContext instance.
-     * @param request  the incoming servlet request.
-     * @param response  the incoming servlet response.
-     */
-    public PortalRequestContext(ServletContext servletContext,
-                                HttpServletRequest request,
-                                HttpServletResponse response) {
-        this.servletContext = servletContext;
-        this.request = request;
-        this.response = response;
-
-        // Bind the instance to servlet request for later use.
-        request.setAttribute(REQUEST_KEY, this);
-    }
-
-    /**
-     * Returns the portal environment from the servlet request. The portal
-     * envirionment instance is saved in the request scope.
-     * @param request  the servlet request.
-     * @return the portal environment.
-     */
-    public static PortalRequestContext getContext(
-            HttpServletRequest request) {
-        return (PortalRequestContext) request.getAttribute(REQUEST_KEY);
-    }
-
-    /**
-     * Returns the servlet request.
-     * @return the servlet request.
-     */
-    public HttpServletRequest getRequest() {
-        return request;
-    }
-
-    /**
-     * Returns the servlet response.
-     * @return the servlet response.
-     */
-    public HttpServletResponse getResponse() {
-        return response;
-    }
-
-    /**
-     * Returns the requested portal URL.
-     * @return the requested portal URL.
-     */
-    public synchronized PortalURL getRequestedPortalURL() {
-        if(requestedPortalURL == null) {
-            DriverConfiguration config = (DriverConfiguration)
-                servletContext.getAttribute(AttributeKeys.DRIVER_CONFIG);
-            if (config != null) {
-            	PortalURLParser parser = config.getPortalUrlParser();
-            	requestedPortalURL = parser.parse(request);
-            } else {
-            	String msg = "Driver configuration not found while parsing portal URL!";
-            	LOG.error(msg);
-            	throw new IllegalStateException(msg);
-            }
-        }
-        return requestedPortalURL;
-    }
-
-    public PortalURL createPortalURL() {
-        return getRequestedPortalURL().clone();
-    }
-
-    public synchronized void mergePortalURL(PortalURL portalURL, String windowId){
-        if (requestedPortalURL == null)
-        {
-            requestedPortalURL = portalURL;
-        }
-        else
-        {
-            requestedPortalURL.merge(portalURL, windowId);
-        }
-    }
-
-	public ServletContext getServletContext() {
-		return servletContext;
-	}
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.driver.core;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.pluto.driver.AttributeKeys;
+import org.apache.pluto.driver.config.DriverConfiguration;
+import org.apache.pluto.driver.url.PortalURL;
+import org.apache.pluto.driver.url.PortalURLParser;
+
+/**
+ * Defines the context of the currentl portal request.
+ * Allows for the retrieval of the original request
+ * and response throughout the lifetime of the request.
+ *
+ * Provides a consistent interface for parsing/creating
+ * PortalURLs to the outside world.
+ *
+ */
+public class PortalRequestContext {
+
+    /** Internal Logger. */
+    private static final Logger LOG = LoggerFactory.getLogger(PortalRequestContext.class);
+
+    /**
+     * The attribute key to bind the portal environment instance to servlet
+     * request.
+     */
+    private final static String REQUEST_KEY =
+            PortalRequestContext.class.getName();
+
+    /** The servletContext of execution. **/
+    private ServletContext servletContext;
+
+    /** The incoming servlet request. */
+    private HttpServletRequest request;
+
+    /** The incoming servlet response. */
+    private HttpServletResponse response;
+
+    /** The requested portal URL. */
+    private PortalURL requestedPortalURL;
+
+
+    // Constructor -------------------------------------------------------------
+
+    /**
+     * Creates a PortalRequestContext instance.
+     * @param request  the incoming servlet request.
+     * @param response  the incoming servlet response.
+     */
+    public PortalRequestContext(ServletContext servletContext,
+                                HttpServletRequest request,
+                                HttpServletResponse response) {
+        this.servletContext = servletContext;
+        this.request = request;
+        this.response = response;
+
+        // Bind the instance to servlet request for later use.
+        request.setAttribute(REQUEST_KEY, this);
+    }
+
+    /**
+     * Returns the portal environment from the servlet request. The portal
+     * envirionment instance is saved in the request scope.
+     * @param request  the servlet request.
+     * @return the portal environment.
+     */
+    public static PortalRequestContext getContext(
+            HttpServletRequest request) {
+        return (PortalRequestContext) request.getAttribute(REQUEST_KEY);
+    }
+
+    /**
+     * Returns the servlet request.
+     * @return the servlet request.
+     */
+    public HttpServletRequest getRequest() {
+        return request;
+    }
+
+    /**
+     * Returns the servlet response.
+     * @return the servlet response.
+     */
+    public HttpServletResponse getResponse() {
+        return response;
+    }
+
+    /**
+     * Returns the requested portal URL.
+     * @return the requested portal URL.
+     */
+    public synchronized PortalURL getRequestedPortalURL() {
+        if(requestedPortalURL == null) {
+            DriverConfiguration config = (DriverConfiguration)
+                servletContext.getAttribute(AttributeKeys.DRIVER_CONFIG);
+            if (config != null) {
+            	PortalURLParser parser = config.getPortalUrlParser();
+            	requestedPortalURL = parser.parse(request);
+            } else {
+            	String msg = "Driver configuration not found while parsing portal URL!";
+            	LOG.error(msg);
+            	throw new IllegalStateException(msg);
+            }
+        }
+        return requestedPortalURL;
+    }
+
+    public PortalURL createPortalURL() {
+        return getRequestedPortalURL();
+    }
+
+    public synchronized void mergePortalURL(PortalURL portalURL, String windowId){
+       requestedPortalURL = portalURL;
+//         if (requestedPortalURL == null)
+//         {
+//             requestedPortalURL = portalURL;
+//         }
+//         else
+//         {
+//             requestedPortalURL.merge(portalURL, windowId);
+//         }
+    }
+
+	public ServletContext getServletContext() {
+		return servletContext;
+	}
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/9dc7bee1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PublicRenderParameterQNameMapper.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PublicRenderParameterQNameMapper.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PublicRenderParameterQNameMapper.java
index 056944f..42fb80e 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PublicRenderParameterQNameMapper.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PublicRenderParameterQNameMapper.java
@@ -260,17 +260,23 @@ public class PublicRenderParameterQNameMapper implements PublicRenderParameterMa
          dbgstr.append(prefix + qn.toString());
          prefix = ", ";
       }
+
       dbgstr.append(" / window IDs: ");
       prefix = "";
+      
       for (PortalURLPublicParameter prp : prpList) {
-         prpm.prpList.add(prp);
-         prpm.qn2PRP.get(prp.getQName()).add(prp.clone());
+         PortalURLPublicParameter newPrp = prp.clone();
+         prpm.prpList.add(newPrp);
+         prpm.qn2PRP.get(newPrp.getQName()).add(newPrp);
+         
          dbgstr.append(prefix + prp.getWindowId());
          prefix = ", ";
       }
+      
       if (isTrace) {
 //          LOGGER.trace(dbgstr.toString());       // fills log with entries.
       }
+      
       return prpm;
    }
 


[06/22] portals-pluto git commit: Progress on merge

Posted by ms...@apache.org.
Progress on merge


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/727abbe1
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/727abbe1
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/727abbe1

Branch: refs/heads/V3Prototype
Commit: 727abbe18313faa2ffa70ea70c1e3c432aadce55
Parents: aabd8d9
Author: Scott Nicklous <ms...@apache.org>
Authored: Thu Feb 5 16:58:52 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Thu Feb 5 16:58:52 2015 +0100

----------------------------------------------------------------------
 .../container/PortletParameterFactory.java      | 111 +++++++++++++++
 .../container/PortletRequestContextImpl.java    | 134 +------------------
 .../pluto/driver/url/PortalURLParameter.java    |   6 +-
 3 files changed, 119 insertions(+), 132 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/727abbe1/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletParameterFactory.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletParameterFactory.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletParameterFactory.java
new file mode 100644
index 0000000..45cc15c
--- /dev/null
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletParameterFactory.java
@@ -0,0 +1,111 @@
+/*  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.pluto.driver.services.container;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.pluto.driver.services.portal.PublicRenderParameterMapper;
+import org.apache.pluto.driver.url.PortalURL;
+import org.apache.pluto.driver.url.PortalURLParameter;
+import org.apache.pluto.driver.url.PortalURLPublicParameter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Scott Nicklous
+ * 
+ * This class bridges between the URL parameter representation and the parameter
+ * representation presented through the portlet API. It also bridges between the 
+ * JSR 286 and the JSR 362 parameter handling APIs. 
+ *
+ */
+public class PortletParameterFactory {
+   private static final Logger LOGGER = LoggerFactory.getLogger(PortletParameterFactory.class);
+   private final static boolean isDebug = LOGGER.isDebugEnabled();
+   
+   PortalURL url;
+   
+   public PortletParameterFactory(PortalURL url) {
+      this.url = url;
+   }
+
+   public Map<String, String[]> getPrivateParameterMap(String windowId) {
+      HashMap<String, String[]> parameters = new HashMap<String, String[]>();
+//       if (useRequestParameters) {
+//          parameters.putAll(servletRequest.getParameterMap());
+//       }
+//       for (Map.Entry<String, String[]> entry : getPrivateRenderParameterMap()
+//             .entrySet()) {
+//          String[] values = parameters.get(entry.getKey());
+//          if (values == null) {
+//             parameters.put(entry.getKey(), entry.getValue());
+//          } else {
+//             String[] copy = new String[values.length + entry.getValue().length];
+//             System.arraycopy(values, 0, copy, 0, values.length);
+//             System.arraycopy(entry.getValue(), 0, copy, values.length,
+//                   entry.getValue().length);
+//             parameters.put(entry.getKey(), copy);
+//          }
+//       }
+      for (PortalURLParameter parm : url.getParameters()) {
+         if (windowId.equals(parm.getWindowId()) 
+               && PortalURLParameter.PARAM_TYPE_RENDER.equals(parm.getType())) {
+            String[] values = parameters.get(parm.getName());
+            if (values == null) {
+               parameters.put(parm.getName(), parm.getValues());
+            } else {
+               String[] copy = new String[values.length
+                     + parm.getValues().length];
+               System.arraycopy(values, 0, copy, 0, values.length);
+               System.arraycopy(parm.getValues(), 0, copy, values.length,
+                     parm.getValues().length);
+               parameters.put(parm.getName(), copy);
+            }
+         }
+      }
+      if (isDebug) {
+         StringBuffer sb = new StringBuffer();
+         sb.append("Dump private Parameter Map:");
+         for (String k : parameters.keySet()) {
+            sb.append("\nName: " + k + ", Values: ");
+            String sep = "";
+            for (String v : parameters.get(k)) {
+               sb.append(sep + v);
+               sep = ", ";
+            }
+         }
+         LOGGER.debug(sb.toString());
+      }
+      return parameters;
+   }
+   
+   public Map<String, String[]> getPublicParameterMap(String windowId) {
+      HashMap<String, String[]> parameters = new HashMap<String, String[]>();
+      PublicRenderParameterMapper mapper = url.getPublicRenderParameterMapper();
+      // get the active PRPs only
+      List<PortalURLPublicParameter> prps = mapper.getPRPsForWindow(windowId, true);
+      for (PortalURLPublicParameter prp : prps) {
+         parameters.put(prp.getName(), prp.getValues().clone());
+      }
+      return parameters;
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/727abbe1/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java
index 35bf3d8..67b3bba 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletRequestContextImpl.java
@@ -16,38 +16,29 @@
  */
 package org.apache.pluto.driver.services.container;
 
-import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 
-import static java.util.logging.Level.*;
-
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.portlet.PortletConfig;
 import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.Part;
 
 import org.apache.pluto.container.PortletContainer;
 import org.apache.pluto.container.PortletRequestContext;
 import org.apache.pluto.container.PortletWindow;
 import org.apache.pluto.driver.core.PortalRequestContext;
-import org.apache.pluto.driver.services.portal.PublicRenderParameterMapper;
 import org.apache.pluto.driver.url.PortalURL;
 import org.apache.pluto.driver.url.PortalURLParameter;
-import org.apache.pluto.driver.url.PortalURLPublicParameter;
 
 /**
  * @version $Id$
@@ -65,6 +56,7 @@ public class PortletRequestContextImpl implements PortletRequestContext {
    private HttpServletResponse servletResponse;
    private PortletWindow       window;
    private PortalURL           url;
+   private PortletParameterFactory paramFactory;
    private PortletConfig       portletConfig;
    private ServletContext      servletContext;
    private Cookie              cookies[];
@@ -81,6 +73,7 @@ public class PortletRequestContextImpl implements PortletRequestContext {
       this.useRequestParameters = useRequestParameters;
       this.url = PortalRequestContext.getContext(containerRequest)
             .createPortalURL();
+      this.paramFactory = new PortletParameterFactory(url);
    }
 
    protected boolean isReservedAttributeName(String name) {
@@ -104,10 +97,6 @@ public class PortletRequestContextImpl implements PortletRequestContext {
       return result != null ? result : name;
    }
 
-   protected Map<String, String[]> getPrivateRenderParameterMap() {
-      return Collections.emptyMap();
-   }
-
    protected PortalURL getPortalURL() {
       return url;
    }
@@ -129,7 +118,6 @@ public class PortletRequestContextImpl implements PortletRequestContext {
       return servletRequest.getAttribute(name);
    }
 
-   @SuppressWarnings("unchecked")
    public Enumeration<String> getAttributeNames() {
       ArrayList<String> names = new ArrayList<String>();
       for (Enumeration<String> e = servletRequest.getAttributeNames(); e
@@ -177,117 +165,10 @@ public class PortletRequestContextImpl implements PortletRequestContext {
       return servletRequest.getLocale();
    }
 
-   @SuppressWarnings("unchecked")
    public Map<String, String[]> getPrivateParameterMap() {
-      HashMap<String, String[]> parameters = new HashMap<String, String[]>();
-      if (useRequestParameters) {
-         parameters.putAll(servletRequest.getParameterMap());
-         parameters.putAll(decodeMultipartForm());
-      }
-      for (Map.Entry<String, String[]> entry : getPrivateRenderParameterMap()
-            .entrySet()) {
-         String[] values = parameters.get(entry.getKey());
-         if (values == null) {
-            parameters.put(entry.getKey(), entry.getValue());
-         } else {
-            String[] copy = new String[values.length + entry.getValue().length];
-            System.arraycopy(values, 0, copy, 0, values.length);
-            System.arraycopy(entry.getValue(), 0, copy, values.length,
-                  entry.getValue().length);
-            parameters.put(entry.getKey(), copy);
-         }
-      }
-      String windowId = window.getId().getStringId();
-      for (PortalURLParameter parm : url.getParameters()) {
-         if (windowId.equals(parm.getWindowId())) {
-            String[] values = parameters.get(parm.getName());
-            if (values == null) {
-               parameters.put(parm.getName(), parm.getValues());
-            } else {
-               String[] copy = new String[values.length
-                     + parm.getValues().length];
-               System.arraycopy(values, 0, copy, 0, values.length);
-               System.arraycopy(parm.getValues(), 0, copy, values.length,
-                     parm.getValues().length);
-               parameters.put(parm.getName(), copy);
-            }
-         }
-      }
-      if (LOGGER.isLoggable(Level.FINE)) {
-         StringBuffer sb = new StringBuffer();
-         sb.append("Dump private Parameter Map:");
-         for (String k : parameters.keySet()) {
-            sb.append("\nName: " + k + ", Values: ");
-            String sep = "";
-            for (String v : parameters.get(k)) {
-               sb.append(sep + v);
-               sep = ", ";
-            }
-         }
-         LOGGER.fine(sb.toString());
-      }
-      return parameters;
+      return paramFactory.getPrivateParameterMap(window.getId().getStringId());
    }
 
-   /**
-    * Looks for multipart form data on an action or serveResource request, and decodes
-    * it into a parameter map if found. (doesn't handle file upload or anything like that) 
-    * 
-    * NOTE!! : At the current time, this method really only outputs debug info, as it
-    * seems that the servlet container automatically interprets multipart form data
-    * in the same manner that it interprets URL encoded form data.
-    * 
-    * @return A Map containing parameter values extracted from a multipart form
-    */
-   private Map<String, String[]> decodeMultipartForm() {
-      Map<String, String[]> parms = new HashMap<String, String[]>();
-      Map<String, String[]> servletMap = servletRequest.getParameterMap();
-      String ct = servletRequest.getContentType();
-
-      if (LOGGER.isLoggable(Level.FINE)) {
-         LOGGER.fine("Looking for multipart form data. Content Type = " + ct);
-      }
-
-      if ((ct != null) && ct.contains("multipart/form-data")) {
-         try {
-            Collection<Part> parts = servletRequest.getParts();
-
-            if (LOGGER.isLoggable(Level.FINE)) {
-               LOGGER.fine("There are " + parts.size() + " parts to process.");
-            }
-            
-            StringBuilder sb = new StringBuilder();
-            for (Part p : parts) {
-               if (LOGGER.isLoggable(Level.FINE)) {
-                  sb.append("\nPart name: " + p.getName());
-                  sb.append(", size: " + p.getSize());
-                  sb.append(", type: " + p.getContentType());
-                  sb.append(", in servletMap=" + servletMap.containsKey(p.getName()));
-                  Collection<String> hn = p.getHeaderNames();
-                  if (hn != null) {
-                     for (String h : hn) {
-                        sb.append(", hdr==" + h + "==");
-                     }
-                  } else {
-                     sb.append(", hdrNames=" + hn);
-                  }
-                  sb.append(", cdHdr==" + p.getHeader("content-disposition") + "==");
-               }
-            }
-            if (LOGGER.isLoggable(Level.FINE)) {
-               LOGGER.fine(sb.toString());
-            }
-
-         } catch (Exception e) {
-            LOGGER.logp(FINE, LOG_CLASS, "decodeMultipartForm",
-                  "Error reading form data", e);
-         }
-      }
-
-      return parms;
-   }
-
-   @SuppressWarnings("unchecked")
    public Map<String, String[]> getProperties() {
       HashMap<String, String[]> properties = new HashMap<String, String[]>();
       for (Enumeration<String> names = servletRequest.getHeaderNames(); names
@@ -307,14 +188,7 @@ public class PortletRequestContextImpl implements PortletRequestContext {
    }
 
    public Map<String, String[]> getPublicParameterMap() {
-      HashMap<String, String[]> parameters = new HashMap<String, String[]>();
-      PublicRenderParameterMapper mapper = url.getPublicRenderParameterMapper();
-      // get the active PRPs only
-      List<PortalURLPublicParameter> prps = mapper.getPRPsForWindow(window.getId().getStringId(), true);
-      for (PortalURLPublicParameter prp : prps) {
-         parameters.put(prp.getName(), prp.getValues().clone());
-      }
-      return parameters;
+      return paramFactory.getPublicParameterMap(window.getId().getStringId());
    }
 
    public HttpServletRequest getContainerRequest() {

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/727abbe1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLParameter.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLParameter.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLParameter.java
index e988478..46277b6 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLParameter.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/url/PortalURLParameter.java
@@ -126,7 +126,7 @@ public class PortalURLParameter {
    }
 
    /**
-    * For this class, "equals" means "refers to the same parameter". The parameter name & window
+    * For this class, "equals" means "refers to the same parameter". The parameter type, name & window
     * are compared, the values are NOT compared. The combination of window ID and parameter name 
     * must always be unique when the objects are used in collections. 
     */
@@ -140,7 +140,9 @@ public class PortalURLParameter {
             PortalURLParameter pup = (PortalURLParameter) o;
             if (equals(window, pup.window)) {
                if (equals(name, pup.name)) {
-                  eq = true;
+                  if (equals(type, pup.type)) {
+                     eq = true;
+                  }
                }
             }
          }