james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r360063 - in /james/server/trunk/src/java/org/apache: james/ james/core/ james/mailrepository/ james/pop3server/ james/services/ james/smtpserver/ james/transport/ james/transport/mailets/ james/transport/matchers/ mailet/
Date Fri, 30 Dec 2005 10:27:07 GMT
Author: bago
Date: Fri Dec 30 02:26:48 2005
New Revision: 360063

URL: http://svn.apache.org/viewcvs?rev=360063&view=rev
Log:
Updated Mailet's Mail to support most of the current james mailets (JAMES-411).
Moved get/setName, get/setLastUpdated, getMessageSize from MailImpl to Mail interface (tagged with @since Mailet API 2.3.0).
Updated James code to support simple "Mail" objects without the casts to MailImpl (not compliant with the api).
Fixed 2 possible non closed streams (JAMES-430).

Modified:
    james/server/trunk/src/java/org/apache/james/James.java
    james/server/trunk/src/java/org/apache/james/core/MailImpl.java
    james/server/trunk/src/java/org/apache/james/mailrepository/AvalonMailRepository.java
    james/server/trunk/src/java/org/apache/james/mailrepository/AvalonSpoolRepository.java
    james/server/trunk/src/java/org/apache/james/mailrepository/JDBCMailRepository.java
    james/server/trunk/src/java/org/apache/james/mailrepository/JDBCSpoolRepository.java
    james/server/trunk/src/java/org/apache/james/mailrepository/MBoxMailRepository.java
    james/server/trunk/src/java/org/apache/james/mailrepository/MailStoreSpoolRepository.java
    james/server/trunk/src/java/org/apache/james/pop3server/POP3Handler.java
    james/server/trunk/src/java/org/apache/james/services/MailRepository.java
    james/server/trunk/src/java/org/apache/james/smtpserver/SMTPHandler.java
    james/server/trunk/src/java/org/apache/james/smtpserver/SMTPSession.java
    james/server/trunk/src/java/org/apache/james/transport/JamesSpoolManager.java
    james/server/trunk/src/java/org/apache/james/transport/LinearProcessor.java
    james/server/trunk/src/java/org/apache/james/transport/mailets/AbstractRedirect.java
    james/server/trunk/src/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java
    james/server/trunk/src/java/org/apache/james/transport/mailets/AddFooter.java
    james/server/trunk/src/java/org/apache/james/transport/mailets/CommandListservFooter.java
    james/server/trunk/src/java/org/apache/james/transport/mailets/DSNBounce.java
    james/server/trunk/src/java/org/apache/james/transport/mailets/FromRepository.java
    james/server/trunk/src/java/org/apache/james/transport/mailets/RemoteDelivery.java
    james/server/trunk/src/java/org/apache/james/transport/mailets/ToMultiRepository.java
    james/server/trunk/src/java/org/apache/james/transport/mailets/ToRepository.java
    james/server/trunk/src/java/org/apache/james/transport/matchers/AbstractStorageQuota.java
    james/server/trunk/src/java/org/apache/mailet/Mail.java

Modified: james/server/trunk/src/java/org/apache/james/James.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/James.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/James.java (original)
+++ james/server/trunk/src/java/org/apache/james/James.java Fri Dec 30 02:26:48 2005
@@ -50,8 +50,10 @@
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.MailetContext;
+import org.apache.mailet.RFC2822Headers;
 
 import javax.mail.Address;
+import javax.mail.Message;
 import javax.mail.MessagingException;
 import javax.mail.internet.InternetAddress;
 import javax.mail.internet.MimeMessage;
@@ -61,6 +63,7 @@
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.Collection;
+import java.util.Date;
 import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.Hashtable;
@@ -478,12 +481,11 @@
      *                            on the spool
      */
     public void sendMail(Mail mail) throws MessagingException {
-        MailImpl mailimpl = (MailImpl)mail;
         try {
-            spool.store(mailimpl);
+            spool.store(mail);
         } catch (Exception e) {
             try {
-                spool.remove(mailimpl);
+                spool.remove(mail);
             } catch (Exception ignored) {
             }
             throw new MessagingException("Exception spooling message: " + e.getMessage(), e);
@@ -492,7 +494,7 @@
             StringBuffer logBuffer =
                 new StringBuffer(64)
                         .append("Mail ")
-                        .append(mailimpl.getName())
+                        .append(mail.getName())
                         .append(" pushed in spool");
             getLogger().debug(logBuffer.toString());
         }
@@ -665,13 +667,42 @@
                 getLogger().info("Processing a bounce request for a message with a reverse path of " + mail.getSender().toString());
         }
 
-        Mail reply = ((MailImpl) mail).bounce(message);
+        MailImpl reply = rawBounce(mail,message);
         //Change the sender...
         reply.getMessage().setFrom(bouncer.toInternetAddress());
         reply.getMessage().saveChanges();
         //Send it off ... with null reverse-path
-        ((MailImpl)reply).setSender(null);
+        reply.setSender(null);
         sendMail(reply);
