[jboss-svn-commits] JBoss Portal SVN: r5627 - in trunk/wsrp: . src/main/org/jboss/portal/test/wsrp/other src/main/org/jboss/portal/wsrp/producer/registration src/main/org/jboss/portal/wsrp/producer/registration/impl src/main/org/jboss/portal/wsrp/producer/registration/policies

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Nov 13 10:08:44 EST 2006


Author: julien at jboss.com
Date: 2006-11-13 10:08:33 -0500 (Mon, 13 Nov 2006)
New Revision: 5627

Added:
   trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ConsumerRegistryTestCase.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/DuplicateRegistrationException.java
Removed:
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerData.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/NoSuchConsumerException.java
Modified:
   trunk/wsrp/build.xml
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/Consumer.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerRegistry.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerRegistryImpl.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/BasicRegistrationPolicy.java
Log:
- removed unnecessary ConsumerData, when a consumer is registered we only need its name, all other data belong to the registration
- started testing the consumer registry

Modified: trunk/wsrp/build.xml
===================================================================
--- trunk/wsrp/build.xml	2006-11-13 14:42:12 UTC (rev 5626)
+++ trunk/wsrp/build.xml	2006-11-13 15:08:33 UTC (rev 5627)
@@ -625,6 +625,7 @@
    <target name="other-test" depends="package-other-test">
       <execute-tests>
          <x-test>
+            <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.other.ConsumerRegistryTestCase"/>
             <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.other.ProducerSessionInformationTestCase"/>
             <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.other.WSRPPortletURLTestCase"/>
             <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.handler.RequestHeaderClientHandlerTestCase"/>

Added: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ConsumerRegistryTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ConsumerRegistryTestCase.java	2006-11-13 14:42:12 UTC (rev 5626)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ConsumerRegistryTestCase.java	2006-11-13 15:08:33 UTC (rev 5627)
@@ -0,0 +1,160 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.test.wsrp.other;
+
+import junit.framework.TestCase;
+import org.jboss.portal.wsrp.producer.registration.ConsumerRegistry;
+import org.jboss.portal.wsrp.producer.registration.Consumer;
+import org.jboss.portal.wsrp.producer.registration.NoSuchRegistrationException;
+import org.jboss.portal.wsrp.producer.registration.DuplicateRegistrationException;
+import org.jboss.portal.wsrp.producer.registration.impl.ConsumerRegistryImpl;
+import org.jboss.portal.wsrp.core.RegistrationData;
+import org.jboss.portal.wsrp.core.Property;
+import org.jboss.portal.wsrp.core.Extension;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Collection;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ConsumerRegistryTestCase extends TestCase
+{
+
+   /** . */
+   private ConsumerRegistry registry;
+
+   /** . */
+   private RegistrationData registrationData;
+
+   public void setUp()
+   {
+      registry = new ConsumerRegistryImpl();
+      registrationData = new RegistrationData(null, null, false, new String[0], new String[0], new String[0], new String[0], new Property[0], new Extension[0]);
+   }
+
+   protected void tearDown() throws Exception
+   {
+      registry = null;
+      registrationData = null;
+   }
+
+   public void testGetConsumerThrowsIAE() throws Exception
+   {
+      try
+      {
+         registry.getConsumer(null);
+         fail();
+      }
+      catch (IllegalArgumentException expected)
+      {
+      }
+   }
+
+   public void testAddConsumer() throws Exception
+   {
+      Consumer consumer = registry.addConsumer("Foo");
+      assertNotNull(consumer);
+      assertEquals("Foo", consumer.getName());
+      assertEquals(Collections.EMPTY_LIST, new ArrayList(consumer.getRegistrations()));
+
+      // Test by retrieving the same consumer
+      consumer = registry.getConsumer("Foo");
+      assertNotNull(consumer);
+      assertEquals("Foo", consumer.getName());
+      assertEquals(Collections.EMPTY_LIST, new ArrayList(consumer.getRegistrations()));
+
+      // Test by retrieving the consumer list
+      Collection consumers = registry.getConsumers();
+      assertNotNull(consumers);
+      assertEquals(1, consumers.size());
+      consumer = (Consumer)consumers.iterator().next();
+      assertNotNull(consumer);
+      assertEquals("Foo", consumer.getName());
+      assertEquals(Collections.EMPTY_LIST, new ArrayList(consumer.getRegistrations()));
+   }
+
+   public void testAddDuplicateConsumer() throws Exception
+   {
+      registry.addConsumer("Foo");
+      try
+      {
+         registry.addConsumer("Foo");
+         fail();
+      }
+      catch (DuplicateRegistrationException expected)
+      {
+      }
+   }
+
+   public void testAddConsumerThrowsIAE() throws Exception
+   {
+      try
+      {
+         registry.addConsumer(null);
+      }
+      catch (IllegalArgumentException expected)
+      {
+         assertEquals(Collections.EMPTY_SET, new HashSet(registry.getConsumers()));
+      }
+   }
+
+   public void testRemoveConsumer() throws Exception
+   {
+      registry.addConsumer("Foo");
+      registry.removeConsumer("Foo");
+      assertNull(registry.getConsumer("Foo"));
+      assertEquals(Collections.EMPTY_SET, new HashSet(registry.getConsumers()));
+   }
+
+   public void testRemoveConsumerThrowsIAE() throws Exception
+   {
+      try
+      {
+         registry.removeConsumer(null);
+      }
+      catch (IllegalArgumentException expected)
+      {
+      }
+   }
+
+   public void testRemoveNonExistingConsumer() throws Exception
+   {
+      try
+      {
+         registry.removeConsumer("Foo");
+      }
+      catch (NoSuchRegistrationException expected)
+      {
+      }
+   }
+
+   public void testAddRegistration() throws Exception
+   {
+//      Consumer consumer = registry.addConsumer("Foo");
+//      consumer.addRegistration()
+   }
+}

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/Consumer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/Consumer.java	2006-11-13 14:42:12 UTC (rev 5626)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/Consumer.java	2006-11-13 15:08:33 UTC (rev 5627)
@@ -36,6 +36,7 @@
  */
 public interface Consumer 
 {
+
    /**
     * Return the consumer name.
     *
@@ -61,6 +62,7 @@
     * Return all the registrations for the specified consumer.
     *
     * @return the consumer registrations
+    * @throws RegistrationException
     */
    Collection getRegistrations() throws RegistrationException;
 
@@ -68,6 +70,8 @@
     * Add the given Registration to this Consumer.
     *
     * @param registration the Registration to be added
+    * @throws IllegalArgumentException if the registration data is null
+    * @throws RegistrationException
     */
-   Registration addRegistration(RegistrationData registration) throws RegistrationException;
+   Registration addRegistration(RegistrationData registration) throws IllegalArgumentException, RegistrationException;
 }

