cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject svn commit: r349807 - in /cocoon/branches/BRANCH_2_1_X: src/java/org/apache/cocoon/i18n/I18nUtils.java src/java/org/apache/cocoon/i18n/XMLResourceBundle.java src/java/org/apache/cocoon/transformation/I18nTransformer.java status.xml
Date Tue, 29 Nov 2005 21:00:17 GMT
Author: joerg
Date: Tue Nov 29 13:00:03 2005
New Revision: 349807

URL: http://svn.apache.org/viewcvs?rev=349807&view=rev
Log:
fixing bug COCOON-1700:
XMLResourceBundle now checks for both the old and the new namespace.

Modified:
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/I18nUtils.java
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundle.java
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/I18nTransformer.java
    cocoon/branches/BRANCH_2_1_X/status.xml

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/I18nUtils.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/I18nUtils.java?rev=349807&r1=349806&r2=349807&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/I18nUtils.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/I18nUtils.java Tue Nov 29
13:00:03 2005
@@ -22,6 +22,7 @@
 import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.environment.Session;
 import org.apache.cocoon.environment.Response;
+import org.apache.cocoon.util.Deprecation;
 
 import java.util.Enumeration;
 import java.util.Locale;
@@ -40,6 +41,24 @@
     // Locale string delimiter
     private static final String LOCALE_DELIMITER = "_-@.";
 
+    /**
+     * The namespace for i18n is "http://apache.org/cocoon/i18n/2.1".
+     */
+    public static final String I18N_NAMESPACE_URI =
+            "http://apache.org/cocoon/i18n/2.1";
+
+    /**
+     * The old namespace for i18n is "http://apache.org/cocoon/i18n/2.0".
+     */
+    public static final String I18N_OLD_NAMESPACE_URI =
+            "http://apache.org/cocoon/i18n/2.0";
+
+    /**
+     * Did we already encountered an old namespace? This is static to ensure
+     * that the associated message will be logged only once.
+     */
+    private static boolean deprecationFound = false;
+
     private I18nUtils() {
         // Disable instantiation
     }
@@ -242,4 +261,19 @@
             response.addCookie(response.createCookie(attribute, locale));
         }
     }
