Author: chris.laprun(a)jboss.com
Date: 2007-06-18 20:44:22 -0400 (Mon, 18 Jun 2007)
New Revision: 7458
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationPropertyTestCase.java
Modified:
trunk/wsrp/build.xml
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/EndpointConfigurationInfoTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationInfoTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/ServiceDescriptionBehavior.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/BehaviorBackedServiceFactory.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:
- Modified RegistrationProperty handling of values to be able to better detect the
validity status of the property and related test case.
- Modified Hibernate mapping for RegistrationProperty (invalid property is now a
java.lang.Boolean instead of boolean).
- Started testing registration behavior on ProducerInfo.
- Added more test cases in particular to check that some methods properly result in the
expected state.
Modified: trunk/wsrp/build.xml
===================================================================
--- trunk/wsrp/build.xml 2007-06-18 21:48:52 UTC (rev 7457)
+++ trunk/wsrp/build.xml 2007-06-19 00:44:22 UTC (rev 7458)
@@ -781,6 +781,7 @@
<test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.consumer.EndpointConfigurationInfoTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.consumer.ProducerInfoTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.consumer.RegistrationInfoTestCase"/>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.consumer.RegistrationPropertyTestCase"/>
<zest todir="${test.reports}"
name="org.jboss.portal.test.wsrp.consumer.ConsumerRegistryTestCase"
outfile="TEST-ConsumerRegistryTestCase">
<parameter name="Config"
value="persistent-jboss-beans.xml"/>
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/EndpointConfigurationInfoTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/EndpointConfigurationInfoTestCase.java 2007-06-18
21:48:52 UTC (rev 7457)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/EndpointConfigurationInfoTestCase.java 2007-06-19
00:44:22 UTC (rev 7458)
@@ -23,10 +23,12 @@
package org.jboss.portal.test.wsrp.consumer;
import junit.framework.TestCase;
+import org.jboss.portal.portlet.InvokerUnavailableException;
import org.jboss.portal.test.wsrp.framework.support.BehaviorBackedServiceFactory;
import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
import org.jboss.portal.wsrp.services.PerEndpointSOAPInvokerServiceFactory;
import org.jboss.portal.wsrp.services.RemoteSOAPInvokerServiceFactory;
+import org.jboss.portal.wsrp.services.ServiceFactory;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
@@ -43,7 +45,7 @@
info = new EndpointConfigurationInfo();
}
- public void testSetURLs()
+ public void testSetURLs() throws InvokerUnavailableException
{
info.setServiceDescriptionURL(url);
assertEquals(url, info.getServiceDescriptionURL());
@@ -63,7 +65,7 @@
assertTrue(info.getServiceFactory().isAvailable());
}
- public void testSetWSDLURL()
+ public void testSetWSDLURL() throws InvokerUnavailableException
{
info.setServiceDescriptionURL(url);
info.setMarkupURL(url);
@@ -124,4 +126,18 @@
info.getServiceDescriptionService();
assertFalse(info.isRefreshNeeded());
}
+
+ public void testGetServiceFactory() throws Exception
+ {
+ assertTrue(info.isRefreshNeeded());
+ assertFalse(info.isAvailable());
+
+ // change the service factory to a fake one to be able to simulate access to
endpoint
+ info.setServiceFactory(new BehaviorBackedServiceFactory());
+ ServiceFactory factory = info.getServiceFactory();
+ assertNotNull(factory);
+ assertFalse(info.isRefreshNeeded());
+ assertTrue(info.isAvailable());
+ assertTrue(factory.isAvailable());
+ }
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java 2007-06-18
21:48:52 UTC (rev 7457)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java 2007-06-19
00:44:22 UTC (rev 7458)
@@ -26,14 +26,17 @@
import junit.framework.TestCase;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.test.wsrp.framework.PortletManagementBehavior;
import org.jboss.portal.test.wsrp.framework.RegistrationBehavior;
import org.jboss.portal.test.wsrp.framework.ServiceDescriptionBehavior;
import org.jboss.portal.test.wsrp.framework.support.BehaviorBackedServiceFactory;
import org.jboss.portal.test.wsrp.framework.support.MockConsumerRegistry;
+import org.jboss.portal.wsrp.WSRPExceptionFactory;
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
import org.jboss.portal.wsrp.consumer.ProducerInfo;
+import org.jboss.portal.wsrp.consumer.RegistrationInfo;
import org.jboss.portal.wsrp.core.AccessDeniedFault;
import org.jboss.portal.wsrp.core.GetPortletDescription;
import org.jboss.portal.wsrp.core.InconsistentParametersFault;
@@ -43,7 +46,9 @@
import org.jboss.portal.wsrp.core.MissingParametersFault;
import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.core.PortletDescriptionResponse;
+import org.jboss.portal.wsrp.core.Property;
import org.jboss.portal.wsrp.core.RegistrationContext;
+import org.jboss.portal.wsrp.core.RegistrationData;
import java.rmi.RemoteException;
@@ -166,6 +171,36 @@
assertEquals("Service description should have been called once unregistered
and once registered", 2, sd.getCallCount());
}
+ public void testRegister() throws Exception
+ {
+ ServiceDescriptionBehavior sd = new ServiceDescriptionBehavior();
+ sd.setServiceDescription(true, 1);
+
+ serviceFactory.getRegistry().setServiceDescriptionBehavior(sd);
+ RegistrationBehavior regBehavior = new TestRegistrationBehavior();
+ serviceFactory.getRegistry().setRegistrationBehavior(regBehavior);
+
+ try
+ {
+ info.register();
+ fail("Shouldn't register with invalid information");
+ }
+ catch (PortletInvokerException expected)
+ {
+ }
+
+ RegistrationInfo regInfo = info.getRegistrationInfo();
+ regInfo.setRegistrationPropertyValue("prop0", "value");
+
+ info.register();
+ RegistrationContext registrationContext = info.getRegistrationContext();
+ assertNotNull(registrationContext);
+ assertEquals(RegistrationBehavior.REGISTRATION_HANDLE,
registrationContext.getRegistrationHandle());
+ assertTrue(info.isRegistered());
+ assertTrue(info.isRegistrationChecked());
+ assertTrue(info.isRegistrationRequired());
+ }
+
private static class TestPortletManagementBehavior extends PortletManagementBehavior
{
public PortletDescriptionResponse getPortletDescription(GetPortletDescription
getPortletDescription)
@@ -176,4 +211,27 @@
return
WSRPTypeFactory.createPortletDescriptionResponse(createPortletDescription("test2",
null));
}
}
+
+ private static class TestRegistrationBehavior extends RegistrationBehavior
+ {
+ public RegistrationContext register(RegistrationData register) throws
MissingParametersFault, OperationFailedFault, RemoteException
+ {
+ WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(register,
"RegistrationData");
+
+ Property[] props = register.getRegistrationProperties();
+ WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(props,
"Registration properties");
+
+ Property prop = props[0];
+ WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(prop,
"Registration property");
+
+ String value = prop.getStringValue();
+ if ("value".equals(value) &&
"prop0".equals(prop.getName()))
+ {
+ return super.register(register);
+ }
+
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
+ value + " is not a valid value for 'prop0'", null);
+ }
+ }
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationInfoTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationInfoTestCase.java 2007-06-18
21:48:52 UTC (rev 7457)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationInfoTestCase.java 2007-06-19
00:44:22 UTC (rev 7458)
@@ -24,12 +24,11 @@
package org.jboss.portal.test.wsrp.consumer;
import junit.framework.TestCase;
-import org.jboss.portal.wsrp.WSRPConstants;
+import org.jboss.portal.test.wsrp.framework.ServiceDescriptionBehavior;
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.consumer.RefreshResult;
import org.jboss.portal.wsrp.consumer.RegistrationInfo;
import org.jboss.portal.wsrp.consumer.RegistrationProperty;
-import org.jboss.portal.wsrp.core.PropertyDescription;
import org.jboss.portal.wsrp.core.RegistrationContext;
import org.jboss.portal.wsrp.core.ServiceDescription;
@@ -88,7 +87,7 @@
}
}
- public void testSetGetRegistrationProperty()
+ public void testSimpleSetGetRegistrationProperty()
{
String key = "foo";
info.setRegistrationPropertyValue(key, "bar");
@@ -104,6 +103,25 @@
assertEquals("bar", info.getRegistrationProperty(key).getValue());
}
+ public void testRegistrationPropertiesAndRefresh()
+ {
+ info.setRegistrationPropertyValue("prop0", "value0");
+ RefreshResult result = info.refresh(createServiceDescription(true, 1), producerId,
true, false);
+ RegistrationProperty prop = info.getRegistrationProperty("prop0");
+ assertNull(prop.isInvalid());
+ assertFalse(result.hasIssues());
+
+ // specifiy that the prop is valid to simulate a successful registration
(integration test, should have something
+ // testing that in ProducerInfoTestCase)
+ prop.setInvalid(Boolean.FALSE, null);
+
+ info.setRegistrationPropertyValue("prop0", "value1");
+ assertTrue(info.isRefreshNeeded());
+ assertNull("Property value has changed since last refresh, status should be
unknown", prop.isInvalid());
+ assertEquals("Property value has changed since last refresh, status should be
unknown",
+ RegistrationProperty.UNCHECKED_VALUE_STATUS, prop.getStatus());
+ }
+
public void testRefreshNoRegistration()
{
// no registration expected
@@ -164,7 +182,7 @@
RegistrationProperty prop = (RegistrationProperty)regProps.get("foo");
assertNotNull(prop);
assertEquals("bar", prop.getValue());
- assertTrue(prop.isInvalid());
+ assertTrue(prop.isInvalid().booleanValue());
assertEquals(RegistrationProperty.INEXISTENT_STATUS, prop.getStatus());
}
@@ -187,7 +205,7 @@
RegistrationProperty prop = (RegistrationProperty)regProps.get("prop0");
assertNotNull(prop);
- assertTrue(prop.isInvalid());
+ assertTrue(prop.isInvalid().booleanValue());
assertEquals(RegistrationProperty.MISSING_STATUS, prop.getStatus());
}
@@ -203,13 +221,13 @@
RegistrationProperty prop = info.getRegistrationProperty("prop0");
assertNotNull(prop);
assertNull(prop.getValue());
- assertTrue(prop.isInvalid());
+ assertTrue(prop.isInvalid().booleanValue());
assertEquals(RegistrationProperty.MISSING_VALUE_STATUS, prop.getStatus());
prop = info.getRegistrationProperty("prop1");
assertNotNull(prop);
assertNull(prop.getValue());
- assertTrue(prop.isInvalid());
+ assertTrue(prop.isInvalid().booleanValue());
assertEquals(RegistrationProperty.MISSING_VALUE_STATUS, prop.getStatus());
assertEquals(2, info.getRegistrationProperties().size());
assertEquals(2, result.getRegistrationProperties().size());
@@ -268,18 +286,6 @@
private ServiceDescription createServiceDescription(boolean requiresRegistration, int
numberOfProperties)
{
- ServiceDescription sd =
WSRPTypeFactory.createServiceDescription(requiresRegistration);
-
- if (requiresRegistration)
- {
- PropertyDescription[] descriptions = new
PropertyDescription[numberOfProperties];
- for (int i = 0; i < numberOfProperties; i++)
- {
- descriptions[i] = WSRPTypeFactory.createPropertyDescription("prop"
+ i, WSRPConstants.XSD_STRING);
- }
-
sd.setRegistrationPropertyDescription(WSRPTypeFactory.createModelDescription(descriptions));
- }
-
- return sd;
+ return ServiceDescriptionBehavior.createServiceDescription(requiresRegistration,
numberOfProperties);
}
}
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationPropertyTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationPropertyTestCase.java
(rev 0)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationPropertyTestCase.java 2007-06-19
00:44:22 UTC (rev 7458)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.test.wsrp.consumer;
+
+import junit.framework.TestCase;
+import org.jboss.portal.wsrp.consumer.RegistrationProperty;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class RegistrationPropertyTestCase extends TestCase
+{
+ private RegistrationProperty prop;
+
+ protected void setUp() throws Exception
+ {
+ prop = new RegistrationProperty("name", "value",
"en");
+ }
+
+ public void testGetters()
+ {
+ assertEquals("name", prop.getName());
+ assertEquals("value", prop.getValue());
+ assertEquals("en", prop.getLang());
+ assertNull(prop.isInvalid());
+ assertFalse(prop.isDeterminedInvalid());
+ assertNull(prop.getDescription());
+ assertEquals(RegistrationProperty.UNCHECKED_VALUE_STATUS, prop.getStatus());
+ }
+
+ public void testSetValue()
+ {
+ prop.setInvalid(Boolean.FALSE, null);
+ assertEquals(Boolean.FALSE, prop.isInvalid());
+ assertNull(prop.getStatus());
+
+ // we haven't changed the value, so the status shouldn't have changed
+ prop.setValue("value");
+ assertEquals(Boolean.FALSE, prop.isInvalid());
+ assertNull(prop.getStatus());
+
+ // we changed the value, status is now unknown
+ prop.setValue("value2");
+ assertEquals("value2", prop.getValue());
+ assertNull(prop.isInvalid());
+ assertEquals(RegistrationProperty.UNCHECKED_VALUE_STATUS, prop.getStatus());
+ }
+}
Property changes on:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationPropertyTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/ServiceDescriptionBehavior.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/ServiceDescriptionBehavior.java 2007-06-18
21:48:52 UTC (rev 7457)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/ServiceDescriptionBehavior.java 2007-06-19
00:44:22 UTC (rev 7458)
@@ -24,12 +24,14 @@
package org.jboss.portal.test.wsrp.framework;
import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.wsrp.WSRPConstants;
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.core.CookieProtocol;
import org.jboss.portal.wsrp.core.GetServiceDescription;
import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.core.PortletDescription;
+import org.jboss.portal.wsrp.core.PropertyDescription;
import org.jboss.portal.wsrp.core.ServiceDescription;
import org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType;
@@ -71,6 +73,11 @@
serviceDescription.setRequiresInitCookie(requiresInitCookie);
}
+ public void setServiceDescription(boolean requiresRegistration, int numberOfProps)
+ {
+ serviceDescription = createServiceDescription(requiresRegistration,
numberOfProps);
+ }
+
public static ServiceDescription getDefaultServiceDescription()
{
return DEFAULT_SERVICE_DESCRIPTION;
@@ -90,4 +97,21 @@
serviceDescription.setOfferedPortlets((PortletDescription[])portlets.toArray(new
PortletDescription[0]));
}
}
+
+ public static ServiceDescription createServiceDescription(boolean
requiresRegistration, int numberOfProperties)
+ {
+ ServiceDescription sd =
WSRPTypeFactory.createServiceDescription(requiresRegistration);
+
+ if (requiresRegistration)
+ {
+ PropertyDescription[] descriptions = new
PropertyDescription[numberOfProperties];
+ for (int i = 0; i < numberOfProperties; i++)
+ {
+ descriptions[i] = WSRPTypeFactory.createPropertyDescription("prop"
+ i, WSRPConstants.XSD_STRING);
+ }
+
sd.setRegistrationPropertyDescription(WSRPTypeFactory.createModelDescription(descriptions));
+ }
+
+ return sd;
+ }
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/BehaviorBackedServiceFactory.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/BehaviorBackedServiceFactory.java 2007-06-18
21:48:52 UTC (rev 7457)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/BehaviorBackedServiceFactory.java 2007-06-19
00:44:22 UTC (rev 7458)
@@ -63,6 +63,7 @@
private final static String M_URL = "m";
private final static String PM_URL = "pm";
private final static String R_URL = "r";
+ private boolean initialized = false;
public BehaviorBackedServiceFactory()
@@ -104,6 +105,11 @@
public boolean isAvailable()
{
+ if (!initialized)
+ {
+ initialized = true;
+ return false;
+ }
return true;
}
@@ -154,7 +160,7 @@
public void start() throws Exception
{
- throw new NotYetImplemented();
+ // do nothing
}
public void stop()
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-06-18
21:48:52 UTC (rev 7457)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-06-19
00:44:22 UTC (rev 7458)
@@ -208,7 +208,7 @@
{
RegistrationProperty prop = (RegistrationProperty)entries.next();
String value = prop.getValue();
- if (value != null && !prop.isInvalid())
+ if (value != null && !prop.isDeterminedInvalid())
{
properties.add(WSRPTypeFactory.createProperty(prop.getName(),
prop.getLang(), prop.getValue()));
}
@@ -363,7 +363,7 @@
{
// take the opportunity to add the property description... ^_^
existing.setDescription(prop.getDescription());
- if (existing.isInvalid())
+ if (existing.isDeterminedInvalid())
{
result.setHasIssues(true);
}
@@ -469,13 +469,11 @@
{
// mark the prop as invalid
RegistrationProperty prop = (RegistrationProperty)properties.get(name);
- prop.setInvalid(true);
- prop.setStatus(RegistrationProperty.INEXISTENT_STATUS);
+ prop.setInvalid(Boolean.TRUE, RegistrationProperty.INEXISTENT_STATUS);
// do the same in the result
prop =
(RegistrationProperty)result.getRegistrationProperties().get(name);
- prop.setInvalid(true);
- prop.setStatus(RegistrationProperty.INEXISTENT_STATUS);
+ prop.setInvalid(Boolean.TRUE, RegistrationProperty.INEXISTENT_STATUS);
}
else
{
@@ -504,8 +502,7 @@
RegistrationPropertyDescription desc =
WSRPUtils.convertToRegistrationPropertyDescription(description);
RegistrationProperty prop = new RegistrationProperty(name, null,
WSRPUtils.toString(desc.getLang()));
prop.setDescription(desc);
- prop.setStatus(RegistrationProperty.MISSING_VALUE_STATUS);
- prop.setInvalid(true);
+ prop.setInvalid(Boolean.TRUE, RegistrationProperty.MISSING_VALUE_STATUS);
result.put(name, prop);
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationProperty.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationProperty.java 2007-06-18
21:48:52 UTC (rev 7457)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationProperty.java 2007-06-19
00:44:22 UTC (rev 7458)
@@ -35,7 +35,7 @@
{
private Long persistentId;
private RegistrationPropertyDescription persistentDescription;
- private boolean persistentInvalid;
+ private Boolean persistentInvalid;
private String persistentLang;
private String persistentName;
private String persistentValue;
@@ -44,6 +44,8 @@
public static final String INEXISTENT_STATUS = "Inexistent on Producer";
public static final String MISSING_STATUS = "Missing";
public static final String MISSING_VALUE_STATUS = "Missing value";
+ public static final String UNCHECKED_VALUE_STATUS = "Undetermined status";
+ public static final String INVALID_VALUE_STATUS = "Invalid value";
public RegistrationProperty()
{
@@ -54,9 +56,8 @@
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name, "Name",
"RegistrationProperty");
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(lang, "Lang",
"RegistrationProperty");
this.persistentName = name;
- this.persistentValue = stringValue;
this.persistentLang = lang;
- persistentInvalid = (stringValue == null || stringValue.length() == 0);
+ setValue(stringValue);
}
public boolean equals(Object o)
@@ -72,15 +73,15 @@
RegistrationProperty that = (RegistrationProperty)o;
- if (!persistentName.equals(that.persistentName))
+ if (persistentId != null ? !persistentId.equals(that.persistentId) :
that.persistentId != null)
{
return false;
}
- if (!persistentLang.equals(that.persistentLang))
+ if (!persistentName.equals(that.persistentName))
{
return false;
}
- if (persistentInvalid != that.persistentInvalid)
+ if (!persistentValue.equals(that.persistentValue))
{
return false;
}
@@ -88,14 +89,18 @@
{
return false;
}
- if (persistentId != null ? !persistentId.equals(that.persistentId) :
that.persistentId != null)
+ if (persistentInvalid != null ? !persistentInvalid.equals(that.persistentInvalid) :
that.persistentInvalid != null)
{
return false;
}
- if (persistentValue != null ? !persistentValue.equals(that.persistentValue) :
that.persistentValue != null)
+ if (!persistentLang.equals(that.persistentLang))
{
return false;
}
+ if (status != null ? !status.equals(that.status) : that.status != null)
+ {
+ return false;
+ }
return true;
}
@@ -105,10 +110,11 @@
int result;
result = (persistentId != null ? persistentId.hashCode() : 0);
result = 31 * result + persistentName.hashCode();
+ result = 31 * result + persistentValue.hashCode();
+ result = 31 * result + (persistentDescription != null ?
persistentDescription.hashCode() : 0);
+ result = 31 * result + (persistentInvalid != null ? persistentInvalid.hashCode() :
0);
result = 31 * result + persistentLang.hashCode();
- result = 31 * result + (persistentDescription != null ?
persistentDescription.hashCode() : 0);
- result = 31 * result + (persistentInvalid ? 1 : 0);
- result = 31 * result + (persistentValue != null ? persistentValue.hashCode() : 0);
+ result = 31 * result + (status != null ? status.hashCode() : 0);
return result;
}
@@ -148,21 +154,42 @@
this.persistentDescription = description;
}
- public boolean isInvalid()
+ public Boolean isInvalid()
{
return persistentInvalid;
}
- public void setInvalid(boolean invalid)
+ void setInvalid(Boolean invalid)
{
this.persistentInvalid = invalid;
}
+ public boolean isDeterminedInvalid()
+ {
+ return persistentInvalid != null && persistentInvalid.booleanValue();
+ }
+
+ public void setInvalid(Boolean invalid, String status)
+ {
+ this.persistentInvalid = invalid;
+ this.status = status;
+ }
+
public void setValue(String stringValue)
{
- persistentValue = stringValue;
- persistentInvalid = (persistentValue == null);
- status = (persistentValue == null ? MISSING_VALUE_STATUS : null);
+ if ((persistentValue != null && !persistentValue.equals(stringValue)) ||
(persistentValue == null && stringValue != null))
+ {
+ persistentValue = stringValue;
+ persistentInvalid = null;
+ if (persistentValue == null)
+ {
+ status = MISSING_VALUE_STATUS;
+ }
+ else
+ {
+ status = UNCHECKED_VALUE_STATUS;
+ }
+ }
}
public String getLang()
@@ -181,7 +208,7 @@
return status;
}
- public void setStatus(String status)
+ void setStatus(String status)
{
this.status = status;
}
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-06-18
21:48:52 UTC (rev 7457)
+++
trunk/wsrp/src/resources/portal-wsrp-sar/conf/consumer/hibernate/domain.hbm.xml 2007-06-19
00:44:22 UTC (rev 7458)
@@ -93,7 +93,7 @@
</id>
<property name="name" type="java.lang.String"
not-null="true"/>
<property name="value" type="java.lang.String"/>
- <property name="invalid" type="boolean"/>
+ <property name="invalid" type="java.lang.Boolean"/>
<property name="lang" type="java.lang.String"
not-null="true"/>
<many-to-one
name="description"