james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r659992 - in /james/mime4j/trunk/src: main/java/org/apache/james/mime4j/message/ test/java/org/apache/james/mime4j/message/
Date Sun, 25 May 2008 14:30:55 GMT
Author: rdonkin
Date: Sun May 25 07:30:55 2008
New Revision: 659992

URL: http://svn.apache.org/viewvc?rev=659992&view=rev
Log:
Pass mode through to all writeTo calls

Modified:
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Body.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/BodyPart.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Entity.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Header.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Message.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Multipart.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/TempFileBinaryBody.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/TempFileTextBody.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageTest.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MultipartFormTest.java

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Body.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Body.java?rev=659992&r1=659991&r2=659992&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Body.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Body.java Sun May 25
07:30:55 2008
@@ -22,6 +22,8 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
+import org.apache.james.mime4j.MimeException;
+
 /**
  * Encapsulates the body of an entity (see RFC 2045).
  *
@@ -48,7 +50,8 @@
      * Writes this body to the given stream in MIME message format.
      * 
      * @param out the stream to write to.
+     * @param mode output mode {@link MessageUtils}
      * @throws IOException on I/O errors.
      */
-    void writeTo(OutputStream out) throws IOException;
+    void writeTo(OutputStream out, int mode) throws IOException, MimeException;
 }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/BodyPart.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/BodyPart.java?rev=659992&r1=659991&r2=659992&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/BodyPart.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/BodyPart.java Sun May
25 07:30:55 2008
@@ -22,6 +22,8 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
+import org.apache.james.mime4j.MimeException;
+
 
 /**
  * Represents a MIME body part  (see RFC 2045).
@@ -33,10 +35,10 @@
 
     /**
      * 
-     * @see org.apache.james.mime4j.message.Entity#writeTo(java.io.OutputStream)
+     * @see org.apache.james.mime4j.message.Entity#writeTo(java.io.OutputStream, int)
      */
-    public void writeTo(OutputStream out) throws IOException {
-        getHeader().writeTo(out);
-        getBody().writeTo(out);
+    public void writeTo(OutputStream out, int mode) throws IOException, MimeException {
+        getHeader().writeTo(out, mode);
+        getBody().writeTo(out, mode);
     }
 }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Entity.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Entity.java?rev=659992&r1=659991&r2=659992&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Entity.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Entity.java Sun May 25
07:30:55 2008
@@ -22,6 +22,7 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
+import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.field.ContentTransferEncodingField;
 import org.apache.james.mime4j.field.ContentTypeField;
 import org.apache.james.mime4j.field.Field;
@@ -164,7 +165,8 @@
      * Write the content to the given outputstream
      * 
      * @param out the outputstream to write to
+     * @param mode output mode {@link MessageUtils}
      * @throws IOException 
      */
-    public abstract void writeTo(OutputStream out) throws IOException;
+    public abstract void writeTo(OutputStream out, int mode) throws IOException, MimeException;
 }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Header.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Header.java?rev=659992&r1=659991&r2=659992&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Header.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Header.java Sun May 25
07:30:55 2008
@@ -195,19 +195,4 @@
         writer.write(MessageUtils.CRLF);
         writer.flush();
     }
-
-    /**
-     * Write the Header to the given OutputStream
-     * 
-     * @param out the OutputStream to write to
-     * @throws IOException
-     */
-    public void writeTo(final OutputStream out) throws IOException {
-        try {
-            writeTo(out, MessageUtils.LENIENT);
-        } catch (MimeException ex) {
-            throw new IOException(ex.getMessage());
-        }
-    }
-
 }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Message.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Message.java?rev=659992&r1=659991&r2=659992&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Message.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Message.java Sun May
25 07:30:55 2008
@@ -87,40 +87,19 @@
     public UnstructuredField getSubject() {
         return (UnstructuredField) getHeader().getField(Field.SUBJECT);
     }
-
-    /**
-     * 
-     * @see org.apache.james.mime4j.message.Entity#writeTo(java.io.OutputStream)
-     */
-    public void writeTo(OutputStream out) throws IOException {
-        getHeader().writeTo(out);
-
-        Body body = getBody();
-        if (body instanceof Multipart) {
-            Multipart mp = (Multipart) body;
-            mp.writeTo(out);
-        } else {
-            body.writeTo(out);
-        }
-    }
     
     /**
      * Writes out the content of this message..
      * @param out not null
      * @param mode header out validation mode {@link MessageUtils}
      * @throws MimeException 
-     * @see org.apache.james.mime4j.message.Entity#writeTo(java.io.OutputStream)
+     * @see org.apache.james.mime4j.message.Entity#writeTo(java.io.OutputStream, int)
      */
     public void writeTo(OutputStream out, int mode) throws IOException, MimeException {
         getHeader().writeTo(out, mode);
 
-        Body body = getBody();
-        if (body instanceof Multipart) {
-            Multipart mp = (Multipart) body;
-            mp.writeTo(out);
-        } else {
-            body.writeTo(out);
-        }
+        final Body body = getBody();
+        body.writeTo(out, MessageUtils.LENIENT);
     }
     
     private class MessageBuilder implements ContentHandler {

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Multipart.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Multipart.java?rev=659992&r1=659991&r2=659992&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Multipart.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Multipart.java Sun May
25 07:30:55 2008
@@ -208,7 +208,7 @@
             writer.write(boundary);
             writer.write(MessageUtils.CRLF);
             writer.flush();
-            ((BodyPart) bodyParts.get(i)).writeTo(out);
+            ((BodyPart) bodyParts.get(i)).writeTo(out, mode);
             writer.write(MessageUtils.CRLF);
         }
 
