geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickmcgu...@apache.org
Subject svn commit: r398564 - in /geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet: InternetHeaders.java MimeMessage.java
Date Mon, 01 May 2006 09:51:29 GMT
Author: rickmcguire
Date: Mon May  1 02:51:26 2006
New Revision: 398564

URL: http://svn.apache.org/viewcvs?rev=398564&view=rev
Log:
GERONIMO-1952 Fix setting/updating of the modified and saved flags in MimeMessage. 



Modified:
    geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/InternetHeaders.java
    geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/MimeMessage.java

Modified: geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/InternetHeaders.java
URL: http://svn.apache.org/viewcvs/geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/InternetHeaders.java?rev=398564&r1=398563&r2=398564&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/InternetHeaders.java
(original)
+++ geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/InternetHeaders.java
Mon May  1 02:51:26 2006
@@ -37,7 +37,7 @@
 
 /**
  * Class that represents the RFC822 headers associated with a message.
- * 
+ *
  * @version $Rev$ $Date$
  */
 public class InternetHeaders {
@@ -88,7 +88,7 @@
     /**
      * Create a new InternetHeaders initialized by reading headers from the
      * stream.
-     * 
+     *
      * @param in
      *            the RFC822 input stream to load from
      * @throws MessagingException
@@ -101,7 +101,7 @@
     /**
      * Read and parse the supplied stream and add all headers to the current
      * set.
-     * 
+     *
      * @param in
      *            the RFC822 input stream to load from
      * @throws MessagingException
@@ -160,7 +160,10 @@
                     }
                 }
                 // skip LF
-                in.read();
+                c = in.read();
+                if (c == -1) {
+                    break;
+                }
             }
             if (name.length() > 0) {
                 addHeader(name.toString().trim(), value.toString().trim());
@@ -172,7 +175,7 @@
 
     /**
      * Return all the values for the specified header.
-     * 
+     *
      * @param name
      *            the header to return
      * @return the values for that header, or null if the header is not present
@@ -195,7 +198,7 @@
      * Return the values for the specified header as a single String. If the
      * header has more than one value then all values are concatenated together
      * separated by the supplied delimiter.
-     * 
+     *
      * @param name
      *            the header to return
      * @param delimiter
@@ -224,7 +227,7 @@
     /**
      * Set the value of the header to the supplied value; any existing headers
      * are removed.
-     * 
+     *
      * @param name
      *            the name of the header
      * @param value
@@ -238,7 +241,7 @@
 
     /**
      * Add a new value to the header with the supplied name.
-     * 
+     *
      * @param name
      *            the name of the header to add a new value for
      * @param value
@@ -255,7 +258,7 @@
 
     /**
      * Remove all header entries with the supplied name
-     * 
+     *
      * @param name
      *            the header to remove
      */
@@ -266,7 +269,7 @@
 
     /**
      * Return all headers.
-     * 
+     *
      * @return an Enumeration<Header> containing all headers
      */
     public Enumeration getAllHeaders() {
@@ -323,9 +326,9 @@
      * Add an RFC822 header line to the header store. If the line starts with a
      * space or tab (a continuation line), add it to the last header line in the
      * list. Otherwise, append the new header line to the list.
-     * 
+     *
      * Note that RFC822 headers can only contain US-ASCII characters
-     * 
+     *
      * @param line
      *            raw RFC822 header line
      */

Modified: geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/MimeMessage.java
URL: http://svn.apache.org/viewcvs/geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/MimeMessage.java?rev=398564&r1=398563&r2=398564&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/MimeMessage.java
(original)
+++ geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/MimeMessage.java
Mon May  1 02:51:26 2006
@@ -131,7 +131,9 @@
         super(session);
         headers = new InternetHeaders();
         flags = new Flags();
+        // empty messages are modified, because the content is not there, and require saving
before use.
         modified = true;
+        saved = false;
     }
 
     /**
@@ -144,6 +146,10 @@
     public MimeMessage(Session session, InputStream in) throws MessagingException {
         this(session);
         parse(in);
+        // this message is complete, so marked as unmodified.
+        modified = false;
+        // and no saving required
+        saved = true;
     }
 
     /**
@@ -176,6 +182,8 @@
             parse (inData);
             // writing out the source data requires saving it, so we should consider this
one saved also.
             saved = true;
+            // this message is complete, so marked as unmodified.
+            modified = false;
         } catch (IOException e) {
             // I'm not sure ByteArrayInput/OutputStream actually throws IOExceptions or not,
but the method
             // signatures declare it, so we need to deal with it.  Turning it into a messaging
exception
@@ -194,7 +202,11 @@
         super(folder, number);
         headers = new InternetHeaders();
         flags = new Flags();
+        // saving primarly involves updates to the message header.  Since we're taking the
header info
+        // from a message store in this context, we mark the message as saved.
         saved = true;
+        // we've not filled in the content yet, so this needs to be marked as modified
+        modified = true;
     }
 
     /**
@@ -208,8 +220,13 @@
     protected MimeMessage(Folder folder, InputStream in, int number) throws MessagingException
{
         this(folder, number);
         parse(in);
+        // this message is complete, so marked as unmodified.
+        modified = false;
+        // and no saving required
+        saved = true;
     }
 
+
     /**
      * Create a MimeMessage with the supplied headers and content.
      *
@@ -223,6 +240,8 @@
         this(folder, number);
         this.headers = headers;
         this.content = content;
+        // this message is complete, so marked as unmodified.
+        modified = false;
     }
 
     /**
@@ -1086,14 +1105,19 @@
      * @exception IOException
      */
     public void writeTo(OutputStream out, String[] ignoreHeaders) throws MessagingException,
IOException {
+        // make sure everything is saved before we write
         if (!saved) {
             saveChanges();
         }
+
         // write out the headers first
         headers.writeTo(out, ignoreHeaders);
         // add the separater between the headers and the data portion.
         out.write('\r');
         out.write('\n');
+
+        // if the modfied flag, we don't have current content, so the data handler needs
to
+        // take care of writing this data out.
         if (modified) {
             dh.writeTo(MimeUtility.encode(out, getEncoding()));
         } else {
@@ -1116,6 +1140,7 @@
                 in.close();
             }
         }
+
         // flush any data we wrote out, but do not close the stream.  That's the caller's
duty.
         out.flush();
     }
@@ -1273,6 +1298,7 @@
      * @exception MessagingException
      */
     public void saveChanges() throws MessagingException {
+        // setting modified invalidates the current content.
         modified = true;
         saved = true;
         // update message headers from the content.



Mime
View raw message