pgoldstein    2002/09/30 00:35:09

  Modified:    src/java/org/apache/james/core AvalonMailStore.java
  Log:
  Fixed a major bug that was exposed by a recent change to JDBCMailRepository to 
restore dbfile capability.
  
  This bug caused configurations of one repository to be used by another differently 
configured
  repository of the same class.  For some configurations, this means that a formerly 
db repository
  behaved as if it were a dbfile repository.
  
  Before using this code make sure that you don't need anything in var/dbmail.
  
  Revision  Changes    Path
  1.15      +13 -8     
jakarta-james/src/java/org/apache/james/core/AvalonMailStore.java
  
  Index: AvalonMailStore.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/core/AvalonMailStore.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- AvalonMailStore.java      25 Sep 2002 23:29:39 -0000      1.14
  +++ AvalonMailStore.java      30 Sep 2002 07:35:09 -0000      1.15
  @@ -51,7 +51,7 @@
       // map of [protocol(destinationURL) + type ]->classname of repository;
       private HashMap classes;
   
  -    // map of [Repository Class]->default config for repository.
  +    // map of [protocol(destinationURL) + type ]->default config for repository.
       private HashMap defaultConfigs;
   
       /**
  @@ -175,11 +175,20 @@
           {
               String protocol = protocols[i].getValue();
   
  +            // Get the default configuration for these protocol/type combinations.
  +            Configuration defConf = repConf.getChild("config");
  +
               for ( int j = 0; j < types.length; j++ )
               {
                   String type = types[j].getValue();
                   String key = protocol + type ;
  +                if (classes.get(key) != null) {
  +                    throw new ConfigurationException("The combination of protocol 
and type comprise a unique key for repositories.  This constraint has been violated.  
Please check your repository configuration.");
  +                }
                   classes.put(key, className);
  +                if (defConf != null) {
  +                    defaultConfigs.put(key, defConf);
  +                }
                   if (infoEnabled) {
                       StringBuffer logBuffer =
                           new StringBuffer(128)
  @@ -192,11 +201,6 @@
               }
           }
   
  -        // Get the default configuration for this Repository class.
  -        Configuration defConf = repConf.getChild("config");
  -        if ( defConf != null ) {
  -            defaultConfigs.put(className, defConf);
  -        }
       }
   
       /**
  @@ -258,7 +262,8 @@
                   }
                   return (Component)reply;
               } else {
  -                String repClass = (String) classes.get( protocol + type );
  +                String key = protocol + type;
  +                String repClass = (String) classes.get( key );
   
                   if (getLogger().isDebugEnabled()) {
                       logBuffer =
  @@ -277,7 +282,7 @@
                   // and the values in the selector.
                   // If no default values, just use the selector.
                   Configuration config;
  -                Configuration defConf = (Configuration)defaultConfigs.get(repClass);
  +                Configuration defConf = (Configuration)defaultConfigs.get(key);
                   if ( defConf == null) {
                       config = repConf;
                   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to