Author: chris.laprun(a)jboss.com
Date: 2010-01-05 17:40:22 -0500 (Tue, 05 Jan 2010)
New Revision: 1169
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/AbstractRegistrationPersistenceManager.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPersistenceManager.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationPersistenceManagerImpl.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/RegistrationHandler.java
Log:
- Added RegistrationPersistenceManager.saveChangesTo method to be able to save changes
that occurred in a Consumer.
- Consumer is now set valid when we update the registration information and changes should
be saved to persistent storage.
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/AbstractRegistrationPersistenceManager.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/AbstractRegistrationPersistenceManager.java 2010-01-05
22:24:55 UTC (rev 1168)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/AbstractRegistrationPersistenceManager.java 2010-01-05
22:40:22 UTC (rev 1169)
@@ -48,6 +48,18 @@
return consumer;
}
+ public void saveChangesTo(Consumer consumer)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(consumer,
"Consumer");
+
+ if (consumer.getPersistentKey() == null)
+ {
+ throw new IllegalArgumentException("Consumer " + consumer + "
hasn't yet been persisted and thus cannot be updated.");
+ }
+
+ internalSaveChangesTo(consumer);
+ }
+
public ConsumerGroup createConsumerGroup(String name) throws RegistrationException
{
ConsumerGroup group = getConsumerGroup(name);
@@ -153,6 +165,8 @@
protected abstract ConsumerSPI internalCreateConsumer(String consumerId, String
consumerName);
+ protected abstract ConsumerSPI internalSaveChangesTo(Consumer consumer);
+
protected abstract void internalAddConsumerGroup(ConsumerGroupSPI group);
protected abstract ConsumerGroupSPI internalRemoveConsumerGroup(String name);
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPersistenceManager.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPersistenceManager.java 2010-01-05
22:24:55 UTC (rev 1168)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPersistenceManager.java 2010-01-05
22:40:22 UTC (rev 1169)
@@ -43,6 +43,13 @@
Consumer createConsumer(String consumerId, String consumerName) throws
RegistrationException;
/**
+ * Saves changes made to the specified consumer.
+ *
+ * @param consumer
+ */
+ void saveChangesTo(Consumer consumer);
+
+ /**
* Retrieves the ConsumerGroup identified by the specified name.
*
* @param name the name of the group to be retrieved
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationPersistenceManagerImpl.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationPersistenceManagerImpl.java 2010-01-05
22:24:55 UTC (rev 1168)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationPersistenceManagerImpl.java 2010-01-05
22:40:22 UTC (rev 1169)
@@ -162,4 +162,10 @@
{
return (ConsumerSPI)getConsumerById(consumerId);
}
+
+ @Override
+ protected ConsumerSPI internalSaveChangesTo(Consumer consumer)
+ {
+ return (ConsumerSPI)consumer; // nothing to do here, left up to subclasses to
implement update in persistent store
+ }
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/RegistrationHandler.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/RegistrationHandler.java 2010-01-05
22:24:55 UTC (rev 1168)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/RegistrationHandler.java 2010-01-05
22:40:22 UTC (rev 1169)
@@ -113,6 +113,7 @@
registration.setStatus(RegistrationStatus.VALID);
Consumer consumer = registration.getConsumer();
consumer.setConsumerAgent(registrationData.getConsumerAgent());
+ consumer.setStatus(RegistrationStatus.VALID);
ConsumerCapabilities capabilities = consumer.getCapabilities();
List<String> modeStrings = registrationData.getConsumerModes();
@@ -142,6 +143,8 @@
capabilities.setSupportedUserProfileData(registrationData.getCustomUserProfileData());
capabilities.setSupportedUserScopes(registrationData.getConsumerUserScopes());
capabilities.setSupportsGetMethod(registrationData.isMethodGetSupported());
+
+ producer.getRegistrationManager().getPersistenceManager().saveChangesTo(consumer);
}
public ReturnAny deregister(RegistrationContext deregister) throws OperationFailed,
InvalidRegistration
@@ -351,7 +354,7 @@
{
List<Property> regProperties = registrationData.getRegistrationProperties();
Map<QName, Object> properties;
- if (regProperties != null)
+ if (regProperties != null && !regProperties.isEmpty())
{
properties = new HashMap<QName, Object>(regProperties.size());
for (Property property : regProperties)