@@ -220,19 +220,4 @@
         writer.write(MessageUtils.CRLF);
         writer.flush();
     }
-
-    /**
-     * Write the Header to the given OutputStream
-     * 
-     * @param out the OutputStream to write to
-     * @throws IOException
-     */
-    public void writeTo(final OutputStream out) throws IOException {
-        try {
-            writeTo(out, MessageUtils.LENIENT);
-        } catch (MimeException ex) {
-            throw new IOException(ex.getMessage());
-        }
-    }
-
 }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/TempFileBinaryBody.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/TempFileBinaryBody.java?rev=659992&r1=659991&r2=659992&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/TempFileBinaryBody.java
(original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/TempFileBinaryBody.java
Sun May 25 07:30:55 2008
@@ -81,9 +81,9 @@
     }
     
     /**
-     * @see org.apache.james.mime4j.message.Body#writeTo(java.io.OutputStream)
+     * @see org.apache.james.mime4j.message.Body#writeTo(java.io.OutputStream, int)
      */
-    public void writeTo(OutputStream out) throws IOException {
+    public void writeTo(OutputStream out, int mode) throws IOException {
 	IOUtils.copy(getInputStream(),out);
     }
 }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/TempFileTextBody.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/TempFileTextBody.java?rev=659992&r1=659991&r2=659992&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/TempFileTextBody.java
(original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/TempFileTextBody.java
Sun May 25 07:30:55 2008
@@ -107,9 +107,9 @@
     
     
     /**
-     * @see org.apache.james.mime4j.message.Body#writeTo(java.io.OutputStream)
+     * @see org.apache.james.mime4j.message.Body#writeTo(java.io.OutputStream, int)
      */
-    public void writeTo(OutputStream out) throws IOException {
+    public void writeTo(OutputStream out, int mode) throws IOException {
 	IOUtils.copy(tempFile.getInputStream(), out);	
     }
 }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageTest.java?rev=659992&r1=659991&r2=659992&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageTest.java Sun
May 25 07:30:55 2008
@@ -22,17 +22,15 @@
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.List;
 
+import junit.framework.TestCase;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.james.mime4j.field.Field;
-import org.apache.james.mime4j.message.Header;
-import org.apache.james.mime4j.message.Message;
-
-import junit.framework.TestCase;
+import org.apache.james.mime4j.util.MessageUtils;
 
 /**
  * 
@@ -125,13 +123,13 @@
         assertTrue("multipart/mixed", m.isMultipart());
     }
     
-    public void testWriteTo() throws IOException {
+    public void testWriteTo() throws Exception {
         byte[] inputByte = getRawMessageAsByteArray();
 
         Message m = new Message(new ByteArrayInputStream(inputByte));
         ByteArrayOutputStream out = new ByteArrayOutputStream();
 
-        m.writeTo(out);
+        m.writeTo(out, MessageUtils.LENIENT);
 
         InputStream output = new ByteArrayInputStream(out.toByteArray());
 
@@ -143,7 +141,7 @@
         }
     }
 
-    public void testAddHeaderWriteTo() throws IOException {
+    public void testAddHeaderWriteTo() throws Exception {
         String headerName = "testheader";
         String headerValue = "testvalue";
         String testheader = headerName + ": " + headerValue;
@@ -157,7 +155,7 @@
                 .getBody(), headerValue);
 
         ByteArrayOutputStream out = new ByteArrayOutputStream();
-        m.writeTo(out);
+        m.writeTo(out, MessageUtils.LENIENT);
         List lines = IOUtils.readLines((new BufferedReader(
                 new InputStreamReader(new ByteArrayInputStream(out
                         .toByteArray())))));

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MultipartFormTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MultipartFormTest.java?rev=659992&r1=659991&r2=659992&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MultipartFormTest.java
(original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MultipartFormTest.java
Sun May 25 07:30:55 2008
@@ -27,6 +27,7 @@
 
 import org.apache.commons.io.IOUtils;
 import org.apache.james.mime4j.field.Field;
+import org.apache.james.mime4j.util.MessageUtils;
 
 import junit.framework.TestCase;
 
@@ -68,7 +69,7 @@
         multipart.addBodyPart(p3);
         
         ByteArrayOutputStream out = new ByteArrayOutputStream();
-        multipart.writeTo(out);
+        multipart.writeTo(out, MessageUtils.LENIENT);
         out.close();
         
         String expected = "\r\n" + 
@@ -115,7 +116,7 @@
             return new StringReader(this.text);
         }
 
-        public void writeTo(final OutputStream out) throws IOException {
+        public void writeTo(final OutputStream out, int mode) throws IOException {
             if (out == null) {
                 throw new IllegalArgumentException("Output stream may not be null");
             }



---------------------------------------------------------------------
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