sylvain     2004/02/04 07:16:01

  Modified:    src/java/org/apache/cocoon/i18n
                        XMLResourceBundleFactory.java
               src/java/org/apache/cocoon/transformation
                        I18nTransformer.java
  Log:
  Cache keys for XMLResourceBundles are now absolute. Otherwise, conflicts 
arise when different subsitemaps use the same catalogue names
  
  Revision  Changes    Path
  1.11      +30 -8     
cocoon-2.1/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java
  
  Index: XMLResourceBundleFactory.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- XMLResourceBundleFactory.java     16 Jan 2004 15:55:38 -0000      1.10
  +++ XMLResourceBundleFactory.java     4 Feb 2004 15:16:01 -0000       1.11
  @@ -50,6 +50,7 @@
   */
   package org.apache.cocoon.i18n;
   
  +import java.io.IOException;
   import java.util.HashMap;
   import java.util.Iterator;
   import java.util.Locale;
  @@ -64,10 +65,13 @@
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.logger.LogEnabled;
   import org.apache.avalon.framework.logger.Logger;
  +import org.apache.avalon.framework.service.ServiceException;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
   import org.apache.avalon.framework.thread.ThreadSafe;
  +import org.apache.excalibur.source.Source;
   import org.apache.excalibur.source.SourceNotFoundException;
  +import org.apache.excalibur.source.SourceResolver;
   import org.apache.cocoon.ResourceNotFoundException;
   import org.xml.sax.SAXParseException;
   
  @@ -108,6 +112,11 @@
        * Service Manager
        */
       protected ServiceManager manager = null;
  +    
  +    /**
  +     * Source resolver
  +     */
  +    protected SourceResolver resolver;
   
   
       /**
  @@ -127,8 +136,9 @@
           return this.logger;
       }
   
  -    public void service(ServiceManager manager) {
  +    public void service(ServiceManager manager) throws ServiceException {
           this.manager = manager;
  +        this.resolver = 
(SourceResolver)this.manager.lookup(SourceResolver.ROLE);
       }
   
       public void dispose() {
  @@ -140,6 +150,7 @@
               }
               i.remove();
           }
  +        this.manager.release(this.resolver);
           this.manager = null;
       }
   
  @@ -376,14 +387,25 @@
        * @return                  the parent locale
        */
       protected String getFileName(String base, String name, Locale locale) {
  -        if (base == null) {
  -            base = "";
  +        StringBuffer sb = new StringBuffer();
  +        if (base == null || base.length() == 0) {
  +            // FIXME (SW): can this happen?
  +        } else {
  +            try {
  +                Source src = this.resolver.resolveURI(base);
  +                String uri = src.getURI();
  +                sb.append(uri);
  +                if (!uri.endsWith("/")) {
  +                    sb.append('/');
  +                }
  +                this.resolver.release(src);
  +            } catch(IOException ioe) {
  +                throw new RuntimeException("Cannot resolve " + base, ioe);
  +            }
           }
  +        
  +        sb.append(name);
   
  -        StringBuffer sb = new StringBuffer(base);
  -        if (!base.endsWith("/")) {
  -            sb.append('/').append(name);
  -        }
           if (locale != null) {
               if (!locale.getLanguage().equals("")) {
                   sb.append("_");
  
  
  
  1.24      +5 -1      
cocoon-2.1/src/java/org/apache/cocoon/transformation/I18nTransformer.java
  
  Index: I18nTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/transformation/I18nTransformer.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- I18nTransformer.java      15 Jan 2004 15:24:31 -0000      1.23
  +++ I18nTransformer.java      4 Feb 2004 15:16:01 -0000       1.24
  @@ -975,6 +975,10 @@
       public void configure(Configuration conf) throws ConfigurationException {
           // read in the config options from the transformer definition
           Configuration cataloguesConf = conf.getChild("catalogues", false);
  +        
  +        if (cataloguesConf == null) {
  +            throw new ConfigurationException("I18NTransformer needs a 
'catalogues' configuration at " + conf.getLocation());
  +        }
   
           // new configuration style
           Configuration[] catalogueConfs = 
cataloguesConf.getChildren("catalogue");
  
  
  

Reply via email to