cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: r315012 - /cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java
Date Wed, 12 Oct 2005 19:36:48 GMT
Author: vgritsenko
Date: Wed Oct 12 12:36:45 2005
New Revision: 315012

URL: http://svn.apache.org/viewcvs?rev=315012&view=rev
Log:
release source in finally.
deparameterize URI before appending to it.

Modified:
    cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java

Modified: cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java?rev=315012&r1=315011&r2=315012&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java Wed Oct 12
12:36:45 2005
@@ -31,8 +31,13 @@
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.excalibur.store.Store;
 
+import org.apache.cocoon.util.NetUtils;
+
 import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.Locale;
+import java.util.Map;
 
 /**
  * This is the XMLResourceBundleFactory, the method for getting and creating
@@ -338,21 +343,33 @@
             base = "";
         }
 
+        // Resolve base URI
+        Source src = null;
+        Map parameters = Collections.EMPTY_MAP;
         StringBuffer sb = new StringBuffer();
         try {
-            Source src = this.resolver.resolveURI(base);
-            String uri = src.getURI();
+            src = this.resolver.resolveURI(base);
+
+            // Deparameterize base URL before adding catalogue name
+            String uri = NetUtils.deparameterize(src.getURI(),
+                                                 parameters = new HashMap(7));
+
+            // Append trailing slash
             sb.append(uri);
             if (!uri.endsWith("/")) {
                 sb.append('/');
             }
-            this.resolver.release(src);
+
         } catch (IOException e) {
             throw new SourceNotFoundException("Cannot resolve catalogue base URI <" +
base + ">", e);
+        } finally {
+            this.resolver.release(src);
         }
 
+        // Append catalogue name
         sb.append(name);
 
+        // Append catalogue locale
         if (locale != null) {
             if (!locale.getLanguage().equals("")) {
                 sb.append("_");
@@ -369,12 +386,14 @@
         }
         sb.append(".xml");
 
-        String result = sb.toString();
+        // Reconstruct complete bundle URI with parameters
+        String uri = NetUtils.parameterize(sb.toString(), parameters);
+
         if (getLogger().isDebugEnabled()) {
             getLogger().debug("Resolved name: " + name +
-                              ", locale: " + locale + " --> " + result);
+                              ", locale: " + locale + " --> " + uri);
         }
-        return result;
+        return uri;
     }
 
     /**



Mime
View raw message