james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ieu...@apache.org
Subject svn commit: r1351619 - in /james/mime4j/trunk: ./ examples/ examples/src/main/java/org/apache/james/mime4j/samples/mbox/ mbox/ mbox/src/ mbox/src/main/ mbox/src/main/java/ mbox/src/main/java/org/ mbox/src/main/java/org/apache/ mbox/src/main/java/org/ap...
Date Tue, 19 Jun 2012 09:41:01 GMT
Author: ieugen
Date: Tue Jun 19 09:41:00 2012
New Revision: 1351619

URL: http://svn.apache.org/viewvc?rev=1351619&view=rev
Log:
Integrated Mbox Iterator to Apache James Mime4j

 * integrated https://github.com/ieugen/mbox-iterator into mime4j
 * bumped junit version to 4.10
 * added Guava in dependency management (used only in mbox-iterator)

Added:
    james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/mbox/
    james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/mbox/IterateOverMbox.java
    james/mime4j/trunk/mbox/
    james/mime4j/trunk/mbox/README.mdtext
    james/mime4j/trunk/mbox/pom.xml
      - copied, changed from r1327188, james/mime4j/trunk/examples/pom.xml
    james/mime4j/trunk/mbox/src/
    james/mime4j/trunk/mbox/src/main/
    james/mime4j/trunk/mbox/src/main/java/
    james/mime4j/trunk/mbox/src/main/java/org/
    james/mime4j/trunk/mbox/src/main/java/org/apache/
    james/mime4j/trunk/mbox/src/main/java/org/apache/james/
    james/mime4j/trunk/mbox/src/main/java/org/apache/james/mime4j/
    james/mime4j/trunk/mbox/src/main/java/org/apache/james/mime4j/mboxiterator/
    james/mime4j/trunk/mbox/src/main/java/org/apache/james/mime4j/mboxiterator/CharBufferWrapper.java
    james/mime4j/trunk/mbox/src/main/java/org/apache/james/mime4j/mboxiterator/FromLinePatterns.java
    james/mime4j/trunk/mbox/src/main/java/org/apache/james/mime4j/mboxiterator/MboxIterator.java
    james/mime4j/trunk/mbox/src/test/
    james/mime4j/trunk/mbox/src/test/java/
    james/mime4j/trunk/mbox/src/test/java/org/
    james/mime4j/trunk/mbox/src/test/java/org/apache/
    james/mime4j/trunk/mbox/src/test/java/org/apache/james/
    james/mime4j/trunk/mbox/src/test/java/org/apache/james/mime4j/
    james/mime4j/trunk/mbox/src/test/java/org/apache/james/mime4j/mboxiterator/
    james/mime4j/trunk/mbox/src/test/java/org/apache/james/mime4j/mboxiterator/MboxIteratorTest.java
    james/mime4j/trunk/mbox/src/test/resources/
    james/mime4j/trunk/mbox/src/test/resources/test-1/
    james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug
    james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-0
    james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-1
    james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-2
    james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-3
    james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-4
Modified:
    james/mime4j/trunk/examples/pom.xml
    james/mime4j/trunk/pom.xml

Modified: james/mime4j/trunk/examples/pom.xml
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/examples/pom.xml?rev=1351619&r1=1351618&r2=1351619&view=diff
==============================================================================
--- james/mime4j/trunk/examples/pom.xml (original)
+++ james/mime4j/trunk/examples/pom.xml Tue Jun 19 09:41:00 2012
@@ -17,7 +17,8 @@
     specific language governing permissions and limitations
     under the License.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
@@ -40,6 +41,11 @@
         </dependency>
         <dependency>
             <groupId>org.apache.james</groupId>
+            <artifactId>apache-mime4j-mbox-iterator</artifactId>
+            <version>0.8-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
             <artifactId>apache-mime4j-storage</artifactId>
             <version>${project.version}</version>
         </dependency>

Added: james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/mbox/IterateOverMbox.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/mbox/IterateOverMbox.java?rev=1351619&view=auto
==============================================================================
--- james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/mbox/IterateOverMbox.java (added)
+++ james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/mbox/IterateOverMbox.java Tue Jun 19 09:41:00 2012
@@ -0,0 +1,85 @@
+/****************************************************************
+ * 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.samples.mbox;
+
+import com.google.common.base.Charsets;
+import org.apache.james.mime4j.MimeException;
+import org.apache.james.mime4j.dom.Message;
+import org.apache.james.mime4j.dom.MessageBuilder;
+import org.apache.james.mime4j.mboxiterator.CharBufferWrapper;
+import org.apache.james.mime4j.mboxiterator.MboxIterator;
+import org.apache.james.mime4j.message.DefaultMessageBuilder;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.channels.FileChannel;
+import java.nio.charset.CharsetEncoder;
+
+/**
+ * Simple example of how to use Apache Mime4j Mbox Iterator. We split one mbox file file into
+ * individual email messages.
+ */
+public class IterateOverMbox {
+
+    private final static CharsetEncoder ENCODER = Charsets.UTF_8.newEncoder();
+
+    // simple example of how to split an mbox into individual files
+    public static void main(String[] args) throws Exception {
+        if (args.length != 1) {
+            System.out.println("Please supply a path to an mbox file to parse");
+        }
+
+        final File mbox = new File(args[0]);
+        long start = System.currentTimeMillis();
+        int count = 0;
+
+        for (CharBufferWrapper message : MboxIterator.fromFile(mbox).charset(Charsets.UTF_8).build()) {
+            // saveMessageToFile(count, buf);
+            System.out.println(messageSummary(message.asInputStreamUTF8Encoded()));
+            count++;
+        }
+        System.out.println("Found " + count + " messages");
+        long end = System.currentTimeMillis();
+        System.out.println("Done in: " + (end - start) + " milis");
+    }
+
+    private static void saveMessageToFile(int count, CharBuffer buf) throws IOException {
+        FileOutputStream fout = new FileOutputStream(new File("target/messages/msg-" + count));
+        FileChannel fileChannel = fout.getChannel();
+        ByteBuffer buf2 = ENCODER.encode(buf);
+        fileChannel.write(buf2);
+        fileChannel.close();
+        fout.close();
+    }
+
+    private static String messageSummary(InputStream messageBytes) throws IOException, MimeException {
+        MessageBuilder builder = new DefaultMessageBuilder();
+        Message message = builder.parseMessage(messageBytes);
+        return String.format("\nMessage %s \n" +
+                "Sent by:\t%s\n" +
+                "To:\t%s\n",
+                message.getSubject(),
+                message.getSender(),
+                message.getTo());
+    }
+}

Added: james/mime4j/trunk/mbox/README.mdtext
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/mbox/README.mdtext?rev=1351619&view=auto
==============================================================================
--- james/mime4j/trunk/mbox/README.mdtext (added)
+++ james/mime4j/trunk/mbox/README.mdtext Tue Jun 19 09:41:00 2012
@@ -0,0 +1,17 @@
+# Apache James Mime4j Mbox Iterator
+
+Apache James Mbox Iterator provides an iterator like interface over mbox files. It's designed
+to allow easy parsing with mime4j.
+
+It uses NIO memory mapped files and should provide fast processing capabilities.
+
+## Dependencies
+
+It has no direct dependencies other than the JDK and Google Guava (for convenience).
+
+## Building
+
+The project uses Maven as a build tool. To build go to the root directory and run:
+
+$ mvn clean package
+

Copied: james/mime4j/trunk/mbox/pom.xml (from r1327188, james/mime4j/trunk/examples/pom.xml)
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/mbox/pom.xml?p2=james/mime4j/trunk/mbox/pom.xml&p1=james/mime4j/trunk/examples/pom.xml&r1=1327188&r2=1351619&rev=1351619&view=diff
==============================================================================
--- james/mime4j/trunk/examples/pom.xml (original)
+++ james/mime4j/trunk/mbox/pom.xml Tue Jun 19 09:41:00 2012
@@ -17,36 +17,37 @@
     specific language governing permissions and limitations
     under the License.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
