james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r718356 - in /james/mime4j/trunk/src: main/java/org/apache/james/mime4j/message/ test/java/org/apache/james/mime4j/message/
Date Mon, 17 Nov 2008 20:16:32 GMT
Author: olegk
Date: Mon Nov 17 12:16:31 2008
New Revision: 718356

URL: http://svn.apache.org/viewvc?rev=718356&view=rev
Log:
#writeTo(InputStream, Mode) method of message components to throw MimeIOException instead
of MimeException

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/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/Multipart.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/HeaderTest.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageTest.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=718356&r1=718355&r2=718356&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 Mon Nov 17
12:16:31 2008
@@ -22,7 +22,7 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.james.mime4j.MimeException;
+import org.apache.james.mime4j.MimeIOException;
 
 /**
  * Encapsulates the body of an entity (see RFC 2045).
@@ -51,7 +51,8 @@
      * 
      * @param out the stream to write to.
      * @param mode compatibility mode  
-     * @throws IOException on I/O errors.
+     * @throws IOException if case of an I/O error
+     * @throws MimeIOException if case of a MIME protocol violation
      */
-    void writeTo(OutputStream out, Mode mode) throws IOException, MimeException;
+    void writeTo(OutputStream out, Mode mode) throws IOException, MimeIOException;
 }

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=718356&r1=718355&r2=718356&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 Mon Nov 17
12:16:31 2008
@@ -19,7 +19,7 @@
 
 package org.apache.james.mime4j.message;
 
-import org.apache.james.mime4j.MimeException;
+import org.apache.james.mime4j.MimeIOException;
 import org.apache.james.mime4j.decoder.CodecUtil;
 import org.apache.james.mime4j.field.ContentTransferEncodingField;
 import org.apache.james.mime4j.field.ContentTypeField;
@@ -168,9 +168,10 @@
      * 
      * @param out the outputstream to write to
      * @param mode compatibility mode  
-     * @throws IOException 
+     * @throws IOException if case of an I/O error
+     * @throws MimeIOException if case of a MIME protocol violation
      */
-    public void writeTo(OutputStream out, Mode mode) throws IOException, MimeException {
+    public void writeTo(OutputStream out, Mode mode) throws IOException, MimeIOException
{
         getHeader().writeTo(out, mode);
         
         out.flush();

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=718356&r1=718355&r2=718356&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 Mon Nov 17
12:16:31 2008
@@ -243,9 +243,9 @@
      *   {@link Mode#LENIENT}, {@link Mode#STRICT_ERROR}, {@link Mode#STRICT_IGNORE}  
      * 
      * @throws IOException if case of an I/O error
-     * @throws MimeException if case of a MIME protocol violation
+     * @throws MimeIOException if case of a MIME protocol violation
      */
-    public void writeTo(final OutputStream out, Mode mode) throws IOException, MimeException
{
+    public void writeTo(final OutputStream out, Mode mode) throws IOException, MimeIOException
{
         Charset charset = null;
         if (mode == Mode.LENIENT) {
             final ContentTypeField contentTypeField = ((ContentTypeField) getField(Field.CONTENT_TYPE));
@@ -267,7 +267,7 @@
         for (Field field : fields) {
             String fs = field.toString();
             if (mode == Mode.STRICT_ERROR && !MessageUtils.isASCII(fs)) {
-                throw new MimeException("Header '" + fs + "' violates RFC 822");
+                throw new MimeIOException(new MimeException("Header '" + fs + "' violates
RFC 822"));
             }
             writer.write(fs);
             writer.write(MessageUtils.CRLF);

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=718356&r1=718355&r2=718356&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 Mon Nov
17 12:16:31 2008
@@ -29,6 +29,7 @@
 import java.util.List;
 
 import org.apache.james.mime4j.MimeException;
+import org.apache.james.mime4j.MimeIOException;
 import org.apache.james.mime4j.field.ContentTypeField;
 import org.apache.james.mime4j.field.Field;
 import org.apache.james.mime4j.util.CharsetUtil;
@@ -171,15 +172,15 @@
      * @param mode compatibility mode
      * 
      * @throws IOException if case of an I/O error
-     * @throws MimeException if case of a MIME protocol violation
+     * @throws MimeIOException if case of a MIME protocol violation
      */
-    public void writeTo(final OutputStream out, Mode mode) throws IOException, MimeException
{
+    public void writeTo(final OutputStream out, Mode mode) throws IOException, MimeIOException
{
         Entity e = getParent();
         
         ContentTypeField cField = (ContentTypeField) e.getHeader().getField(
                 Field.CONTENT_TYPE);
         if (cField == null || cField.getBoundary() == null) {
-            throw new MimeException("Multipart boundary not specified");
+            throw new MimeIOException(new MimeException("Multipart boundary not specified"));
         }
         String boundary = cField.getBoundary();
 

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/HeaderTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/HeaderTest.java?rev=718356&r1=718355&r2=718356&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/HeaderTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/HeaderTest.java Mon Nov
17 12:16:31 2008
@@ -20,7 +20,7 @@
 package org.apache.james.mime4j.message;
 
 import org.apache.commons.io.output.ByteArrayOutputStream;
-import org.apache.james.mime4j.MimeException;
+import org.apache.james.mime4j.MimeIOException;
 import org.apache.james.mime4j.field.Field;
 import org.apache.james.mime4j.message.Header;
 import org.apache.james.mime4j.util.MessageUtils;
@@ -79,8 +79,8 @@
         
         try {
             header.writeTo(buffer, Mode.STRICT_ERROR);
-            fail("MimeException should have been thrown");
-        } catch (MimeException expected) {
+            fail("MimeIOException should have been thrown");
+        } catch (MimeIOException expected) {
         }
     }
     

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=718356&r1=718355&r2=718356&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 Mon
Nov 17 12:16:31 2008
@@ -31,7 +31,6 @@
 import junit.framework.TestCase;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.field.Field;
 
 /**
@@ -217,8 +216,7 @@
 
         public boolean disposed = false;
 
-        public void writeTo(OutputStream out, Mode mode) throws IOException,
-                MimeException {
+        public void writeTo(OutputStream out, Mode mode) throws IOException {
             out.write("dummy".getBytes("US-ASCII"));
         }
 



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