Deleted: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerData.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerData.java	2006-11-13 14:42:12 UTC (rev 5626)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerData.java	2006-11-13 15:08:33 UTC (rev 5627)
@@ -1,85 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
- * contributors as indicated by the @authors tag. See the                     *
- * copyright.txt in the distribution for a full listing of                    *
- * individual contributors.                                                   *
- *                                                                            *
- * This is free software; you can redistribute it and/or modify it            *
- * under the terms of the GNU Lesser General Public License as                *
- * published by the Free Software Foundation; either version 2.1 of           *
- * the License, or (at your option) any later version.                        *
- *                                                                            *
- * This software is distributed in the hope that it will be useful,           *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
- * Lesser General Public License for more details.                            *
- *                                                                            *
- * You should have received a copy of the GNU Lesser General Public           *
- * License along with this software; if not, write to the Free                *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
- ******************************************************************************/
-
-package org.jboss.portal.wsrp.producer.registration;
-
-import java.util.List;
-import java.util.Collections;
-
-/**
- * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public class ConsumerData
-{
-
-   private String agent;
-   private boolean supportsGetMethod;
-   private List supportedModes;
-   private List supportedWindowStates;
-   private List supportedUserScopes;
-   private List supportedUserProfileData;
-
-
-   public ConsumerData(String agent, boolean supportsGetMethod, List supportedModes, List supportedWindowStates,
-                               List supportedUserScopes, List supportedUserProfileData)
-   {
-      this.agent = agent;
-      this.supportsGetMethod = supportsGetMethod;
-      this.supportedModes = supportedModes;
-      this.supportedWindowStates = supportedWindowStates;
-      this.supportedUserScopes = supportedUserScopes;
-      this.supportedUserProfileData = supportedUserProfileData;
-   }
-
-   public String getConsumerAgent()
-   {
-      return agent;
-   }
-
-   public boolean supportsGetMethod()
-   {
-      return supportsGetMethod;
-   }
-
-   public List getSupportedModes()
-   {
-      return Collections.unmodifiableList(supportedModes);
-   }
-
-   public List getSupportedWindowStates()
-   {
-      return Collections.unmodifiableList(supportedWindowStates);
-   }
-
-   public List getSupportedUserScopes()
-   {
-      return Collections.unmodifiableList(supportedUserScopes);
-   }
-
-   public List getSupportedUserProfileData()
-   {
-      return Collections.unmodifiableList(supportedUserProfileData);
-   }
-}

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerRegistry.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerRegistry.java	2006-11-13 14:42:12 UTC (rev 5626)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerRegistry.java	2006-11-13 15:08:33 UTC (rev 5627)
@@ -34,6 +34,7 @@
     * Return a collection of the known consumers.
     *
     * @return the consumer collection
+    * @throws RegistrationException
     */
    Collection getConsumers() throws RegistrationException;
 
