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:44 UTC

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

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);
     }