Author: chris.laprun(a)jboss.com
Date: 2007-05-01 01:52:03 -0400 (Tue, 01 May 2007)
New Revision: 7158
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationPropertyDescriptionTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.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/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeployer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/registration/RegistrationPropertyDescription.java
trunk/wsrp/src/resources/portal-wsrp-sar/conf/consumer/hibernate/domain.hbm.xml
Log:
- JBPORTAL-715: Better exception handling, in particular when an error occured that
rendered the Consumer unavailable. FederatedPortletInvoker is not always in synch though
so needed to account for that. A better solution will be needed at some point.
- Added isActive method on WSRPConsumer.
- Made lang property required on RegistrationProperty but handling is not perfect (i.e. a
language is not always readily available when a property is created...).
RegistrationPropertyDescription tries to determine the language of the associated
property...
- ConsumerRegistryService now ignores exceptions during start and stop to be able to
process all the Consumers if one fails.
- Fixed error in RegistrationInfo.initialize (where local data was reset).
- RegistrationInfo.refreshRegistrationRequirementsFor now adds description to local
properties when refresh occurs.
- Correctly set resource name when present in WSRPUtils.convertToLocalizedString.
- Updated and improved test cases.
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java 2007-04-30
22:30:17 UTC (rev 7157)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java 2007-05-01
05:52:03 UTC (rev 7158)
@@ -95,10 +95,10 @@
assertEquals("inDB2", consumer.getProducerId());
assertNull(consumer.getProducerInfo().getExpirationCacheSeconds());
// since inDB2 is loaded from MockConsumerRegistry, it shouldn't be processed
by WSRPDeploymentFactory and should
- // therefore return the default value for the mandatory URLs
+ // therefore return the values set in MockConsumerRegistry
EndpointConfigurationInfo endpoint =
consumer.getProducerInfo().getEndpointConfigurationInfo();
- assertEquals(EndpointConfigurationInfo.UNSET,
endpoint.getServiceDescriptionURL());
- assertEquals(EndpointConfigurationInfo.UNSET, endpoint.getMarkupURL());
+ assertEquals(MockConsumerRegistry.MOCK_SERVICE_DESCRIPTION,
endpoint.getServiceDescriptionURL());
+ assertEquals(MockConsumerRegistry.MOCK_MARKUP, endpoint.getMarkupURL());
//
consumer = (WSRPConsumer)services.get(2);
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java 2007-04-30
22:30:17 UTC (rev 7157)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java 2007-05-01
05:52:03 UTC (rev 7158)
@@ -28,6 +28,7 @@
import org.jboss.portal.wsrp.WSRPConsumer;
import org.jboss.portal.wsrp.consumer.ConsumerException;
import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
+import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
import org.jboss.portal.wsrp.consumer.ProducerInfo;
import java.util.Collection;
@@ -42,12 +43,17 @@
public class MockConsumerRegistry implements ConsumerRegistry
{
private Map consumers = new HashMap(3);
+ public static final String MOCK_SERVICE_DESCRIPTION =
"mock-service-description";
+ public static final String MOCK_MARKUP = "mock-markup";
public MockConsumerRegistry()
{
consumers.put("inDB", new MockWSRPConsumer("inDB"));
MockWSRPConsumer consumer = new MockWSRPConsumer("inDB2");
consumer.getProducerInfo().setActive(true);
+ EndpointConfigurationInfo info =
consumer.getProducerInfo().getEndpointConfigurationInfo();
+ info.setServiceDescriptionURL(MOCK_SERVICE_DESCRIPTION);
+ info.setMarkupURL(MOCK_MARKUP);
consumers.put("inDB2", consumer);
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java 2007-04-30
22:30:17 UTC (rev 7157)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java 2007-05-01
05:52:03 UTC (rev 7158)
@@ -111,6 +111,11 @@
return null;
}
+ public boolean isActive()
+ {
+ return true;
+ }
+
public Set getPortlets() throws PortletInvokerException
{
return null;
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationPropertyDescriptionTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationPropertyDescriptionTestCase.java 2007-04-30
22:30:17 UTC (rev 7157)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationPropertyDescriptionTestCase.java 2007-05-01
05:52:03 UTC (rev 7158)
@@ -28,9 +28,11 @@
import org.jboss.portal.registration.RegistrationPropertyChangeListener;
import org.jboss.portal.wsrp.WSRPConstants;
import org.jboss.portal.wsrp.producer.config.ProducerRegistrationRequirements;
+import org.jboss.portal.wsrp.registration.LocalizedString;
import org.jboss.portal.wsrp.registration.RegistrationPropertyDescription;
import javax.xml.namespace.QName;
+import java.util.Locale;
import java.util.Map;
/**
@@ -69,6 +71,13 @@
assertEquals(null, desc.modifyIfNeeded(oldValue, null));
}
+ public void testGetLang()
+ {
+ assertEquals(Locale.getDefault(), desc.getLang());
+ desc.setLabel(new LocalizedString("etiquette", Locale.FRENCH));
+ assertEquals(Locale.FRENCH, desc.getLang());
+ }
+
class TestParent implements ProducerRegistrationRequirements
{
private boolean notifyCalled;
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java 2007-04-30 22:30:17 UTC
(rev 7157)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java 2007-05-01 05:52:03 UTC
(rev 7158)
@@ -117,4 +117,10 @@
* @since 2.6
*/
RegistrationInfo.RegistrationRefreshResult refreshRegistrationInfo(boolean
eraseLocalData) throws PortletInvokerException;
+
+ /**
+ * @return
+ * @since 2.6
+ */
+ boolean isActive();
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java 2007-04-30 22:30:17 UTC (rev
7157)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java 2007-05-01 05:52:03 UTC (rev
7158)
@@ -344,7 +344,9 @@
locale = LocaleInfo.decodeLocaleInfoFromRFC3066LanguageTag(lang).getLocale();
}
- return new LocalizedString(wsrpLocalizedString.getValue(), locale);
+ LocalizedString localizedString = new
LocalizedString(wsrpLocalizedString.getValue(), locale);
+ localizedString.setResourceName(wsrpLocalizedString.getResourceName());
+ return localizedString;
}
/**
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2007-04-30
22:30:17 UTC (rev 7157)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2007-05-01
05:52:03 UTC (rev 7158)
@@ -24,7 +24,6 @@
package org.jboss.portal.wsrp.admin.ui;
import org.jboss.portal.wsrp.WSRPConsumer;
-import org.jboss.portal.wsrp.consumer.ConsumerException;
import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
import org.jboss.portal.wsrp.consumer.ProducerInfo;
import org.jboss.portal.wsrp.consumer.RegistrationInfo;
@@ -148,15 +147,16 @@
{
getProducerInfo().getEndpointConfigurationInfo().setWsdlDefinitionURL(wsdlURL);
}
- catch (RuntimeException e)
+ catch (Exception e)
{
+ registry.deactivateConsumerWith(getId());
createErrorMessageFrom("wsdl", e);
}
}
public boolean isActive()
{
- return getProducerInfo().isActive();
+ return consumer.isActive();
}
public boolean isRegistered()
@@ -184,7 +184,7 @@
{
registry.updateProducerInfo(getProducerInfo());
}
- catch (ConsumerException e)
+ catch (Exception e)
{
createErrorMessageFrom(e);
return null;
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2007-04-30
22:30:17 UTC (rev 7157)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2007-05-01
05:52:03 UTC (rev 7158)
@@ -170,37 +170,6 @@
this.sessionFactoryJNDIName = sessionFactoryJNDIName;
}
- protected void startService() throws Exception
- {
- InitialContext initialContext = new InitialContext();
- sessionFactory = (SessionFactory)initialContext.lookup(sessionFactoryJNDIName);
-
- // load the configured consumers
- consumers = new TreeMap();
-
- Session session = sessionFactory.getCurrentSession();
-
- Iterator producerInfos = session.createQuery("from ProducerInfo pi order by
pi.id").iterate();
-
- // load the configured producers
- ProducerInfo producerInfo;
- while (producerInfos.hasNext())
- {
- producerInfo = (ProducerInfo)producerInfos.next();
-
- // need to set the registry after loading from DB since registry is not
persisted.
- producerInfo.setRegistry(this);
-
- createConsumerFrom(producerInfo);
-
- // if the producer is marked as active, activate it fo' real! :)
- if (producerInfo.isActive())
- {
- activateConsumerWith(producerInfo.getId());
- }
- }
- }
-
private WSRPConsumer createConsumerFrom(ProducerInfo producerInfo)
{
WSRPConsumer consumer = new WSRPConsumerImpl(producerInfo);
@@ -218,6 +187,16 @@
{
startOrStopConsumer(id, true);
}
+ else
+ {
+ // todo: fix-me federated portlet invoker gets desynchronized...
+ WSRPConsumer consumer = getConsumer(id);
+ if (consumer != null && !consumer.isActive())
+ {
+ federatingPortletInvoker.unregisterInvoker(id);
+ startOrStopConsumer(id, true);
+ }
+ }
}
public void deactivateConsumerWith(String id) throws ConsumerException
@@ -229,6 +208,16 @@
{
startOrStopConsumer(id, false);
}
+ else
+ {
+ // todo: fix-me federated portlet invoker gets desynchronized...
+ WSRPConsumer consumer = getConsumer(id);
+ if (consumer != null && consumer.isActive())
+ {
+ federatingPortletInvoker.registerInvoker(id, consumer);
+ startOrStopConsumer(id, false);
+ }
+ }
}
public void updateProducerInfo(ProducerInfo producerInfo)
@@ -246,6 +235,44 @@
}
}
+ protected void startService() throws Exception
+ {
+ InitialContext initialContext = new InitialContext();
+ sessionFactory = (SessionFactory)initialContext.lookup(sessionFactoryJNDIName);
+
+ // load the configured consumers
+ consumers = new TreeMap();
+
+ Session session = sessionFactory.getCurrentSession();
+
+ Iterator producerInfos = session.createQuery("from ProducerInfo pi order by
pi.id").iterate();
+
+ // load the configured producers
+ ProducerInfo producerInfo;
+ while (producerInfos.hasNext())
+ {
+ producerInfo = (ProducerInfo)producerInfos.next();
+
+ // need to set the registry after loading from DB since registry is not
persisted.
+ producerInfo.setRegistry(this);
+
+ createConsumerFrom(producerInfo);
+
+ // if the producer is marked as active, activate it fo' real! :)
+ if (producerInfo.isActive())
+ {
+ try
+ {
+ activateConsumerWith(producerInfo.getId());
+ }
+ catch (ConsumerException e)
+ {
+ // ignore and continue
+ }
+ }
+ }
+ }
+
protected void stopService() throws Exception
{
sessionFactory = null;
@@ -261,7 +288,14 @@
federatingPortletInvoker.unregisterInvoker(consumer.getProducerId());
}
- consumer.stop();
+ try
+ {
+ consumer.stop();
+ }
+ catch (Exception e)
+ {
+ // ignore and continue
+ }
}
consumers.clear();
@@ -301,15 +335,19 @@
consumer.getProducerInfo().deregister();
}
}
- catch (PortletInvokerException e)
+ catch (Exception e)
{
- throw new ConsumerException("Couldn't " + (register ?
"register" : "deregister") + CONSUMER_WITH_ID + id +
"'", e);
+ // unexpected exception: deactivate the consumer
+ deactivateConsumerWith(id);
+ Throwable cause = e.getCause();
+ throw new ConsumerException("Couldn't " + (register ?
"register" : "deregister") + CONSUMER_WITH_ID + id +
"'",
+ cause != null ? cause : e);
}
}
private void startOrStopConsumer(String id, boolean start)
{
- WSRPConsumer consumer = null;
+ WSRPConsumer consumer;
try
{
@@ -352,10 +390,6 @@
}
catch (Exception e)
{
- if (consumer != null)
- {
- consumer.getProducerInfo().setActive(false);
- }
throw new ConsumerException("Couldn't " + (start ?
"start" : "stop") + " Consumer service '" + id +
"'", e);
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-04-30
22:30:17 UTC (rev 7157)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-05-01
05:52:03 UTC (rev 7158)
@@ -180,7 +180,7 @@
*/
public boolean isActive()
{
- return persistentActive;
+ return persistentActive && persistentEndpointInfo.isAvailable();
}
/**
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-04-30
22:30:17 UTC (rev 7157)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-05-01
05:52:03 UTC (rev 7158)
@@ -24,6 +24,7 @@
package org.jboss.portal.wsrp.consumer;
import org.jboss.logging.Logger;
+import org.jboss.portal.common.i18n.LocaleInfo;
import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.wsrp.WSRPConstants;
import org.jboss.portal.wsrp.WSRPTypeFactory;
@@ -42,6 +43,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
@@ -178,7 +180,8 @@
}
else
{
- prop = new RegistrationProperty(name, value);
+ // todo: deal with language more appropriately
+ prop = new RegistrationProperty(name, value,
LocaleInfo.getRFC3066LanguageTagFor(Locale.getDefault()));
getOrCreateRegistrationPropertiesMap(false).put(name, prop);
}
@@ -238,7 +241,7 @@
*/
boolean initialize(ServiceDescription serviceDescription, String producerId)
{
- return refreshRegistrationRequirementsFor(serviceDescription, producerId,
true).isValid();
+ return refreshRegistrationRequirementsFor(serviceDescription, producerId,
false).isValid();
}
@@ -290,12 +293,17 @@
{
String name = (String)descriptionNames.next();
RegistrationProperty prop =
(RegistrationProperty)registrationProperties.get(name);
+ RegistrationProperty producerProp =
(RegistrationProperty)descriptionsMap.get(name);
if (prop == null)
{
- Object missingProp = descriptionsMap.get(name);
- registrationProperties.put(name, missingProp);
+ registrationProperties.put(name, producerProp);
missingProps.append("Missing value for property
'").append(name).append("'\n");
}
+ else
+ {
+ // take the opportunity to add the property description... ^_^
+ prop.setDescription(producerProp.getDescription());
+ }
}
if (missingProps.length() > 0)
@@ -394,8 +402,8 @@
{
PropertyDescription description = descriptions[i];
String name = description.getName();
- RegistrationProperty prop = new RegistrationProperty(name, null);
RegistrationPropertyDescription desc =
WSRPUtils.convertToRegistrationPropertyDescription(description);
+ RegistrationProperty prop = new RegistrationProperty(name, null,
LocaleInfo.getRFC3066LanguageTagFor(desc.getLang()));
prop.setDescription(desc);
result.put(name, prop);
}
@@ -488,7 +496,7 @@
}
else
{
- status.append(message).append(" ");
+ status.append(" ").append(message);
}
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationProperty.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationProperty.java 2007-04-30
22:30:17 UTC (rev 7157)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationProperty.java 2007-05-01
05:52:03 UTC (rev 7158)
@@ -23,6 +23,7 @@
package org.jboss.portal.wsrp.consumer;
+import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.wsrp.registration.RegistrationPropertyDescription;
/**
@@ -44,10 +45,13 @@
{
}
- public RegistrationProperty(String name, String stringValue)
+ public RegistrationProperty(String name, String stringValue, String lang)
{
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name, "Name",
"RegistrationProperty");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(lang, "Lang",
"RegistrationProperty");
this.name = name;
this.value = stringValue;
+ this.lang = lang;
}
@@ -64,27 +68,27 @@
RegistrationProperty that = (RegistrationProperty)o;
- if (key != null ? !key.equals(that.key) : that.key != null)
+ if (!name.equals(that.name))
{
return false;
}
- if (!name.equals(that.name))
+ if (!lang.equals(that.lang))
{
return false;
}
- if (value != null ? !value.equals(that.value) : that.value != null)
+ if (invalid != that.invalid)
{
return false;
}
- if (invalid != that.invalid)
+ if (description != null ? !description.equals(that.description) : that.description
!= null)
{
return false;
}
- if (lang != null ? !lang.equals(that.lang) : that.lang != null)
+ if (key != null ? !key.equals(that.key) : that.key != null)
{
return false;
}
- if (description != null ? !description.equals(that.description) : that.description
!= null)
+ if (value != null ? !value.equals(that.value) : that.value != null)
{
return false;
}
@@ -96,10 +100,10 @@
{
int result;
result = (key != null ? key.hashCode() : 0);
+ result = 31 * result + name.hashCode();
+ result = 31 * result + lang.hashCode();
result = 31 * result + (description != null ? description.hashCode() : 0);
result = 31 * result + (invalid ? 1 : 0);
- result = 31 * result + (lang != null ? lang.hashCode() : 0);
- result = 31 * result + name.hashCode();
result = 31 * result + (value != null ? value.hashCode() : 0);
return result;
}
@@ -121,6 +125,7 @@
public void setName(String name)
{
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name, "Name",
"RegistrationProperty");
this.name = name;
}
@@ -161,6 +166,7 @@
public void setLang(String lang)
{
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(lang, "Lang",
"RegistrationProperty");
this.lang = lang;
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-04-30
22:30:17 UTC (rev 7157)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-05-01
05:52:03 UTC (rev 7158)
@@ -493,6 +493,11 @@
return producerInfo.refreshRegistrationInfo(eraseLocalData);
}
+ public boolean isActive()
+ {
+ return producerInfo.isActive() && started;
+ }
+
// Service implementation
*******************************************************************************************
protected void startService() throws Exception
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeployer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeployer.java 2007-04-30
22:30:17 UTC (rev 7157)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeployer.java 2007-05-01
05:52:03 UTC (rev 7158)
@@ -27,6 +27,7 @@
import org.jboss.deployment.SubDeployerSupport;
import org.jboss.portal.common.xml.NullEntityResolver;
import org.jboss.portal.wsrp.WSRPConsumer;
+import org.jboss.portal.wsrp.consumer.ConsumerException;
import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
import org.jboss.xb.binding.ObjectModelFactory;
import org.jboss.xb.binding.Unmarshaller;
@@ -119,7 +120,14 @@
for (Iterator i = deployment.getConsumers().iterator(); i.hasNext();)
{
WSRPConsumer consumer = (WSRPConsumer)i.next();
- consumerRegistry.activateConsumerWith(consumer.getProducerId());
+ try
+ {
+ consumerRegistry.activateConsumerWith(consumer.getProducerId());
+ }
+ catch (ConsumerException e)
+ {
+ // ignore and continue
+ }
}
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/registration/RegistrationPropertyDescription.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/registration/RegistrationPropertyDescription.java 2007-04-30
22:30:17 UTC (rev 7157)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/registration/RegistrationPropertyDescription.java 2007-05-01
05:52:03 UTC (rev 7158)
@@ -30,6 +30,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
+import java.util.Locale;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
@@ -327,4 +328,35 @@
return oldValue;
}
+
+ /**
+ * Tries to heuristically determine the language for this
RegistrationPropertyDescription
+ *
+ * @return
+ */
+ public Locale getLang()
+ {
+ Locale defaultLocale = Locale.getDefault();
+ Locale locale;
+
+ locale = label != null ? label.getLocale() : defaultLocale;
+ if (!defaultLocale.equals(locale))
+ {
+ return locale;
+ }
+
+ locale = hint != null ? hint.getLocale() : defaultLocale;
+ if (!defaultLocale.equals(locale))
+ {
+ return locale;
+ }
+
+ locale = description != null ? description.getLocale() : defaultLocale;
+ if (!defaultLocale.equals(locale))
+ {
+ return locale;
+ }
+
+ return defaultLocale;
+ }
}
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-04-30
22:30:17 UTC (rev 7157)
+++
trunk/wsrp/src/resources/portal-wsrp-sar/conf/consumer/hibernate/domain.hbm.xml 2007-05-01
05:52:03 UTC (rev 7158)
@@ -94,7 +94,7 @@
<property name="name" type="java.lang.String"
not-null="true" insert="false" update="false"/>
<property name="value" type="java.lang.String"/>
<property name="invalid" type="boolean"/>
- <property name="lang" type="java.lang.String"/>
+ <property name="lang" type="java.lang.String"
not-null="true"/>
<many-to-one
name="description"
column="DESC_PK"