Author: chris.laprun(a)jboss.com
Date: 2009-12-19 11:01:59 -0500 (Sat, 19 Dec 2009)
New Revision: 1076
Modified:
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/ProducerInfoMapping.java
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/RegistrationInfoMapping.java
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/RegistrationPropertyMapping.java
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/JCRRegistrationPersistenceManager.java
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/mapping/ConsumerMapping.java
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/mapping/RegistrationMapping.java
portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/conf/wsrp/producer-registrations-nodetypes.xml
Log:
- Use @DefaultValue on active per Julien's recommendation.
- RegistrationPropertyMapping.status is now using the proper type
RegistrationProperty.Status instead of String.
- Added ConsumerMapping.createAndAddRegistrationMappingFrom method to encapsulate
RegistrationMapping creation logic.
- Now considering that when RegistrationMapping.initFrom is called, the
RegistrationMapping has alread been added to its parent.
- Made sure that created objects are attached before being interacted with.
- Made capabilities auto-created on ConsumerMapping.
Modified:
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/ProducerInfoMapping.java
===================================================================
---
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/ProducerInfoMapping.java 2009-12-18
22:37:20 UTC (rev 1075)
+++
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/ProducerInfoMapping.java 2009-12-19
16:01:59 UTC (rev 1076)
@@ -23,6 +23,7 @@
package org.gatein.portal.wsrp.state.consumer.mapping;
+import org.chromattic.api.annotations.DefaultValue;
import org.chromattic.api.annotations.Id;
import org.chromattic.api.annotations.MappedBy;
import org.chromattic.api.annotations.NodeMapping;
@@ -60,9 +61,10 @@
public abstract void setExpirationCacheSeconds(Integer expiration);
@Property(name = "active")
- public abstract Boolean getActive();
+ @DefaultValue.Boolean(false)
+ public abstract boolean getActive();
- public abstract void setActive(Boolean active);
+ public abstract void setActive(boolean active);
@Id
public abstract String getKey();
@@ -94,11 +96,7 @@
// basic properties
info.setKey(getKey());
info.setId(getId());
- Boolean active = getActive();
- if (active != null)
- {
- info.setActive(active);
- }
+ info.setActive(getActive());
info.setExpirationCacheSeconds(getExpirationCacheSeconds());
// endpoint
Modified:
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/RegistrationInfoMapping.java
===================================================================
---
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/RegistrationInfoMapping.java 2009-12-18
22:37:20 UTC (rev 1075)
+++
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/RegistrationInfoMapping.java 2009-12-19
16:01:59 UTC (rev 1076)
@@ -115,7 +115,7 @@
prop.setDescription(desc);
}
- prop.setStatus(RegistrationProperty.Status.valueOf(rpm.getStatus()));
+ prop.setStatus(rpm.getStatus());
}
return regInfo;
Modified:
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/RegistrationPropertyMapping.java
===================================================================
---
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/RegistrationPropertyMapping.java 2009-12-18
22:37:20 UTC (rev 1075)
+++
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/RegistrationPropertyMapping.java 2009-12-19
16:01:59 UTC (rev 1076)
@@ -27,7 +27,6 @@
import org.chromattic.api.annotations.NodeMapping;
import org.chromattic.api.annotations.OneToOne;
import org.chromattic.api.annotations.Property;
-import org.chromattic.api.annotations.RelatedMappedBy;
import org.gatein.portal.wsrp.state.mapping.RegistrationPropertyDescriptionMapping;
import org.gatein.wsrp.consumer.RegistrationProperty;
import org.gatein.wsrp.registration.RegistrationPropertyDescription;
@@ -58,15 +57,15 @@
// todo: this should really be an enum�
@Property(name = "status")
- public abstract String getStatus();
+ public abstract RegistrationProperty.Status getStatus();
- public abstract void setStatus(String status);
+ public abstract void setStatus(RegistrationProperty.Status status);
public void initFrom(RegistrationProperty property)
{
// set properties
setName(property.getName());
- setStatus(property.getStatus().name());
+ setStatus(property.getStatus());
setValue(property.getValue());
// description
Modified:
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/JCRRegistrationPersistenceManager.java
===================================================================
---
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/JCRRegistrationPersistenceManager.java 2009-12-18
22:37:20 UTC (rev 1075)
+++
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/JCRRegistrationPersistenceManager.java 2009-12-19
16:01:59 UTC (rev 1076)
@@ -98,7 +98,7 @@
{
ChromatticSession session = persister.getSession();
ConsumerMapping cm = session.findById(ConsumerMapping.class,
consumer.getPersistentKey());
- RegistrationMapping rm = cm.createRegistration();
+ RegistrationMapping rm = cm.createAndAddRegistrationMappingFrom(null);
RegistrationSPI registration = newRegistrationSPI(consumer, registrationProperties,
rm.getPersistentKey());
rm.initFrom(registration);
persister.closeSession(session, true);
@@ -128,6 +128,7 @@
ChromatticSession session = persister.getSession();
ConsumerMapping cm = mappings.createConsumer(consumerId);
+ mappings.getConsumers().add(cm);
cm.initFrom(consumer);
persister.closeSession(session, true);
@@ -157,6 +158,7 @@
ChromatticSession session = persister.getSession();
ConsumerGroupMapping cgm = mappings.createConsumerGroup(name);
+ mappings.getConsumerGroups().add(cgm);
group.setPersistentKey(cgm.getPersistentKey());
cgm.initFrom(group);
persister.closeSession(session, true);
Modified:
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/mapping/ConsumerMapping.java
===================================================================
---
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/mapping/ConsumerMapping.java 2009-12-18
22:37:20 UTC (rev 1075)
+++
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/mapping/ConsumerMapping.java 2009-12-19
16:01:59 UTC (rev 1076)
@@ -95,6 +95,18 @@
@FindById
public abstract ConsumerGroupMapping findGroupById(String id);
+ public RegistrationMapping createAndAddRegistrationMappingFrom(Registration
registration)
+ {
+ // create, add to parent then init
+ RegistrationMapping rm = createRegistration();
+ getRegistrations().put(rm.getPersistentKey(), rm);
+ if (registration != null)
+ {
+ rm.initFrom(registration);
+ }
+ return rm;
+ }
+
public void initFrom(Consumer consumer)
{
setName(consumer.getName());
@@ -113,12 +125,9 @@
try
{
- Map<String, RegistrationMapping> rms = getRegistrations();
for (Registration reg : consumer.getRegistrations())
{
- RegistrationMapping rm = createRegistration();
- rm.initFrom(reg);
- rms.put(reg.getRegistrationHandle(), rm);
+ createAndAddRegistrationMappingFrom(reg);
}
}
catch (RegistrationException e)
Modified:
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/mapping/RegistrationMapping.java
===================================================================
---
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/mapping/RegistrationMapping.java 2009-12-18
22:37:20 UTC (rev 1075)
+++
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/mapping/RegistrationMapping.java 2009-12-19
16:01:59 UTC (rev 1076)
@@ -22,7 +22,6 @@
package org.gatein.portal.wsrp.state.producer.registrations.mapping;
-import org.chromattic.api.annotations.FindById;
import org.chromattic.api.annotations.Id;
import org.chromattic.api.annotations.ManyToOne;
import org.chromattic.api.annotations.MappedBy;
@@ -66,18 +65,17 @@
@MappedBy("properties")
public abstract RegistrationPropertiesMapping getProperties();
- @FindById
- public abstract ConsumerMapping findConsumerById(String id);
-
+ /**
+ * At this point, this RegistrationMapping should already have been added to its
parent
+ *
+ * @param registration
+ */
public void initFrom(Registration registration)
{
setStatus(registration.getStatus());
setRegistrationHandle(registration.getRegistrationHandle());
getProperties().initFrom(registration.getProperties());
-
- ConsumerMapping cm = findConsumerById(registration.getConsumer().getId());
- cm.getRegistrations().put(registration.getPersistentKey(), this);
}
public RegistrationSPI toRegistration(JCRRegistrationPersistenceManager
persistenceManager, ConsumerSPI consumer) throws RegistrationException
Modified:
portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/conf/wsrp/producer-registrations-nodetypes.xml
===================================================================
---
portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/conf/wsrp/producer-registrations-nodetypes.xml 2009-12-18
22:37:20 UTC (rev 1075)
+++
portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/conf/wsrp/producer-registrations-nodetypes.xml 2009-12-19
16:01:59 UTC (rev 1076)
@@ -87,7 +87,7 @@
<requiredPrimaryType>wsrp:registration</requiredPrimaryType>
</requiredPrimaryTypes>
</childNodeDefinition>
- <childNodeDefinition name="capabilities"
defaultPrimaryType="wsrp:consumercapabilities" autoCreated="false"
+ <childNodeDefinition name="capabilities"
defaultPrimaryType="wsrp:consumercapabilities" autoCreated="true"
mandatory="false"
onParentVersion="COPY"
protected="false" sameNameSiblings="false">
<requiredPrimaryTypes>