+    }
+
+    /**
+     * Generates a bounce mail that is a bounce of the original message.
+     *
+     * @param bounceText the text to be prepended to the message to describe the bounce condition
+     *
+     * @return the bounce mail
+     *
+     * @throws MessagingException if the bounce mail could not be created
+     */
+    private MailImpl rawBounce(Mail mail, String bounceText) throws MessagingException {
+        //This sends a message to the james component that is a bounce of the sent message
+        MimeMessage original = mail.getMessage();
+        MimeMessage reply = (MimeMessage) original.reply(false);
+        reply.setSubject("Re: " + original.getSubject());
+        reply.setSentDate(new Date());
+        Collection recipients = new HashSet();
+        recipients.add(mail.getSender());
+        InternetAddress addr[] = { new InternetAddress(mail.getSender().toString())};
+        reply.setRecipients(Message.RecipientType.TO, addr);
+        reply.setFrom(new InternetAddress(mail.getRecipients().iterator().next().toString()));
+        reply.setText(bounceText);
+        reply.setHeader(RFC2822Headers.MESSAGE_ID, "replyTo-" + mail.getName());
+        return new MailImpl(
+            "replyTo-" + mail.getName(),
+            new MailAddress(mail.getRecipients().iterator().next().toString()),
+            recipients,
+            reply);
     }
 
     /**

Modified: james/server/trunk/src/java/org/apache/james/core/MailImpl.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/core/MailImpl.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/core/MailImpl.java (original)
+++ james/server/trunk/src/java/org/apache/james/core/MailImpl.java Fri Dec 30 02:26:48 2005
@@ -19,24 +19,20 @@
 
 import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.container.ContainerUtil;
-
-import org.apache.mailet.RFC2822Headers;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
+import org.apache.mailet.RFC2822Headers;
 
 import javax.mail.Address;
-import javax.mail.Message;
 import javax.mail.MessagingException;
 import javax.mail.internet.InternetAddress;
 import javax.mail.internet.MimeMessage;
 import javax.mail.internet.ParseException;
 
-import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.OptionalDataException;
@@ -46,9 +42,8 @@
 import java.util.Collection;
 import java.util.Date;
 import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Iterator;
 import java.util.HashMap;
+import java.util.Iterator;
 
 /**
  * <P>Wraps a MimeMessage adding routing information (from SMTP) and some simple
@@ -138,6 +133,36 @@
             }
         }
     }
+    
+    /**
+     * @param mail
+     * @param newName
+     * @throws MessagingException
+     */
+    public MailImpl(Mail mail, String newName) throws MessagingException {
+        this(newName, mail.getSender(), mail.getRecipients(), mail.getMessage());
+        setRemoteHost(mail.getRemoteHost());
+        setRemoteAddr(mail.getRemoteAddr());
+        setLastUpdated(mail.getLastUpdated());
+        try {
+            if (mail instanceof MailImpl) {
+                setAttributesRaw((HashMap) cloneSerializableObject(((MailImpl) mail).getAttributesRaw()));
+            } else {
+                HashMap attribs = new HashMap();
+                for (Iterator i = mail.getAttributeNames(); i.hasNext(); ) {
+                    String hashKey = (String) i.next();
+                    attribs.put(hashKey,cloneSerializableObject(mail.getAttribute(hashKey)));
+                }
+                setAttributesRaw(attribs);
+            }
+        } catch (IOException e) {
+            // should never happen for in memory streams
+            setAttributesRaw(new HashMap());
+        } catch (ClassNotFoundException e) {
+            // should never happen as we just serialized it
+            setAttributesRaw(new HashMap());
+        }
+    }
 
     /**
      * A constructor that creates a MailImpl with the specified name,
@@ -242,20 +267,7 @@
      */
     public Mail duplicate(String newName) {
         try {
-            MailImpl newMail = new MailImpl(newName, sender, recipients, getMessage());
-            newMail.setRemoteHost(remoteHost);
-            newMail.setRemoteAddr(remoteAddr);
-            newMail.setLastUpdated(lastUpdated);
-            try {
-                newMail.setAttributesRaw((HashMap) cloneSerializableObject(attributes));
-            } catch (IOException e) {
-                // should never happen for in memory streams
-                newMail.setAttributesRaw(new HashMap());
-            } catch (ClassNotFoundException e) {
-                // should never happen as we just serialized it
-                newMail.setAttributesRaw(new HashMap());
-            }
-            return newMail;
+            return new MailImpl(this, newName);
         } catch (MessagingException me) {
             // Ignored.  Return null in the case of an error.
         }
@@ -450,61 +462,6 @@
     public void writeMessageTo(OutputStream out) throws IOException, MessagingException {
         if (message != null) {
             message.writeTo(out);
-        } else {
-            throw new MessagingException("No message set for this MailImpl.");
-        }
-    }
-    /**
-     * Generates a bounce mail that is a bounce of the original message.
-     *
-     * @param bounceText the text to be prepended to the message to describe the bounce condition
-     *
-     * @return the bounce mail
-     *
-     * @throws MessagingException if the bounce mail could not be created
-     */
-    public Mail bounce(String bounceText) throws MessagingException {
-        //This sends a message to the james component that is a bounce of the sent message
-        MimeMessage original = getMessage();
-        MimeMessage reply = (MimeMessage) original.reply(false);
-        reply.setSubject("Re: " + original.getSubject());
-        reply.setSentDate(new Date());
-        Collection recipients = new HashSet();
-        recipients.add(getSender());
-        InternetAddress addr[] = { new InternetAddress(getSender().toString())};
-        reply.setRecipients(Message.RecipientType.TO, addr);
-        reply.setFrom(new InternetAddress(getRecipients().iterator().next().toString()));
-        reply.setText(bounceText);
-        reply.setHeader(RFC2822Headers.MESSAGE_ID, "replyTo-" + getName());
-        return new MailImpl(
-            "replyTo-" + getName(),
-            new MailAddress(getRecipients().iterator().next().toString()),
-            recipients,
-            reply);
-    }
-    /**
-     * Writes the content of the message, up to a total number of lines, out to 
-     * an OutputStream.
-     *
-     * @param out the OutputStream to which to write the content
-     * @param lines the number of lines to write to the stream
-     *
-     * @throws MessagingException if the MimeMessage is not set for this MailImpl
-     * @throws IOException if an error occurs while reading or writing from the stream
-     */
-    public void writeContentTo(OutputStream out, int lines)
-        throws IOException, MessagingException {
-        String line;
-        BufferedReader br;
-        if (message != null) {
-            br = new BufferedReader(new InputStreamReader(message.getInputStream()));
-            while (lines-- > 0) {
-                if ((line = br.readLine()) == null) {
-                    break;
-                }
-                line += "\r\n";
-                out.write(line.getBytes());
-            }
         } else {
             throw new MessagingException("No message set for this MailImpl.");
         }

Modified: james/server/trunk/src/java/org/apache/james/mailrepository/AvalonMailRepository.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/mailrepository/AvalonMailRepository.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/mailrepository/AvalonMailRepository.java (original)
+++ james/server/trunk/src/java/org/apache/james/mailrepository/AvalonMailRepository.java Fri Dec 30 02:26:48 2005
@@ -21,18 +21,20 @@
 import org.apache.avalon.cornerstone.services.store.Store;
 import org.apache.avalon.cornerstone.services.store.StreamRepository;
 import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.configuration.DefaultConfiguration;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.james.core.MailImpl;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
 import org.apache.james.core.MimeMessageWrapper;
 import org.apache.james.services.MailRepository;
 import org.apache.james.util.Lock;
+import org.apache.mailet.Mail;
+
+import javax.mail.MessagingException;
 
 import java.io.OutputStream;
 import java.util.ArrayList;
@@ -42,8 +44,6 @@
 import java.util.Iterator;
 import java.util.Set;
 
-import javax.mail.MessagingException;
-
 /**
  * Implementation of a MailRepository on a FileSystem.
  *
@@ -241,7 +241,7 @@
      *
      * @param mc the mail message to store
      */
-    public void store(MailImpl mc) throws MessagingException {
+    public void store(Mail mc) throws MessagingException {
         try {
             String key = mc.getName();
             //Remember whether this key was locked
@@ -289,7 +289,7 @@
                     OutputStream out = null;
                     try {
                         out = sr.put(key);
-                        mc.writeMessageTo(out);
+                        mc.getMessage().writeTo(out);
                     } finally {
                         if (out != null) out.close();
                     }
@@ -328,14 +328,14 @@
      * @param key the key of the message to retrieve
      * @return the mail corresponding to this key, null if none exists
      */
-    public MailImpl retrieve(String key) throws MessagingException {
+    public Mail retrieve(String key) throws MessagingException {
         if ((DEEP_DEBUG) && (getLogger().isDebugEnabled())) {
             getLogger().debug("Retrieving mail: " + key);
         }
         try {
-            MailImpl mc = null;
+            Mail mc = null;
             try {
-                mc = (MailImpl) or.get(key);
+                mc = (Mail) or.get(key);
             } 
             catch (RuntimeException re){
                 StringBuffer exceptionBuffer = new StringBuffer(128);
@@ -366,7 +366,7 @@
      *
      * @param mail the message to be removed from the repository
      */
-    public void remove(MailImpl mail) throws MessagingException {
+    public void remove(Mail mail) throws MessagingException {
         remove(mail.getName());
     }
 
@@ -380,7 +380,7 @@
     public void remove(Collection mails) throws MessagingException {
         Iterator delList = mails.iterator();
         while (delList.hasNext()) {
-            remove((MailImpl)delList.next());
+            remove((Mail)delList.next());
         }
     }
 

Modified: james/server/trunk/src/java/org/apache/james/mailrepository/AvalonSpoolRepository.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/mailrepository/AvalonSpoolRepository.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/mailrepository/AvalonSpoolRepository.java (original)
+++ james/server/trunk/src/java/org/apache/james/mailrepository/AvalonSpoolRepository.java Fri Dec 30 02:26:48 2005
@@ -17,7 +17,6 @@
 
 package org.apache.james.mailrepository;
 
-import org.apache.james.core.MailImpl;
 import org.apache.james.services.SpoolRepository;
 import org.apache.mailet.Mail;
 
@@ -149,7 +148,7 @@
                         getLogger().debug("accept(Filter) has locked: " + s);
                     }
                     try {
-                        MailImpl mail = retrieve(s);
+                        Mail mail = retrieve(s);
                         // Retrieve can return null if the mail is no longer on the spool
                         // (i.e. another thread has gotten to it first).
                         // In this case we simply continue to the next key

Modified: james/server/trunk/src/java/org/apache/james/mailrepository/JDBCMailRepository.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/mailrepository/JDBCMailRepository.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/mailrepository/JDBCMailRepository.java (original)
+++ james/server/trunk/src/java/org/apache/james/mailrepository/JDBCMailRepository.java Fri Dec 30 02:26:48 2005
@@ -40,6 +40,7 @@
 import org.apache.james.util.JDBCUtil;
 import org.apache.james.util.Lock;
 import org.apache.james.util.SqlResources;
+import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 
 import javax.mail.MessagingException;
@@ -529,7 +530,7 @@
      * Store this message to the database.  Optionally stores the message
      * body to the filesystem and only writes the headers to the database.
      */
-    public void store(MailImpl mc) throws MessagingException {
+    public void store(Mail mc) throws MessagingException {
         Connection conn = null;
         boolean wasLocked = true;
         String key = mc.getName();
@@ -610,7 +611,16 @@
                         ByteArrayOutputStream baos = new ByteArrayOutputStream();
                         ObjectOutputStream oos = new ObjectOutputStream(baos);
                         try {
-                            oos.writeObject(((MailImpl)mc).getAttributesRaw());
+                            if (mc instanceof MailImpl) {
+                                oos.writeObject(((MailImpl)mc).getAttributesRaw());
+                            } else {
+                                HashMap temp = new HashMap();
+                                for (Iterator i = mc.getAttributeNames(); i.hasNext(); ) {
+                                    String hashKey = (String) i.next();
+                                    temp.put(hashKey,mc.getAttribute(hashKey));
+                                }
+                                oos.writeObject(temp);
+                            }
                             oos.flush();
                             ByteArrayInputStream attrInputStream =
                                 new ByteArrayInputStream(baos.toByteArray());
@@ -737,7 +747,16 @@
                         ByteArrayOutputStream baos = new ByteArrayOutputStream();
                         ObjectOutputStream oos = new ObjectOutputStream(baos);
                         try {
-                            oos.writeObject(((MailImpl)mc).getAttributesRaw());
+                            if (mc instanceof MailImpl) {
+                                oos.writeObject(((MailImpl)mc).getAttributesRaw());
+                            } else {
+                                HashMap temp = new HashMap();
+                                for (Iterator i = mc.getAttributeNames(); i.hasNext(); ) {
+                                    String hashKey = (String) i.next();
+                                    temp.put(hashKey,mc.getAttribute(hashKey));
+                                }
+                                oos.writeObject(temp);
+                            }
                             oos.flush();
                             ByteArrayInputStream attrInputStream =
                                 new ByteArrayInputStream(baos.toByteArray());
@@ -783,7 +802,7 @@
      * @param key the key of the message to retrieve
      * @return the mail corresponding to this key, null if none exists
      */
-    public MailImpl retrieve(String key) throws MessagingException {
+    public Mail retrieve(String key) throws MessagingException {
         if (DEEP_DEBUG) {
             System.err.println("retrieving " + key);
         }
@@ -932,7 +951,7 @@
      *
      * @param mail the message to be removed from the repository
      */
-    public void remove(MailImpl mail) throws MessagingException {
+    public void remove(Mail mail) throws MessagingException {
         remove(mail.getName());
     }
 
@@ -945,7 +964,7 @@
     public void remove(Collection mails) throws MessagingException {
         Iterator delList = mails.iterator();
         while (delList.hasNext()) {
-            remove((MailImpl)delList.next());
+            remove((Mail)delList.next());
         }
     }
 

Modified: james/server/trunk/src/java/org/apache/james/mailrepository/JDBCSpoolRepository.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/mailrepository/JDBCSpoolRepository.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/mailrepository/JDBCSpoolRepository.java (original)
+++ james/server/trunk/src/java/org/apache/james/mailrepository/JDBCSpoolRepository.java Fri Dec 30 02:26:48 2005
@@ -197,7 +197,7 @@
                 
                 if (shouldProcess && lock(next.key)) {
                     try {
-                        MailImpl mail = retrieve(next.key);
+                        Mail mail = retrieve(next.key);
                         // Retrieve can return null if the mail is no longer on the spool
                         // (i.e. another thread has gotten to it first).
                         // In this case we simply continue to the next key

Modified: james/server/trunk/src/java/org/apache/james/mailrepository/MBoxMailRepository.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/mailrepository/MBoxMailRepository.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/mailrepository/MBoxMailRepository.java (original)
+++ james/server/trunk/src/java/org/apache/james/mailrepository/MBoxMailRepository.java Fri Dec 30 02:26:48 2005
@@ -53,6 +53,7 @@
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.james.core.MailImpl;
 import org.apache.james.services.MailRepository;
+import org.apache.mailet.Mail;
 import org.apache.oro.text.regex.MalformedPatternException;
 import org.apache.oro.text.regex.Perl5Compiler;
 import org.apache.oro.text.regex.Pattern;
@@ -494,7 +495,7 @@
      * Store the given email in the current mbox file
      * @param mc The mail to store
      */
-    public void store(MailImpl mc) {
+    public void store(Mail mc) {
 
         if ((DEEP_DEBUG) && (getLogger().isDebugEnabled())) {
             StringBuffer logBuffer =
@@ -561,7 +562,7 @@
      * @param key
      * @return The mail found from the key. Returns null if the key is not found
      */
-    public MailImpl retrieve(String key) {
+    public Mail retrieve(String key) {
 
         loadKeys();
         MailImpl res = null;
@@ -592,7 +593,7 @@
      * Remove an existing message
      * @param mail
      */
-    public void remove(MailImpl mail) {
+    public void remove(Mail mail) {
         // Convert the message into a key
         Vector delVec = new Vector();
         delVec.addElement(mail);
@@ -690,7 +691,7 @@
                         String key;
                         while (mailList.hasNext()) {
                             // Attempt to find the current key in the array
-                            key = ((MailImpl)mailList.next()).getName();
+                            key = ((Mail)mailList.next()).getName();
                             if (key.equals(currentKey)) {
                                 // Don't write the message to disk
                                 foundKey = true;
@@ -729,7 +730,7 @@
             String key;
             while (mailList.hasNext()) {
                 // Attempt to find the current key in the array
-                key = ((MailImpl)mailList.next()).getName();
+                key = ((Mail)mailList.next()).getName();
                 mList.remove(key);
             }
 

Modified: james/server/trunk/src/java/org/apache/james/mailrepository/MailStoreSpoolRepository.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/mailrepository/MailStoreSpoolRepository.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/mailrepository/MailStoreSpoolRepository.java (original)
+++ james/server/trunk/src/java/org/apache/james/mailrepository/MailStoreSpoolRepository.java Fri Dec 30 02:26:48 2005
@@ -26,7 +26,6 @@
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
-import org.apache.james.core.MailImpl;
 import org.apache.james.services.SpoolRepository;
 import org.apache.mailet.Mail;
 
@@ -121,7 +120,7 @@
     /**
      * @see org.apache.james.services.MailRepository#store(org.apache.james.core.MailImpl)
      */
-    public void store(MailImpl mc) throws MessagingException {
+    public void store(Mail mc) throws MessagingException {
         spoolRep.store(mc);
     }
 
@@ -135,14 +134,14 @@
     /**
      * @see org.apache.james.services.MailRepository#retrieve(java.lang.String)
      */
-    public MailImpl retrieve(String key) throws MessagingException {
+    public Mail retrieve(String key) throws MessagingException {
         return spoolRep.retrieve(key);
     }
 
     /**
      * @see org.apache.james.services.MailRepository#remove(org.apache.james.core.MailImpl)
      */
-    public void remove(MailImpl mail) throws MessagingException {
+    public void remove(Mail mail) throws MessagingException {
         spoolRep.remove(mail);
     }
 

Modified: james/server/trunk/src/java/org/apache/james/pop3server/POP3Handler.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/pop3server/POP3Handler.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/pop3server/POP3Handler.java (original)
+++ james/server/trunk/src/java/org/apache/james/pop3server/POP3Handler.java Fri Dec 30 02:26:48 2005
@@ -22,7 +22,6 @@
 import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.commons.collections.ListUtils;
-
 import org.apache.james.Constants;
 import org.apache.james.core.MailImpl;
 import org.apache.james.services.MailRepository;
@@ -35,10 +34,13 @@
 import org.apache.mailet.Mail;
 
 import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
 
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
 import java.io.IOException;
+import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.net.Socket;
@@ -568,7 +570,7 @@
             int count = 0;
             try {
                 for (Iterator i = userMailbox.iterator(); i.hasNext(); ) {
-                    MailImpl mc = (MailImpl) i.next();
+                    Mail mc = (Mail) i.next();
                     if (mc != DELETED) {
                         size += mc.getMessageSize();
                         count++;
@@ -611,7 +613,7 @@
                 int count = 0;
                 try {
                     for (Iterator i = userMailbox.iterator(); i.hasNext(); ) {
-                        MailImpl mc = (MailImpl) i.next();
+                        Mail mc = (Mail) i.next();
                         if (mc != DELETED) {
                             size += mc.getMessageSize();
                             count++;
@@ -628,7 +630,7 @@
                     writeLoggedFlushedResponse(responseString);
                     count = 0;
                     for (Iterator i = userMailbox.iterator(); i.hasNext(); count++) {
-                        MailImpl mc = (MailImpl) i.next();
+                        Mail mc = (Mail) i.next();
 
                         if (mc != DELETED) {
                             responseBuffer =
@@ -649,7 +651,7 @@
                 int num = 0;
                 try {
                     num = Integer.parseInt(argument);
-                    MailImpl mc = (MailImpl) userMailbox.get(num);
+                    Mail mc = (Mail) userMailbox.get(num);
                     if (mc != DELETED) {
                         StringBuffer responseBuffer =
                             new StringBuffer(64)
@@ -715,7 +717,7 @@
                 writeLoggedFlushedResponse(responseString);
                 int count = 0;
                 for (Iterator i = userMailbox.iterator(); i.hasNext(); count++) {
-                    MailImpl mc = (MailImpl) i.next();
+                    Mail mc = (Mail) i.next();
                     if (mc != DELETED) {
                         StringBuffer responseBuffer =
                             new StringBuffer(64)
@@ -731,7 +733,7 @@
                 int num = 0;
                 try {
                     num = Integer.parseInt(argument);
-                    MailImpl mc = (MailImpl) userMailbox.get(num);
+                    Mail mc = (Mail) userMailbox.get(num);
                     if (mc != DELETED) {
                         StringBuffer responseBuffer =
                             new StringBuffer(64)
@@ -817,7 +819,7 @@
                 return;
             }
             try {
-                MailImpl mc = (MailImpl) userMailbox.get(num);
+                Mail mc = (Mail) userMailbox.get(num);
                 if (mc == DELETED) {
                     StringBuffer responseBuffer =
                         new StringBuffer(64)
@@ -887,7 +889,7 @@
                 return;
             }
             try {
-                MailImpl mc = (MailImpl) userMailbox.get(num);
+                Mail mc = (Mail) userMailbox.get(num);
                 if (mc != DELETED) {
                     responseString = OK_RESPONSE + " Message follows";
                     writeLoggedFlushedResponse(responseString);
@@ -896,7 +898,7 @@
                     nouts = new BytesWrittenResetOutputStream(nouts,
                                                               theWatchdog,
                                                               theConfigData.getResetLength());
-                    mc.writeMessageTo(nouts);
+                    mc.getMessage().writeTo(nouts);
                     nouts.flush();
                     // TODO: Is this an extra CRLF?
                     out.println();
@@ -960,7 +962,7 @@
                 return;
             }
             try {
-                MailImpl mc = (MailImpl) userMailbox.get(num);
+                Mail mc = (Mail) userMailbox.get(num);
                 if (mc != DELETED) {
                     responseString = OK_RESPONSE + " Message follows";
                     writeLoggedFlushedResponse(responseString);
@@ -973,7 +975,7 @@
                     nouts = new BytesWrittenResetOutputStream(nouts,
                                                               theWatchdog,
                                                               theConfigData.getResetLength());
-                    mc.writeContentTo(nouts, lines);
+                    writeMessageContentTo(mc.getMessage(),nouts,lines);
                     nouts.flush();
                     out.println(".");
                     out.flush();
@@ -1010,6 +1012,40 @@
     }
 
     /**
+     * Writes the content of the message, up to a total number of lines, out to 
+     * an OutputStream.
+     *
+     * @param out the OutputStream to which to write the content
+     * @param lines the number of lines to write to the stream
+     *
+     * @throws MessagingException if the MimeMessage is not set for this MailImpl
+     * @throws IOException if an error occurs while reading or writing from the stream
+     */
+    public void writeMessageContentTo(MimeMessage message, OutputStream out, int lines)
+        throws IOException, MessagingException {
+        String line;
+        BufferedReader br = null;
+        if (message != null) {
+            try {
+                br = new BufferedReader(new InputStreamReader(message.getInputStream()));
+                while (lines-- > 0) {
+                    if ((line = br.readLine()) == null) {
+                        break;
+                    }
+                    line += "\r\n";
+                    out.write(line.getBytes());
+                }
+            } finally {
+                if (br != null) {
+                    br.close();
+                }
+            }
+        } else {
+            throw new MessagingException("No message set for this MailImpl.");
+        }
+    }
+
+    /**
      * Handler method called upon receipt of a QUIT command.
      * This method handles cleanup of the POP3Handler state.
      *
@@ -1028,7 +1064,7 @@
         try {
             userInbox.remove(toBeRemoved);
             // for (Iterator it = toBeRemoved.iterator(); it.hasNext(); ) {
-            //    MailImpl mc = (MailImpl) it.next();
+            //    Mail mc = (Mail) it.next();
             //    userInbox.remove(mc.getName());
             //}
             responseString = OK_RESPONSE + " Apache James POP3 Server signing off.";

Modified: james/server/trunk/src/java/org/apache/james/services/MailRepository.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/services/MailRepository.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/services/MailRepository.java (original)
+++ james/server/trunk/src/java/org/apache/james/services/MailRepository.java Fri Dec 30 02:26:48 2005
@@ -17,7 +17,7 @@
 
 package org.apache.james.services;
 
-import org.apache.james.core.MailImpl;
+import org.apache.mailet.Mail;
 
 import javax.mail.MessagingException;
 
@@ -43,7 +43,7 @@
      *
      * @param mc the mail message to store
      */
-    void store(MailImpl mc) throws MessagingException;
+    void store(Mail mc) throws MessagingException;
 
     /**
      * List string keys of messages in repository.
@@ -60,14 +60,14 @@
      * @param key the key of the message to retrieve
      * @return the mail corresponding to this key, null if none exists
      */
-    MailImpl retrieve(String key) throws MessagingException;
+    Mail retrieve(String key) throws MessagingException;
 
     /**
      * Removes a specified message
      *
      * @param mail the message to be removed from the repository
      */
-    void remove(MailImpl mail) throws MessagingException;
+    void remove(Mail mail) throws MessagingException;
 
     /**
      * Remove an Collection of mails from the repository

Modified: james/server/trunk/src/java/org/apache/james/smtpserver/SMTPHandler.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/smtpserver/SMTPHandler.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/smtpserver/SMTPHandler.java (original)
+++ james/server/trunk/src/java/org/apache/james/smtpserver/SMTPHandler.java Fri Dec 30 02:26:48 2005
@@ -19,15 +19,15 @@
 
 import org.apache.avalon.cornerstone.services.connection.ConnectionHandler;
 import org.apache.avalon.excalibur.pool.Poolable;
+import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.james.Constants;
-import org.apache.james.core.MailImpl;
 import org.apache.james.util.CRLFTerminatedReader;
 import org.apache.james.util.InternetPrintWriter;
+import org.apache.james.util.mail.dsn.DSNStatus;
 import org.apache.james.util.watchdog.Watchdog;
 import org.apache.james.util.watchdog.WatchdogTarget;
-import org.apache.james.util.mail.dsn.DSNStatus;
 import org.apache.mailet.Mail;
 import org.apache.mailet.dates.RFC822DateFormat;
 
@@ -113,7 +113,7 @@
     /**
      * The MailImpl object set by the DATA command
      */
-    private MailImpl mail = null;
+    private Mail mail = null;
 
     /**
      * The session termination status
@@ -438,7 +438,9 @@
 
               //do the clean up
               if(mail != null) {
-                  mail.dispose();
+                  if (mail instanceof Disposable) {
+                      ((Disposable) mail).dispose();
+                  }
                   mail = null;
                   resetState();
 
@@ -604,7 +606,7 @@
      *
      * @param Mail the mail object
      */
-    public void sendMail(MailImpl mail) {
+    public void sendMail(Mail mail) {
         String responseString = null;
         try {
             setMail(mail);
@@ -699,9 +701,9 @@
     }
 
     /**
-     * @see org.apache.james.smtpserver.SMTPSession#setMail(MailImpl)
+     * @see org.apache.james.smtpserver.SMTPSession#setMail(Mail)
      */
-    public void setMail(MailImpl mail) {
+    public void setMail(Mail mail) {
         this.mail = mail;
         this.mode = MESSAGE_RECEIVED_MODE;
     }

Modified: james/server/trunk/src/java/org/apache/james/smtpserver/SMTPSession.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/smtpserver/SMTPSession.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/smtpserver/SMTPSession.java (original)
+++ james/server/trunk/src/java/org/apache/james/smtpserver/SMTPSession.java Fri Dec 30 02:26:48 2005
@@ -18,12 +18,12 @@
 package org.apache.james.smtpserver;
 
 
+import org.apache.james.util.watchdog.Watchdog;
 import org.apache.mailet.Mail;
-import org.apache.james.core.MailImpl;
-import java.util.HashMap;
+
 import java.io.IOException;
 import java.io.InputStream;
-import org.apache.james.util.watchdog.Watchdog;
+import java.util.HashMap;
 
 /**
  * All the handlers access this interface to communicate with
@@ -96,7 +96,7 @@
      *
      * @param mail MailImpl object
      */
-    void setMail(MailImpl mail);
+    void setMail(Mail mail);
 
     /**
      * Returns host name of the client

Modified: james/server/trunk/src/java/org/apache/james/transport/JamesSpoolManager.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/transport/JamesSpoolManager.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/transport/JamesSpoolManager.java (original)
+++ james/server/trunk/src/java/org/apache/james/transport/JamesSpoolManager.java Fri Dec 30 02:26:48 2005
@@ -27,7 +27,6 @@
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
-import org.apache.james.core.MailImpl;
 import org.apache.james.services.MailetLoader;
 import org.apache.james.services.MatcherLoader;
 import org.apache.james.services.SpoolRepository;
@@ -294,7 +293,7 @@
         while(active) {
             String key = null;
             try {
-                MailImpl mail = (MailImpl)spool.accept();
+                Mail mail = (Mail)spool.accept();
                 key = mail.getName();
                 if (getLogger().isDebugEnabled()) {
                     StringBuffer debugBuffer =
@@ -363,7 +362,7 @@
      *
      * @param mail the mail message to be processed
      */
-    protected void process(MailImpl mail) {
+    protected void process(Mail mail) {
         while (true) {
             String processorName = mail.getState();
             if (processorName.equals(Mail.GHOST)) {

Modified: james/server/trunk/src/java/org/apache/james/transport/LinearProcessor.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/transport/LinearProcessor.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/transport/LinearProcessor.java (original)
+++ james/server/trunk/src/java/org/apache/james/transport/LinearProcessor.java Fri Dec 30 02:26:48 2005
@@ -218,7 +218,7 @@
                         // will show up in the error store.
                         StringBuffer warnBuffer = new StringBuffer(256)
                                               .append("Message ")
-                                              .append(((MailImpl)mail).getName())
+                                              .append(mail.getName())
                                               .append(" reached the end of this processor, and is automatically deleted.  This may indicate a configuration error.");
                         LinearProcessor.this.getLogger().warn(warnBuffer.toString());
                     }
@@ -255,7 +255,7 @@
      * @throws IllegalStateException when this method is called before the processor lists have been closed
      *                                  or the spool has been initialized
      */
-    public void service(MailImpl mail) throws MessagingException {
+    public void service(Mail mail) throws MessagingException {
         if (spool == null) {
             throw new IllegalStateException("Attempt to service mail before the spool has been set to a non-null value");
         }
@@ -320,7 +320,7 @@
             for (i = 0; i < unprocessed.length; i++) {
                 if (unprocessed[i].size() > 0) {
                     //Get the first element from the queue, and remove it from there
-                    mail = (MailImpl)unprocessed[i].remove(0);
+                    mail = (Mail)unprocessed[i].remove(0);
                     break;
                 }
             }
@@ -393,7 +393,7 @@
                 // There are a mix of recipients and not recipients.
                 // We need to clone this message, put the notRecipients on the clone
                 // and store it in the next spot
-                MailImpl notMail = (MailImpl)mail.duplicate(newName(mail));
+                Mail notMail = new MailImpl(mail,newName(mail));
                 notMail.setRecipients(notRecipients);
                 unprocessed[i + 1].add(notMail);
                 //We have to set the reduce possible recipients on the old message
@@ -461,7 +461,7 @@
      * 
      * @return a new name
      */
-    private String newName(MailImpl mail) {
+    private String newName(Mail mail) {
         StringBuffer nameBuffer =
             new StringBuffer(64)
                     .append(mail.getName())

Modified: james/server/trunk/src/java/org/apache/james/transport/mailets/AbstractRedirect.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/transport/mailets/AbstractRedirect.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/transport/mailets/AbstractRedirect.java (original)
+++ james/server/trunk/src/java/org/apache/james/transport/mailets/AbstractRedirect.java Fri Dec 30 02:26:48 2005
@@ -463,7 +463,7 @@
      */
     protected void setRecipients(Mail newMail, Collection recipients, Mail originalMail) throws MessagingException {
         if (recipients != null) {
-            ((MailImpl) newMail).setRecipients(recipients);
+            newMail.setRecipients(recipients);
             if (isDebug) {
                 log("recipients set to: " + arrayToString(recipients.toArray()));
             }
@@ -703,12 +703,12 @@
      * If the requested value is null does nothing.
      * Is a "setX(Mail, Tx, Mail)" method.
      */
-    protected void setReversePath(Mail newMail, MailAddress reversePath, Mail originalMail) throws MessagingException {
+    protected void setReversePath(MailImpl newMail, MailAddress reversePath, Mail originalMail) throws MessagingException {
         if(reversePath != null) {
             if (reversePath == SpecialAddress.NULL) {
                 reversePath = null;
             }
-            ((MailImpl) newMail).setSender(reversePath);
+            newMail.setSender(reversePath);
             if (isDebug) {
                 log("reversePath set to: " + reversePath);
             }
@@ -1003,28 +1003,27 @@
         boolean keepMessageId = false;
 
         // duplicates the Mail object, to be able to modify the new mail keeping the original untouched
-        Mail newMail = ((MailImpl) originalMail).duplicate(newName((MailImpl) originalMail));
+        MailImpl newMail = new MailImpl(originalMail,newName(originalMail));
         // We don't need to use the original Remote Address and Host,
         // and doing so would likely cause a loop with spam detecting
         // matchers.
         try {
-            ((MailImpl) newMail).setRemoteAddr(java.net.InetAddress.getLocalHost().getHostAddress());
-            ((MailImpl) newMail).setRemoteHost(java.net.InetAddress.getLocalHost().getHostName());
+            newMail.setRemoteAddr(java.net.InetAddress.getLocalHost().getHostAddress());
+            newMail.setRemoteHost(java.net.InetAddress.getLocalHost().getHostName());
         } catch (java.net.UnknownHostException _) {
-            ((MailImpl) newMail).setRemoteAddr("127.0.0.1");
-            ((MailImpl) newMail).setRemoteHost("localhost");
+            newMail.setRemoteAddr("127.0.0.1");
+            newMail.setRemoteHost("localhost");
         }
 
         if (isDebug) {
-            MailImpl newMailImpl = (MailImpl) newMail;
-            log("New mail - sender: " + newMailImpl.getSender()
-                       + ", recipients: " + arrayToString(newMailImpl.getRecipients().toArray())
-                       + ", name: " + newMailImpl.getName()
-                       + ", remoteHost: " + newMailImpl.getRemoteHost()
-                       + ", remoteAddr: " + newMailImpl.getRemoteAddr()
-                       + ", state: " + newMailImpl.getState()
-                       + ", lastUpdated: " + newMailImpl.getLastUpdated()
-                       + ", errorMessage: " + newMailImpl.getErrorMessage());
+            log("New mail - sender: " + newMail.getSender()
+                       + ", recipients: " + arrayToString(newMail.getRecipients().toArray())
+                       + ", name: " + newMail.getName()
+                       + ", remoteHost: " + newMail.getRemoteHost()
+                       + ", remoteAddr: " + newMail.getRemoteAddr()
+                       + ", state: " + newMail.getState()
+                       + ", lastUpdated: " + newMail.getLastUpdated()
+                       + ", errorMessage: " + newMail.getErrorMessage());
         }
 
         //Create the message
@@ -1089,7 +1088,7 @@
             StringBuffer logBuffer = new StringBuffer(256)
                                     .append(getMailetName())
                                     .append(" mailet cannot forward ")
-                                    .append(((MailImpl) originalMail).getName())
+                                    .append(originalMail.getName())
                                     .append(". Invalid sender domain for ")
                                     .append(newMail.getSender())
                                     .append(". Consider using the Resend mailet ")
@@ -1110,7 +1109,7 @@
      * @param mail the mail to use as the basis for the new mail name
      * @return a new name
      */
-    private String newName(MailImpl mail) throws MessagingException {
+    private String newName(Mail mail) throws MessagingException {
         String oldName = mail.getName();
         
         // Checking if the original mail name is too long, perhaps because of a
@@ -1212,60 +1211,60 @@
         java.io.ByteArrayOutputStream bodyOs = new java.io.ByteArrayOutputStream();
 
         try {
-            // Get the message as a stream.  This will encode
-            // objects as necessary, and we have some overhead from
-            // decoding and re-encoding the stream.  I'd prefer the
-            // raw stream, but see the WARNING below.
-            bos = javax.mail.internet.MimeUtility.encode(bodyOs, message.getEncoding());
-            bis = message.getInputStream();
-        } catch(javax.activation.UnsupportedDataTypeException udte) {
-            /* If we get an UnsupportedDataTypeException try using
-             * the raw input stream as a "best attempt" at rendering
-             * a message.
-             *
-             * WARNING: JavaMail v1.3 getRawInputStream() returns
-             * INVALID (unchanged) content for a changed message.
-             * getInputStream() works properly, but in this case
-             * has failed due to a missing DataHandler.
-             *
-             * MimeMessage.getRawInputStream() may throw a "no
-             * content" MessagingException.  In JavaMail v1.3, when
-             * you initially create a message using MimeMessage
-             * APIs, there is no raw content available.
-             * getInputStream() works, but getRawInputStream()
-             * throws an exception.  If we catch that exception,
-             * throw the UDTE.  It should mean that someone has
-             * locally constructed a message part for which JavaMail
-             * doesn't have a DataHandler.
-             */
-
-            try {
-                bis = message.getRawInputStream();
-                bos = bodyOs;
-            } catch(javax.mail.MessagingException _) {
-                throw udte;
-            }
-        }
-        catch(javax.mail.MessagingException me) {
-            /* This could be another kind of MessagingException
-             * thrown by MimeMessage.getInputStream(), such as a
-             * javax.mail.internet.ParseException.
-             *
-             * The ParseException is precisely one of the reasons
-             * why the getRawInputStream() method exists, so that we
-             * can continue to stream the content, even if we cannot
-             * handle it.  Again, if we get an exception, we throw
-             * the one that caused us to call getRawInputStream().
-             */
             try {
-                bis = message.getRawInputStream();
-                bos = bodyOs;
-            } catch(javax.mail.MessagingException _) {
-                throw me;
+                // Get the message as a stream.  This will encode
+                // objects as necessary, and we have some overhead from
+                // decoding and re-encoding the stream.  I'd prefer the
+                // raw stream, but see the WARNING below.
+                bos = javax.mail.internet.MimeUtility.encode(bodyOs, message.getEncoding());
+                bis = message.getInputStream();
+            } catch(javax.activation.UnsupportedDataTypeException udte) {
+                /* If we get an UnsupportedDataTypeException try using
+                 * the raw input stream as a "best attempt" at rendering
+                 * a message.
+                 *
+                 * WARNING: JavaMail v1.3 getRawInputStream() returns
+                 * INVALID (unchanged) content for a changed message.
+                 * getInputStream() works properly, but in this case
+                 * has failed due to a missing DataHandler.
+                 *
+                 * MimeMessage.getRawInputStream() may throw a "no
+                 * content" MessagingException.  In JavaMail v1.3, when
+                 * you initially create a message using MimeMessage
+                 * APIs, there is no raw content available.
+                 * getInputStream() works, but getRawInputStream()
+                 * throws an exception.  If we catch that exception,
+                 * throw the UDTE.  It should mean that someone has
+                 * locally constructed a message part for which JavaMail
+                 * doesn't have a DataHandler.
+                 */
+    
+                try {
+                    bis = message.getRawInputStream();
+                    bos = bodyOs;
+                } catch(javax.mail.MessagingException _) {
+                    throw udte;
+                }
+            }
+            catch(javax.mail.MessagingException me) {
+                /* This could be another kind of MessagingException
+                 * thrown by MimeMessage.getInputStream(), such as a
+                 * javax.mail.internet.ParseException.
+                 *
+                 * The ParseException is precisely one of the reasons
+                 * why the getRawInputStream() method exists, so that we
+                 * can continue to stream the content, even if we cannot
+                 * handle it.  Again, if we get an exception, we throw
+                 * the one that caused us to call getRawInputStream().
+                 */
+                try {
+                    bis = message.getRawInputStream();
+                    bos = bodyOs;
+                } catch(javax.mail.MessagingException _) {
+                    throw me;
+                }
             }
-        }
 
-        try {
             byte[] block = new byte[1024];
             int read = 0;
             while ((read = bis.read(block)) > -1) {

Modified: james/server/trunk/src/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java (original)
+++ james/server/trunk/src/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java Fri Dec 30 02:26:48 2005
@@ -1,5 +1,5 @@
 /***********************************************************************
- * Copyright (c) 2000-2004 The Apache Software Foundation.             *
+ * Copyright (c) 2000-2005 The Apache Software Foundation.             *
  * All rights reserved.                                                *
  * ------------------------------------------------------------------- *
  * Licensed under the Apache License, Version 2.0 (the "License"); you *
@@ -17,30 +17,27 @@
 
 package org.apache.james.transport.mailets;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import javax.mail.MessagingException;
-import javax.mail.internet.ParseException;
-
 import org.apache.james.core.MailImpl;
 import org.apache.james.util.XMLResources;
-
 import org.apache.mailet.GenericMailet;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
-
-import org.apache.oro.text.regex.MalformedPatternException;
 import org.apache.oro.text.regex.MatchResult;
 import org.apache.oro.text.regex.Pattern;
 import org.apache.oro.text.regex.Perl5Compiler;
 import org.apache.oro.text.regex.Perl5Matcher;
 
+import javax.mail.MessagingException;
+import javax.mail.internet.ParseException;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.StringTokenizer;
+
 /**
  * Provides an abstraction of common functionality needed for implementing
  * a Virtual User Table. Override the <code>mapRecipients</code> method to
@@ -160,7 +157,7 @@
             // getMailetContext().sendMail(mail.getSender(), recipientsToAddForward, mail.getMessage());
 
             // duplicates the Mail object, to be able to modify the new mail keeping the original untouched
-            MailImpl newMail = (MailImpl) ((MailImpl) mail).duplicate(newName((MailImpl) mail));
+            MailImpl newMail = new MailImpl(mail,newName(mail));
             try {
                 newMail.setRemoteAddr(java.net.InetAddress.getLocalHost().getHostAddress());
                 newMail.setRemoteHost(java.net.InetAddress.getLocalHost().getHostName());
@@ -281,7 +278,7 @@
    * @param mail the mail to use as the basis for the new mail name
    * @return a new name
    */
-  private String newName(MailImpl mail) throws MessagingException {
+  private String newName(Mail mail) throws MessagingException {
       String oldName = mail.getName();
 
         // Checking if the original mail name is too long, perhaps because of a

Modified: james/server/trunk/src/java/org/apache/james/transport/mailets/AddFooter.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/transport/mailets/AddFooter.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/transport/mailets/AddFooter.java (original)
+++ james/server/trunk/src/java/org/apache/james/transport/mailets/AddFooter.java Fri Dec 30 02:26:48 2005
@@ -1,5 +1,5 @@
 /***********************************************************************
- * Copyright (c) 2000-2004 The Apache Software Foundation.             *
+ * Copyright (c) 2000-2005 The Apache Software Foundation.             *
  * All rights reserved.                                                *
  * ------------------------------------------------------------------- *
  * Licensed under the Apache License, Version 2.0 (the "License"); you *
@@ -17,7 +17,6 @@
 
 package org.apache.james.transport.mailets;
 
-import org.apache.james.core.MailImpl;
 import org.apache.mailet.GenericMailet;
 import org.apache.mailet.Mail;
 
@@ -26,6 +25,7 @@
 import javax.mail.internet.MimeMessage;
 import javax.mail.internet.MimeMultipart;
 import javax.mail.internet.MimePart;
+
 import java.io.IOException;
 import java.util.StringTokenizer;
 
@@ -59,7 +59,7 @@
     public void service(Mail mail) throws MessagingException {
         try {
             MimeMessage message = mail.getMessage();
-//            log("Trying to add footer to mail " + ((MailImpl)mail).getName());
+//            log("Trying to add footer to mail " + mail.getName());
             if (attachFooter(message)) {
                 message.saveChanges();
 //                log("Message after saving: " + message.getContent().toString());
@@ -91,7 +91,7 @@
                 log("Message from stream: " + bodyOs.toString());
                 */
             } else {
-                log("Unable to add footer to mail " + ((MailImpl)mail).getName());
+                log("Unable to add footer to mail " + mail.getName());
             }
         } catch (IOException ioe) {
             throw new MessagingException("Could not read message", ioe);

Modified: james/server/trunk/src/java/org/apache/james/transport/mailets/CommandListservFooter.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/transport/mailets/CommandListservFooter.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/transport/mailets/CommandListservFooter.java (original)
+++ james/server/trunk/src/java/org/apache/james/transport/mailets/CommandListservFooter.java Fri Dec 30 02:26:48 2005
@@ -19,8 +19,6 @@
 
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.james.util.XMLResources;
-
-import org.apache.james.core.MailImpl;
 import org.apache.mailet.GenericMailet;
 import org.apache.mailet.Mail;
 import org.apache.oro.text.regex.MalformedPatternException;
@@ -35,6 +33,7 @@
 import javax.mail.internet.MimeMessage;
 import javax.mail.internet.MimeMultipart;
 import javax.mail.internet.MimePart;
+
 import java.io.IOException;
 
 
@@ -111,7 +110,7 @@
     public void service(Mail mail) throws MessagingException {
         try {
             MimeMessage message = mail.getMessage();
-//            log("Trying to add footer to mail " + ((MailImpl)mail).getName());
+//            log("Trying to add footer to mail " + mail.getName());
             if (attachFooter(message)) {
                 message.saveChanges();
 //                log("Message after saving: " + message.getContent().toString());
@@ -143,7 +142,7 @@
                 log("Message from stream: " + bodyOs.toString());
                 */
             } else {
-                log("Unable to add footer to mail " + ((MailImpl)mail).getName());
+                log("Unable to add footer to mail " + mail.getName());
             }
         } catch (IOException ioe) {
             throw new MessagingException("Could not read message", ioe);

Modified: james/server/trunk/src/java/org/apache/james/transport/mailets/DSNBounce.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/transport/mailets/DSNBounce.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/transport/mailets/DSNBounce.java (original)
+++ james/server/trunk/src/java/org/apache/james/transport/mailets/DSNBounce.java Fri Dec 30 02:26:48 2005
@@ -17,6 +17,27 @@
 
 package org.apache.james.transport.mailets;
 
+import org.apache.james.Constants;
+import org.apache.james.core.MailImpl;
+import org.apache.james.util.mail.MimeMultipartReport;
+import org.apache.james.util.mail.dsn.DSNStatus;
+import org.apache.mailet.Mail;
+import org.apache.mailet.MailAddress;
+import org.apache.mailet.RFC2822Headers;
+import org.apache.mailet.dates.RFC822DateFormat;
+import org.apache.oro.text.regex.MalformedPatternException;
+import org.apache.oro.text.regex.MatchResult;
+import org.apache.oro.text.regex.Pattern;
+import org.apache.oro.text.regex.Perl5Compiler;
+import org.apache.oro.text.regex.Perl5Matcher;
+
+import javax.mail.MessagingException;
+import javax.mail.SendFailedException;
+import javax.mail.Session;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.net.ConnectException;
@@ -28,28 +49,6 @@
 import java.util.HashSet;
 import java.util.Iterator;
 
-import javax.mail.MessagingException;
-import javax.mail.SendFailedException;
-import javax.mail.Session;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeBodyPart;
-import javax.mail.internet.MimeMessage;
-
-import org.apache.james.core.MailImpl;
-import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
-import org.apache.mailet.RFC2822Headers;
-import org.apache.mailet.dates.RFC822DateFormat;
-import org.apache.james.Constants;
-import org.apache.james.util.mail.MimeMultipartReport;
-import org.apache.james.util.mail.dsn.DSNStatus;
-
-import org.apache.oro.text.regex.MalformedPatternException;
-import org.apache.oro.text.regex.Pattern;
-import org.apache.oro.text.regex.Perl5Compiler;
-import org.apache.oro.text.regex.Perl5Matcher;
-import org.apache.oro.text.regex.MatchResult;
-
 
 
 
@@ -150,7 +149,7 @@
 
 
         // duplicates the Mail object, to be able to modify the new mail keeping the original untouched
-        MailImpl newMail = (MailImpl) ((MailImpl) originalMail).duplicate(newName((MailImpl) originalMail));
+        MailImpl newMail = new MailImpl(originalMail,newName(originalMail));
         // We don't need to use the original Remote Address and Host,
         // and doing so would likely cause a loop with spam detecting
         // matchers.
@@ -388,7 +387,7 @@
             
                 //optional: last attempt
                 out.println("Last-Attempt-Date: "+
-                            rfc822DateFormat.format(((MailImpl)originalMail).getLastUpdated()));
+                            rfc822DateFormat.format(originalMail.getLastUpdated()));
 
                 //optional: retry until
                 //only for 'delayed' reports .. but we don't report this (at least until now)
@@ -580,7 +579,7 @@
      * @param mail the mail to use as the basis for the new mail name
      * @return a new name
      */
-    protected String newName(MailImpl mail) throws MessagingException {
+    protected String newName(Mail mail) throws MessagingException {
         String oldName = mail.getName();
 
         // Checking if the original mail name is too long, perhaps because of a

Modified: james/server/trunk/src/java/org/apache/james/transport/mailets/FromRepository.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/transport/mailets/FromRepository.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/transport/mailets/FromRepository.java (original)
+++ james/server/trunk/src/java/org/apache/james/transport/mailets/FromRepository.java Fri Dec 30 02:26:48 2005
@@ -18,14 +18,14 @@
 package org.apache.james.transport.mailets;
 
 import org.apache.avalon.cornerstone.services.store.Store;
+import org.apache.avalon.framework.configuration.DefaultConfiguration;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.configuration.DefaultConfiguration;
 import org.apache.james.Constants;
-import org.apache.james.core.MailImpl;
 import org.apache.james.services.MailRepository;
 import org.apache.mailet.GenericMailet;
 import org.apache.mailet.Mail;
+
 import javax.mail.MessagingException;
 
 import java.util.Iterator;
@@ -104,7 +104,7 @@
         while (list.hasNext()) {
             String key = (String) list.next();
             try {
-                MailImpl mail =  repository.retrieve(key);
+                Mail mail =  repository.retrieve(key);
                 if (mail != null && mail.getRecipients() != null) {
                     log((new StringBuffer(160).append("Spooling mail ").append(mail.getName()).append(" from ").append(repositoryPath)).toString());
 

Modified: james/server/trunk/src/java/org/apache/james/transport/mailets/RemoteDelivery.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/transport/mailets/RemoteDelivery.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/transport/mailets/RemoteDelivery.java (original)
+++ james/server/trunk/src/java/org/apache/james/transport/mailets/RemoteDelivery.java Fri Dec 30 02:26:48 2005
@@ -17,6 +17,39 @@
 
 package org.apache.james.transport.mailets;
 
+import org.apache.avalon.cornerstone.services.store.Store;
+import org.apache.avalon.framework.configuration.DefaultConfiguration;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.james.Constants;
+import org.apache.james.services.SpoolRepository;
+import org.apache.mailet.GenericMailet;
+import org.apache.mailet.HostAddress;
+import org.apache.mailet.Mail;
+import org.apache.mailet.MailAddress;
+import org.apache.mailet.MailetContext;
+import org.apache.oro.text.regex.MalformedPatternException;
+import org.apache.oro.text.regex.MatchResult;
+import org.apache.oro.text.regex.Pattern;
+import org.apache.oro.text.regex.Perl5Compiler;
+import org.apache.oro.text.regex.Perl5Matcher;
+
+import com.sun.mail.smtp.SMTPAddressFailedException;
+import com.sun.mail.smtp.SMTPAddressSucceededException;
+import com.sun.mail.smtp.SMTPSendFailedException;
+import com.sun.mail.smtp.SMTPTransport;
+
+import javax.mail.Address;
+import javax.mail.MessagingException;
+import javax.mail.SendFailedException;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+import javax.mail.internet.MimePart;
+import javax.mail.internet.ParseException;
+
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
@@ -24,52 +57,17 @@
 import java.net.InetAddress;
 import java.net.SocketException;
 import java.net.UnknownHostException;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Date;
-import java.util.Hashtable;
 import java.util.HashMap;
+import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Locale;
 import java.util.Properties;
 import java.util.StringTokenizer;
 import java.util.Vector;
-import java.util.ArrayList;
-
-import javax.mail.Address;
-import javax.mail.MessagingException;
-import javax.mail.SendFailedException;
-import javax.mail.Session;
-import javax.mail.Transport;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.MimeMultipart;
-import javax.mail.internet.MimePart;
-import javax.mail.internet.ParseException;
-
-import com.sun.mail.smtp.SMTPSendFailedException;
-import com.sun.mail.smtp.SMTPAddressFailedException;
-import com.sun.mail.smtp.SMTPAddressSucceededException;
-import com.sun.mail.smtp.SMTPTransport;
-
-import org.apache.avalon.cornerstone.services.store.Store;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.configuration.DefaultConfiguration;
-import org.apache.james.Constants;
-import org.apache.james.core.MailImpl;
-import org.apache.james.services.SpoolRepository;
-import org.apache.mailet.MailetContext;
-import org.apache.mailet.GenericMailet;
-import org.apache.mailet.HostAddress;
-import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
-
-import org.apache.oro.text.regex.MalformedPatternException;
-import org.apache.oro.text.regex.Pattern;
-import org.apache.oro.text.regex.Perl5Compiler;
-import org.apache.oro.text.regex.Perl5Matcher;
-import org.apache.oro.text.regex.MatchResult;
 
 
 /**
@@ -402,7 +400,7 @@
      * @param session javax.mail.Session
      * @return boolean Whether the delivery was successful and the message can be deleted
      */
-    private boolean deliver(MailImpl mail, Session session) {
+    private boolean deliver(Mail mail, Session session) {
         try {
             if (isDebug) {
                 log("Attempting to deliver " + mail.getName());
@@ -791,7 +789,7 @@
      * @param boolean permanent
      * @return boolean Whether the message failed fully and can be deleted
      */
-    private boolean failMessage(MailImpl mail, MessagingException ex, boolean permanent) {
+    private boolean failMessage(Mail mail, MessagingException ex, boolean permanent) {
         StringWriter sout = new StringWriter();
         PrintWriter out = new PrintWriter(sout, true);
         if (permanent) {
@@ -864,7 +862,7 @@
         return true;
     }
 
-    private void bounce(MailImpl mail, MessagingException ex) {
+    private void bounce(Mail mail, MessagingException ex) {
         StringWriter sout = new StringWriter();
         PrintWriter out = new PrintWriter(sout, true);
         String machine = "[unknown]";
@@ -930,9 +928,7 @@
      *
      * @param mail org.apache.mailet.Mail
      */
-    public void service(Mail genericmail) throws MessagingException{
-        MailImpl mail = (MailImpl)genericmail;
-
+    public void service(Mail mail) throws MessagingException{
         // Do I want to give the internal key, or the message's Message ID
         if (isDebug) {
             log("Remotely delivering mail " + mail.getName());
@@ -1073,7 +1069,7 @@
         try {
             while (!Thread.currentThread().interrupted() && !destroyed) {
                 try {
-                    MailImpl mail = (MailImpl)outgoing.accept(delayFilter);
+                    Mail mail = (Mail)outgoing.accept(delayFilter);
                     String key = mail.getName();
                     try {
                         if (isDebug) {

Modified: james/server/trunk/src/java/org/apache/james/transport/mailets/ToMultiRepository.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/transport/mailets/ToMultiRepository.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/transport/mailets/ToMultiRepository.java (original)
+++ james/server/trunk/src/java/org/apache/james/transport/mailets/ToMultiRepository.java Fri Dec 30 02:26:48 2005
@@ -215,7 +215,7 @@
 
         Collection recipients = new HashSet();
         recipients.add(recipient);
-        MailImpl mailImpl = new MailImpl(getId(), sender, recipients, message);
+        Mail mail = new MailImpl(getId(), sender, recipients, message);
         MailRepository userInbox = getRepository(username);
         if (userInbox == null) {
             StringBuffer errorBuffer = new StringBuffer(128).append(
@@ -223,7 +223,7 @@
                     " was not found on this server.");
             throw new MessagingException(errorBuffer.toString());
         }
-        userInbox.store(mailImpl);
+        userInbox.store(mail);
     }
 
     /**

Modified: james/server/trunk/src/java/org/apache/james/transport/mailets/ToRepository.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/transport/mailets/ToRepository.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/transport/mailets/ToRepository.java (original)
+++ james/server/trunk/src/java/org/apache/james/transport/mailets/ToRepository.java Fri Dec 30 02:26:48 2005
@@ -18,11 +18,10 @@
 package org.apache.james.transport.mailets;
 
 import org.apache.avalon.cornerstone.services.store.Store;
+import org.apache.avalon.framework.configuration.DefaultConfiguration;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.configuration.DefaultConfiguration;
 import org.apache.james.Constants;
-import org.apache.james.core.MailImpl;
 import org.apache.james.services.MailRepository;
 import org.apache.mailet.GenericMailet;
 import org.apache.mailet.Mail;
@@ -86,8 +85,7 @@
      *
      * @param mail the mail to process
      */
-    public void service(Mail genericmail) throws javax.mail.MessagingException {
-        MailImpl mail = (MailImpl)genericmail;
+    public void service(Mail mail) throws javax.mail.MessagingException {
         StringBuffer logBuffer =
             new StringBuffer(160)
                     .append("Storing mail ")

Modified: james/server/trunk/src/java/org/apache/james/transport/matchers/AbstractStorageQuota.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/transport/matchers/AbstractStorageQuota.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/transport/matchers/AbstractStorageQuota.java (original)
+++ james/server/trunk/src/java/org/apache/james/transport/matchers/AbstractStorageQuota.java Fri Dec 30 02:26:48 2005
@@ -17,25 +17,22 @@
 
 package org.apache.james.transport.matchers;
 
-import java.util.Iterator;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
-
-
 import org.apache.james.Constants;
-import org.apache.james.core.MailImpl;
-import org.apache.james.services.MailServer;
+import org.apache.james.services.JamesUser;
 import org.apache.james.services.MailRepository;
-import org.apache.james.services.UsersStore;
+import org.apache.james.services.MailServer;
 import org.apache.james.services.UsersRepository;
-import org.apache.james.services.JamesUser;
-
+import org.apache.james.services.UsersStore;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.MailetContext;
 
 import javax.mail.MessagingException;
 
+import java.util.Iterator;
+
 /**
  * <P>Abstract matcher checking whether a recipient has exceeded a maximum allowed
  * <I>storage</I> quota for messages standing in his inbox.</P>
@@ -101,7 +98,7 @@
         MailRepository userInbox = mailServer.getUserInbox(getPrimaryName(recipient.getUser()));
         for (Iterator it = userInbox.list(); it.hasNext(); ) {
             String key = (String) it.next();
-            MailImpl mc = userInbox.retrieve(key);
+            Mail mc = userInbox.retrieve(key);
             // Retrieve can return null if the mail is no longer in the store.
             if (mc != null) try {
                 size += mc.getMessageSize();

Modified: james/server/trunk/src/java/org/apache/mailet/Mail.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/mailet/Mail.java?rev=360063&r1=360062&r2=360063&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/mailet/Mail.java (original)
+++ james/server/trunk/src/java/org/apache/mailet/Mail.java Fri Dec 30 02:26:48 2005
@@ -20,6 +20,7 @@
 import javax.mail.internet.MimeMessage;
 import java.io.Serializable;
 import java.util.Collection;
+import java.util.Date;
 import java.util.Iterator;
 
 /**
@@ -37,6 +38,20 @@
     String ERROR = "error";
     String TRANSPORT = "transport";
     /**
+     * Returns the message name of this message
+     * 
+     * @return the message name
+     * @since Mailet API v2.3
+     */
+    String getName();
+    /**
+     * Set the message name of this message
+     * 
+     * @param newName new name
+     * @since Mailet API v2.3
+     */
+    void setName(String newName);
+    /**
      * Returns the MimeMessage stored in this message
      *
      * @return the MimeMessage that this Mail object wraps
@@ -170,4 +185,19 @@
      * @since Mailet API v2.1
      */
     Serializable setAttribute(String name, Serializable object);
+    /**
+     * @return message size
+     * @since Mailet API v2.3
+     */
+    long getMessageSize() throws MessagingException;
+    /**
+     * @return the last update date
+     * @since Mailet API v2.3
+     */
+    Date getLastUpdated();
+    /**
+     * @param lastUpdated the new last updated date
+     * @since Mailet API v2.3
+     */
+    void setLastUpdated(Date lastUpdated);
 }



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