Author: chris.laprun(a)jboss.com
Date: 2007-05-01 19:44:19 -0400 (Tue, 01 May 2007)
New Revision: 7166
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationInfoTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationProperty.java
trunk/wsrp/src/resources/portal-wsrp-sar/conf/consumer/hibernate/domain.hbm.xml
Log:
- Fixed incorrect update of RegistrationInfo properties when replacing local data. Might
need a better solution via better Hibernate mapping.
- Added length on hibernate mapping to hopefully resolve JBPORTAL-1375 (though it's
far from certain).
- RegistrationProperty is now marked as invalid if the value is null.
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationInfoTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationInfoTestCase.java 2007-05-01
21:06:42 UTC (rev 7165)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationInfoTestCase.java 2007-05-01
23:44:19 UTC (rev 7166)
@@ -32,6 +32,7 @@
import org.jboss.portal.wsrp.core.ServiceDescription;
import java.util.Map;
+import java.util.Set;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
@@ -62,12 +63,14 @@
{
String key = "foo";
info.setRegistrationPropertyValue(key, "bar");
- assertFalse(info.getRegistrationProperties().isEmpty());
- assertFalse(info.getRegistrationPropertyNames().isEmpty());
- assertTrue(info.getRegistrationProperties().containsKey(key));
- assertTrue(info.getRegistrationPropertyNames().contains(key));
- assertNotNull(info.getRegistrationProperties().get(key));
- assertEquals(info.getRegistrationProperties().get(key),
info.getRegistrationProperty(key));
+ Map properties = info.getRegistrationProperties();
+ assertFalse(properties.isEmpty());
+ Set names = info.getRegistrationPropertyNames();
+ assertFalse(names.isEmpty());
+ assertTrue(properties.containsKey(key));
+ assertTrue(names.contains(key));
+ assertNotNull(properties.get(key));
+ assertEquals(properties.get(key), info.getRegistrationProperty(key));
assertEquals("bar", info.getRegistrationProperty(key).getValue());
}
@@ -132,6 +135,23 @@
assertTrue(status.indexOf("prop0") != -1 &&
status.indexOf("prop1") != -1);
}
+ public void testRefreshRegistrationRegistrationEraseLocalInfo()
+ {
+ RegistrationInfo.RegistrationRefreshResult result =
info.refreshRegistrationRequirementsFor(createServiceDescription(true, 2),
+ producerId, true);
+ assertNotNull(result);
+ assertFalse(result.isValid());
+ RegistrationProperty prop = info.getRegistrationProperty("prop0");
+ assertNotNull(prop);
+ assertNull(prop.getValue());
+ assertTrue(prop.isInvalid());
+ prop = info.getRegistrationProperty("prop1");
+ assertNotNull(prop);
+ assertNull(prop.getValue());
+ assertTrue(prop.isInvalid());
+ assertEquals(2, info.getRegistrationProperties().size());
+ }
+
private ServiceDescription createServiceDescription(boolean requiresRegistration, int
numberOfProperties)
{
ServiceDescription sd =
WSRPTypeFactory.createServiceDescription(requiresRegistration);
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-05-01
21:06:42 UTC (rev 7165)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-05-01
23:44:19 UTC (rev 7166)
@@ -64,13 +64,14 @@
private Map registrationProperties;
private transient RegistrationData registrationData;
+ private transient ProducerInfo parent;
public RegistrationInfo(ProducerInfo producerInfo)
{
+ this();
ParameterValidation.throwIllegalArgExceptionIfNull(producerInfo,
"ProducerInfo");
producerInfo.setRegistrationInfo(this);
- consumerName = WSRPConstants.DEFAULT_CONSUMER_NAME;
- requiresRegistration = true;
+ parent = producerInfo;
}
public RegistrationInfo()
@@ -276,7 +277,37 @@
if (discardLocalInfo)
{
- registrationProperties = descriptionsMap;
+ registrationProperties = getOrCreateRegistrationPropertiesMap(true);
+
+ // Remove extra properties
+ Set unexpected = new HashSet(registrationProperties.keySet());
+ unexpected.removeAll(descriptionsMap.keySet());
+ if (!unexpected.isEmpty())
+ {
+ for (Iterator invalidProps = unexpected.iterator();
invalidProps.hasNext();)
+ {
+ registrationProperties.remove(invalidProps.next());
+ }
+ }
+
+ // Resets existing properties
+ for (Iterator props = descriptionsMap.values().iterator();
props.hasNext();)
+ {
+ RegistrationProperty prop = (RegistrationProperty)props.next();
+ String name = prop.getName();
+ RegistrationProperty existing = getRegistrationProperty(name);
+ if (existing != null)
+ {
+ existing.setValue(null);
+ existing.setDescription(prop.getDescription());
+ }
+ else
+ {
+ registrationProperties.put(name, prop);
+ }
+ }
+
+ resetRegistration();
result.setValid(false);
}
else
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationProperty.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationProperty.java 2007-05-01
21:06:42 UTC (rev 7165)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationProperty.java 2007-05-01
23:44:19 UTC (rev 7166)
@@ -52,6 +52,7 @@
this.name = name;
this.value = stringValue;
this.lang = lang;
+ invalid = (stringValue == null);
}
@@ -157,6 +158,10 @@
public void setValue(String stringValue)
{
value = stringValue;
+ if (value == null)
+ {
+ invalid = true;
+ }
}
public String getLang()
Modified: trunk/wsrp/src/resources/portal-wsrp-sar/conf/consumer/hibernate/domain.hbm.xml
===================================================================
---
trunk/wsrp/src/resources/portal-wsrp-sar/conf/consumer/hibernate/domain.hbm.xml 2007-05-01
21:06:42 UTC (rev 7165)
+++
trunk/wsrp/src/resources/portal-wsrp-sar/conf/consumer/hibernate/domain.hbm.xml 2007-05-01
23:44:19 UTC (rev 7166)
@@ -75,8 +75,8 @@
</id>
<property name="consumerName" column="CONSUMER_NAME"
type="java.lang.String" not-null="true"/>
<property name="registrationHandle" column="HANDLE"
type="java.lang.String"/>
- <property name="registrationState" column="STATE"
type="binary"/>
- <map name="registrationProperties" cascade="all"
lazy="false">
+ <property name="registrationState" column="STATE"
type="binary" length="50000000"/>
+ <map name="registrationProperties"
cascade="all,delete-orphan" lazy="false" access="field">
<cache usage="@portal.hibernate.cache.usage(a)"/>
<key column="REG_PK" not-null="true"/>
<map-key type="string" column="name"/>
@@ -91,7 +91,9 @@
<param name="sequence">wsrpconsumer_seq</param>
</generator>
</id>
- <property name="name" type="java.lang.String"
not-null="true" insert="false" update="false"/>
+ <natural-id>
+ <property name="name" type="java.lang.String"
not-null="true" unique="false" insert="false"
update="false"/>
+ </natural-id>
<property name="value" type="java.lang.String"/>
<property name="invalid" type="boolean"/>
<property name="lang" type="java.lang.String"
not-null="true"/>
Show replies by date