[gatein-commits] gatein SVN: r8661 - components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Mar 28 11:35:23 EDT 2012
Author: chris.laprun at jboss.com
Date: 2012-03-28 11:35:22 -0400 (Wed, 28 Mar 2012)
New Revision: 8661
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java
Log:
Bug 807626 / GTNWSRP-283 - Producer registration error when producer is set to not use registrations: added a workaround (and fix) in case we have improper persisted state.
Modified: components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java
===================================================================
--- components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java 2012-03-28 13:14:33 UTC (rev 8660)
+++ components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java 2012-03-28 15:35:22 UTC (rev 8661)
@@ -146,12 +146,17 @@
RegistrationSPI registration = persistenceManager.addRegistrationFor((ConsumerSPI)consumer, registrationProperties);
// let the policy decide what the handle should be
- String handle = policy.createRegistrationHandleFor(registration.getPersistentKey());
- registration.setRegistrationHandle(handle);
+ createAndSetRegistrationHandle(registration);
return registration;
}
+ private void createAndSetRegistrationHandle(RegistrationSPI registration)
+ {
+ String handle = policy.createRegistrationHandleFor(registration.getPersistentKey());
+ registration.setRegistrationHandle(handle);
+ }
+
public Consumer createConsumer(String name) throws RegistrationException, InvalidConsumerDataException
{
// check with policy if we allow the consumer
@@ -288,8 +293,21 @@
getPersistenceManager().saveChangesTo(registration);
return registration;
}
- //The unregistered consumer should only ever have one registration, return that
- return unregConsumer.getRegistrations().iterator().next();
+ else
+ {
+ //The unregistered consumer should only ever have one registration, return that
+ final Registration registration = unregConsumer.getRegistrations().iterator().next();
+
+ // but first check that we don't have an improper persisted state due to GTNWSRP-283
+ if (registration.getRegistrationHandle() == null || RegistrationStatus.PENDING == registration.getStatus())
+ {
+ // if we have improper persisted state, correct it
+ createAndSetRegistrationHandle((RegistrationSPI)registration);
+ registration.setStatus(RegistrationStatus.VALID);
+ getPersistenceManager().saveChangesTo(registration);
+ }
+ return registration;
+ }
}
public void removeRegistration(String registrationHandle) throws RegistrationException, NoSuchRegistrationException
More information about the gatein-commits
mailing list