@@ -41,39 +42,49 @@
     * Return a specific consumer in the portal
     *
     * @param consumerName the consumer name
-    * @return the consumer registration
+    * @return the consumer registration or null if it does not exist
+    * @throws IllegalArgumentException if the consumer name is null
+    * @throws RegistrationException
     */
-   Consumer getConsumer(String consumerName) throws RegistrationException;
+   Consumer getConsumer(String consumerName) throws IllegalArgumentException, RegistrationException;
 
    /**
     * Adds the given Consumer to the list of registered Consumers.
     *
     * @param consumerName the consumer name
-    * @param data the meta data of the consumer to be added
     * @return the newly created consumer
+    * @throws IllegalArgumentException if the consumer name is null or if the consumer data iks null
+    * @throws RegistrationException
+    * @throws DuplicateRegistrationException if a consumer is already registered under that name
     */
-   Consumer addConsumer(String consumerName, ConsumerData data) throws RegistrationException;
+   Consumer addConsumer(String consumerName) throws IllegalArgumentException, RegistrationException, DuplicateRegistrationException;
 
    /**
     * Removes the given consumer from the list of registered Consumers as well as all the related registrations
     * of that consumer.
     *
     * @param consumerName the consumer name
+    * @throws IllegalArgumentException if the consumer name is null
+    * @throws RegistrationException
+    * @throws NoSuchRegistrationException if there is no consumer registered under that name
     */
-   void removeConsumer(String consumerName) throws RegistrationException, NoSuchConsumerException;
+   void removeConsumer(String consumerName) throws IllegalArgumentException, RegistrationException, NoSuchRegistrationException;
 
    /**
     * Return a specific registration for this consumer.
     *
     * @param registrationId
-    * @return the registration
+    * @return the registration or null if it does not exist
+    * @throws IllegalArgumentException if the registration id is null
+    * @throws RegistrationException
     */
-   Registration getRegistration(String registrationId) throws RegistrationException, NoSuchRegistrationException;
+   Registration getRegistration(String registrationId) throws IllegalArgumentException, RegistrationException;
 
    /**
-    * Remove the Registration associated with the given handle from this Consumer's registrations.
+    * Remove the Registration associated with the given id from this Consumer's registrations.
     *
-    * @param registrationId
+    * @param registrationId the registration id
+    * @throws NoSuchRegistrationException if the registration does not exist
     */
-   void removeRegistration(String registrationId) throws RegistrationException, NoSuchRegistrationException;
+   void removeRegistration(String registrationId) throws IllegalArgumentException, RegistrationException, NoSuchRegistrationException;
 }

Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/DuplicateRegistrationException.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/DuplicateRegistrationException.java	2006-11-13 14:42:12 UTC (rev 5626)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/DuplicateRegistrationException.java	2006-11-13 15:08:33 UTC (rev 5627)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.wsrp.producer.registration;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DuplicateRegistrationException extends RegistrationException
+{
+   public DuplicateRegistrationException()
+   {
+   }
+
+   public DuplicateRegistrationException(String message)
+   {
+      super(message);
+   }
+
+   public DuplicateRegistrationException(String message, Throwable cause)
+   {
+      super(message, cause);
+   }
+
+   public DuplicateRegistrationException(Throwable cause)
+   {
+      super(cause);
+   }
+}

