You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by se...@apache.org on 2001/08/06 05:41:18 UTC

cvs commit: jakarta-james/src/java/org/apache/james/imapserver MimeMessageFileSource.java BaseCommand.java CommandFetch.java CommandStore.java FileMailbox.java Mailbox.java SimpleMessageAttributes.java

serge       01/08/05 20:41:18

  Modified:    src/java/org/apache/james/imapserver BaseCommand.java
                        CommandFetch.java CommandStore.java
                        FileMailbox.java Mailbox.java
                        SimpleMessageAttributes.java
  Added:       src/java/org/apache/james/imapserver
                        MimeMessageFileSource.java
  Log:
  Various modifications to make imapserver compile with new MimeMessageWrapper/Source structure.
  
  Revision  Changes    Path
  1.2       +1 -1      jakarta-james/src/java/org/apache/james/imapserver/BaseCommand.java
  
  Index: BaseCommand.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/imapserver/BaseCommand.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseCommand.java	2001/05/11 11:01:10	1.1
  +++ BaseCommand.java	2001/08/06 03:41:17	1.2
  @@ -17,7 +17,7 @@
   import org.apache.james.AccessControlException;
   import org.apache.james.AuthorizationException;
   import org.apache.james.BaseConnectionHandler;
  -import org.apache.james.core.EnhancedMimeMessage;
  +//import org.apache.james.core.EnhancedMimeMessage;
   
   
   /**
  
  
  
  1.2       +3 -2      jakarta-james/src/java/org/apache/james/imapserver/CommandFetch.java
  
  Index: CommandFetch.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/imapserver/CommandFetch.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CommandFetch.java	2001/05/11 11:01:10	1.1
  +++ CommandFetch.java	2001/08/06 03:41:17	1.2
  @@ -15,7 +15,7 @@
   import javax.mail.internet.InternetHeaders;
   import org.apache.james.AccessControlException;
   import org.apache.james.AuthorizationException;
  -import org.apache.james.core.EnhancedMimeMessage;
  +import org.apache.james.core.MimeMessageWrapper;
   
   /**
    * Implements the IMAP FETCH command for a given ImapRequest.
  @@ -158,7 +158,8 @@
                   }
                   MessageAttributes  attrs = null;
                   String flags = null;
  -                EnhancedMimeMessage msg = null;
  +                //EnhancedMimeMessage msg = null;
  +                MimeMessageWrapper msg = null;
                   String response = UNTAGGED + SP + msn + SP + "FETCH (";
                   boolean responseAdded = false;
                   Iterator it = fetchAttrs.iterator();
  
  
  
  1.2       +5 -5      jakarta-james/src/java/org/apache/james/imapserver/CommandStore.java
  
  Index: CommandStore.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/imapserver/CommandStore.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CommandStore.java	2001/05/11 11:01:10	1.1
  +++ CommandStore.java	2001/08/06 03:41:17	1.2
  @@ -15,7 +15,7 @@
   import javax.mail.internet.InternetHeaders;
   import org.apache.james.AccessControlException;
   import org.apache.james.AuthorizationException;
  -import org.apache.james.core.EnhancedMimeMessage;
  +//import org.apache.james.core.EnhancedMimeMessage;
   
   /**
    * Implements the IMAP FETCH command for a given ImapRequest.
  @@ -24,9 +24,9 @@
    * @author <a href="mailto:charles@benett1.demon.co.uk">Charles Benett</a>
    * @version 0.1 on 17 Jan 2001
    */
  -public class CommandStore 
  +public class CommandStore
       extends BaseCommand {
  -    //mainly to switch on stack traces and catch responses;  
  +    //mainly to switch on stack traces and catch responses;
       private static final boolean DEEP_DEBUG = true;
   
       private static final String OK = "OK";
  @@ -64,7 +64,7 @@
       }
   
       /**
  -     * Implements IMAP store commands given an ImapRequest. 
  +     * Implements IMAP store commands given an ImapRequest.
        * <p>Warning - maybecome service(ImapRequest request)
        */
       public void service() {
  @@ -125,7 +125,7 @@
               }
               caller.checkSize();
               out.println(tag + SP + OK + SP + "STORE completed");
  -            
  +
           } catch (AccessControlException ace) {
               out.println(tag + SP + NO + SP + "No such mailbox");
               caller.logACE(ace);
  
  
  
  1.5       +9 -9      jakarta-james/src/java/org/apache/james/imapserver/FileMailbox.java
  
  Index: FileMailbox.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/imapserver/FileMailbox.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FileMailbox.java	2001/06/24 12:14:31	1.4
  +++ FileMailbox.java	2001/08/06 03:41:17	1.5
  @@ -20,7 +20,7 @@
   import org.apache.james.AccessControlException;
   import org.apache.james.AuthorizationException;
   import org.apache.james.Constants;
  -import org.apache.james.core.EnhancedMimeMessage;
  +import org.apache.james.core.MimeMessageWrapper;
   import org.apache.james.services.UsersRepository;
   import org.apache.mailet.Mail;
   
  @@ -1083,14 +1083,14 @@
        *
        * @param msn the message sequence number
        * @param username String represnting user
  -     * @returns an  EnhancedMimeMessage object containing the message, null if no message with
  +     * @returns an  MimeMessageWrapper object containing the message, null if no message with
        * the given msn.
        * @throws AccessControlException if user does not have read rights for
        * this mailbox.
        * @throws AuthorizationException if user has lookup rights but does not
        * have read rights.
        */
  -    public synchronized EnhancedMimeMessage retrieve(int msn, String user)
  +    public synchronized MimeMessageWrapper retrieve(int msn, String user)
           throws AccessControlException, AuthorizationException {
           if (!hasReadRights(user)) { //throws AccessControlException
               throw new AuthorizationException("Not authorized to read.");
  @@ -1110,24 +1110,24 @@
        *
        * @param uid the unique identifier of a message
        * @param username String represnting user
  -     * @returns an EnhancedMimeMessage object containing the message, null if no message with
  +     * @returns an MimeMessageWrapper object containing the message, null if no message with
        * the given msn.
        * @throws AccessControlException if user does not have read rights for
        * this mailbox.
        * @throws AuthorizationException if user has lookup rights but does not
        * have read rights.
        */
  -    public synchronized EnhancedMimeMessage retrieveUID(int uid, String user)
  +    public synchronized MimeMessageWrapper retrieveUID(int uid, String user)
           throws AccessControlException, AuthorizationException {
           if (!hasReadRights(user)) { //throws AccessControlException
               throw new AuthorizationException("Not authorized to read.");
           }
  -        EnhancedMimeMessage response = null;
  +        MimeMessageWrapper response = null;
           if (sequence.contains(new Integer(uid))) {
               BufferedInputStream inMsg = null;
               try {
  -                inMsg = new BufferedInputStream( new FileInputStream(path + File.separator + uid + MESSAGE_EXTENSION));
  -                response = new EnhancedMimeMessage(Session.getDefaultInstance(System.getProperties(), null),inMsg);
  +				MimeMessageFileSource source = new MimeMessageFileSource(path + File.separator + uid + MESSAGE_EXTENSION);
  +                response = new MimeMessageWrapper(source);
                   inMsg.close();
               } catch(Exception e) {
                   getLogger().error("Error reading message from disc: " + e);
  @@ -1142,7 +1142,7 @@
                       getLogger().error("Error closing streams: " + ie);
                   }
               }
  -            getLogger().info("EnhancedMimeMessage " + uid + " read from " + absoluteName);
  +            getLogger().info("MimeMessageWrapper " + uid + " read from " + absoluteName);
               return response;
           } else {
               return null;
  
  
  
  1.3       +24 -24    jakarta-james/src/java/org/apache/james/imapserver/Mailbox.java
  
  Index: Mailbox.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/imapserver/Mailbox.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Mailbox.java	2001/06/24 12:14:32	1.2
  +++ Mailbox.java	2001/08/06 03:41:17	1.3
  @@ -15,7 +15,7 @@
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.james.AccessControlException;
   import org.apache.james.AuthorizationException;
  -import org.apache.james.core.EnhancedMimeMessage;
  +import org.apache.james.core.MimeMessageWrapper;
   import org.apache.mailet.Mail;
   
   /**
  @@ -28,7 +28,7 @@
    * shouldn't get thrown because the Host will have checked access before
    * returning a reference to this mailbox. However, having the methods here
    * throw this exception allows the acl to be changed while a mailbox is
  - * selected. 
  + * selected.
    *
    * Mailbox Related Flags (rfc2060 name attributes)
    *     \Noinferiors   It is not possible for any child levels of hierarchy to
  @@ -42,7 +42,7 @@
    *      \Unmarked      The mailbox does not contain any additional messages
    * since the last time the mailbox was selected.
    *
  - * Message related flags. 
  + * Message related flags.
    * The flags allowed per message are specific to each mailbox.
    * The minimum list (rfc2060 system flags) is:
    *  \Seen       Message has been read
  @@ -58,15 +58,15 @@
    * is the first session to be notified about a message, then that message
    * SHOULD be considered recent.
    *
  - * Reference: RFC 2060 
  + * Reference: RFC 2060
    * @author <a href="mailto:charles@benett1.demon.co.uk">Charles Benett</a>
    * @version 0.1 on 14 Dec 2000
    */
  -public interface Mailbox 
  +public interface Mailbox
       extends Configurable, Composable {
   
       String SYSTEM_FLAGS = "\\Seen \\Answered \\Flagged \\Deleted \\Draft";
  -    String RECENT_FLAG =  "\\Recent"; 
  +    String RECENT_FLAG =  "\\Recent";
   
       /**
        * Returns name of this mailbox relative to its parent in the mailbox
  @@ -205,8 +205,8 @@
        */
       void unsetRecent();
   
  -    /** 
  -     * Indicates the oldest unseen message for the specified user. 
  +    /**
  +     * Indicates the oldest unseen message for the specified user.
        *
        * @returns int Message Sequence Number of first message without \Seen
        * flag set for this User.
  @@ -215,8 +215,8 @@
        */
       int getOldestUnseen( String user );
   
  -   /** 
  -     * Indicates the number of  unseen messages for the specified user. 
  +   /**
  +     * Indicates the number of  unseen messages for the specified user.
        *
        * @returns int number of messages without \Seen flag set for this User.
        */
  @@ -236,13 +236,13 @@
        * @throws AccessControlException if the user can not open this mailbox
        * at least Read-Only.
        */
  -    boolean isReadOnly( String username ) 
  +    boolean isReadOnly( String username )
           throws AccessControlException;
   
       /**
        * Mailbox Events are used to inform registered listeners of events in the
        * Mailbox.
  -     * Example if mail is delivered to an Inbox or if another user appends/ 
  +     * Example if mail is delivered to an Inbox or if another user appends/
        * deletes a message.
        */
       void addMailboxEventListener( MailboxEventListener mel );
  @@ -274,16 +274,16 @@
        * @throws AuthorizationException if username has lookup rights but does
        * not have insert rights.
        */
  -    boolean store( MimeMessage message, 
  +    boolean store( MimeMessage message,
                      String username,
  -                   MessageAttributes attrs, 
  +                   MessageAttributes attrs,
                      Flags flags )
           throws AccessControlException, AuthorizationException, IllegalArgumentException;
   
       /**
        * Retrieves a message given a message sequence number.
        *
  -     * @param msn the message sequence number 
  +     * @param msn the message sequence number
        * @param username String represnting user
        * @returns a Mail object containing the message, null if no message with
        * the given msn.
  @@ -292,7 +292,7 @@
        * @throws AuthorizationException if user has lookup rights but does not
        * have read rights.
        */
  -    EnhancedMimeMessage retrieve( int msn, String user )
  +    MimeMessageWrapper retrieve( int msn, String user )
           throws AccessControlException, AuthorizationException;
   
       /**
  @@ -307,13 +307,13 @@
        * @throws AuthorizationException if user has lookup rights but does not
        * have read rights.
        */
  -    EnhancedMimeMessage retrieveUID( int uid, String user )
  +    MimeMessageWrapper retrieveUID( int uid, String user )
           throws AccessControlException, AuthorizationException;
   
       /**
        * Marks a message for deletion given a message sequence number.
        *
  -     * @param msn the message sequence number 
  +     * @param msn the message sequence number
        * @param username String represnting user
        * @returns boolean true if successful.
        * @throws AccessControlException if user does not have read rights for
  @@ -410,9 +410,9 @@
        */
       String getFlagsUID(int uid, String user)
           throws AccessControlException, AuthorizationException;
  -    
  +
       /**
  -     * Updates the flags of a message. 
  +     * Updates the flags of a message.
        *
        * @param msn message sequence number for a message in this mailbox
        * @param username String represnting user
  @@ -426,7 +426,7 @@
           throws AccessControlException, AuthorizationException, IllegalArgumentException;
   
       /**
  -     * Updates the flags of a message. 
  +     * Updates the flags of a message.
        *
        * @param uid UniqueIdentifier for a message in this mailbox
        * @param username String represnting user
  @@ -495,7 +495,7 @@
        * @returns true if user has at least lookup rights
        */
       boolean hasLookupRights( String user );
  -        
  +
       /**
        * Establishes if specified user has create rights for this mailbox.
        *
  @@ -525,7 +525,7 @@
       boolean checkpoint();
   
       /**
  -     * Mark this mailbox as not selectable by anyone. 
  +     * Mark this mailbox as not selectable by anyone.
        * Example folders at the roots of hierarchies, e. #mail for each user.
        *
        * @param state true if folder is not selectable by anyone
  @@ -541,5 +541,5 @@
        */
       Map getUnseenByUser();
   }
  - 
  +
   
  
  
  
  1.3       +6 -3      jakarta-james/src/java/org/apache/james/imapserver/SimpleMessageAttributes.java
  
  Index: SimpleMessageAttributes.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/imapserver/SimpleMessageAttributes.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SimpleMessageAttributes.java	2001/06/06 13:18:07	1.2
  +++ SimpleMessageAttributes.java	2001/08/06 03:41:17	1.3
  @@ -15,7 +15,7 @@
   import javax.mail.Session;
   import javax.mail.internet.*;
   import org.apache.avalon.framework.logger.AbstractLoggable;
  -import org.apache.james.core.EnhancedMimeMessage;
  +import org.apache.james.core.MimeMessageWrapper;
   import org.apache.james.util.RFC822DateFormat;
   import org.apache.log.Logger;
   import org.apache.mailet.*;
  @@ -262,19 +262,22 @@
               if (secondaryType.equalsIgnoreCase("RFC822")) {
                   try {
   
  -                    EnhancedMimeMessage message = new EnhancedMimeMessage(Session.getDefaultInstance(System.getProperties(), null), part.getInputStream());
  +                    /*
  +                    MimeMessageWrapper message = new MimeMessageWrapper(part.getInputStream());
                       SimpleMessageAttributes msgAttrs = new SimpleMessageAttributes();
                       msgAttrs.setAttributesFor(message);
   
                       if (part instanceof MimeMessage) {
  +						Comments out because I don't know what it should do here
                           MimeMessage msg1 = (MimeMessage) part;
  -                        EnhancedMimeMessage message2 = new EnhancedMimeMessage(msg1);
  +                        MimeMessageWrapper message2 = new MimeMessageWrapper(msg1);
                           SimpleMessageAttributes msgAttrs2 = new SimpleMessageAttributes();
                           msgAttrs.setAttributesFor(message2);
                       }
   
                       parts = new SimpleMessageAttributes[1];
                       parts[0] = msgAttrs;
  +                    */
                   } catch (Exception e) {
                       getLogger().error("Error interpreting a message/rfc822: " + e);
                       e.printStackTrace();
  
  
  
  1.1                  jakarta-james/src/java/org/apache/james/imapserver/MimeMessageFileSource.java
  
  Index: MimeMessageFileSource.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.james.imapserver;
  
  import java.io.FileInputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import org.apache.james.core.MimeMessageSource;
  
  public class MimeMessageFileSource extends MimeMessageSource {
  
      //Define how to get to the data
      String filename = null;;
  
      public MimeMessageFileSource(String filename) {
          this.filename = filename;
      }
  
      public InputStream getInputStream() throws IOException {
          return new FileInputStream(filename);
      }
  
  }
  
  
  

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