james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r711252 - in /james/mime4j/trunk/src/main/java/org/apache/james/mime4j: MimeException.java MimeIOException.java io/MaxLineLimitException.java message/Header.java message/Message.java parser/AbstractEntity.java parser/MimeEntity.java
Date Tue, 04 Nov 2008 13:42:01 GMT
Author: olegk
Date: Tue Nov  4 05:42:00 2008
New Revision: 711252

URL: http://svn.apache.org/viewvc?rev=711252&view=rev
Log:
MIME4J-77: MimeException no longer extends IOException

Added:
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeIOException.java
Modified:
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeException.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/io/MaxLineLimitException.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/parser/AbstractEntity.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeEntity.java

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeException.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeException.java?rev=711252&r1=711251&r2=711252&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeException.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeException.java Tue Nov  4
05:42:00 2008
@@ -16,12 +16,10 @@
  */
 package org.apache.james.mime4j;
 
-import java.io.IOException;
-
 /**
  * MIME processing exception.
  */
-public class MimeException extends IOException {
+public class MimeException extends Exception {
 
     private static final long serialVersionUID = 8352821278714188542L;
 

Added: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeIOException.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeIOException.java?rev=711252&view=auto
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeIOException.java (added)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeIOException.java Tue Nov
 4 05:42:00 2008
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.james.mime4j;
+
+import java.io.IOException;
+
+/**
+ * A wrapper class based on {@link IOException} for MIME protocol 
+ * exceptions.
+ */
+public class MimeIOException extends IOException {
+
+    private static final long serialVersionUID = 5393613459533735409L;
+
+    /**
+     * Constructs an IO exception based on {@link MimeException}.
+     *
+     * @param ex cause
+     */
+    public MimeIOException(MimeException cause) {
+        super(cause.getMessage());
+        initCause(cause);
+    }
+
+}

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/io/MaxLineLimitException.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/io/MaxLineLimitException.java?rev=711252&r1=711251&r2=711252&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/io/MaxLineLimitException.java
(original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/io/MaxLineLimitException.java
Tue Nov  4 05:42:00 2008
@@ -20,17 +20,18 @@
 package org.apache.james.mime4j.io;
 
 import org.apache.james.mime4j.MimeException;
+import org.apache.james.mime4j.MimeIOException;
 
 /**
  * Signals a I/O error due to a line exceeding the limit on the 
  * maximum line length.
  */
-public class MaxLineLimitException extends MimeException {
+public class MaxLineLimitException extends MimeIOException {
     
     private static final long serialVersionUID = 8039001187837730773L;
 
     public MaxLineLimitException(final String message) {
-        super(message);
+        super(new MimeException(message));
     }
 
 }

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=711252&r1=711251&r2=711252&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 Tue Nov 
4 05:42:00 2008
@@ -1,267 +1,276 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mime4j.message;
-
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.nio.charset.Charset;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.james.mime4j.MimeException;
-import org.apache.james.mime4j.field.ContentTypeField;
-import org.apache.james.mime4j.field.Field;
-import org.apache.james.mime4j.parser.AbstractContentHandler;
-import org.apache.james.mime4j.parser.MimeStreamParser;
-import org.apache.james.mime4j.util.CharArrayBuffer;
-import org.apache.james.mime4j.util.CharsetUtil;
-import org.apache.james.mime4j.util.MessageUtils;
-
-
-/**
- * The header of an entity (see RFC 2045).
- *
- * 
- * @version $Id: Header.java,v 1.3 2004/10/04 15:36:44 ntherning Exp $
- */
-public class Header {
-    private List fields = new LinkedList();
-    private Map/*<String, List<Field>>*/ fieldMap = new HashMap();
-    
-    /**
-     * Creates a new empty <code>Header</code>.
-     */
-    public Header() {
-    }
-
-    /**
-     * Creates a new <code>Header</code> from the specified stream.
-     * 
-     * @param is the stream to read the header from.
-     */
-    public Header(InputStream is) throws MimeException, IOException {
-        final MimeStreamParser parser = new MimeStreamParser();
-        parser.setContentHandler(new AbstractContentHandler() {
-            public void endHeader() {
-                parser.stop();
-            }
-            public void field(String fieldData) throws MimeException {
-                addField(Field.parse(fieldData));
-            }
-        });
-        parser.parse(is);
-    }
-
-    /**
-     * Adds a field to the end of the list of fields.
-     * 
-     * @param field the field to add.
-     */
-    public void addField(Field field) {
-        List values = (List) fieldMap.get(field.getName().toLowerCase());
-        if (values == null) {
-            values = new LinkedList();
-            fieldMap.put(field.getName().toLowerCase(), values);
-        }
-        values.add(field);
-        fields.add(field);
-    }
-    
-    /**
-     * Gets the fields of this header. The returned list will not be
-     * modifiable.
-     * 
-     * @return the list of <code>Field</code> objects.
-     */
-    public List getFields() {
-        return Collections.unmodifiableList(fields);
-    }
-
-    /**
-     * Gets a <code>Field</code> given a field name. If there are multiple
-     * such fields defined in this header the first one will be returned.
-     * 
-     * @param name the field name (e.g. From, Subject).
-     * @return the field or <code>null</code> if none found.
-     */
-    public Field getField(String name) {
-        List l = (List) fieldMap.get(name.toLowerCase());
-        if (l != null && !l.isEmpty()) {
-            return (Field) l.get(0);
-        }
-        return null;
-    }
-    
-    /**
-     * Gets all <code>Field</code>s having the specified field name. 
-     * 
-     * @param name the field name (e.g. From, Subject).
-     * @return the list of fields.
-     */
-    public List getFields(final String name) {
-        final String lowerCaseName = name.toLowerCase();
-        final List l = (List) fieldMap.get(lowerCaseName);
-        final List results;
-        if (l == null || l.isEmpty()) {
-            results = Collections.EMPTY_LIST;
-        } else {
-            results = Collections.unmodifiableList(l);
-        }
-        return results;
-    }
-
-    /**
-     * Removes all <code>Field</code>s having the specified field name.
-     * 
-     * @param name
-     *            the field name (e.g. From, Subject).
-     * @return number of fields removed.
-     */
-    public int removeFields(String name) {
-        final String lowerCaseName = name.toLowerCase();
-        List removed = (List) fieldMap.remove(lowerCaseName);
-        if (removed == null || removed.isEmpty())
-            return 0;
-
-        for (Iterator iterator = fields.iterator(); iterator.hasNext();) {
-            Field field = (Field) iterator.next();
-            if (field.getName().equalsIgnoreCase(name))
-                iterator.remove();
-        }
-
-        return removed.size();
-    }
-
-    /**
-     * Sets or replaces a field. This method is useful for header fields such as
-     * Subject or Message-ID that should not occur more than once in a message.
-     * 
-     * If this <code>Header</code> does not already contain a header field of
-     * the same name as the given field then it is added to the end of the list
-     * of fields (same behavior as {@link #addField(Field)}). Otherwise the
-     * first occurrence of a field with the same name is replaced by the given
-     * field and all further occurrences are removed.
-     * 
-     * @param field the field to set.
-     */
-    public void setField(Field field) {
-        final String lowerCaseName = field.getName().toLowerCase();
-        List l = (List) fieldMap.get(lowerCaseName);
-        if (l == null || l.isEmpty()) {
-            addField(field);
-            return;
-        }
-
-        l.clear();
-        l.add(field);
-
-        int firstOccurrence = -1;
-        int index = 0;
-        for (Iterator iterator = fields.iterator(); iterator.hasNext(); index++) {
-            Field f = (Field) iterator.next();
-            if (f.getName().equalsIgnoreCase(field.getName())) {
-                iterator.remove();
-
-                if (firstOccurrence == -1)
-                    firstOccurrence = index;
-            }
-        }
-
-        fields.add(firstOccurrence, field);
-    }
-
-    /**
-     * Return Header Object as String representation. Each headerline is
-     * seperated by "\r\n"
-     * 
-     * @return headers
-     */
-    public String toString() {
-        CharArrayBuffer str = new CharArrayBuffer(128);
-        for (Iterator it = fields.iterator(); it.hasNext();) {
-            str.append(it.next().toString());
-            str.append("\r\n");
-        }
-        return str.toString();
-    }
-    
-    
-    /**
-     * Write the Header to the given OutputStream. 
-     * <p>
-     * Compatibility mode:
-     * <ul>
-     *  <li>
-     *   {@link MessageUtils#LENIENT}: use charset of the Content-Type header
-     *  </li>
-     *  <li>
-     *   {@link MessageUtils#STRICT_ERROR}: use US-ASCII and throw {@link MimeException}

-     *    if a non ASCII character is encountered
-     *   </li>
-     *  <li>
-     *   {@link MessageUtils#STRICT_ERROR}: ignore non ASCII characters if encountered
-     *   </li>
-     * </ul>
-     * @param out the OutputStream to write to
-     * @param mode compatibility mode:
-     *   {@link MessageUtils#LENIENT}, {@link MessageUtils#STRICT_ERROR}, {@link MessageUtils#STRICT_IGNORE}
 
-     * 
-     * @throws IOException if case of an I/O error
-     * @throws MimeException if case of a MIME protocol violation
-     */
-    public void writeTo(final OutputStream out, int mode) throws IOException, MimeException
{
-        Charset charset = null;
-        if (mode == MessageUtils.LENIENT) {
-            final ContentTypeField contentTypeField = ((ContentTypeField) getField(Field.CONTENT_TYPE));
-            if (contentTypeField == null) {
-                charset = MessageUtils.DEFAULT_CHARSET;
-            } else {
-                final String contentTypeFieldCharset = contentTypeField.getCharset();
-                if (contentTypeField != null && contentTypeFieldCharset != null)
{
-                    charset = CharsetUtil.getCharset(contentTypeFieldCharset);
-                } else {
-                    charset = MessageUtils.ISO_8859_1;
-                }
-            }
-        } else {
-            charset = MessageUtils.DEFAULT_CHARSET;
-        }
-        BufferedWriter writer = new BufferedWriter(
-                new OutputStreamWriter(out, charset), 8192);
-        for (Iterator it = fields.iterator(); it.hasNext();) {
-            Field field = (Field) it.next();
-            String fs = field.toString();
-            if (mode == MessageUtils.STRICT_ERROR && !MessageUtils.isASCII(fs)) {
-                throw new MimeException("Header '" + fs + "' violates RFC 822");
-            }
-            writer.write(fs);
-            writer.write(MessageUtils.CRLF);
-        }
-        writer.write(MessageUtils.CRLF);
-        writer.flush();
-    }
-}
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mime4j.message;
+
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.nio.charset.Charset;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+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.parser.AbstractContentHandler;
+import org.apache.james.mime4j.parser.MimeStreamParser;
+import org.apache.james.mime4j.util.CharArrayBuffer;
+import org.apache.james.mime4j.util.CharsetUtil;
+import org.apache.james.mime4j.util.MessageUtils;
+
+
+/**
+ * The header of an entity (see RFC 2045).
+ *
+ * 
+ * @version $Id: Header.java,v 1.3 2004/10/04 15:36:44 ntherning Exp $
+ */
+public class Header {
+    private List fields = new LinkedList();
+    private Map/*<String, List<Field>>*/ fieldMap = new HashMap();
+    
+    /**
+     * Creates a new empty <code>Header</code>.
+     */
+    public Header() {
+    }
+
+    /**
+     * Creates a new <code>Header</code> from the specified stream.
+     * 
+     * @param is the stream to read the header from.
+     * 
+     * @throws IOException on I/O errors.
+     * @throws MimeIOException on MIME protocol violations.
+     */
+    public Header(InputStream is) 
+            throws IOException, MimeIOException {
+        final MimeStreamParser parser = new MimeStreamParser();
+        parser.setContentHandler(new AbstractContentHandler() {
+            public void endHeader() {
+                parser.stop();
+            }
+            public void field(String fieldData) throws MimeException {
+                addField(Field.parse(fieldData));
+            }
+        });
+        try {
+            parser.parse(is);
+        } catch (MimeException ex) {
+            throw new MimeIOException(ex);
+        }
+    }
+
+    /**
+     * Adds a field to the end of the list of fields.
+     * 
+     * @param field the field to add.
+     */
+    public void addField(Field field) {
+        List values = (List) fieldMap.get(field.getName().toLowerCase());
+        if (values == null) {
+            values = new LinkedList();
+            fieldMap.put(field.getName().toLowerCase(), values);
+        }
+        values.add(field);
+        fields.add(field);
+    }
+    
+    /**
+     * Gets the fields of this header. The returned list will not be
+     * modifiable.
+     * 
+     * @return the list of <code>Field</code> objects.
+     */
+    public List getFields() {
+        return Collections.unmodifiableList(fields);
+    }
+
+    /**
+     * Gets a <code>Field</code> given a field name. If there are multiple
+     * such fields defined in this header the first one will be returned.
+     * 
+     * @param name the field name (e.g. From, Subject).
+     * @return the field or <code>null</code> if none found.
+     */
+    public Field getField(String name) {
+        List l = (List) fieldMap.get(name.toLowerCase());
+        if (l != null && !l.isEmpty()) {
+            return (Field) l.get(0);
+        }
+        return null;
+    }
+    
+    /**
+     * Gets all <code>Field</code>s having the specified field name. 
+     * 
+     * @param name the field name (e.g. From, Subject).
+     * @return the list of fields.
+     */
+    public List getFields(final String name) {
+        final String lowerCaseName = name.toLowerCase();
+        final List l = (List) fieldMap.get(lowerCaseName);
+        final List results;
+        if (l == null || l.isEmpty()) {
+            results = Collections.EMPTY_LIST;
+        } else {
+            results = Collections.unmodifiableList(l);
+        }
+        return results;
+    }
+
+    /**
+     * Removes all <code>Field</code>s having the specified field name.
+     * 
+     * @param name
+     *            the field name (e.g. From, Subject).
+     * @return number of fields removed.
+     */
+    public int removeFields(String name) {
+        final String lowerCaseName = name.toLowerCase();
+        List removed = (List) fieldMap.remove(lowerCaseName);
+        if (removed == null || removed.isEmpty())
+            return 0;
+
+        for (Iterator iterator = fields.iterator(); iterator.hasNext();) {
+            Field field = (Field) iterator.next();
+            if (field.getName().equalsIgnoreCase(name))
+                iterator.remove();
+        }
+
+        return removed.size();
+    }
+
+    /**
+     * Sets or replaces a field. This method is useful for header fields such as
+     * Subject or Message-ID that should not occur more than once in a message.
+     * 
+     * If this <code>Header</code> does not already contain a header field of
+     * the same name as the given field then it is added to the end of the list
+     * of fields (same behavior as {@link #addField(Field)}). Otherwise the
+     * first occurrence of a field with the same name is replaced by the given
+     * field and all further occurrences are removed.
+     * 
+     * @param field the field to set.
+     */
+    public void setField(Field field) {
+        final String lowerCaseName = field.getName().toLowerCase();
+        List l = (List) fieldMap.get(lowerCaseName);
+        if (l == null || l.isEmpty()) {
+            addField(field);
+            return;
+        }
+
+        l.clear();
+        l.add(field);
+
+        int firstOccurrence = -1;
+        int index = 0;
+        for (Iterator iterator = fields.iterator(); iterator.hasNext(); index++) {
+            Field f = (Field) iterator.next();
+            if (f.getName().equalsIgnoreCase(field.getName())) {
+                iterator.remove();
+
+                if (firstOccurrence == -1)
+                    firstOccurrence = index;
+            }
+        }
+
+        fields.add(firstOccurrence, field);
+    }
+
+    /**
+     * Return Header Object as String representation. Each headerline is
+     * seperated by "\r\n"
+     * 
+     * @return headers
+     */
+    public String toString() {
+        CharArrayBuffer str = new CharArrayBuffer(128);
+        for (Iterator it = fields.iterator(); it.hasNext();) {
+            str.append(it.next().toString());
+            str.append("\r\n");
+        }
+        return str.toString();
+    }
+    
+    
+    /**
+     * Write the Header to the given OutputStream. 
+     * <p>
+     * Compatibility mode:
+     * <ul>
+     *  <li>
+     *   {@link MessageUtils#LENIENT}: use charset of the Content-Type header
+     *  </li>
+     *  <li>
+     *   {@link MessageUtils#STRICT_ERROR}: use US-ASCII and throw {@link MimeException}

+     *    if a non ASCII character is encountered
+     *   </li>
+     *  <li>
+     *   {@link MessageUtils#STRICT_ERROR}: ignore non ASCII characters if encountered
+     *   </li>
+     * </ul>
+     * @param out the OutputStream to write to
+     * @param mode compatibility mode:
+     *   {@link MessageUtils#LENIENT}, {@link MessageUtils#STRICT_ERROR}, {@link MessageUtils#STRICT_IGNORE}
 
+     * 
+     * @throws IOException if case of an I/O error
+     * @throws MimeException if case of a MIME protocol violation
+     */
+    public void writeTo(final OutputStream out, int mode) throws IOException, MimeException
{
+        Charset charset = null;
+        if (mode == MessageUtils.LENIENT) {
+            final ContentTypeField contentTypeField = ((ContentTypeField) getField(Field.CONTENT_TYPE));
+            if (contentTypeField == null) {
+                charset = MessageUtils.DEFAULT_CHARSET;
+            } else {
+                final String contentTypeFieldCharset = contentTypeField.getCharset();
+                if (contentTypeField != null && contentTypeFieldCharset != null)
{
+                    charset = CharsetUtil.getCharset(contentTypeFieldCharset);
+                } else {
+                    charset = MessageUtils.ISO_8859_1;
+                }
+            }
+        } else {
+            charset = MessageUtils.DEFAULT_CHARSET;
+        }
+        BufferedWriter writer = new BufferedWriter(
+                new OutputStreamWriter(out, charset), 8192);
+        for (Iterator it = fields.iterator(); it.hasNext();) {
+            Field field = (Field) it.next();
+            String fs = field.toString();
+            if (mode == MessageUtils.STRICT_ERROR && !MessageUtils.isASCII(fs)) {
+                throw new MimeException("Header '" + fs + "' violates RFC 822");
+            }
+            writer.write(fs);
+            writer.write(MessageUtils.CRLF);
+        }
+        writer.write(MessageUtils.CRLF);
+        writer.flush();
+    }
+}

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=711252&r1=711251&r2=711252&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 Tue Nov
 4 05:42:00 2008
@@ -20,6 +20,7 @@
 package org.apache.james.mime4j.message;
 
 import org.apache.james.mime4j.MimeException;
+import org.apache.james.mime4j.MimeIOException;
 import org.apache.james.mime4j.field.Field;
 import org.apache.james.mime4j.field.UnstructuredField;
 import org.apache.james.mime4j.parser.MimeEntityConfig;
@@ -55,11 +56,17 @@
      * 
      * @param is the stream to parse.
      * @throws IOException on I/O errors.
+     * @throws MimeIOException on MIME protocol violations.
      */
-    public Message(InputStream is, MimeEntityConfig config) throws MimeException, IOException
{
+    public Message(InputStream is, MimeEntityConfig config) 
+            throws IOException,MimeIOException {
         MimeStreamParser parser = new MimeStreamParser(config);
         parser.setContentHandler(new MessageBuilder(this));
-        parser.parse(is);
+        try {
+            parser.parse(is);
+        } catch (MimeException ex) {
+            throw new MimeIOException(ex);
+        }
     }
 
     /**

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java?rev=711252&r1=711251&r2=711252&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java Tue
Nov  4 05:42:00 2008
@@ -167,7 +167,7 @@
         }
     }
 
-    protected boolean parseField() throws IOException {
+    protected boolean parseField() throws MimeException, IOException {
         int maxHeaderLimit = config.getMaxHeaderCount();
         for (;;) {
             if (endOfHeader) {

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeEntity.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeEntity.java?rev=711252&r1=711251&r2=711252&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeEntity.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeEntity.java Tue Nov
 4 05:42:00 2008
@@ -190,7 +190,7 @@
         return null;
     }
 
-    private void createMimeStream() throws IOException {
+    private void createMimeStream() throws MimeException, IOException {
         String boundary = body.getBoundary();
         int bufferSize = 2 * boundary.length();
         if (bufferSize < 4096) {



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