Deleted: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/NoSuchConsumerException.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/NoSuchConsumerException.java	2006-11-13 14:42:12 UTC (rev 5626)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/NoSuchConsumerException.java	2006-11-13 15:08:33 UTC (rev 5627)
@@ -1,49 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
- * contributors as indicated by the @authors tag. See the                     *
- * copyright.txt in the distribution for a full listing of                    *
- * individual contributors.                                                   *
- *                                                                            *
- * This is free software; you can redistribute it and/or modify it            *
- * under the terms of the GNU Lesser General Public License as                *
- * published by the Free Software Foundation; either version 2.1 of           *
- * the License, or (at your option) any later version.                        *
- *                                                                            *
- * This software is distributed in the hope that it will be useful,           *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
- * Lesser General Public License for more details.                            *
- *                                                                            *
- * You should have received a copy of the GNU Lesser General Public           *
- * License along with this software; if not, write to the Free                *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
- ******************************************************************************/
-package org.jboss.portal.wsrp.producer.registration;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class NoSuchConsumerException extends RegistrationException
-{
-   public NoSuchConsumerException()
-   {
-   }
-
-   public NoSuchConsumerException(String message)
-   {
-      super(message);
-   }
-
-   public NoSuchConsumerException(String message, Throwable cause)
-   {
-      super(message, cause);
-   }
-
-   public NoSuchConsumerException(Throwable cause)
-   {
-      super(cause);
-   }
-}

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java	2006-11-13 14:42:12 UTC (rev 5626)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java	2006-11-13 15:08:33 UTC (rev 5627)
@@ -25,7 +25,6 @@
 
 import org.jboss.portal.common.util.ParameterValidation;
 import org.jboss.portal.wsrp.producer.registration.Consumer;
-import org.jboss.portal.wsrp.producer.registration.ConsumerData;
 import org.jboss.portal.wsrp.producer.registration.Registration;
 import org.jboss.portal.wsrp.producer.registration.RegistrationException;
 import org.jboss.portal.wsrp.producer.registration.RegistrationStatus;
@@ -47,17 +46,14 @@
    private String name;
    Set registrationIds;
    private RegistrationStatus status;
-   private ConsumerData metadata;
    private ConsumerRegistryImpl registry;
 
-   public ConsumerImpl(String name, ConsumerData metadata, ConsumerRegistryImpl registry)
+   public ConsumerImpl(String name, ConsumerRegistryImpl registry)
    {
       ParameterValidation.throwIllegalArgExceptionIfNull(name, "Consumer name");
-      ParameterValidation.throwIllegalArgExceptionIfNull(metadata, "ConsumerMetaData");
 
       //
       this.name = name;
-      this.metadata = metadata;
       this.registrationIds = new HashSet();
       this.registry = registry;
    }
@@ -100,10 +96,4 @@
    {
       registrationIds.remove(registrationId);
    }
-
-   public ConsumerData getMetaData() throws RegistrationException
-   {
-      return metadata;
-   }
-
 }

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerRegistryImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerRegistryImpl.java	2006-11-13 14:42:12 UTC (rev 5626)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerRegistryImpl.java	2006-11-13 15:08:33 UTC (rev 5627)
@@ -26,13 +26,13 @@
 import org.jboss.portal.common.util.ParameterValidation;
 import org.jboss.portal.wsrp.producer.registration.Consumer;
 import org.jboss.portal.wsrp.producer.registration.ConsumerRegistry;
-import org.jboss.portal.wsrp.producer.registration.NoSuchConsumerException;
 import org.jboss.portal.wsrp.producer.registration.RegistrationException;
-import org.jboss.portal.wsrp.producer.registration.ConsumerData;
 import org.jboss.portal.wsrp.producer.registration.Registration;
 import org.jboss.portal.wsrp.producer.registration.NoSuchRegistrationException;
 import org.jboss.portal.wsrp.producer.registration.RegistrationStatus;
+import org.jboss.portal.wsrp.producer.registration.DuplicateRegistrationException;
 import org.jboss.portal.wsrp.core.RegistrationData;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
 
 import java.util.Collection;
 import java.util.Collections;
@@ -45,7 +45,7 @@
  * @version $Revision$
  * @since 2.6
  */
