Author: chris.laprun(a)jboss.com
Date: 2008-02-07 20:51:33 -0500 (Thu, 07 Feb 2008)
New Revision: 9849
Modified:
branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ConsumerRegistryTestCase.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java
Log:
- JBPORTAL-1877: ConsumerRegistryService was not properly updated when the producer info
id was updated.
Modified:
branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2008-02-08
01:35:21 UTC (rev 9848)
+++
branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2008-02-08
01:51:33 UTC (rev 9849)
@@ -113,13 +113,20 @@
else
{
consumer = registry.getConsumer(id);
- EndpointConfigurationInfo endpoint =
getProducerInfo().getEndpointConfigurationInfo();
- serviceDescription = endpoint.getServiceDescriptionURL();
- markup = endpoint.getMarkupURL();
- portletManagement = endpoint.getPortletManagementURL();
- registration = endpoint.getRegistrationURL();
- wsdl = endpoint.getWsdlDefinitionURL();
- useWSDL = endpoint.usesWSDL();
+ if (consumer != null)
+ {
+ EndpointConfigurationInfo endpoint =
getProducerInfo().getEndpointConfigurationInfo();
+ serviceDescription = endpoint.getServiceDescriptionURL();
+ markup = endpoint.getMarkupURL();
+ portletManagement = endpoint.getPortletManagementURL();
+ registration = endpoint.getRegistrationURL();
+ wsdl = endpoint.getWsdlDefinitionURL();
+ useWSDL = endpoint.usesWSDL();
+ }
+ else
+ {
+ beanContext.createErrorMessage("Couldn't find consumer '" +
id + "'!");
+ }
}
}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ConsumerRegistryTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ConsumerRegistryTestCase.java 2008-02-08
01:35:21 UTC (rev 9848)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ConsumerRegistryTestCase.java 2008-02-08
01:51:33 UTC (rev 9849)
@@ -113,8 +113,22 @@
TransactionAssert.commitTransaction();
}
- public void testPersist()
+ public void testUpdateProducerInfo()
{
-// registry.persistConsumer();
+ // create a foo consumer
+ TransactionAssert.beginTransaction();
+ String id = "foo";
+ WSRPConsumer consumer = registry.createConsumer(id, null);
+ ProducerInfo info = consumer.getProducerInfo();
+ TransactionAssert.commitTransaction();
+
+ TransactionAssert.beginTransaction();
+ // change the id on the consumer's producer info and save it
+ info.setId("bar");
+ registry.updateProducerInfo(info);
+
+ assertNull(registry.getConsumer(id));
+ assertEquals(consumer, registry.getConsumer("bar"));
+ TransactionAssert.commitTransaction();
}
}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2008-02-08
01:35:21 UTC (rev 9848)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2008-02-08
01:51:33 UTC (rev 9849)
@@ -233,7 +233,28 @@
Session session = sessionFactory.getCurrentSession();
try
{
- session.update(producerInfo);
+
+ // Retrieve the previous id of the given ProducerInfo to update local consumers
map if needed
+ String oldId = null;
+ ProducerInfo old = (ProducerInfo)session.get(ProducerInfo.class,
producerInfo.getKey());
+ if (old != null)
+ {
+ oldId = old.getId();
+ if (producerInfo.getId().equals(oldId))
+ {
+ oldId = null; // reset oldId as the ProducerInfo's id hasn't been
modified
+ }
+ }
+
+ // merge old producer info with new data
+ session.merge(producerInfo);
+
+ // if we updated and oldId is not null, we need to update the local consumers
map
+ if (oldId != null)
+ {
+ WSRPConsumer consumer = consumers.remove(oldId);
+ consumers.put(producerInfo.getId(), consumer);
+ }
}
catch (HibernateException e)
{