cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: rev 36115 - cocoon/trunk/src/java/org/apache/cocoon/matching
Date Mon, 09 Aug 2004 15:16:54 GMT
Author: vgritsenko
Date: Mon Aug  9 08:16:53 2004
New Revision: 36115

Modified:
   cocoon/trunk/src/java/org/apache/cocoon/matching/I18nMatcher.java
Log:
Add debug output, fix cookie handling


Modified: cocoon/trunk/src/java/org/apache/cocoon/matching/I18nMatcher.java
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/matching/I18nMatcher.java	(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/matching/I18nMatcher.java	Mon Aug  9 08:16:53
2004
@@ -178,16 +178,25 @@
 
         // 1. Request parameter 'locale'
         String locale = request.getParameter(localeAttribute);
-        if (locale != null && isValidResource(pattern, new Locale(locale, ""), map))
{
-             return map;
+        if (locale != null) {
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug("Testing locale from request: '" + locale + "'");
+            }
+            if (isValidResource(pattern, new Locale(locale, ""), map)) {
+                return map;
+            }
         }
 
         // 2. Session attribute 'locale'
         Session session = request.getSession(false);
         if (session != null &&
-            ((locale = (String) session.getAttribute(localeAttribute)) != null) &&
-                isValidResource(pattern, new Locale(locale, ""), map)) {
-            return map;
+                ((locale = (String) session.getAttribute(localeAttribute)) != null)) {
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug("Testing locale from session: '" + locale + "'");
+            }
+            if (isValidResource(pattern, new Locale(locale, ""), map)) {
+                return map;
+            }
         }
 
         // 3. First matching cookie parameter 'locale' within each cookie sent
@@ -196,6 +205,10 @@
             for (int i = 0; i < cookies.length; i++) {
                 Cookie cookie = cookies[i];
                 if (cookie.getName().equals(localeAttribute)) {
+                    locale = cookie.getValue();
+                    if (getLogger().isDebugEnabled()) {
+                        getLogger().debug("Testing locale from cookie: '" + locale + "'");
+                    }
                     if (isValidResource(pattern, new Locale(locale, ""), map)) {
                         return map;
                     }
@@ -206,13 +219,21 @@
 
         // 4. Sitemap parameter "locale"
         locale = parameters.getParameter("locale", null);
-        if (locale != null && isValidResource(pattern, new Locale(locale, ""), map))
{
-              return map;
+        if (locale != null) {
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug("Testing locale from sitemap: '" + locale + "'");
+            }
+            if (isValidResource(pattern, new Locale(locale, ""), map)) {
+                return map;
+            }
         }
 
         // 5. Locale setting of the requesting browser or server default
         if (useLocale && !useLocales) {
             Locale l = request.getLocale();
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug("Testing locale from request: '" + l + "'");
+            }
             if(isValidResource(pattern, l, map)) {
                 return map;
             }
@@ -222,6 +243,9 @@
             Enumeration locales = request.getLocales();
             while (locales.hasMoreElements()) {
                 Locale l = (Locale)locales.nextElement();
+                if (getLogger().isDebugEnabled()) {
+                    getLogger().debug("Testing locale from request: '" + l + "'");
+                }
                 if (isValidResource(pattern, l, map)) {
                     return map;
                 }
@@ -229,13 +253,27 @@
         }
 
         // 6. Default
-        if (defaultLocale != null && isValidResource(pattern, defaultLocale, map))
{
-            return map;
+        if (defaultLocale != null) {
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug("Testing default locale: '" + defaultLocale + "'");
+            }
+            if (isValidResource(pattern, defaultLocale, map)) {
+                return map;
+            }
         }
 
         // 7. Blank
-        if (testBlankLocale && isValidResource(pattern, null, map)) {
-            return map;
+        if (testBlankLocale) {
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug("Testing blank locale");
+            }
+            if (isValidResource(pattern, null, map)) {
+                return map;
+            }
+        }
+
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("No locale found for resource: " + pattern);
         }
         return null;
     }

Mime
View raw message