-public class ConsumerRegistryImpl implements ConsumerRegistry
+public class ConsumerRegistryImpl extends AbstractJBossService implements ConsumerRegistry
 {
 
    long lastId;
@@ -75,30 +75,35 @@
       return consumer;
    }
 
-   public Consumer addConsumer(String consumerName, ConsumerData data) throws RegistrationException
+   public Consumer addConsumer(String consumerName) throws RegistrationException
    {
       ParameterValidation.throwIllegalArgExceptionIfNull(consumerName, "Consumer name");
-      ParameterValidation.throwIllegalArgExceptionIfNull(data, "Consumer meta data");
-
       if (consumers == null)
       {
          consumers = new HashMap(7);
       }
-
-      Consumer consumer = new ConsumerImpl(consumerName, data, this);
+      if (consumers.containsKey(consumerName))
+      {
+         throw new DuplicateRegistrationException("Consumer " + consumerName + " is already registered");
+      }
+      Consumer consumer = new ConsumerImpl(consumerName, this);
       consumers.put(consumerName, consumer);
       return consumer;
    }
 
-   public void removeConsumer(String consumerName) throws RegistrationException, NoSuchConsumerException
+   public void removeConsumer(String consumerName) throws RegistrationException, NoSuchRegistrationException
    {
       ParameterValidation.throwIllegalArgExceptionIfNull(consumerName, "Consumer name");
 
       //
-      ConsumerImpl consumer = (ConsumerImpl)consumers.remove(consumerName);
+      ConsumerImpl consumer = null;
+      if (consumers != null)
+      {
+         consumer = (ConsumerImpl)consumers.remove(consumerName);
+      }
       if (consumer == null)
       {
-         throw new NoSuchConsumerException("No registered consumer named '" + consumerName + "'");
+         throw new NoSuchRegistrationException("No registered consumer named '" + consumerName + "'");
       }
 
       //
@@ -109,15 +114,10 @@
       }
    }
 
-   public Registration getRegistration(String registrationId) throws RegistrationException, NoSuchRegistrationException
+   public Registration getRegistration(String registrationId) throws RegistrationException
    {
       ParameterValidation.throwIllegalArgExceptionIfNull(registrationId, "Registration id");
-      Registration reg = (Registration)registrations.get(registrationId);
-      if (reg == null)
-      {
-         throw new NoSuchRegistrationException();
-      }
-      return reg;
+      return (Registration)registrations.get(registrationId);
    }
 
    public void removeRegistration(String registrationId) throws RegistrationException, NoSuchRegistrationException
@@ -129,7 +129,7 @@
          throw new NoSuchRegistrationException();
       }
 
-      // Remove association
+      // Destroy association
       reg.consumer.removeRegistration(reg.id);
       reg.consumer = null;
    }

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/BasicRegistrationPolicy.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/BasicRegistrationPolicy.java	2006-11-13 14:42:12 UTC (rev 5626)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/BasicRegistrationPolicy.java	2006-11-13 15:08:33 UTC (rev 5627)
@@ -31,9 +31,7 @@
 import org.jboss.portal.wsrp.producer.registration.ConsumerRegistry;
 import org.jboss.portal.wsrp.producer.registration.Registration;
 import org.jboss.portal.wsrp.producer.registration.RegistrationException;
-import org.jboss.portal.wsrp.producer.registration.ConsumerData;
 import org.jboss.portal.wsrp.producer.registration.impl.ConsumerRegistryImpl;
-import org.jboss.portal.wsrp.producer.registration.policies.RegistrationMetaDataImpl;
 
 import javax.xml.namespace.QName;
 import java.util.Arrays;
@@ -71,12 +69,7 @@
       // A consumer already exists with that name, we need to check that we can allow a new registration
       if (consumer == null)
       {
-         ConsumerData metaData = new ConsumerData(registrationData.getConsumerAgent(),
-            registrationData.isMethodGetSupported(), getListFromArray(registrationData.getConsumerModes()),
-            getListFromArray(registrationData.getConsumerWindowStates()),
-            getListFromArray(registrationData.getConsumerUserScopes()),
-            getListFromArray(registrationData.getCustomUserProfileData()));
-         consumer = consumerRegistry.addConsumer(name, metaData);
+         consumer = consumerRegistry.addConsumer(name);
       }
 
       return consumer.addRegistration(registrationData);




More information about the jboss-svn-commits mailing list