You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2003/03/10 21:40:18 UTC

cvs commit: jakarta-james/src/java/org/apache/james/core MimeMessageWrapper.java

noel        2003/03/10 12:40:18

  Modified:    src/java/org/apache/james/core Tag: branch_2_1_fcs
                        MimeMessageWrapper.java
  Log:
  Fixed stream handling in MimeMessageWrapper to address a JavaMail issue introduced in v2.1.2
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.17.4.7  +41 -1     jakarta-james/src/java/org/apache/james/core/MimeMessageWrapper.java
  
  Index: MimeMessageWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/core/MimeMessageWrapper.java,v
  retrieving revision 1.17.4.6
  retrieving revision 1.17.4.7
  diff -u -r1.17.4.6 -r1.17.4.7
  --- MimeMessageWrapper.java	8 Mar 2003 21:54:03 -0000	1.17.4.6
  +++ MimeMessageWrapper.java	10 Mar 2003 20:40:17 -0000	1.17.4.7
  @@ -336,7 +336,9 @@
   
               InputStream bis = null;
               OutputStream bos = null;
  -            // Write the raw body to the output stream
  +            // Write the body to the output stream
  +
  +            /*
               try {
                   bis = message.getRawInputStream();
                   bos = bodyOs;
  @@ -351,6 +353,44 @@
   
                   bos = MimeUtility.encode(bodyOs, message.getEncoding());
                   bis = message.getInputStream();
  +            }
  +            */
  +
  +            try {
  +                // Get the message as a stream.  This will encode
  +                // objects as necessary, and we have some input from
  +                // decoding an re-encoding the stream.  I'd prefer the
  +                // raw stream, but see 
  +                bos = MimeUtility.encode(bodyOs, message.getEncoding());
  +                bis = message.getInputStream();
  +            } catch(javax.activation.UnsupportedDataTypeException udte) {
  +
  +                /* If we get an UnsupportedDataTypeException try using
  +                 * the raw input stream as a "best attempt" at rendering
  +                 * a message.
  +                 *
  +                 * WARNING: JavaMail v1.3 getRawInputStream() returns
  +                 * INVALID (unchanged) content for a changed message.
  +                 * getInputStream() works properly, but in this case
  +                 * has failed due to a missing DataHandler.
  +                 *
  +                 * MimeMessage.getRawInputStream() may throw a "no
  +                 * content" MessagingException.  In JavaMail v1.3, when
  +                 * you initially create a message using MimeMessage
  +                 * APIs, there is no raw content available.
  +                 * getInputStream() works, but getRawInputStream()
  +                 * throws an exception.  If we catch that exception,
  +                 * throw the UDTE.  It should mean that someone has
  +                 * locally constructed a message part for which JavaMail
  +                 * doesn't have a DataHandler.
  +                */
  +
  +                try {
  +                    bis = message.getRawInputStream();
  +                    bos = bodyOs;
  +                } catch(javax.mail.MessagingException me) {
  +                    throw udte;
  +                }
               }
   
               try {
  
  
  

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