[portal-commits] JBoss Portal SVN: r8949 - in modules/portlet/branches/JBP_PORTLET_BRANCH_1_0: portlet/src/main/org/jboss/portal/portlet and 2 other directories.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Thu Nov 15 11:20:16 EST 2007


Author: julien at jboss.com
Date: 2007-11-15 11:20:16 -0500 (Thu, 15 Nov 2007)
New Revision: 8949

Modified:
   modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/build/build-thirdparty.xml
   modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/portlet/PortletParameters.java
   modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/portlet/state/AbstractPropertyMap.java
   modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/portlet/state/SimplePropertyMap.java
   modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/test/src/main/org/jboss/portal/portlet/test/PortletController.java
Log:
update 1.0 snapshot to common and web update

Modified: modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/build/build-thirdparty.xml
===================================================================
--- modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/build/build-thirdparty.xml	2007-11-15 16:07:42 UTC (rev 8948)
+++ modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/build/build-thirdparty.xml	2007-11-15 16:20:16 UTC (rev 8949)
@@ -47,7 +47,7 @@
       -->
 
       <componentref name="jboss-portal/modules/common" version="trunk-SNAPSHOT"/>
-      <componentref name="jboss-portal/modules/web" version="1.0.0"/>
+      <componentref name="jboss-portal/modules/web" version="trunk-SNAPSHOT"/>
       <componentref name="jboss-portal/modules/test" version="1.0-SNAPSHOT"/>
       <componentref name="sun-servlet" version="2.4"/>
       <componentref name="sun-jaf" version="1.1"/>

