james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vince...@apache.org
Subject cvs commit: james-server/src/java/org/apache/james/mailrepository JDBCMailRepository.java
Date Thu, 17 Jul 2003 13:23:49 GMT
vincenzo    2003/07/17 06:23:48

  Modified:    src/conf sqlResources.xml
               src/java/org/apache/james/core MailImpl.java
               src/java/org/apache/james/mailrepository
                        JDBCMailRepository.java
  Log:
  Implementing "forward" compatibility for mail attributes.
  
  Revision  Changes    Path
  1.21      +12 -12    james-server/src/conf/sqlResources.xml
  
  Index: sqlResources.xml
  ===================================================================
  RCS file: /home/cvs/james-server/src/conf/sqlResources.xml,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- sqlResources.xml	15 Jul 2003 10:11:57 -0000	1.20
  +++ sqlResources.xml	17 Jul 2003 13:23:41 -0000	1.21
  @@ -225,7 +225,7 @@
               remote_host varchar (255) NOT NULL ,
               remote_addr varchar (20) NOT NULL ,
               message_body longblob NOT NULL ,
  -            message_attributes longblob NOT NULL ,
  +            message_attributes longblob NULL ,
               last_updated datetime NOT NULL,
               PRIMARY KEY (repository_name, message_name)
           )
  @@ -241,7 +241,7 @@
               remote_host varchar (255) NOT NULL ,
               remote_addr varchar (20) NOT NULL ,
               message_body varchar NOT NULL ,
  -            message_attributes varchar NOT NULL ,
  +            message_attributes varchar NULL ,
               last_updated timestamp NOT NULL,
               PRIMARY KEY (repository_name, message_name)
           )
  @@ -257,7 +257,7 @@
               [remote_host] [varchar] (255) NOT NULL ,
               [remote_addr] [varchar] (20) NOT NULL ,
               [message_body] [image] NOT NULL ,
  -            [message_attributes] [image] NOT NULL ,
  +            [message_attributes] [image] NULL ,
               [last_updated] [datetime] NOT NULL,
               PRIMARY KEY (repository_name, message_name)
           )
  @@ -273,7 +273,7 @@
           remote_host varchar2(100) NOT NULL ,
           remote_addr varchar2(20) NOT NULL ,
           message_body long raw NOT NULL ,
  -        message_attributes long raw NOT NULL ,
  +        message_attributes long raw NULL ,
           last_updated date NOT NULL ,
           PRIMARY KEY (repository_name, message_name)
           )
  @@ -290,7 +290,7 @@
               remote_host varchar (255) NOT NULL ,
               remote_addr varchar (20) NOT NULL ,
               message_body bytea NOT NULL ,
  -            message_attributes bytea NOT NULL ,
  +            message_attributes bytea NULL ,
               last_updated timestamp NOT NULL,
               PRIMARY KEY (repository_name, message_name)
           )
  @@ -306,7 +306,7 @@
               remote_host varchar (100) NOT NULL ,
               remote_addr varchar (20) NOT NULL ,
               message_body long byte NOT NULL ,
  -            message_attributes long byte NOT NULL ,
  +            message_attributes long byte NULL ,
               last_updated date NOT NULL,
               PRIMARY KEY (repository_name, message_name)
           )
  @@ -380,7 +380,7 @@
               remote_host varchar (255) NOT NULL ,
               remote_addr varchar (20) NOT NULL ,
               message_body varchar NOT NULL ,
  -            message_attributes varchar NOT NULL ,
  +            message_attributes varchar NULL ,
               last_updated timestamp NOT NULL,
               PRIMARY KEY (message_name, repository_name)
           )
  @@ -396,7 +396,7 @@
               remote_host varchar (255) NOT NULL ,
               remote_addr varchar (20) NOT NULL ,
               message_body longblob NOT NULL ,
  -            message_attributes longblob NOT NULL ,
  +            message_attributes longblob NULL ,
               last_updated datetime NOT NULL,
               PRIMARY KEY (message_name, repository_name)
           )
  @@ -412,7 +412,7 @@
               [remote_host] [varchar] (255) NOT NULL ,
               [remote_addr] [varchar] (20) NOT NULL ,
               [message_body] [image] NOT NULL ,
  -            [message_attributes] [image] NOT NULL ,
  +            [message_attributes] [image] NULL ,
               [last_updated] [datetime] NOT NULL,
               PRIMARY KEY (message_name, repository_name)
           )
  @@ -428,7 +428,7 @@
           remote_host varchar2(255) NOT NULL ,
           remote_addr varchar2(20) NOT NULL ,
           message_body long raw NOT NULL ,
  -        message_attributes long raw NOT NULL ,
  +        message_attributes long raw NULL ,
           last_updated date NOT NULL ,
           PRIMARY KEY (message_name, repository_name)
           )
  @@ -444,7 +444,7 @@
               remote_host varchar (255) NOT NULL ,
               remote_addr varchar (20) NOT NULL ,
               message_body bytea NOT NULL ,
  -            message_attributes bytea NOT NULL ,
  +            message_attributes bytea NULL ,
               last_updated timestamp NOT NULL,
               PRIMARY KEY (message_name, repository_name)
           )
  @@ -460,7 +460,7 @@
               remote_host varchar (255) NOT NULL ,
               remote_addr varchar (20) NOT NULL ,
               message_body long byte NOT NULL ,
  -            message_attributes long byte NOT NULL ,
  +            message_attributes long byte NULL ,
               last_updated date NOT NULL,
               PRIMARY KEY (message_name, repository_name)
           )
  
  
  
  1.27      +23 -12    james-server/src/java/org/apache/james/core/MailImpl.java
  
  Index: MailImpl.java
  ===================================================================
  RCS file: /home/cvs/james-server/src/java/org/apache/james/core/MailImpl.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- MailImpl.java	15 Jul 2003 10:11:58 -0000	1.26
  +++ MailImpl.java	17 Jul 2003 13:23:45 -0000	1.27
  @@ -64,6 +64,7 @@
   import java.io.InputStreamReader;
   import java.io.OutputStream;
   import java.io.Serializable;
  +import java.io.OptionalDataException;
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.Date;
  @@ -85,8 +86,15 @@
   import org.apache.mailet.RFC2822Headers;
   
   /**
  - * Wraps a MimeMessage adding routing information (from SMTP) and some simple
  - * API enhancements.
  + * <P>Wraps a MimeMessage adding routing information (from SMTP) and some simple
  + * API enhancements.</P>
  + * <P>From James version > 2.2.0a8 "mail attributes" have been added.
  + * Backward and forward compatibility is supported:
  + * messages stored in file repositories <I>without</I> attributes by James
version <= 2.2.0a8
  + * will be processed by later versions as having an empty attributes hashmap;
  + * messages stored in file repositories <I>with</I> attributes by James version
> 2.2.0a8
  + * will be processed by previous versions, ignoring the attributes.</P>
  + *
    * @version CVS $Revision$ $Date$
    */
   public class MailImpl implements Disposable, Mail {
  @@ -524,15 +532,18 @@
           name = (String) in.readObject();
           remoteHost = (String) in.readObject();
           remoteAddr = (String) in.readObject();
  -        Object o = in.readObject();
  -        //this check is done to be backwards compatible with mail repositories
  -        if (o instanceof Date) {
  -            setLastUpdated ((Date)o);
  -            attributes = new HashMap();
  -        } else {
  -            attributes = (HashMap)o;
           setLastUpdated((Date) in.readObject());
  -    }
  +        // the following is under try/catch to be backwards compatible
  +        // with messages created with James version <= 2.2.0a8
  +        try {
  +            attributes = (HashMap) in.readObject();
  +        } catch (OptionalDataException ode) {
  +            if (ode.eof) {
  +                attributes = new HashMap();
  +            } else {
  +                throw ode;
  +            }
  +        }
       }
       /**
        * Write the MailImpl to an <code>ObjectOutputStream</code>.
  @@ -550,8 +561,8 @@
           out.writeObject(name);
           out.writeObject(remoteHost);
           out.writeObject(remoteAddr);
  -        out.writeObject(attributes);
           out.writeObject(lastUpdated);
  +        out.writeObject(attributes);
       }
   
       /**
  
  
  
  1.46      +8 -5      james-server/src/java/org/apache/james/mailrepository/JDBCMailRepository.java
  
  Index: JDBCMailRepository.java
  ===================================================================
  RCS file: /home/cvs/james-server/src/java/org/apache/james/mailrepository/JDBCMailRepository.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- JDBCMailRepository.java	15 Jul 2003 10:11:58 -0000	1.45
  +++ JDBCMailRepository.java	17 Jul 2003 13:23:46 -0000	1.46
  @@ -787,10 +787,13 @@
                       if (rsMessageAttr.next()) {
                           try {
                               byte[] serialized_attr = rsMessageAttr.getBytes(1);
  -                            ByteArrayInputStream bais = new ByteArrayInputStream (serialized_attr);
  -                            ObjectInputStream ois = new ObjectInputStream (bais);
  -                            attributes = (HashMap)ois.readObject();
  -                            ois.close();
  +                            // this check is for better backwards compatibility
  +                            if (serialized_attr != null) {
  +                                ByteArrayInputStream bais = new ByteArrayInputStream(serialized_attr);
  +                                ObjectInputStream ois = new ObjectInputStream(bais);
  +                                attributes = (HashMap)ois.readObject();
  +                                ois.close();
  +                            }
                           } catch (IOException ioe) {
                               if (getLogger().isDebugEnabled()) {
                                   StringBuffer debugBuffer =
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message