+
+    public static boolean matchesI18nNamespace(String uri) {
+        if (I18N_NAMESPACE_URI.equals(uri)) {
+            return true;
+        } else if (I18N_OLD_NAMESPACE_URI.equals(uri)) {
+            if (!deprecationFound) {
+                deprecationFound = true;
+                Deprecation.logger.warn("The namespace <" + I18N_OLD_NAMESPACE_URI +
+                                        "> is deprecated, use: <" + I18N_NAMESPACE_URI
+ ">");
+            }
+            return true;
+        }
+        return false;
+    }
+
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundle.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundle.java?rev=349807&r1=349806&r2=349807&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundle.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundle.java Tue
Nov 29 13:00:03 2005
@@ -149,7 +149,7 @@
             switch (this.state) {
                 case 0:
                     // <i18n:catalogue>
-                    if (!"".equals(ns) && !NS.equals(ns)) {
+                    if (!"".equals(ns) && !I18nUtils.matchesI18nNamespace(ns)) {
                         throw new SAXException("Root element <" + EL_CATALOGUE +
                                                "> must be non-namespaced or in i18n namespace.");
                     }

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/I18nTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/I18nTransformer.java?rev=349807&r1=349806&r2=349807&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/I18nTransformer.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/I18nTransformer.java
Tue Nov 29 13:00:03 2005
@@ -271,24 +271,6 @@
                              implements CacheableProcessingComponent,
                                         Serviceable, Configurable, Disposable {
 
-    /**
-     * The namespace for i18n is "http://apache.org/cocoon/i18n/2.1".
-     */
-    public static final String I18N_NAMESPACE_URI =
-            "http://apache.org/cocoon/i18n/2.1";
-
-    /**
-     * The old namespace for i18n is "http://apache.org/cocoon/i18n/2.0".
-     */
-    public static final String I18N_OLD_NAMESPACE_URI =
-            "http://apache.org/cocoon/i18n/2.0";
-
-    /**
-     * Did we already encountered an old namespace? This is static to ensure
-     * that the associated message will be logged only once.
-     */
-    private static boolean deprecationFound = false;
-
     //
     // i18n elements
     //
@@ -1119,23 +1101,11 @@
         }
 
         // Process start element event
-        if (I18N_NAMESPACE_URI.equals(uri)) {
+        if (I18nUtils.matchesI18nNamespace(uri)) {
             if (getLogger().isDebugEnabled()) {
                 getLogger().debug("Starting i18n element: " + name);
             }
             startI18NElement(name, attr);
-
-        } else if (I18N_OLD_NAMESPACE_URI.equals(uri)) {
-            if (!deprecationFound) {
-                deprecationFound = true;
-                getLogger().warn("The namespace <" + I18N_OLD_NAMESPACE_URI +
-                                 "> is deprecated, use: <" + I18N_NAMESPACE_URI + ">");
-            }
-            if (getLogger().isDebugEnabled()) {
-                getLogger().debug("Starting deprecated i18n element: " + name);
-            }
-            startI18NElement(name, attr);
-
         } else {
             // We have a non i18n element event
             if (current_state == STATE_OUTSIDE) {
@@ -1163,7 +1133,7 @@
             strBuffer = null;
         }
 
-        if (I18N_NAMESPACE_URI.equals(uri) || I18N_OLD_NAMESPACE_URI.equals(uri)) {
+        if (I18nUtils.matchesI18nNamespace(uri)) {
             endI18NElement(name);
         } else if (current_state == STATE_INSIDE_PARAM) {
             param_recorder.endElement(uri, name, raw);
@@ -1225,17 +1195,17 @@
             currentKey = attr.getValue("", I18N_KEY_ATTRIBUTE);
             if (currentKey == null) {
                 // Try the namespaced attribute
-                currentKey = attr.getValue(I18N_NAMESPACE_URI, I18N_KEY_ATTRIBUTE);
+                currentKey = attr.getValue(I18nUtils.I18N_NAMESPACE_URI, I18N_KEY_ATTRIBUTE);
                 if (currentKey == null) {
                     // Try the old namespace
-                    currentKey = attr.getValue(I18N_OLD_NAMESPACE_URI, I18N_KEY_ATTRIBUTE);
+                    currentKey = attr.getValue(I18nUtils.I18N_OLD_NAMESPACE_URI, I18N_KEY_ATTRIBUTE);
                 }
             }
 
             currentCatalogueId = attr.getValue("", I18N_CATALOGUE_ATTRIBUTE);
             if (currentCatalogueId == null) {
                 // Try the namespaced attribute
-                currentCatalogueId = attr.getValue(I18N_NAMESPACE_URI, I18N_CATALOGUE_ATTRIBUTE);
+                currentCatalogueId = attr.getValue(I18nUtils.I18N_NAMESPACE_URI, I18N_CATALOGUE_ATTRIBUTE);
             }
 
             if (prev_state != STATE_INSIDE_PARAM) {
@@ -1549,10 +1519,10 @@
 
         // Translate all attributes from i18n:attr="name1 name2 ..."
         // using their values as keys.
-        int attrIndex = attr.getIndex(I18N_NAMESPACE_URI, I18N_ATTR_ATTRIBUTE);
+        int attrIndex = attr.getIndex(I18nUtils.I18N_NAMESPACE_URI, I18N_ATTR_ATTRIBUTE);
         if (attrIndex == -1) {
             // Try the old namespace
-            attrIndex = attr.getIndex(I18N_OLD_NAMESPACE_URI, I18N_ATTR_ATTRIBUTE);
+            attrIndex = attr.getIndex(I18nUtils.I18N_OLD_NAMESPACE_URI, I18N_ATTR_ATTRIBUTE);
         }
 
         if (attrIndex != -1) {
@@ -1586,7 +1556,7 @@
 
         // Translate all attributes from i18n:expr="name1 name2 ..."
         // using their values as keys.
-        attrIndex = attr.getIndex(I18N_NAMESPACE_URI, I18N_EXPR_ATTRIBUTE);
+        attrIndex = attr.getIndex(I18nUtils.I18N_NAMESPACE_URI, I18N_EXPR_ATTRIBUTE);
         if (attrIndex != -1) {
             StringTokenizer st = new StringTokenizer(attr.getValue(attrIndex));
 

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?rev=349807&r1=349806&r2=349807&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Tue Nov 29 13:00:03 2005
@@ -179,7 +179,10 @@
   <release version="@version@" date="@date@">
 -->
   <release version="2.1.9" date="TBD">
-	 <action dev="SW" type="add">
+    <action dev="JH" type="fix" fixes-bug="COCOON-1700">
+      I18n: XMLResourceBundle checks now for both the new and the old namespace.
+    </action>
+    <action dev="SW" type="add">
       XMLDB: heavy refactoring. The source is now traversable (like file and jcr) and has
two specific
       methods: <code>createId</code> to create a new document ID for a collection,
and and <code>getBinaryOutputStream</code>
       to write binary data to the database.



Mime
View raw message