axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r550616 - /webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLFaultUtils.java
Date Mon, 25 Jun 2007 21:37:59 GMT
Author: rott
Date: Mon Jun 25 14:37:58 2007
New Revision: 550616

URL: http://svn.apache.org/viewvc?view=rev&rev=550616
Log:
XMLFaultUtils setting fault reason locale incorrectly according to soap spec

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLFaultUtils.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLFaultUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLFaultUtils.java?view=diff&rev=550616&r1=550615&r2=550616
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLFaultUtils.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLFaultUtils.java
Mon Jun 25 14:37:58 2007
@@ -260,8 +260,7 @@
         // TODO what if this fails
         String text = soapFault.getFaultString();
         Locale locale = soapFault.getFaultStringLocale();
-        String lang = (locale == null) ? Locale.getDefault().getLanguage() : locale.getLanguage();
-        XMLFaultReason reason = new XMLFaultReason(text, lang);
+        XMLFaultReason reason = new XMLFaultReason(text, localeToXmlLang(locale));
 
         // Construct the XMLFault from the required information (code, reason, detail blocks)
         XMLFault xmlFault = new XMLFault(code, reason, detailBlocks);
@@ -299,8 +298,7 @@
                         first = false;
                     } else {
                         text = soapFault.getFaultReasonText(locale);
-                        lang = locale.getLanguage();
-                        list.add(new XMLFaultReason(text, lang));
+                        list.add(new XMLFaultReason(text, localeToXmlLang(locale)));
                     }
                 }
                 if (list.size() > 0) {
@@ -635,5 +633,24 @@
 
         return soapFault;
 
+    }
+    
+    /**
+     * Converte a Locale object to an xmlLang String
+     * @param locale
+     * @return String of the form <locale.getLanguage()>-<locale.getCountry()>
+     */
+    private static String localeToXmlLang(Locale locale) {
+        if (locale == null) {
+            return Locale.getDefault().getLanguage() + "-" + Locale.getDefault().getCountry();
+        }
+        String lang = locale.getLanguage();
+        String countryCode = locale.getCountry();
+        if (countryCode == null || countryCode.length() == 0) {
+            return lang;
+        } else {
+            return new String(lang + "-" + countryCode);
+        }
+        
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message