-        <artifactId>apache-mime4j-project</artifactId>
         <groupId>org.apache.james</groupId>
+        <artifactId>apache-mime4j-project</artifactId>
         <version>0.8-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
-    <artifactId>apache-mime4j-examples</artifactId>
+    <artifactId>apache-mime4j-mbox-iterator</artifactId>
+    <packaging>jar</packaging>
+
+    <name>Apache JAMES Mime4j (Mbox Iterator)</name>
+    <description>Provides a fast iterator like interface for Mbox files using NIO.</description>
 
-    <name>Apache JAMES Mime4j (Code Examples)</name>
-    <description>Examples for Mime4J stream based MIME message parser</description>
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
 
     <dependencies>
         <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>apache-mime4j-dom</artifactId>
-            <version>${project.version}</version>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>apache-mime4j-storage</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>commons-logging</groupId>
-            <artifactId>commons-logging</artifactId>
-            <scope>compile</scope>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
         </dependency>
     </dependencies>
+
 </project>

Added: james/mime4j/trunk/mbox/src/main/java/org/apache/james/mime4j/mboxiterator/CharBufferWrapper.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/mbox/src/main/java/org/apache/james/mime4j/mboxiterator/CharBufferWrapper.java?rev=1351619&view=auto
==============================================================================
--- james/mime4j/trunk/mbox/src/main/java/org/apache/james/mime4j/mboxiterator/CharBufferWrapper.java (added)
+++ james/mime4j/trunk/mbox/src/main/java/org/apache/james/mime4j/mboxiterator/CharBufferWrapper.java Tue Jun 19 09:41:00 2012
@@ -0,0 +1,98 @@
+/****************************************************************
+ * 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.mboxiterator;
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Preconditions;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+
+/**
+ * Wraps a CharBuffer and exposes some convenience methods to easy parse with Mime4j.
+ */
+public class CharBufferWrapper {
+
+    private final CharBuffer messageBuffer;
+
+    public CharBufferWrapper(CharBuffer messageBuffer) {
+        Preconditions.checkNotNull(messageBuffer);
+        this.messageBuffer = messageBuffer;
+    }
+
+    public InputStream asInputStreamUTF8Encoded() {
+        return new ByteBufferInputStream(Charsets.UTF_8.encode(messageBuffer));
+    }
+
+    public InputStream asInputStream(Charset encoding) {
+        return new ByteBufferInputStream(encoding.encode(messageBuffer));
+    }
+
+    public char[] asCharArray() {
+        return messageBuffer.array();
+    }
+
+    @Override
+    public String toString() {
+        return messageBuffer.toString();
+    }
+
+    @Override
+    public int hashCode() {
+        return messageBuffer.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        return messageBuffer.equals(obj);
+    }
+
+    /**
+     * Provide an InputStream view over a ByteBuffer.
+     */
+    private static class ByteBufferInputStream extends InputStream {
+
+        private final ByteBuffer buf;
+
+        private ByteBufferInputStream(ByteBuffer buf) {
+            this.buf = buf;
+        }
+
+        @Override
+        public int read() throws IOException {
+            if (!buf.hasRemaining()) {
+                return -1;
+            }
+            return buf.get() & 0xFF;
+        }
+
+        @Override
+        public int read(byte[] bytes, int off, int len) throws IOException {
+            if (!buf.hasRemaining()) {
+                return -1;
+            }
+            buf.get(bytes, off, Math.min(len, buf.remaining()));
+            return len;
+        }
+
+    }
+}

Added: james/mime4j/trunk/mbox/src/main/java/org/apache/james/mime4j/mboxiterator/FromLinePatterns.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/mbox/src/main/java/org/apache/james/mime4j/mboxiterator/FromLinePatterns.java?rev=1351619&view=auto
==============================================================================
--- james/mime4j/trunk/mbox/src/main/java/org/apache/james/mime4j/mboxiterator/FromLinePatterns.java (added)
+++ james/mime4j/trunk/mbox/src/main/java/org/apache/james/mime4j/mboxiterator/FromLinePatterns.java Tue Jun 19 09:41:00 2012
@@ -0,0 +1,38 @@
+/****************************************************************
+ * 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.mboxiterator;
+
+/**
+ * Collection of From_ line patterns. Messages inside an mbox are separated by these lines.
+ * The pattern is usually constant in a file but depends on the mail agents that wrote it.
+ * It's possible that more mailer agents wrote in the same file using different From_ lines.
+ */
+public interface FromLinePatterns {
+
+    /**
+     * Match a line like: From ieugen@apache.org Fri Sep 09 14:04:52 2011
+     */
+    static final String DEFAULT = "^From \\S+@\\S.*\\d{4}$";
+
+    /**
+     * Other type of From_ line: From MAILER-DAEMON Wed Oct 05 21:54:09 2011
+     */
+
+
+}

