Author: chris.laprun(a)jboss.com
Date: 2008-07-08 11:05:51 -0400 (Tue, 08 Jul 2008)
New Revision: 11351
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/interop/LiferayServiceDescriptionBehavior.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java
Log:
- Make sure we handle null lang case properly.
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/interop/LiferayServiceDescriptionBehavior.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/interop/LiferayServiceDescriptionBehavior.java 2008-07-08
15:05:22 UTC (rev 11350)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/interop/LiferayServiceDescriptionBehavior.java 2008-07-08
15:05:51 UTC (rev 11351)
@@ -65,6 +65,12 @@
locString.setLang(lang);
locString.setValue("Software Catalog");
- serviceDescription.setOfferedPortlets(new PortletDescription[]{pd});
+ // add another value that checks that we handle null lang properly
+ PortletDescription pd2 = createPortletDescription("99", null);
+ pd.getMarkupTypes()[0].getLocales()[0] = "en_US";
+ locString = pd.getShortTitle();
+ locString.setLang(null);
+
+ serviceDescription.setOfferedPortlets(new PortletDescription[]{pd, pd2});
}
}
\ No newline at end of file
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java 2008-07-08
15:05:22 UTC (rev 11350)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java 2008-07-08
15:05:51 UTC (rev 11351)
@@ -434,31 +434,38 @@
public static Locale getLocale(String lang) throws IllegalArgumentException
{
- String possiblyRelaxed = lang;
- if (!WSRPUtils.strict)
+ if (lang != null)
{
- // treat en_US as valid by en_US => en-US
- // todo: maybe this should be handled by an interceptor...
- possiblyRelaxed = lang.replace('_', '-');
- }
+ String possiblyRelaxed = lang;
+ if (!WSRPUtils.strict)
+ {
+ // treat en_US as valid by en_US => en-US
+ // todo: maybe this should be handled by an interceptor...
+ possiblyRelaxed = lang.replace('_', '-');
+ }
- try
- {
- return LocaleFormat.RFC3066_LANGUAGE_TAG.getLocale(possiblyRelaxed);
- }
- catch (ConversionException e)
- {
- if (WSRPUtils.strict)
+ try
{
- throw new IllegalArgumentException(e);
+ return LocaleFormat.RFC3066_LANGUAGE_TAG.getLocale(possiblyRelaxed);
}
- else
+ catch (ConversionException e)
{
- log.debug("Was given an invalid language: '" + possiblyRelaxed
- + "'. Since we're using relaxed validation, we will
assume " + Locale.ENGLISH + " to avoid crashing!", e);
- return Locale.ENGLISH;
+ if (WSRPUtils.strict)
+ {
+ throw new IllegalArgumentException(e);
+ }
+ else
+ {
+ log.debug("Was given an invalid language: '" +
possiblyRelaxed
+ + "'. Since we're using relaxed validation, we will
assume " + Locale.ENGLISH + " to avoid crashing!", e);
+ return Locale.ENGLISH;
+ }
}
}
+ else
+ {
+ return Locale.getDefault();
+ }
}
public static String toString(Locale locale) throws IllegalArgumentException
Show replies by date