Author: chris.laprun(a)jboss.com
Date: 2008-07-08 11:04:56 -0400 (Tue, 08 Jul 2008)
New Revision: 11349
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/interop/LiferayServiceDescriptionBehavior.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java
Log:
- Make sure we handle null lang attribute properly.
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/interop/LiferayServiceDescriptionBehavior.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/interop/LiferayServiceDescriptionBehavior.java 2008-07-08
12:01:24 UTC (rev 11348)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/interop/LiferayServiceDescriptionBehavior.java 2008-07-08
15:04:56 UTC (rev 11349)
@@ -26,8 +26,6 @@
import org.jboss.portal.wsrp.core.LocalizedString;
import org.jboss.portal.wsrp.core.PortletDescription;
-import java.util.Set;
-
/**
* Liferay behavior as exhibited at
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4162201#...
*
@@ -67,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_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java 2008-07-08
12:01:24 UTC (rev 11348)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java 2008-07-08
15:04:56 UTC (rev 11349)
@@ -426,31 +426,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