chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1064726 - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server: impl/webservices/AbstractService.java shared/HttpUtils.java
Date Fri, 28 Jan 2011 15:23:40 GMT
Author: fmui
Date: Fri Jan 28 15:23:40 2011
New Revision: 1064726

URL: http://svn.apache.org/viewvc?rev=1064726&view=rev
Log:
better "Accept-Language" header parsing

Modified:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java?rev=1064726&r1=1064725&r2=1064726&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
Fri Jan 28 15:23:40 2011
@@ -101,9 +101,14 @@ public abstract class AbstractService {
                     String acceptLanguage = header.getValue().get(0);
                     if (acceptLanguage != null) {
                         String[] locale = acceptLanguage.split("-");
-                        context.put(CallContext.LOCALE_ISO639_LANGUAGE, locale[0]);
+                        context.put(CallContext.LOCALE_ISO639_LANGUAGE, locale[0].trim());
                         if (locale.length > 1) {
-                            context.put(CallContext.LOCALE_ISO3166_COUNTRY, locale[1]);
+                            int x = locale[1].indexOf(',');
+                            if (x == -1) {
+                                context.put(CallContext.LOCALE_ISO3166_COUNTRY, locale[1].trim());
+                            } else {
+                                context.put(CallContext.LOCALE_ISO3166_COUNTRY, locale[1].substring(0,
x).trim());
+                            }
                         }
                     }
                     break;

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java?rev=1064726&r1=1064725&r2=1064726&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java
Fri Jan 28 15:23:40 2011
@@ -101,9 +101,14 @@ public class HttpUtils {
         String acceptLanguage = request.getHeader("Accept-Language");
         if (acceptLanguage != null) {
             String[] locale = acceptLanguage.split("-");
-            context.put(CallContext.LOCALE_ISO639_LANGUAGE, locale[0]);
+            context.put(CallContext.LOCALE_ISO639_LANGUAGE, locale[0].trim());
             if (locale.length > 1) {
-                context.put(CallContext.LOCALE_ISO3166_COUNTRY, locale[1]);
+                int x = locale[1].indexOf(',');
+                if (x == -1) {
+                    context.put(CallContext.LOCALE_ISO3166_COUNTRY, locale[1].trim());
+                } else {
+                    context.put(CallContext.LOCALE_ISO3166_COUNTRY, locale[1].substring(0,
x).trim());
+                }
             }
         }
 



Mime
View raw message