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 bl...@apache.org on 2004/08/12 12:41:16 UTC

svn commit: rev 36283 - in portals/pluto/trunk/container/src/java/org/apache/pluto: core/impl util

Author: blumm
Date: Thu Aug 12 03:41:13 2004
New Revision: 36283

Modified:
   portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/ActionResponseImpl.java
   portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/PortletPreferencesImpl.java
   portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/PortletRequestImpl.java
   portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/PortletURLImpl.java
   portals/pluto/trunk/container/src/java/org/apache/pluto/util/StringUtils.java
Log:
Fixes resolving Issue #14, Portlet 1.0 Errata from July 20, 2004


Modified: portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/ActionResponseImpl.java
==============================================================================
--- portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/ActionResponseImpl.java	(original)
+++ portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/ActionResponseImpl.java	Thu Aug 12 03:41:13 2004
@@ -34,6 +34,7 @@
 import org.apache.pluto.services.information.DynamicInformationProvider;
 import org.apache.pluto.services.information.InformationProviderAccess;
 import org.apache.pluto.services.information.ResourceURLProvider;
+import org.apache.pluto.util.StringUtils;
 
 public class ActionResponseImpl extends PortletResponseImpl
 implements ActionResponse, InternalActionResponse {
@@ -146,7 +147,7 @@
             }
         }
 
-        renderParameters.putAll(parameters);
+        renderParameters = StringUtils.copyParameters(parameters);
 
         redirectAllowed = false;
     }
@@ -176,7 +177,7 @@
             throw new IllegalArgumentException("Render parameter key or value must not be null or values be an empty array.");
         }
 
-        renderParameters.put(key, values);
+        renderParameters.put(key, StringUtils.copy(values));
 
         redirectAllowed = false;
     }

Modified: portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/PortletPreferencesImpl.java
==============================================================================
--- portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/PortletPreferencesImpl.java	(original)
+++ portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/PortletPreferencesImpl.java	Thu Aug 12 03:41:13 2004
@@ -45,6 +45,7 @@
 import org.apache.pluto.om.portlet.PortletDefinition;
 import org.apache.pluto.om.portlet.PortletDefinitionCtrl;
 import org.apache.pluto.util.Enumerator;
+import org.apache.pluto.util.StringUtils;
 
 
 public class PortletPreferencesImpl implements PortletPreferences
@@ -145,7 +146,7 @@
         // get modified preferences
         if (changedPreferences.containsKey(key))
         {
-            return(String[]) changedPreferences.get(key);
+            return StringUtils.copy((String[]) changedPreferences.get(key));
         }
 
         // get all preference sets
@@ -171,7 +172,10 @@
         }
         else
         { // if preference exists
-            return this.getValuesFromPreference(preference);
+            String[] result = this.getValuesFromPreference(preference);
+            if (result != null)
+                result = StringUtils.copy(result);
+            return result;
         }
     }
     
@@ -199,7 +203,7 @@
             throw new ReadOnlyException("Preference attribute called " + key + " may not be modified");
         }
 
-        changedPreferences.put(key, values);
+        changedPreferences.put(key, StringUtils.copy(values));
         removedPreferences.remove(key);
 
     }
@@ -257,10 +261,10 @@
         while (enum.hasMoreElements())
         {
             String name = (String)enum.nextElement();
-            map.put(name, getValues(name,new String[]{"no value set"}));
+            map.put(name, getValues(name,null));
         }
 
-        return Collections.unmodifiableMap(map);
+        return map;
     }
 
     public void reset(String key) throws ReadOnlyException

Modified: portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/PortletRequestImpl.java
==============================================================================
--- portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/PortletRequestImpl.java	(original)
+++ portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/PortletRequestImpl.java	Thu Aug 12 03:41:13 2004
@@ -27,7 +27,6 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.Vector;
-import java.util.Locale;
 
 import javax.portlet.PortalContext;
 import javax.portlet.PortletMode;
@@ -40,16 +39,17 @@
 
 import org.apache.pluto.core.InternalPortletRequest;
 import org.apache.pluto.factory.PortletObjectAccess;
-import org.apache.pluto.om.window.PortletWindow;
 import org.apache.pluto.om.common.SecurityRoleRef;
 import org.apache.pluto.om.common.SecurityRoleRefSet;
 import org.apache.pluto.om.entity.PortletEntity;
 import org.apache.pluto.om.portlet.PortletDefinition;
