james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pgoldst...@apache.org
Subject cvs commit: jakarta-james/src/java/org/apache/james James.java
Date Sun, 29 Sep 2002 00:11:14 GMT
pgoldstein    2002/09/28 17:11:14

  Modified:    src/java/org/apache/james/transport/mailets
                        LocalDelivery.java
               src/java/org/apache/james James.java
  Log:
  This patch is designed to appropriately handle certain error conditions that may arise in
mail storage
  
  Revision  Changes    Path
  1.6       +6 -3      jakarta-james/src/java/org/apache/james/transport/mailets/LocalDelivery.java
  
  Index: LocalDelivery.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/transport/mailets/LocalDelivery.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LocalDelivery.java	19 Aug 2002 18:57:07 -0000	1.5
  +++ LocalDelivery.java	29 Sep 2002 00:11:13 -0000	1.6
  @@ -40,14 +40,17 @@
               try {
                   getMailetContext().storeMail(mail.getSender(), recipient, mail.getMessage());
               } catch (Exception ex) {
  -                ex.printStackTrace();
  +                getMailetContext().log("Error while storing mail.", ex);
                   errors.add(recipient);
               }
           }
   
           if (!errors.isEmpty()) {
  -            //If there were errors, we need to send a message to the sender
  -            //  with the details
  +            // If there were errors, we redirect the email to the ERROR processor.
  +            // In order for this server to meet the requirements of the SMTP specification,
  +            // mails on the ERROR processor must be returned to the sender.  Note that
this
  +            // email doesn't include any details regarding the details of the failure(s).
  +            // In the future we may wish to address this.
               getMailetContext().sendMail(mail.getSender(),
                                           errors, mail.getMessage(), Mail.ERROR);
           }
  
  
  
  1.33      +37 -3     jakarta-james/src/java/org/apache/james/James.java
  
  Index: James.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/James.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- James.java	14 Sep 2002 09:00:56 -0000	1.32
  +++ James.java	29 Sep 2002 00:11:13 -0000	1.33
  @@ -687,8 +687,23 @@
       public void storeMail(MailAddress sender, MailAddress recipient, MimeMessage message)
           throws MessagingException {
           String username;
  +        if (recipient == null) {
  +            throw new IllegalArgumentException("Recipient for mail to be spooled cannot
be null.");
  +        }
  +        if (message == null) {
  +            throw new IllegalArgumentException("Mail message to be spooled cannot be null.");
  +        }
           if (ignoreCase) {
  -            username = localusers.getRealName(recipient.getUser());
  +            String originalUsername = recipient.getUser();
  +            username = localusers.getRealName(originalUsername);
  +            if (username == null) {
  +                StringBuffer errorBuffer =
  +                    new StringBuffer(128)
  +                        .append("The inbox for user ")
  +                        .append(originalUsername)
  +                        .append(" was not found on this server.");
  +                throw new MessagingException(errorBuffer.toString());
  +            }
           } else {
               username = recipient.getUser();
           }
  @@ -698,8 +713,17 @@
               if (enableAliases && user.getAliasing()) {
                   username = user.getAlias();
               }
  +            // Forwarding takes precedence over local aliases
               if (enableForwarding && user.getForwarding()) {
                   MailAddress forwardTo = user.getForwardingDestination();
  +                if (forwardTo == null) {
  +                    StringBuffer errorBuffer = 
  +                        new StringBuffer(128)
  +                            .append("Forwarding was enabled for ")
  +                            .append(username)
  +                            .append(" but no forwarding address was set for this account.");
  +                    throw new MessagingException(errorBuffer.toString());
  +                }
                   Collection recipients = new HashSet();
                   recipients.add(forwardTo);
                   try {
  @@ -721,6 +745,7 @@
                                       .append("attempting local delivery");
                           getLogger().error(logBuffer.toString());
                       }
  +                    throw me;
                   }
               }
           }
  @@ -728,7 +753,16 @@
           Collection recipients = new HashSet();
           recipients.add(recipient);
           MailImpl mailImpl = new MailImpl(getId(), sender, recipients, message);
  -        getUserInbox(username).store(mailImpl);
  +        MailRepository userInbox = getUserInbox(username);
  +        if (userInbox == null) {
  +            StringBuffer errorBuffer =
  +                new StringBuffer(128)
  +                    .append("The inbox for user ")
  +                    .append(username)
  +                    .append(" was not found on this server.");
  +            throw new MessagingException(errorBuffer.toString());
  +        }
  +        userInbox.store(mailImpl);
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <mailto:james-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:james-dev-help@jakarta.apache.org>


Mime
View raw message