Modified: modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/portlet/PortletParameters.java
===================================================================
--- modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/portlet/PortletParameters.java	2007-11-15 16:07:42 UTC (rev 8948)
+++ modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/portlet/PortletParameters.java	2007-11-15 16:20:16 UTC (rev 8949)
@@ -86,45 +86,36 @@
     */
    public void append(Map params) throws ClassCastException, NullPointerException, IllegalArgumentException
    {
-      String[] appendedNames = new String[params.size()];
-      String[][] appendedValues = new String[params.size()][];
+      // Clone
+      params = new HashMap(params);
 
-      // Unwrap all first and validate so we have the atomic behavior guarantee
-      int index = 0;
-      for (Iterator entries = params.entrySet().iterator(); entries.hasNext();)
+      //
+      for (Iterator i = params.entrySet().iterator();i.hasNext();)
       {
-         Map.Entry entry = (Map.Entry)entries.next();
-         appendedNames[index] = (String)unwrapKey(entry.getKey());
-         appendedValues[index++] = (String[])unwrapValue(entry.getValue());
-      }
+         Map.Entry entry = (Entry)i.next();
 
-      // Merge or use appended values
-      Map delegate = getDelegate(true);
-      while (--index >= 0)
-      {
-         String appendedName = appendedNames[index];
-         String[] appendedValue = appendedValues[index];
-
          //
-         String[] value = (String[])delegate.get(appendedName);
-         if (value != null)
+         String[] existingValue = (String[])get(entry.getKey());
+
+         // Perform the appending operation if the entry exist
+         if (existingValue != null)
          {
-            String[] tmp = new String[value.length + appendedValue.length];
-            System.arraycopy(value, 0, tmp, 0, value.length);
-            System.arraycopy(appendedValue, 0, tmp, value.length, appendedValue.length);
-            appendedValue = tmp;
+            String[] appendedValue = (String[])entry.getValue();
+            String[] newValue = new String[existingValue.length + appendedValue.length];
+            System.arraycopy(existingValue, 0, newValue, 0, existingValue.length);
+            System.arraycopy(appendedValue, 0, newValue, existingValue.length, appendedValue.length);
+            entry.setValue(newValue);
          }
-
-         //
-         delegate.put(appendedName, appendedValue);
       }
+
+      //
+      putAll(params);
    }
 
    public String toString()
    {
       StringBuffer buffer = new StringBuffer("Parameters[");
-      Map delegate = getDelegate(false);
-      for (Iterator i = delegate.entrySet().iterator(); i.hasNext();)
+      for (Iterator i = entrySet().iterator(); i.hasNext();)
       {
          Map.Entry entry = (Map.Entry)i.next();
          String name = (String)entry.getKey();

Modified: modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/portlet/state/AbstractPropertyMap.java
===================================================================
--- modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/portlet/state/AbstractPropertyMap.java	2007-11-15 16:07:42 UTC (rev 8948)
+++ modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/portlet/state/AbstractPropertyMap.java	2007-11-15 16:20:16 UTC (rev 8949)
@@ -32,57 +32,19 @@
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  * @version $Revision: 6643 $
  */
-public abstract class AbstractPropertyMap extends TypedMap implements PropertyMap
+public class AbstractPropertyMap extends TypedMap implements PropertyMap
 {
 
-   protected AbstractPropertyMap(MapAccessor accessor)
+   public AbstractPropertyMap(MapAccessor mapAccessor, Converter converter, Converter converter1)
    {
-      super(accessor);
+      super(mapAccessor, converter, converter1);
    }
 
-   protected AbstractPropertyMap(Map delegate)
+   public AbstractPropertyMap(Map map, Converter converter, Converter converter1)
    {
-      super(delegate);
+      super(map, converter, converter1);
    }
 
-   /**
-    * Only accept non null string objects.
-    *
-    * @throws ClassCastException   if the value is not an instance of string
-    */
-   protected void assertKeyValidity(Object value)
-   {
-      if (value instanceof String == false)
-      {
-         throw new ClassCastException("Key must be a String");
-      }
-   }
-
-   /**
-    * Only check are made to the value. The only valid values accepted are non null instance of
-    * <code>org.jboss.portal.common.value.Value</code>.
-    *
-    * @throws NullPointerException if the value is null
-    * @throws ClassCastException   if the value type is not an instance of <code>org.jboss.portal.common.value.Value</code>
-    */
-   protected Object getInternalValue(Object value)
-   {
-      if (value == null)
-      {
-         throw new NullPointerException("Value must not be null");
-      }
-      if (value instanceof Value == false)
-      {
-         throw new ClassCastException("Value must be a Value");
-      }
-      return value;
-   }
-
-   protected Object getExternalValue(Object value)
-   {
-      return value;
-   }
-
    public Value getProperty(String key) throws IllegalArgumentException
    {
       if (key == null)

Modified: modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/portlet/state/SimplePropertyMap.java
===================================================================
--- modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/portlet/state/SimplePropertyMap.java	2007-11-15 16:07:42 UTC (rev 8948)
+++ modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/portlet/state/SimplePropertyMap.java	2007-11-15 16:20:16 UTC (rev 8949)
@@ -22,9 +22,10 @@
  ******************************************************************************/
 package org.jboss.portal.portlet.state;
 
+import org.jboss.portal.common.value.Value;
+
 import java.util.HashMap;
 import java.util.Map;
-import java.io.Serializable;
 
 /**
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
@@ -33,6 +34,54 @@
 public class SimplePropertyMap extends AbstractPropertyMap 
 {
 
+   private static final Converter KEY_CONVERTER = new Converter()
+   {
+      protected Object getInternal(Object o) throws IllegalArgumentException, ClassCastException
+      {
+         if (!(o instanceof String))
+         {
+            throw new ClassCastException("Was expecting an instanceof " + String.class.getName() + " but was " + o.getClass().getName());
+         }
+         return o;
+      }
+      protected Object getExternal(Object o)
+      {
+         if (!(o instanceof String))
+         {
+            throw new ClassCastException("Was expecting an instanceof " + String.class.getName() + " but was " + o.getClass().getName());
+         }
+         return o;
+      }
+      protected boolean equals(Object o, Object o1)
+      {
+         return o.equals(o1);
+      }
+   };
+
+   private static Converter VALUE_CONVERTER = new Converter()
+   {
+      protected Object getInternal(Object o) throws IllegalArgumentException, ClassCastException
+      {
+         if (!(o instanceof Value))
+         {
+            throw new ClassCastException("Was expecting an instanceof " + Value.class.getName() + " but was " + o.getClass().getName());
+         }
+         return o;
+      }
+      protected Object getExternal(Object o)
+      {
+         if (!(o instanceof Value))
+         {
+            throw new ClassCastException("Was expecting an instanceof " + Value.class.getName() + " but was " + o.getClass().getName());
+         }
+         return o;
+      }
+      protected boolean equals(Object o, Object o1)
+      {
+         return o.equals(o1);
+      }
+   };
+
    public SimplePropertyMap()
    {
       this(new HashMap());
@@ -59,6 +108,6 @@
 
    public SimplePropertyMap(Map map)
    {
-      super(map);
+      super(map, KEY_CONVERTER, VALUE_CONVERTER);
    }
 }

Modified: modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/test/src/main/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/test/src/main/org/jboss/portal/portlet/test/PortletController.java	2007-11-15 16:07:42 UTC (rev 8948)
+++ modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/test/src/main/org/jboss/portal/portlet/test/PortletController.java	2007-11-15 16:20:16 UTC (rev 8949)
@@ -165,7 +165,7 @@
                portletNS,
                MARKUP_INFO,
                PortletParametersStateString.create(request.queryParameters),
-               new PortletParameters(request.bodyParameters));
+               request.bodyParameters != null ? new PortletParameters(request.bodyParameters) : null);
             ActionInvocation action = new ActionInvocation(actionContext);
 
             //




More information about the portal-commits mailing list