+import org.apache.pluto.om.window.PortletWindow;
 import org.apache.pluto.services.information.DynamicInformationProvider;
 import org.apache.pluto.services.information.InformationProviderAccess;
 import org.apache.pluto.services.property.PropertyManager;
 import org.apache.pluto.util.Enumerator;
 import org.apache.pluto.util.NamespaceMapperAccess;
+import org.apache.pluto.util.StringUtils;
 
 public abstract class PortletRequestImpl extends javax.servlet.http.HttpServletRequestWrapper
 implements PortletRequest, InternalPortletRequest
@@ -368,15 +368,17 @@
 
         bodyAccessed = true;
 
-        Map parameters = this._getHttpServletRequest().getParameterMap();
-        return(String[])parameters.get(name);
+        String[] values = (String[])this._getHttpServletRequest().getParameterMap().get(name);
+        if (values != null)
+            values = StringUtils.copy(values);
+        return values;
     }
 
     public Map getParameterMap()
     {
         bodyAccessed = true;
-
-        return Collections.unmodifiableMap(this._getHttpServletRequest().getParameterMap());
+        Map result = StringUtils.copyParameters(this._getHttpServletRequest().getParameterMap());
+        return result;
     }
 
     public boolean isSecure()

Modified: portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/PortletURLImpl.java
==============================================================================
--- portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/PortletURLImpl.java	(original)
+++ portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/PortletURLImpl.java	Thu Aug 12 03:41:13 2004
@@ -36,12 +36,13 @@
 import org.apache.pluto.services.information.DynamicInformationProvider;
 import org.apache.pluto.services.information.InformationProviderAccess;
 import org.apache.pluto.services.information.PortletURLProvider;
+import org.apache.pluto.util.StringUtils;
 
 public class PortletURLImpl implements PortletURL {
     protected DynamicInformationProvider provider; // <ibm>
     protected PortletMode mode = null;
 
-    protected HashMap parameters = new HashMap();
+    protected Map parameters = new HashMap();
 
     protected PortletWindow portletWindow;
 
@@ -110,7 +111,7 @@
             throw new IllegalArgumentException("name and values must not be null or values be an empty array");
         }
 
-        parameters.put( name, values);
+        parameters.put(name, StringUtils.copy(values));
     }
     
     /* (non-Javadoc)
@@ -130,7 +131,7 @@
             }
         }
 
-        this.parameters = new HashMap(parameters);
+        this.parameters = StringUtils.copyParameters(parameters);
     }
 
     public void setSecure (boolean secure) throws PortletSecurityException

Modified: portals/pluto/trunk/container/src/java/org/apache/pluto/util/StringUtils.java
==============================================================================
--- portals/pluto/trunk/container/src/java/org/apache/pluto/util/StringUtils.java	(original)
+++ portals/pluto/trunk/container/src/java/org/apache/pluto/util/StringUtils.java	Thu Aug 12 03:41:13 2004
@@ -19,6 +19,10 @@
 
 package org.apache.pluto.util;
 
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
 /**
  ** <CODE>StringUtils</CODE> hosts a couple of utility methods around
  ** strings.
@@ -354,4 +358,32 @@
         }
         return result;
     }
+
+    public static String[] copy(String[] source) 
+    {
+        if (source == null)
+            return null;
+        int length = source.length;
+        String[] result = new String[length];
+        System.arraycopy(source, 0, result, 0, length);
+        return result;    
+    }
+
+    public static Map copyParameters(Map parameters)
+    { 
+        Map result = new HashMap(parameters);
+        for (Iterator iter = result.entrySet().iterator(); iter.hasNext();) {
+            Map.Entry entry = (Map.Entry)iter.next();
+            if (!(entry.getKey() instanceof String)) {
+                throw new IllegalArgumentException("Parameter map keys must not be null and of type java.lang.String.");
+            }
+            try {
+                entry.setValue(copy((String[]) entry.getValue()));
+            } catch (ClassCastException ex) {                
+                throw new IllegalArgumentException("Parameter map values must not be null and of type java.lang.String[].");
+            }
+        }
+        return result;
+    }
+ 
 }