Added: james/mime4j/trunk/mbox/src/main/java/org/apache/james/mime4j/mboxiterator/MboxIterator.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/mbox/src/main/java/org/apache/james/mime4j/mboxiterator/MboxIterator.java?rev=1351619&view=auto
==============================================================================
--- james/mime4j/trunk/mbox/src/main/java/org/apache/james/mime4j/mboxiterator/MboxIterator.java (added)
+++ james/mime4j/trunk/mbox/src/main/java/org/apache/james/mime4j/mboxiterator/MboxIterator.java Tue Jun 19 09:41:00 2012
@@ -0,0 +1,269 @@
+/****************************************************************
+ * 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.mboxiterator;
+
+import com.google.common.base.Charsets;
+
+import java.io.*;
+import java.nio.Buffer;
+import java.nio.CharBuffer;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.FileChannel;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CoderResult;
+import java.util.Iterator;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * <p>
+ * Class that provides an iterator over email messages inside an mbox file. An mbox file is a sequence of
+ * email messages separated by From_ lines.
+ * </p>
+ * <p/>
+ * <p>Description ot the file format:</p>
+ * <ul>
+ * <li>http://tools.ietf.org/html/rfc4155</li>
+ * <li>http://qmail.org/man/man5/mbox.html</li>
+ * </ul>
+ */
+public class MboxIterator implements Iterable<CharBufferWrapper>, Closeable {
+
+    private final FileInputStream theFile;
+    private final CharBuffer mboxCharBuffer;
+    private Matcher fromLineMathcer;
+    private boolean fromLineFound;
+    private final MappedByteBuffer byteBuffer;
+    private final CharsetDecoder DECODER;
+    /**
+     * Flag to signal end of input to {@link java.nio.charset.CharsetDecoder#decode(java.nio.ByteBuffer)} .
+     */
+    private boolean endOfInputFlag = false;
+    private final int maxMessageSize;
+    private final Pattern MESSAGE_START;
+    private int findStart = -1;
+    private int findEnd = -1;
+
+    private MboxIterator(final File mbox,
+                         final Charset charset,
+                         final String regexpPattern,
+                         final int regexpFlags,
+                         final int MAX_MESSAGE_SIZE)
+            throws FileNotFoundException, IOException, CharConversionException {
+        //TODO: do better exception handling - try to process some of them maybe?
+        this.maxMessageSize = MAX_MESSAGE_SIZE;
+        this.MESSAGE_START = Pattern.compile(regexpPattern, regexpFlags);
+        this.DECODER = charset.newDecoder();
+        this.mboxCharBuffer = CharBuffer.allocate(MAX_MESSAGE_SIZE);
+        this.theFile = new FileInputStream(mbox);
+        this.byteBuffer = theFile.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, theFile.getChannel().size());
+        initMboxIterator();
+    }
+
+    private void initMboxIterator() throws IOException, CharConversionException {
+        decodeNextCharBuffer();
+        fromLineMathcer = MESSAGE_START.matcher(mboxCharBuffer);
+        fromLineFound = fromLineMathcer.find();
+        if (fromLineFound) {
+            saveFindPositions(fromLineMathcer);
+        } else if (fromLineMathcer.hitEnd()) {
+            throw new IllegalArgumentException("File does not contain From_ lines! Maybe not be a vaild Mbox.");
+        }
+    }
+
+    private void decodeNextCharBuffer() throws CharConversionException {
+        CoderResult coderResult = DECODER.decode(byteBuffer, mboxCharBuffer, endOfInputFlag);
+        updateEndOfInputFlag();
+        mboxCharBuffer.flip();
+        if (coderResult.isError()) {
+            if (coderResult.isMalformed()) {
+                throw new CharConversionException("Malformed input!");
+            } else if (coderResult.isUnmappable()) {
+                throw new CharConversionException("Unmappable character!");
+            }
+        }
+    }
+
+    private void updateEndOfInputFlag() {
+        if (byteBuffer.remaining() <= maxMessageSize) {
+            endOfInputFlag = true;
+        }
+    }
+
+    private void saveFindPositions(Matcher lineMatcher) {
+        findStart = lineMatcher.start();
+        findEnd = lineMatcher.end();
+    }
+
+    @Override
+    public Iterator<CharBufferWrapper> iterator() {
+        return new MessageIterator();
+    }
+
+    @Override
+    public void close() throws IOException {
+        theFile.close();
+    }
+
+    private class MessageIterator implements Iterator<CharBufferWrapper> {
+
+        @Override
+        public boolean hasNext() {
+            if (!fromLineFound) {
+                try {
+                    close();
+                } catch (IOException e) {
+                    throw new RuntimeException("Exception closing file!");
+                }
+            }
+            return fromLineFound;
+        }
+
+        /**
+         * Returns a CharBuffer instance that contains a message between position and limit.
+         * The array that backs this instance is the whole block of decoded messages.
+         *
+         * @return CharBuffer instance
+         */
+        @Override
+        public CharBufferWrapper next() {
+            final CharBuffer message;
+            fromLineFound = fromLineMathcer.find();
+            if (fromLineFound) {
+                message = mboxCharBuffer.slice();
+                message.position(findEnd + 1);
+                saveFindPositions(fromLineMathcer);
+                message.limit(fromLineMathcer.start());
+            } else {
+                /* We didn't find other From_ lines this means either:
+                 *  - we reached end of mbox and no more messages
+                 *  - we reached end of CharBuffer and need to decode another batch.
+                 */
+                if (byteBuffer.hasRemaining()) {
+                    // decode another batch, but remember to copy the remaining chars first
+                    CharBuffer oldData = mboxCharBuffer.duplicate();
+                    mboxCharBuffer.clear();
+                    oldData.position(findStart);
+                    while (oldData.hasRemaining()) {
+                        mboxCharBuffer.put(oldData.get());
+                    }
+                    try {
+                        decodeNextCharBuffer();
+                    } catch (CharConversionException ex) {
+                        throw new RuntimeException(ex);
+                    }
+                    fromLineMathcer = MESSAGE_START.matcher(mboxCharBuffer);
+                    fromLineFound = fromLineMathcer.find();
+                    if (fromLineFound) {
+                        saveFindPositions(fromLineMathcer);
+                    }
+                    message = mboxCharBuffer.slice();
+                    message.position(fromLineMathcer.end() + 1);
+                    fromLineFound = fromLineMathcer.find();
+                    if (fromLineFound) {
+                        saveFindPositions(fromLineMathcer);
+                        message.limit(fromLineMathcer.start());
+                    }
+                } else {
+                    message = mboxCharBuffer.slice();
+                    message.position(findEnd + 1);
+                    message.limit(message.capacity());
+                }
+            }
+            return new CharBufferWrapper(message);
+        }
+
+        @Override
+        public void remove() {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+    }
+
+    public static Builder fromFile(File filePath) {
+        return new Builder(filePath);
+    }
+
+    public static Builder fromFile(String file) {
+        return new Builder(file);
+    }
+
+    public static class Builder {
+
+        private final File file;
+        private Charset charset = Charsets.UTF_8;
+        private String regexpPattern = FromLinePatterns.DEFAULT;
+        private int flags = Pattern.MULTILINE;
+        /**
+         * Default max message size in chars: ~ 10MB chars. If the mbox file contains larger messages they
+         * will not be decoded correctly.
+         */
+        private int maxMessageSize = 10 * 1024 * 1024;
+
+        private Builder(String filePath) {
+            this(new File(filePath));
+        }
+
+        private Builder(File file) {
+            this.file = file;
+        }
+
+        public Builder charset(Charset charset) {
+            this.charset = charset;
+            return this;
+        }
+
+        public Builder fromLine(String fromLine) {
+            this.regexpPattern = fromLine;
+            return this;
+        }
+
+        public Builder flags(int flags) {
+            this.flags = flags;
+            return this;
+        }
+
+        public Builder maxMessageSize(int maxMessageSize) {
+            this.maxMessageSize = maxMessageSize;
+            return this;
+        }
+
+        public MboxIterator build() throws FileNotFoundException, IOException {
+            return new MboxIterator(file, charset, regexpPattern, flags, maxMessageSize);
+        }
+    }
+
+    /**
+     * Utility method to log important details about buffers.
+     *
+     * @param buffer
+     */
+    public static String bufferDetailsToString(final Buffer buffer) {
+        StringBuilder sb = new StringBuilder("Buffer details: ");
+        sb.append("\ncapacity:\t").append(buffer.capacity())
+                .append("\nlimit:\t").append(buffer.limit())
+                .append("\nremaining:\t").append(buffer.remaining())
+                .append("\nposition:\t").append(buffer.position())
+                .append("\nis direct:\t").append(buffer.isDirect())
+                .append("\nhas array:\t").append(buffer.hasArray())
+                .append("\nbuffer:\t").append(buffer.isReadOnly())
+                .append("\nclass:\t").append(buffer.getClass());
+        return sb.toString();
+    }
+}

Added: james/mime4j/trunk/mbox/src/test/java/org/apache/james/mime4j/mboxiterator/MboxIteratorTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/mbox/src/test/java/org/apache/james/mime4j/mboxiterator/MboxIteratorTest.java?rev=1351619&view=auto
==============================================================================
--- james/mime4j/trunk/mbox/src/test/java/org/apache/james/mime4j/mboxiterator/MboxIteratorTest.java (added)
+++ james/mime4j/trunk/mbox/src/test/java/org/apache/james/mime4j/mboxiterator/MboxIteratorTest.java Tue Jun 19 09:41:00 2012
@@ -0,0 +1,78 @@
+/****************************************************************
+ * 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.mboxiterator;
+
+import com.google.common.base.Charsets;
+import com.google.common.io.Files;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+/**
+ * Tests for {@link MboxIterator}.
+ *
+ * @author estan
+ */
+public class MboxIteratorTest {
+
+    @Rule
+    public final TestName name = new TestName();
+    public static final String MBOX_PATH = "src/test/resources/test-1/mbox.rlug";
+    private int DEFAULT_MESSAGE_SIZE = 10 * 1024;
+    // number of chars oin our largest test message
+    private static final int CHARS_IN_MAX_MSG = 3500;
+    private static final int MORE_THAN_FILE_SIZE = 13291;
+
+    /**
+     * Test of iterator method, of class MboxIterator.
+     */
+    @Test
+    public void testIterator() throws FileNotFoundException, IOException {
+        System.out.println("Executing " + name.getMethodName());
+        iterateWithMaxMessage(DEFAULT_MESSAGE_SIZE);
+    }
+
+    /**
+     * Test of iterator method, of class MboxIterator.
+     */
+    @Test
+    public void testIteratorLoop() throws FileNotFoundException, IOException {
+        System.out.println("Executing " + name.getMethodName());
+        for (int i = CHARS_IN_MAX_MSG; i < MORE_THAN_FILE_SIZE; i++) {
+            System.out.println("Runinng iteration " + (i - CHARS_IN_MAX_MSG) + "  with message size " + i);
+            iterateWithMaxMessage(i);
+        }
+    }
+
+    private void iterateWithMaxMessage(int maxMessageSize) throws IOException {
+        int count = 0;
+        for (CharBufferWrapper msg : MboxIterator.fromFile(MBOX_PATH).maxMessageSize(maxMessageSize).build()) {
+            String message = Files.toString(new File(MBOX_PATH + "-" + count), Charsets.UTF_8);
+            //MboxIterator.printCharBuffer(msg);
+            Assert.assertEquals("String sizes match for file " + count, message.length(), msg.toString().length());
+            Assert.assertEquals("Missmatch with file " + count, message, msg.toString());
+            count++;
+        }
+    }
+}

