noel        2003/08/28 09:22:37

  Modified:    src/java/org/apache/james/mailrepository Tag: branch_2_1_fcs
                        AvalonMailRepository.java
                        AvalonSpoolRepository.java JDBCMailRepository.java
                        JDBCSpoolRepository.java
               src/java/org/apache/james/transport/mailets Tag:
                        branch_2_1_fcs RemoteDelivery.java
                        ToRepository.java
               src/java/org/apache/james/transport/matchers Tag:
                        branch_2_1_fcs AbstractStorageQuota.java
               src/java/org/apache/james/services Tag: branch_2_1_fcs
                        MailRepository.java
  Log:
  MailRepository methods now throw MessagingException instead using RuntimeException.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.20.4.8  +22 -9     
james-server/src/java/org/apache/james/mailrepository/AvalonMailRepository.java
  
  Index: AvalonMailRepository.java
  ===================================================================
  RCS file: 
/home/cvs/james-server/src/java/org/apache/james/mailrepository/AvalonMailRepository.java,v
  retrieving revision 1.20.4.7
  retrieving revision 1.20.4.8
  diff -u -r1.20.4.7 -r1.20.4.8
  --- AvalonMailRepository.java 26 May 2003 06:00:50 -0000      1.20.4.7
  +++ AvalonMailRepository.java 28 Aug 2003 16:22:37 -0000      1.20.4.8
  @@ -74,11 +74,11 @@
   import org.apache.james.core.MailImpl;
   import org.apache.james.core.MimeMessageWrapper;
   import org.apache.james.services.MailRepository;
  -import org.apache.james.services.MailStore;
   import org.apache.james.util.Lock;
   
   import java.io.OutputStream;
   import java.util.*;
  +import javax.mail.MessagingException;
   
   /**
    * Implementation of a MailRepository on a FileSystem.
  @@ -106,7 +106,6 @@
       private Store store;
       private StreamRepository sr;
       private ObjectRepository or;
  -    private MailStore mailstore;
       private String destination;
       private Set keys;
   
  @@ -277,7 +276,7 @@
        *
        * @param mc the mail message to store
        */
  -    public void store(MailImpl mc) {
  +    public void store(MailImpl mc) throws MessagingException {
           try {
               String key = mc.getName();
               //Remember whether this key was locked
  @@ -352,7 +351,7 @@
           } catch (Exception e) {
               getLogger().error("Exception storing mail: " + e);
               e.printStackTrace();
  -            throw new RuntimeException("Exception caught while storing Message 
Container: " + e);
  +            throw new MessagingException("Exception caught while storing Message 
Container: " + e);
           }
       }
   
  @@ -363,7 +362,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) {
  +    public MailImpl retrieve(String key) throws MessagingException {
           if ((DEEP_DEBUG) && (getLogger().isDebugEnabled())) {
               getLogger().debug("Retrieving mail: " + key);
           }
  @@ -387,7 +386,7 @@
               return mc;
           } catch (Exception me) {
               getLogger().error("Exception retrieving mail: " + me);
  -            throw new RuntimeException("Exception while retrieving mail: " + 
me.getMessage());
  +            throw new MessagingException("Exception while retrieving mail: " + 
me.getMessage());
           }
       }
   
  @@ -396,16 +395,30 @@
        *
        * @param mail the message to be removed from the repository
        */
  -    public void remove(MailImpl mail) {
  +    public void remove(MailImpl mail) throws MessagingException {
           remove(mail.getName());
       }
   
  +
  +    /**
  +     * Removes a list of mails from the repository
  +     * @param mails The list of <code>MailImpl</code>'s to delete
  +     * @throws MessagingException
  +     * @since 2.2.0
  +     */
  +    public void remove(Collection mails) throws MessagingException {
  +        Iterator delList = mails.iterator();
  +        while (delList.hasNext()) {
  +            remove((MailImpl)delList.next());
  +        }
  +    }
  +
       /**
        * Removes a message identified by key.
        *
        * @param key the key of the message to be removed from the repository
        */
  -    public void remove(String key) {
  +    public void remove(String key) throws MessagingException {
           if (lock(key)) {
               try {
                   keys.remove(key);
  @@ -420,7 +433,7 @@
                           .append("Cannot lock ")
                           .append(key)
                           .append(" to remove it");
  -            throw new RuntimeException(exceptionBuffer.toString());
  +            throw new MessagingException(exceptionBuffer.toString());
           }
       }
   
  
  
  
  1.7.4.5   +7 -1      
james-server/src/java/org/apache/james/mailrepository/AvalonSpoolRepository.java
  
  Index: AvalonSpoolRepository.java
  ===================================================================
  RCS file: 
/home/cvs/james-server/src/java/org/apache/james/mailrepository/AvalonSpoolRepository.java,v
  retrieving revision 1.7.4.4
  retrieving revision 1.7.4.5
  diff -u -r1.7.4.4 -r1.7.4.5
  --- AvalonSpoolRepository.java        24 Jun 2003 21:10:44 -0000      1.7.4.4
  +++ AvalonSpoolRepository.java        28 Aug 2003 16:22:37 -0000      1.7.4.5
  @@ -159,9 +159,15 @@
                       //We have a lock on this object... let's grab the message
                       //  and see if it's a valid time.
   
  +                    MailImpl mail = null;
  +                    try {
  +                        mail = retrieve(s);
  +                    } catch (javax.mail.MessagingException e) {
  +                        getLogger().error("Exception during retrieve -- skipping 
item " + s, e);
  +                    }
                       // Retrieve can return null if the mail is no longer in the 
store.
  +                    // Or it could have throw an exception, which would would have 
logged.
                       // In this case we simply continue to the next key
  -                    MailImpl mail = retrieve(s);
                       if (mail == null) {
                           continue;
                       }
  
  
  
  1.30.4.9  +26 -12    
james-server/src/java/org/apache/james/mailrepository/JDBCMailRepository.java
  
  Index: JDBCMailRepository.java
  ===================================================================
  RCS file: 
/home/cvs/james-server/src/java/org/apache/james/mailrepository/JDBCMailRepository.java,v
  retrieving revision 1.30.4.8
  retrieving revision 1.30.4.9
  diff -u -r1.30.4.8 -r1.30.4.9
  --- JDBCMailRepository.java   17 Jul 2003 13:26:12 -0000      1.30.4.8
  +++ JDBCMailRepository.java   28 Aug 2003 16:22:37 -0000      1.30.4.9
  @@ -84,6 +84,7 @@
   import org.apache.james.util.SqlResources;
   import org.apache.mailet.MailAddress;
   
  +import javax.mail.MessagingException;
   import javax.mail.internet.MimeMessage;
   import java.io.ByteArrayInputStream;
   import java.io.ByteArrayOutputStream;
  @@ -479,7 +480,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) {
  +    public void store(MailImpl mc) throws MessagingException {
           Connection conn = null;
           try {
               conn = datasource.getConnection();
  @@ -709,7 +710,7 @@
               }
           } catch (Exception e) {
               e.printStackTrace();
  -            throw new RuntimeException("Exception caught while storing mail 
Container: " + e);
  +            throw new MessagingException("Exception caught while storing mail 
Container: " + e);
           } finally {
               theJDBCUtil.closeJDBCConnection(conn);
           }
  @@ -722,7 +723,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) {
  +    public MailImpl retrieve(String key) throws MessagingException {
           if (DEEP_DEBUG) {
               System.err.println("retrieving " + key);
           }
  @@ -852,10 +853,10 @@
                   System.err.println(sqle.getNextException());
                   sqle.printStackTrace();
               }
  -            throw new RuntimeException("Exception while retrieving mail: " + 
sqle.getMessage());
  +            throw new MessagingException("Exception while retrieving mail: " + 
sqle.getMessage());
           } catch (Exception me) {
               me.printStackTrace();
  -            throw new RuntimeException("Exception while retrieving mail: " + 
me.getMessage());
  +            throw new MessagingException("Exception while retrieving mail: " + 
me.getMessage());
           } finally {
               theJDBCUtil.closeJDBCResultSet(rsMessage);
               theJDBCUtil.closeJDBCStatement(retrieveMessage);
  @@ -868,16 +869,29 @@
        *
        * @param mail the message to be removed from the repository
        */
  -    public void remove(MailImpl mail) {
  +    public void remove(MailImpl mail) throws MessagingException {
           remove(mail.getName());
       }
   
       /**
  +     * Removes a list of mails from the repository
  +     * @param mails The list of <code>MailImpl</code>'s to delete
  +     * @throws MessagingException
  +     * @since 2.2.0
  +     */
  +    public void remove(Collection mails) throws MessagingException {
  +        Iterator delList = mails.iterator();
  +        while (delList.hasNext()) {
  +            remove((MailImpl)delList.next());
  +        }
  +    }
  +
  +    /**
        * Removes a message identified by a key.
        *
        * @param key the key of the message to be removed from the repository
        */
  -    public void remove(String key) {
  +    public void remove(String key) throws MessagingException {
           //System.err.println("removing " + key);
           if (lock(key)) {
               Connection conn = null;
  @@ -908,7 +922,7 @@
        *
        * @return an Iterator of the message keys
        */
  -    public Iterator list() {
  +    public Iterator list() throws MessagingException {
           //System.err.println("listing messages");
           Connection conn = null;
           PreparedStatement listMessages = null;
  @@ -927,7 +941,7 @@
               return messageList.iterator();
           } catch (Exception me) {
               me.printStackTrace();
  -            throw new RuntimeException("Exception while listing mail: " + 
me.getMessage());
  +            throw new MessagingException("Exception while listing mail: " + 
me.getMessage());
           } finally {
               theJDBCUtil.closeJDBCResultSet(rsListMessages);
               theJDBCUtil.closeJDBCStatement(listMessages);
  @@ -995,9 +1009,9 @@
       /**
        * Closes output streams used to update message
        * 
  -     * @headerStream the stream containing header information - potentially the same
  +     * @param headerStream the stream containing header information - potentially 
the same
        *               as the body stream
  -     * @bodyStream the stream containing body information
  +     * @param bodyStream the stream containing body information
        */
       private void closeOutputStreams(OutputStream headerStream, OutputStream 
bodyStream) {
           try {
  
  
  
  1.15.4.10 +1 -1      
james-server/src/java/org/apache/james/mailrepository/JDBCSpoolRepository.java
  
  Index: JDBCSpoolRepository.java
  ===================================================================
  RCS file: 
/home/cvs/james-server/src/java/org/apache/james/mailrepository/JDBCSpoolRepository.java,v
  retrieving revision 1.15.4.9
  retrieving revision 1.15.4.10
  diff -u -r1.15.4.9 -r1.15.4.10
  --- JDBCSpoolRepository.java  14 Aug 2003 16:28:38 -0000      1.15.4.9
  +++ JDBCSpoolRepository.java  28 Aug 2003 16:22:37 -0000      1.15.4.10
  @@ -253,7 +253,7 @@
        * is empty... a message that gets added will sit here until that queue
        * time has passed and the list is then reloaded.
        */
  -    public void store(MailImpl mc) {
  +    public void store(MailImpl mc) throws javax.mail.MessagingException {
           pendingMessagesLoadTime = 0;
           super.store(mc);
       }
  
  
  
  No                   revision
  No                   revision
  1.33.4.13 +2 -2      
james-server/src/java/org/apache/james/transport/mailets/RemoteDelivery.java
  
  Index: RemoteDelivery.java
  ===================================================================
  RCS file: 
/home/cvs/james-server/src/java/org/apache/james/transport/mailets/RemoteDelivery.java,v
  retrieving revision 1.33.4.12
  retrieving revision 1.33.4.13
  diff -u -r1.33.4.12 -r1.33.4.13
  --- RemoteDelivery.java       18 Jun 2003 15:50:33 -0000      1.33.4.12
  +++ RemoteDelivery.java       28 Aug 2003 16:22:37 -0000      1.33.4.13
  @@ -639,7 +639,7 @@
        *
        * @param mail org.apache.mailet.Mail
        */
  -    public void service(Mail genericmail) throws AddressException {
  +    public void service(Mail genericmail) throws MessagingException{
           MailImpl mail = (MailImpl)genericmail;
   
           // Do I want to give the internal key, or the message's Message ID
  
  
  
  1.8.4.3   +2 -2      
james-server/src/java/org/apache/james/transport/mailets/ToRepository.java
  
  Index: ToRepository.java
  ===================================================================
  RCS file: 
/home/cvs/james-server/src/java/org/apache/james/transport/mailets/ToRepository.java,v
  retrieving revision 1.8.4.2
  retrieving revision 1.8.4.3
  diff -u -r1.8.4.2 -r1.8.4.3
  --- ToRepository.java 8 Mar 2003 21:54:08 -0000       1.8.4.2
  +++ ToRepository.java 28 Aug 2003 16:22:37 -0000      1.8.4.3
  @@ -127,7 +127,7 @@
        *
        * @param mail the mail to process
        */
  -    public void service(Mail genericmail) {
  +    public void service(Mail genericmail) throws javax.mail.MessagingException {
           MailImpl mail = (MailImpl)genericmail;
           StringBuffer logBuffer =
               new StringBuffer(160)
  
  
  
  No                   revision
  No                   revision
  1.1.2.2   +1 -1      
james-server/src/java/org/apache/james/transport/matchers/Attic/AbstractStorageQuota.java
  
  Index: AbstractStorageQuota.java
  ===================================================================
  RCS file: 
/home/cvs/james-server/src/java/org/apache/james/transport/matchers/Attic/AbstractStorageQuota.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- AbstractStorageQuota.java 16 May 2003 05:24:58 -0000      1.1.2.1
  +++ AbstractStorageQuota.java 28 Aug 2003 16:22:37 -0000      1.1.2.2
  @@ -118,7 +118,7 @@
        *
        * @param recipient the recipient to check
        */    
  -    protected long getUsed(MailAddress recipient, Mail _) {
  +    protected long getUsed(MailAddress recipient, Mail _) throws MessagingException 
{
           long size = 0;
           MailRepository userInbox = mailServer.getUserInbox(recipient.getUser());
           for (Iterator it = userInbox.list(); it.hasNext(); ) {
  
  
  
  No                   revision
  No                   revision
  1.4.4.3   +18 -7     
james-server/src/java/org/apache/james/services/Attic/MailRepository.java
  
  Index: MailRepository.java
  ===================================================================
  RCS file: 
/home/cvs/james-server/src/java/org/apache/james/services/Attic/MailRepository.java,v
  retrieving revision 1.4.4.2
  retrieving revision 1.4.4.3
  diff -u -r1.4.4.2 -r1.4.4.3
  --- MailRepository.java       8 Mar 2003 21:54:06 -0000       1.4.4.2
  +++ MailRepository.java       28 Aug 2003 16:22:37 -0000      1.4.4.3
  @@ -60,6 +60,9 @@
   
   import org.apache.james.core.MailImpl;
   
  +import javax.mail.MessagingException;
  +
  +import java.util.Collection;
   import java.util.Iterator;
   
   /**
  @@ -83,7 +86,7 @@
        *
        * @param mc the mail message to store
        */
  -    void store(MailImpl mc);
  +    void store(MailImpl mc) throws MessagingException;
   
       /**
        * List string keys of messages in repository.
  @@ -91,7 +94,7 @@
        * @return an <code>Iterator</code> over the list of keys in the repository
        *
        */
  -    Iterator list();
  +    Iterator list() throws MessagingException;
   
       /**
        * Retrieves a message given a key. At the moment, keys can be obtained
  @@ -100,21 +103,29 @@
        * @param key the key of the message to retrieve
        * @return the mail corresponding to this key, null if none exists
        */
  -    MailImpl retrieve(String key);
  +    MailImpl retrieve(String key) throws MessagingException;
   
       /**
        * Removes a specified message
        *
        * @param mail the message to be removed from the repository
        */
  -    void remove(MailImpl mail);
  +    void remove(MailImpl mail) throws MessagingException;
  +
  +    /**
  +     * Remove the messages in the collection mails from the repository
  +     *
  +     * @param mails
  +     * @since 2.2.0
  +     */
  +     void remove(Collection mails) throws MessagingException;
   
       /**
        * Removes a message identified by key.
        *
        * @param key the key of the message to be removed from the repository
        */
  -    void remove(String key);
  +    void remove(String key) throws MessagingException;
   
       /**
        * Obtains a lock on a message identified by key
  @@ -123,7 +134,7 @@
        *
        * @return true if successfully obtained the lock, false otherwise
        */
  -    boolean lock(String key);
  +    boolean lock(String key) throws MessagingException;
   
       /**
        * Releases a lock on a message identified the key
  @@ -132,5 +143,5 @@
        *
        * @return true if successfully released the lock, false otherwise
        */
  -    boolean unlock(String key);
  +    boolean unlock(String key) throws MessagingException;
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to