Added: james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug?rev=1351619&view=auto
==============================================================================
--- james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug (added)
+++ james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug Tue Jun 19 09:41:00 2012
@@ -0,0 +1,346 @@
+From news@gmane.org Tue Mar 04 03:33:20 2003
+From: "mmihai" <mmihai@netcompsj.ro>
+Subject: Din windows ma pot, din LINUX NU ma pot conecta (la ZAPP)
+Date: Fri, 7 Feb 2003 18:35:25 +0200
+Lines: 45
+Sender: rlug-bounce@lug.ro
+Message-ID: <001401c2cec7$4eb5b460$941c10ac@ok6f6gr01ta4hv>
+Reply-To: rlug@lug.ro
+Mime-Version: 1.0
+Content-Type: text/plain;
+	charset="iso-8859-2"
+Content-Transfer-Encoding: 7bit
+Return-path: <rlug-bounce@lug.ro>
+Received: from lug.lug.ro ([193.226.140.220])
+	by main.gmane.org with esmtp (Exim 3.35 #1 (Debian))
+	id 18hBoh-0007L5-00
+	for <gourg-rlug@gmane.org>; Fri, 07 Feb 2003 17:57:31 +0100
+Received: from lug.lug.ro (localhost.localdomain [127.0.0.1])
+	by lug.lug.ro (Postfix) with ESMTP
+	id 70A5332D87; Fri,  7 Feb 2003 18:38:06 +0200 (EET)
+Received: with LISTAR (v0.129a; list rlug); Fri, 07 Feb 2003 18:38:05 +0200 (EET)
+Delivered-To: rlug@lug.ro
+Received: from ns.zappmobile.ro (ns.zapp.ro [80.96.151.2])
+	by lug.lug.ro (Postfix) with ESMTP id 2C3BD32CC7
+	for <rlug@lug.ro>; Fri,  7 Feb 2003 18:38:02 +0200 (EET)
+Received: from mail.zappmobile.ro (mail-server.zappmobile.ro [172.31.254.14])
+	by ns.zappmobile.ro (Postfix) with ESMTP id AFDC2490D
+	for <rlug@lug.ro>; Fri,  7 Feb 2003 18:37:48 +0200 (EET)
+Received: from localhost (localhost [127.0.0.1])
+	by mail.zappmobile.ro (Postfix) with ESMTP
+	id 994A6A0BB1; Fri,  7 Feb 2003 18:37:12 +0200 (EET)
+Received: from ok6f6gr01ta4hv (unknown [172.16.28.148])
+	by mail.zappmobile.ro (Postfix) with SMTP id 292599D67B
+	for <rlug@lug.ro>; Fri,  7 Feb 2003 18:37:09 +0200 (EET)
+To: <rlug@lug.ro>
+X-Priority: 3
+X-MSMail-Priority: Normal
+X-Mailer: Microsoft Outlook Express 6.00.2600.0000
+X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
+X-Virus-Scanned: by AMaViS perl-11
+X-archive-position: 23608
+X-listar-version: Listar v0.129a
+Errors-To: rlug-bounce@lug.ro
+X-original-sender: mmihai@netcompsj.ro
+Precedence: bulk
+X-list: rlug
+
+Buna Ziua tuturor,
+
+Am o placa de baza, cu mare probabilitate J-542B, Chipset Ali M1542/M1543,
+Aladdin-V chipset.
+Vreau sa ma conectez la ZAPP, din Linux, pe portul USB
+Un lucru este absolut cert: portul exista si este functional intrucit ma pot
+conecta din XP.
+In Control Panel-ul din XP la "Sectiunea USB" scrie:
+ALI PCI to USB Open Host Controller
+USB Root Hub # Iar sistemul il asigneaza pe COM 4 !!??!!
+L-am lasat in pace ca de mers merge........
+
+Ies din Windows. Pe alta partitie este RH-8.0
+Ma duc in LINUX, RH-8.0, kernel-ul distributiei, nemodificat.
+Inserez modulele:
+1) modprobe usbcore # totul e OK
+2) modprobe usb-ohci # Sistemul imi spune:
+" usb.c: USB device 2 (vend/prod 0X678/0/2303) is not claimed by
+any actine driver.
+#si cele doua module sunt inserate.
+3) Instalez scriptul celor de la ZAPP ( install_hy.sh, e functional, la
+slujba lucreaza excelent)
+4) Incerc conectarea si dau comanda "zapp"
+Modific (de nervi) in /etc/ppp/peers/hyundai-zappmobile de la /dev/ttyUSB0
+pina la /dev/tty/USB4
+si nimic bun, in tail -f /var/log/messages imi zice:
+"Failed to open /dev/ttyUSB0 (#sau cit o fi): No such device.
+Am incercat si pe /dev/ttyS0.......3 si zice:
+Can't get terminal parameters: Input output error
+
+Va rog indrumati-ma si spuneti-mi ce sa fac ca sa lucreze ZAPP-ul  (si) in
+linux, (ca in windows e clar ca e OK ) ??
+
+Va multumesc
+
+
+
+
+---
+Pentru dezabonare, trimiteti mail la 
+listar@lug.ro cu subiectul 'unsubscribe rlug'.
+REGULI, arhive si alte informatii: http://www.lug.ro/mlist/
+
+
+
+
+
+From news@gmane.org Tue Mar 04 03:33:20 2003
+From: lonely wolf <wolfy@pcnet.ro>
+Subject: Re: RH 8.0 boot floppy
+Date: Fri, 07 Feb 2003 19:21:04 +0200
+Lines: 27
+Sender: rlug-bounce@lug.ro
+Message-ID: <3E43EB00.7040006@pcnet.ro>
+References: <3E43BB6D.8080601@myrealbox.com> <3E43BC3C.4050608@apsro.com> <3E43BE1C.9020602@myrealbox.com> <3E43BEC3.5060903@apsro.com>
+Reply-To: rlug@lug.ro
+Mime-Version: 1.0
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+Return-path: <rlug-bounce@lug.ro>
+Received: from lug.lug.ro ([193.226.140.220])
+	by main.gmane.org with esmtp (Exim 3.35 #1 (Debian))
+	id 18hCBB-0001J4-00
+	for <gourg-rlug@gmane.org>; Fri, 07 Feb 2003 18:20:45 +0100
+Received: from lug.lug.ro (localhost.localdomain [127.0.0.1])
+	by lug.lug.ro (Postfix) with ESMTP
+	id 63CDE32D58; Fri,  7 Feb 2003 19:21:17 +0200 (EET)
+Received: with LISTAR (v0.129a; list rlug); Fri, 07 Feb 2003 19:21:16 +0200 (EET)
+Delivered-To: rlug@lug.ro
+Received: from mail.nobugconsulting.ro (nobugconsulting.ro [213.157.160.38])
+	by lug.lug.ro (Postfix) with ESMTP id 4F31632CC7
+	for <rlug@lug.ro>; Fri,  7 Feb 2003 19:21:14 +0200 (EET)
+Received: from 127.0.0.1 (localhost.localdomain [127.0.0.1])
+	by buick.nobugconsulting.ro (Postfix) with SMTP id 146354EDCE
+	for <rlug@lug.ro>; Fri,  7 Feb 2003 19:21:04 +0200 (EET)
+Received: from pcnet.ro (unknown [192.168.1.2])
+	by mail.nobugconsulting.ro (Postfix) with ESMTP id DC16D4ED96
+	for <rlug@lug.ro>; Fri,  7 Feb 2003 19:21:03 +0200 (EET)
+User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01
+X-Accept-Language: en-us, fr, ro
+To: rlug@lug.ro
+X-archive-position: 23609
+X-listar-version: Listar v0.129a
+Errors-To: rlug-bounce@lug.ro
+X-original-sender: wolfy@pcnet.ro
+Precedence: bulk
+X-list: rlug
+
+Nicu Buculei wrote:
+> Daniel Pavel a scris, in 2/7/03 4:09 PM:
+> 
+>> :) nu _am_ CD-ul de instalare...  Imaginea am luat-o de pe un rh mirror.
+> 
+>                                     ^^^^^^^^
+> 
+> si ce ai facut cu imaginea ? nu ai tras-o pe cd ?
+> 
+
+ia cu incredere o discheta de 1.44 (sper ca macar floppy ai), scrie pe 
+ea bootnet.img copiat de pe net si apoi (multumindu-i in gind lui cioby) 
+zici asa:
+- linux rescue (la lilo prompt)
+- alegi ftp ca modalitate de lucru
+- ftp.ines.ro (server)
+- /pub/linux/distributions/redhat-8.0/ftpinstall (path catre distributie)
+
+
+
+---
+Pentru dezabonare, trimiteti mail la 
+listar@lug.ro cu subiectul 'unsubscribe rlug'.
+REGULI, arhive si alte informatii: http://www.lug.ro/mlist/
+
+
+
+
+
+From news@gmane.org Tue Mar 04 03:33:20 2003
+From: Adrian Rapa <adrian@dtedu.net>
+Subject: Qmail mysql virtualusers +ssl + smtp auth +pop3
+Date: Fri, 7 Feb 2003 19:36:01 +0200
+Organization: Asociatia Studenteasca a Retelelor din Drumul Taberei
+Lines: 12
+Sender: rlug-bounce@lug.ro
+Message-ID: <20030207193601.2613a439.adrian@dtedu.net>
+Reply-To: rlug@lug.ro
+Mime-Version: 1.0
+Content-Type: text/plain; charset=US-ASCII
+Content-Transfer-Encoding: 7bit
+Return-path: <rlug-bounce@lug.ro>
+Received: from lug.lug.ro ([193.226.140.220])
+	by main.gmane.org with esmtp (Exim 3.35 #1 (Debian))
+	id 18hCPk-0002ZW-00
+	for <gourg-rlug@gmane.org>; Fri, 07 Feb 2003 18:35:48 +0100
+Received: from lug.lug.ro (localhost.localdomain [127.0.0.1])
+	by lug.lug.ro (Postfix) with ESMTP
+	id DC08032D8E; Fri,  7 Feb 2003 19:36:21 +0200 (EET)
+Received: with LISTAR (v0.129a; list rlug); Fri, 07 Feb 2003 19:36:20 +0200 (EET)
+Delivered-To: rlug@lug.ro
+Received: from www.dtedu.net (tabara.imago.ro [193.254.242.5])
+	by lug.lug.ro (Postfix) with SMTP id 3794D32CC7
+	for <rlug@lug.ro>; Fri,  7 Feb 2003 19:36:17 +0200 (EET)
+Received: (qmail 10170 invoked from network); 7 Feb 2003 17:36:02 -0000
+Received: from games.tabara.net (HELO games) (10.39.2.5)
+  by tabara.imago.ro with SMTP; 7 Feb 2003 17:36:02 -0000
+To: rlug@lug.ro
+X-Mailer: Sylpheed version 0.8.9 (GTK+ 1.2.10; i686-pc-linux-gnu)
+X-archive-position: 23610
+X-listar-version: Listar v0.129a
+Errors-To: rlug-bounce@lug.ro
+X-original-sender: adrian@dtedu.net
+Precedence: bulk
+X-list: rlug
+
+Salut,
+poate cineva sa imi dea combinatia aceasta? am incercat sa pun patchurile dar dadeau erori
+
+
+Adrian Rapa
+---
+Pentru dezabonare, trimiteti mail la 
+listar@lug.ro cu subiectul 'unsubscribe rlug'.
+REGULI, arhive si alte informatii: http://www.lug.ro/mlist/
+
+
+
+
+
+From news@gmane.org Tue Mar 04 03:33:20 2003
+From: teo.55@home.ro
+Subject: Re: Din windows ma pot, din LINUX NU ma pot conecta (la ZAPP)
+Date: Sat, 8 Feb 2003 01:41:31 +0200
+Lines: 25
+Sender: rlug-bounce@lug.ro
+Message-ID: <20030208014131.00fd30ce.teo.55@home.ro>
+References: <001401c2cec7$4eb5b460$941c10ac@ok6f6gr01ta4hv>
+Reply-To: rlug@lug.ro
+Mime-Version: 1.0
+Content-Type: text/plain; charset=US-ASCII
+Content-Transfer-Encoding: 7bit
+Return-path: <rlug-bounce@lug.ro>
+Received: from lug.lug.ro ([193.226.140.220])
+	by main.gmane.org with esmtp (Exim 3.35 #1 (Debian))
+	id 18hI9b-0003OX-00
+	for <gourg-rlug@gmane.org>; Sat, 08 Feb 2003 00:43:31 +0100
+Received: from lug.lug.ro (localhost.localdomain [127.0.0.1])
+	by lug.lug.ro (Postfix) with ESMTP
+	id 6064032D4F; Sat,  8 Feb 2003 01:44:08 +0200 (EET)
+Received: with LISTAR (v0.129a; list rlug); Sat, 08 Feb 2003 01:44:07 +0200 (EET)
+Delivered-To: rlug@lug.ro
+Received: from s1.home.ro (home.rdsnet.ro [193.231.236.40])
+	by lug.lug.ro (Postfix) with SMTP id 0EEE832D02
+	for <rlug@lug.ro>; Sat,  8 Feb 2003 01:44:05 +0200 (EET)
+Received: (qmail 3538 invoked from network); 7 Feb 2003 23:37:23 -0000
+Received: from unknown (HELO linbox) (213.233.108.98)
+  by s1.home.ro with SMTP; 7 Feb 2003 23:37:23 -0000
+To: rlug@lug.ro
+In-Reply-To: <001401c2cec7$4eb5b460$941c10ac@ok6f6gr01ta4hv>
+X-Mailer: Sylpheed version 0.8.6 (GTK+ 1.2.10; i686-pc-linux-gnu)
+X-archive-position: 23611
+X-listar-version: Listar v0.129a
+Errors-To: rlug-bounce@lug.ro
+X-original-sender: teo.55@home.ro
+Precedence: bulk
+X-list: rlug
+
+On Fri, 7 Feb 2003 18:35:25 +0200
+"mmihai" <mmihai@netcompsj.ro> wrote:
+
+> Buna Ziua tuturor,
+> 
+> Am o placa de baza, cu mare probabilitate J-542B, Chipset Ali
+> M1542/M1543, Aladdin-V chipset.
+> Vreau sa ma conectez la ZAPP, din Linux, pe portul USB
+> Un lucru este absolut cert: portul exista si este functional intrucit
+> ma pot conecta din XP.
+> In Control Panel-ul din XP la "Sectiunea USB" scrie:
+> 
+pl2303.o ?
+ai modulul pentru cipul ala de pe cablu ?
+compileaza, insereaza, bla...
+apoi merge
+
+
+---
+Pentru dezabonare, trimiteti mail la 
+listar@lug.ro cu subiectul 'unsubscribe rlug'.
+REGULI, arhive si alte informatii: http://www.lug.ro/mlist/
+
+
+
+
+
+From news@gmane.org Tue Mar 04 03:33:20 2003
+From: "Dragosh M." <dragosh@lsd.ro>
+Subject: LSTP problem - solved
+Date: 08 Feb 2003 01:58:32 +0200
+Lines: 27
+Sender: rlug-bounce@lug.ro
+Message-ID: <1044662313.5121.17.camel@snow.lsd.ro>
+Reply-To: rlug@lug.ro
+Mime-Version: 1.0
+Content-Type: text/plain
+Content-Transfer-Encoding: 7bit
+Return-path: <rlug-bounce@lug.ro>
+Received: from lug.lug.ro ([193.226.140.220])
+	by main.gmane.org with esmtp (Exim 3.35 #1 (Debian))
+	id 18hIID-0003pf-00
+	for <gourg-rlug@gmane.org>; Sat, 08 Feb 2003 00:52:25 +0100
+Received: from lug.lug.ro (localhost.localdomain [127.0.0.1])
+	by lug.lug.ro (Postfix) with ESMTP
+	id 461C532D55; Sat,  8 Feb 2003 01:53:03 +0200 (EET)
+Received: with LISTAR (v0.129a; list rlug); Sat, 08 Feb 2003 01:53:02 +0200 (EET)
+Delivered-To: rlug@lug.ro
+Received: from rdsnet.ro (mail.rdsnet.ro [193.231.236.16])
+	by lug.lug.ro (Postfix) with SMTP id F315032D02
+	for <rlug@lug.ro>; Sat,  8 Feb 2003 01:52:59 +0200 (EET)
+Received: (qmail 5162 invoked from network); 7 Feb 2003 23:52:49 -0000
+Received: from unknown (HELO snow.lsd.ro) (81.196.12.127)
+  by mail.rdsnet.ro with SMTP; 7 Feb 2003 23:52:49 -0000
+To: rlug@lug.ro
+X-Mailer: Ximian Evolution 1.0.8 (1.0.8-10) 
+X-archive-position: 23612
+X-listar-version: Listar v0.129a
+Errors-To: rlug-bounce@lug.ro
+X-original-sender: dragosh@lsd.ro
+Precedence: bulk
+X-list: rlug
+
+In sfarsit am rezolvat crapu, cu ajutorul lui James McQuillan (taticul
+LTSP). E foarte simplu si foarte nedocumentat, 16 mega NU sunt
+suficienti pentru o statie desi peste tot se zice ca si 8 sunt ok, motiv
+pentru care e imperativ necesar sa se foloseasca swap-over-NFS care
+merge super bine (stiu ca majoritatea au o reticenta in a folosi
+swap/nfs, don't be shy, it rocks). Am mai adaugat 64 de ram pe NFS si
+acum rupe tovarashu' terminal, am load 2 la server si totul merge f
+bine.  
+Un 32 de MB sunt minim, 8/16 cat are sistemul + 32 e safe. 
+Sper ca observatia asta sa apara in viitoarea versiune a documentatiei
+ce vine cu LTSP, cel putin asa mi s-a promis.
+
+You've got yourself a happy smilin' motherfucker.
+
+Good fight, good night.
+
+Dragosh "smilin'" M.
+-- 
+I/O error while opening .signature file
+
+---
+Pentru dezabonare, trimiteti mail la 
+listar@lug.ro cu subiectul 'unsubscribe rlug'.
+REGULI, arhive si alte informatii: http://www.lug.ro/mlist/
+
+
+
+
+
+

Added: james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-0
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-0?rev=1351619&view=auto
==============================================================================
--- james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-0 (added)
+++ james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-0 Tue Jun 19 09:41:00 2012
@@ -0,0 +1,93 @@
+From: "mmihai" <mmihai@netcompsj.ro>
+Subject: Din windows ma pot, din LINUX NU ma pot conecta (la ZAPP)
+Date: Fri, 7 Feb 2003 18:35:25 +0200
+Lines: 45
+Sender: rlug-bounce@lug.ro
+Message-ID: <001401c2cec7$4eb5b460$941c10ac@ok6f6gr01ta4hv>
+Reply-To: rlug@lug.ro
+Mime-Version: 1.0
+Content-Type: text/plain;
+	charset="iso-8859-2"
+Content-Transfer-Encoding: 7bit
+Return-path: <rlug-bounce@lug.ro>
+Received: from lug.lug.ro ([193.226.140.220])
+	by main.gmane.org with esmtp (Exim 3.35 #1 (Debian))
+	id 18hBoh-0007L5-00
+	for <gourg-rlug@gmane.org>; Fri, 07 Feb 2003 17:57:31 +0100
+Received: from lug.lug.ro (localhost.localdomain [127.0.0.1])
+	by lug.lug.ro (Postfix) with ESMTP
+	id 70A5332D87; Fri,  7 Feb 2003 18:38:06 +0200 (EET)
+Received: with LISTAR (v0.129a; list rlug); Fri, 07 Feb 2003 18:38:05 +0200 (EET)
+Delivered-To: rlug@lug.ro
+Received: from ns.zappmobile.ro (ns.zapp.ro [80.96.151.2])
+	by lug.lug.ro (Postfix) with ESMTP id 2C3BD32CC7
+	for <rlug@lug.ro>; Fri,  7 Feb 2003 18:38:02 +0200 (EET)
+Received: from mail.zappmobile.ro (mail-server.zappmobile.ro [172.31.254.14])
+	by ns.zappmobile.ro (Postfix) with ESMTP id AFDC2490D
+	for <rlug@lug.ro>; Fri,  7 Feb 2003 18:37:48 +0200 (EET)
+Received: from localhost (localhost [127.0.0.1])
+	by mail.zappmobile.ro (Postfix) with ESMTP
+	id 994A6A0BB1; Fri,  7 Feb 2003 18:37:12 +0200 (EET)
+Received: from ok6f6gr01ta4hv (unknown [172.16.28.148])
+	by mail.zappmobile.ro (Postfix) with SMTP id 292599D67B
+	for <rlug@lug.ro>; Fri,  7 Feb 2003 18:37:09 +0200 (EET)
+To: <rlug@lug.ro>
+X-Priority: 3
+X-MSMail-Priority: Normal
+X-Mailer: Microsoft Outlook Express 6.00.2600.0000
+X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
+X-Virus-Scanned: by AMaViS perl-11
+X-archive-position: 23608
+X-listar-version: Listar v0.129a
+Errors-To: rlug-bounce@lug.ro
+X-original-sender: mmihai@netcompsj.ro
+Precedence: bulk
+X-list: rlug
+
+Buna Ziua tuturor,
+
+Am o placa de baza, cu mare probabilitate J-542B, Chipset Ali M1542/M1543,
+Aladdin-V chipset.
+Vreau sa ma conectez la ZAPP, din Linux, pe portul USB
+Un lucru este absolut cert: portul exista si este functional intrucit ma pot
+conecta din XP.
+In Control Panel-ul din XP la "Sectiunea USB" scrie:
+ALI PCI to USB Open Host Controller
+USB Root Hub # Iar sistemul il asigneaza pe COM 4 !!??!!
+L-am lasat in pace ca de mers merge........
+
+Ies din Windows. Pe alta partitie este RH-8.0
+Ma duc in LINUX, RH-8.0, kernel-ul distributiei, nemodificat.
+Inserez modulele:
+1) modprobe usbcore # totul e OK
+2) modprobe usb-ohci # Sistemul imi spune:
+" usb.c: USB device 2 (vend/prod 0X678/0/2303) is not claimed by
+any actine driver.
+#si cele doua module sunt inserate.
+3) Instalez scriptul celor de la ZAPP ( install_hy.sh, e functional, la
+slujba lucreaza excelent)
+4) Incerc conectarea si dau comanda "zapp"
+Modific (de nervi) in /etc/ppp/peers/hyundai-zappmobile de la /dev/ttyUSB0
+pina la /dev/tty/USB4
+si nimic bun, in tail -f /var/log/messages imi zice:
+"Failed to open /dev/ttyUSB0 (#sau cit o fi): No such device.
+Am incercat si pe /dev/ttyS0.......3 si zice:
+Can't get terminal parameters: Input output error
+
+Va rog indrumati-ma si spuneti-mi ce sa fac ca sa lucreze ZAPP-ul  (si) in
+linux, (ca in windows e clar ca e OK ) ??
+
+Va multumesc
+
+
+
+
+---
+Pentru dezabonare, trimiteti mail la 
+listar@lug.ro cu subiectul 'unsubscribe rlug'.
+REGULI, arhive si alte informatii: http://www.lug.ro/mlist/
+
+
+
+
+

Added: james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-1
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-1?rev=1351619&view=auto
==============================================================================
--- james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-1 (added)
+++ james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-1 Tue Jun 19 09:41:00 2012
@@ -0,0 +1,69 @@
+From: lonely wolf <wolfy@pcnet.ro>
+Subject: Re: RH 8.0 boot floppy
+Date: Fri, 07 Feb 2003 19:21:04 +0200
+Lines: 27
+Sender: rlug-bounce@lug.ro
+Message-ID: <3E43EB00.7040006@pcnet.ro>
+References: <3E43BB6D.8080601@myrealbox.com> <3E43BC3C.4050608@apsro.com> <3E43BE1C.9020602@myrealbox.com> <3E43BEC3.5060903@apsro.com>
+Reply-To: rlug@lug.ro
+Mime-Version: 1.0
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+Return-path: <rlug-bounce@lug.ro>
+Received: from lug.lug.ro ([193.226.140.220])
+	by main.gmane.org with esmtp (Exim 3.35 #1 (Debian))
+	id 18hCBB-0001J4-00
+	for <gourg-rlug@gmane.org>; Fri, 07 Feb 2003 18:20:45 +0100
+Received: from lug.lug.ro (localhost.localdomain [127.0.0.1])
+	by lug.lug.ro (Postfix) with ESMTP
+	id 63CDE32D58; Fri,  7 Feb 2003 19:21:17 +0200 (EET)
+Received: with LISTAR (v0.129a; list rlug); Fri, 07 Feb 2003 19:21:16 +0200 (EET)
+Delivered-To: rlug@lug.ro
+Received: from mail.nobugconsulting.ro (nobugconsulting.ro [213.157.160.38])
+	by lug.lug.ro (Postfix) with ESMTP id 4F31632CC7
+	for <rlug@lug.ro>; Fri,  7 Feb 2003 19:21:14 +0200 (EET)
+Received: from 127.0.0.1 (localhost.localdomain [127.0.0.1])
+	by buick.nobugconsulting.ro (Postfix) with SMTP id 146354EDCE
+	for <rlug@lug.ro>; Fri,  7 Feb 2003 19:21:04 +0200 (EET)
+Received: from pcnet.ro (unknown [192.168.1.2])
+	by mail.nobugconsulting.ro (Postfix) with ESMTP id DC16D4ED96
+	for <rlug@lug.ro>; Fri,  7 Feb 2003 19:21:03 +0200 (EET)
+User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01
+X-Accept-Language: en-us, fr, ro
+To: rlug@lug.ro
+X-archive-position: 23609
+X-listar-version: Listar v0.129a
+Errors-To: rlug-bounce@lug.ro
+X-original-sender: wolfy@pcnet.ro
+Precedence: bulk
+X-list: rlug
+
+Nicu Buculei wrote:
+> Daniel Pavel a scris, in 2/7/03 4:09 PM:
+> 
+>> :) nu _am_ CD-ul de instalare...  Imaginea am luat-o de pe un rh mirror.
+> 
+>                                     ^^^^^^^^
+> 
+> si ce ai facut cu imaginea ? nu ai tras-o pe cd ?
+> 
+
+ia cu incredere o discheta de 1.44 (sper ca macar floppy ai), scrie pe 
+ea bootnet.img copiat de pe net si apoi (multumindu-i in gind lui cioby) 
+zici asa:
+- linux rescue (la lilo prompt)
+- alegi ftp ca modalitate de lucru
+- ftp.ines.ro (server)
+- /pub/linux/distributions/redhat-8.0/ftpinstall (path catre distributie)
+
+
+
+---
+Pentru dezabonare, trimiteti mail la 
+listar@lug.ro cu subiectul 'unsubscribe rlug'.
+REGULI, arhive si alte informatii: http://www.lug.ro/mlist/
+
+
+
+
+

Added: james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-2
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-2?rev=1351619&view=auto
==============================================================================
--- james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-2 (added)
+++ james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-2 Tue Jun 19 09:41:00 2012
@@ -0,0 +1,50 @@
+From: Adrian Rapa <adrian@dtedu.net>
+Subject: Qmail mysql virtualusers +ssl + smtp auth +pop3
+Date: Fri, 7 Feb 2003 19:36:01 +0200
+Organization: Asociatia Studenteasca a Retelelor din Drumul Taberei
+Lines: 12
+Sender: rlug-bounce@lug.ro
+Message-ID: <20030207193601.2613a439.adrian@dtedu.net>
+Reply-To: rlug@lug.ro
+Mime-Version: 1.0
+Content-Type: text/plain; charset=US-ASCII
+Content-Transfer-Encoding: 7bit
+Return-path: <rlug-bounce@lug.ro>
+Received: from lug.lug.ro ([193.226.140.220])
+	by main.gmane.org with esmtp (Exim 3.35 #1 (Debian))
+	id 18hCPk-0002ZW-00
+	for <gourg-rlug@gmane.org>; Fri, 07 Feb 2003 18:35:48 +0100
+Received: from lug.lug.ro (localhost.localdomain [127.0.0.1])
+	by lug.lug.ro (Postfix) with ESMTP
+	id DC08032D8E; Fri,  7 Feb 2003 19:36:21 +0200 (EET)
+Received: with LISTAR (v0.129a; list rlug); Fri, 07 Feb 2003 19:36:20 +0200 (EET)
+Delivered-To: rlug@lug.ro
+Received: from www.dtedu.net (tabara.imago.ro [193.254.242.5])
+	by lug.lug.ro (Postfix) with SMTP id 3794D32CC7
+	for <rlug@lug.ro>; Fri,  7 Feb 2003 19:36:17 +0200 (EET)
+Received: (qmail 10170 invoked from network); 7 Feb 2003 17:36:02 -0000
+Received: from games.tabara.net (HELO games) (10.39.2.5)
+  by tabara.imago.ro with SMTP; 7 Feb 2003 17:36:02 -0000
+To: rlug@lug.ro
+X-Mailer: Sylpheed version 0.8.9 (GTK+ 1.2.10; i686-pc-linux-gnu)
+X-archive-position: 23610
+X-listar-version: Listar v0.129a
+Errors-To: rlug-bounce@lug.ro
+X-original-sender: adrian@dtedu.net
+Precedence: bulk
+X-list: rlug
+
+Salut,
+poate cineva sa imi dea combinatia aceasta? am incercat sa pun patchurile dar dadeau erori
+
+
+Adrian Rapa
+---
+Pentru dezabonare, trimiteti mail la 
+listar@lug.ro cu subiectul 'unsubscribe rlug'.
+REGULI, arhive si alte informatii: http://www.lug.ro/mlist/
+
+
+
+
+

Added: james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-3
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-3?rev=1351619&view=auto
==============================================================================
--- james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-3 (added)
+++ james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-3 Tue Jun 19 09:41:00 2012
@@ -0,0 +1,64 @@
+From: teo.55@home.ro
+Subject: Re: Din windows ma pot, din LINUX NU ma pot conecta (la ZAPP)
+Date: Sat, 8 Feb 2003 01:41:31 +0200
+Lines: 25
+Sender: rlug-bounce@lug.ro
+Message-ID: <20030208014131.00fd30ce.teo.55@home.ro>
+References: <001401c2cec7$4eb5b460$941c10ac@ok6f6gr01ta4hv>
+Reply-To: rlug@lug.ro
+Mime-Version: 1.0
+Content-Type: text/plain; charset=US-ASCII
+Content-Transfer-Encoding: 7bit
+Return-path: <rlug-bounce@lug.ro>
+Received: from lug.lug.ro ([193.226.140.220])
+	by main.gmane.org with esmtp (Exim 3.35 #1 (Debian))
+	id 18hI9b-0003OX-00
+	for <gourg-rlug@gmane.org>; Sat, 08 Feb 2003 00:43:31 +0100
+Received: from lug.lug.ro (localhost.localdomain [127.0.0.1])
+	by lug.lug.ro (Postfix) with ESMTP
+	id 6064032D4F; Sat,  8 Feb 2003 01:44:08 +0200 (EET)
+Received: with LISTAR (v0.129a; list rlug); Sat, 08 Feb 2003 01:44:07 +0200 (EET)
+Delivered-To: rlug@lug.ro
+Received: from s1.home.ro (home.rdsnet.ro [193.231.236.40])
+	by lug.lug.ro (Postfix) with SMTP id 0EEE832D02
+	for <rlug@lug.ro>; Sat,  8 Feb 2003 01:44:05 +0200 (EET)
+Received: (qmail 3538 invoked from network); 7 Feb 2003 23:37:23 -0000
+Received: from unknown (HELO linbox) (213.233.108.98)
+  by s1.home.ro with SMTP; 7 Feb 2003 23:37:23 -0000
+To: rlug@lug.ro
+In-Reply-To: <001401c2cec7$4eb5b460$941c10ac@ok6f6gr01ta4hv>
+X-Mailer: Sylpheed version 0.8.6 (GTK+ 1.2.10; i686-pc-linux-gnu)
+X-archive-position: 23611
+X-listar-version: Listar v0.129a
+Errors-To: rlug-bounce@lug.ro
+X-original-sender: teo.55@home.ro
+Precedence: bulk
+X-list: rlug
+
+On Fri, 7 Feb 2003 18:35:25 +0200
+"mmihai" <mmihai@netcompsj.ro> wrote:
+
+> Buna Ziua tuturor,
+> 
+> Am o placa de baza, cu mare probabilitate J-542B, Chipset Ali
+> M1542/M1543, Aladdin-V chipset.
+> Vreau sa ma conectez la ZAPP, din Linux, pe portul USB
+> Un lucru este absolut cert: portul exista si este functional intrucit
+> ma pot conecta din XP.
+> In Control Panel-ul din XP la "Sectiunea USB" scrie:
+> 
+pl2303.o ?
+ai modulul pentru cipul ala de pe cablu ?
+compileaza, insereaza, bla...
+apoi merge
+
+
+---
+Pentru dezabonare, trimiteti mail la 
+listar@lug.ro cu subiectul 'unsubscribe rlug'.
+REGULI, arhive si alte informatii: http://www.lug.ro/mlist/
+
+
+
+
+

Added: james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-4
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-4?rev=1351619&view=auto
==============================================================================
--- james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-4 (added)
+++ james/mime4j/trunk/mbox/src/test/resources/test-1/mbox.rlug-4 Tue Jun 19 09:41:00 2012
@@ -0,0 +1,65 @@
+From: "Dragosh M." <dragosh@lsd.ro>
+Subject: LSTP problem - solved
+Date: 08 Feb 2003 01:58:32 +0200
+Lines: 27
+Sender: rlug-bounce@lug.ro
+Message-ID: <1044662313.5121.17.camel@snow.lsd.ro>
+Reply-To: rlug@lug.ro
+Mime-Version: 1.0
+Content-Type: text/plain
+Content-Transfer-Encoding: 7bit
+Return-path: <rlug-bounce@lug.ro>
+Received: from lug.lug.ro ([193.226.140.220])
+	by main.gmane.org with esmtp (Exim 3.35 #1 (Debian))
+	id 18hIID-0003pf-00
+	for <gourg-rlug@gmane.org>; Sat, 08 Feb 2003 00:52:25 +0100
+Received: from lug.lug.ro (localhost.localdomain [127.0.0.1])
+	by lug.lug.ro (Postfix) with ESMTP
+	id 461C532D55; Sat,  8 Feb 2003 01:53:03 +0200 (EET)
+Received: with LISTAR (v0.129a; list rlug); Sat, 08 Feb 2003 01:53:02 +0200 (EET)
+Delivered-To: rlug@lug.ro
+Received: from rdsnet.ro (mail.rdsnet.ro [193.231.236.16])
+	by lug.lug.ro (Postfix) with SMTP id F315032D02
+	for <rlug@lug.ro>; Sat,  8 Feb 2003 01:52:59 +0200 (EET)
+Received: (qmail 5162 invoked from network); 7 Feb 2003 23:52:49 -0000
+Received: from unknown (HELO snow.lsd.ro) (81.196.12.127)
+  by mail.rdsnet.ro with SMTP; 7 Feb 2003 23:52:49 -0000
+To: rlug@lug.ro
+X-Mailer: Ximian Evolution 1.0.8 (1.0.8-10) 
+X-archive-position: 23612
+X-listar-version: Listar v0.129a
+Errors-To: rlug-bounce@lug.ro
+X-original-sender: dragosh@lsd.ro
+Precedence: bulk
+X-list: rlug
+
+In sfarsit am rezolvat crapu, cu ajutorul lui James McQuillan (taticul
+LTSP). E foarte simplu si foarte nedocumentat, 16 mega NU sunt
+suficienti pentru o statie desi peste tot se zice ca si 8 sunt ok, motiv
+pentru care e imperativ necesar sa se foloseasca swap-over-NFS care
+merge super bine (stiu ca majoritatea au o reticenta in a folosi
+swap/nfs, don't be shy, it rocks). Am mai adaugat 64 de ram pe NFS si
+acum rupe tovarashu' terminal, am load 2 la server si totul merge f
+bine.  
+Un 32 de MB sunt minim, 8/16 cat are sistemul + 32 e safe. 
+Sper ca observatia asta sa apara in viitoarea versiune a documentatiei
+ce vine cu LTSP, cel putin asa mi s-a promis.
+
+You've got yourself a happy smilin' motherfucker.
+
+Good fight, good night.
+
+Dragosh "smilin'" M.
+-- 
+I/O error while opening .signature file
+
+---
+Pentru dezabonare, trimiteti mail la 
+listar@lug.ro cu subiectul 'unsubscribe rlug'.
+REGULI, arhive si alte informatii: http://www.lug.ro/mlist/
+
+
+
+
+
+

Modified: james/mime4j/trunk/pom.xml
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/pom.xml?rev=1351619&r1=1351618&r2=1351619&view=diff
==============================================================================
--- james/mime4j/trunk/pom.xml (original)
+++ james/mime4j/trunk/pom.xml Tue Jun 19 09:41:00 2012
@@ -43,6 +43,7 @@
         <module>benchmark</module>
         <module>examples</module>
         <module>assemble</module>
+        <module>mbox</module>
     </modules>
 
     <scm>
@@ -81,7 +82,7 @@
             <dependency>
                 <groupId>junit</groupId>
                 <artifactId>junit</artifactId>
-                <version>3.8.2</version>
+                <version>4.10</version>
                 <type>jar</type>
                 <!-- Removed as a workaround for an unidentified M2 bug -->
                 <scope>test</scope>
@@ -94,6 +95,11 @@
                 <scope>test</scope>
                 <optional>true</optional>
             </dependency>
+            <dependency>
+                <groupId>com.google.guava</groupId>
+                <artifactId>guava</artifactId>
+                <version>11.0.1</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 
@@ -123,10 +129,12 @@
                             <excludes>
                                 <exclude>NOTICE.*</exclude>
                                 <exclude>LICENSE.*</exclude>
+                                <exclude>**/README.*</exclude>
                                 <exclude>**/main/resources/long-multipart.msg</exclude>
                                 <exclude>**/main/resources/META-INF/services/org.apache.james.mime4j.dom.MessageServiceFactory</exclude>
                                 <exclude>**/test/resources/testmsgs/*</exclude>
                                 <exclude>**/test/resources/mimetools-testmsgs/*</exclude>
+                                <exclude>**/test/resources/test-1/*</exclude>
                                 <!-- Generated by Maven -->
                                 <exclude>release.properties</exclude>
                                 <exclude>dist/**/*</exclude>



Mime
View raw message