Author: bago
Date: Fri Sep 15 01:19:40 2006
New Revision: 446545

URL: http://svn.apache.org/viewvc?view=rev&rev=446545
Log:
Moved POP3Handler.stat() method from the Handler to the RsetCmdHandler

Modified:
    james/server/trunk/src/java/org/apache/james/pop3server/POP3Handler.java
    james/server/trunk/src/java/org/apache/james/pop3server/POP3Session.java
    james/server/trunk/src/java/org/apache/james/pop3server/PassCmdHandler.java
    james/server/trunk/src/java/org/apache/james/pop3server/RsetCmdHandler.java

Modified: 
james/server/trunk/src/java/org/apache/james/pop3server/POP3Handler.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/pop3server/POP3Handler.java?view=diff&rev=446545&r1=446544&r2=446545
==============================================================================
--- james/server/trunk/src/java/org/apache/james/pop3server/POP3Handler.java 
(original)
+++ james/server/trunk/src/java/org/apache/james/pop3server/POP3Handler.java 
Fri Sep 15 01:19:40 2006
@@ -30,8 +30,6 @@
 import org.apache.james.util.watchdog.Watchdog;
 import org.apache.mailet.Mail;
 
-import javax.mail.MessagingException;
-
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
@@ -102,9 +100,9 @@
      * emails in the user's inbox at any given time
      * during the POP3 transaction.
      */
-    private ArrayList userMailbox = new ArrayList();
+    private List userMailbox = new ArrayList();
 
-    private ArrayList backupUserMailbox;         // A snapshot list 
representing the set of
+    private List backupUserMailbox;         // A snapshot list representing 
the set of
                                                  // emails in the user's inbox 
at the beginning
                                                  // of the transaction
 
@@ -308,38 +306,6 @@
     }
 
     /**
-     * Implements a "stat".  If the handler is currently in
-     * a transaction state, this amounts to a rollback of the
-     * mailbox contents to the beginning of the transaction.
-     * This method is also called when first entering the
-     * transaction state to initialize the handler copies of the
-     * user inbox.
-     *
-     */
-    public void stat() {
-        userMailbox = new ArrayList();
-        userMailbox.add(DELETED);
-        try {
-            for (Iterator it = userInbox.list(); it.hasNext(); ) {
-                String key = (String) it.next();
-                Mail mc = userInbox.retrieve(key);
-                // Retrieve can return null if the mail is no longer in the 
store.
-                // In this case we simply continue to the next key
-                if (mc == null) {
-                    continue;
-                }
-                userMailbox.add(mc);
-            }
-        } catch(MessagingException e) {
-            // In the event of an exception being thrown there may or may not 
be anything in userMailbox
-            getLogger().error("Unable to STAT mail box ", e);
-        }
-        finally {
-            backupUserMailbox = (ArrayList) userMailbox.clone();
-        }
-    }
-
-    /**
      * Reads a line of characters off the command line.
      *
      * @return the trimmed input line
@@ -517,14 +483,14 @@
     /**
      * @see org.apache.james.pop3server.POP3Session#getUserMailbox()
      */
-    public ArrayList getUserMailbox() {
+    public List getUserMailbox() {
         return userMailbox;
     }
 
     /**
      * @see 
org.apache.james.pop3server.POP3Session#setUserMailbox(java.util.ArrayList)
      */
-    public void setUserMailbox(ArrayList userMailbox) {
+    public void setUserMailbox(List userMailbox) {
         this.userMailbox = userMailbox;
     }
 
@@ -533,6 +499,14 @@
      */
     public List getBackupUserMailbox() {
         return backupUserMailbox;
+    }
+
+
+    /**
+     * @see 
org.apache.james.pop3server.POP3Session#setUserMailbox(java.util.ArrayList)
+     */
+    public void setBackupUserMailbox(List backupUserMailbox) {
+        this.backupUserMailbox = backupUserMailbox;
     }
 
     /**

Modified: 
james/server/trunk/src/java/org/apache/james/pop3server/POP3Session.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/pop3server/POP3Session.java?view=diff&rev=446545&r1=446544&r2=446545
==============================================================================
--- james/server/trunk/src/java/org/apache/james/pop3server/POP3Session.java 
(original)
+++ james/server/trunk/src/java/org/apache/james/pop3server/POP3Session.java 
Fri Sep 15 01:19:40 2006
@@ -27,7 +27,6 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
@@ -184,26 +183,29 @@
      * 
      * @return mailbox content
      */
-    ArrayList getUserMailbox();
+    List getUserMailbox();
 
     /**
      * Sets a new mailbox content
      * 
      * @param userMailbox mailbox
      */
-    void setUserMailbox(ArrayList userMailbox);
+    void setUserMailbox(List userMailbox);
     
     /**
-     * Inizialize the mailbox
-     */
-    void stat();
-
-    /**
      * Returns the backup mailbox
      * 
      * @return list backup
      */
     List getBackupUserMailbox();
+
+
+    /**
+     * Sets a new backup mailbox content
+     * 
+     * @param backupUserMailbox the mailbox backup
+     */
+    void setBackupUserMailbox(List backupUserMailbox);
 
     /**
      * Returns the raw output stream

Modified: 
james/server/trunk/src/java/org/apache/james/pop3server/PassCmdHandler.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/pop3server/PassCmdHandler.java?view=diff&rev=446545&r1=446544&r2=446545
==============================================================================
--- james/server/trunk/src/java/org/apache/james/pop3server/PassCmdHandler.java 
(original)
+++ james/server/trunk/src/java/org/apache/james/pop3server/PassCmdHandler.java 
Fri Sep 15 01:19:40 2006
@@ -55,7 +55,7 @@
                         throw new IllegalStateException("MailServer returned a 
null inbox for "+session.getUser());
                     }
                     session.setUserInbox(inbox);
-                    session.stat();
+                    RsetCmdHandler.stat(session, getLogger());
                     
                     // Store the ipAddress to use it later for pop before smtp 
                     
POP3BeforeSMTPHelper.addIPAddress(session.getRemoteIPAddress());

Modified: 
james/server/trunk/src/java/org/apache/james/pop3server/RsetCmdHandler.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/pop3server/RsetCmdHandler.java?view=diff&rev=446545&r1=446544&r2=446545
==============================================================================
--- james/server/trunk/src/java/org/apache/james/pop3server/RsetCmdHandler.java 
(original)
+++ james/server/trunk/src/java/org/apache/james/pop3server/RsetCmdHandler.java 
Fri Sep 15 01:19:40 2006
@@ -21,11 +21,20 @@
 
 package org.apache.james.pop3server;
 
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.mailet.Mail;
+
+import javax.mail.MessagingException;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
 
 /**
   * Handles RSET command
   */
-public class RsetCmdHandler implements CommandHandler {
+public class RsetCmdHandler extends AbstractLogEnabled implements 
CommandHandler {
 
     /**
      * @see org.apache.james.pop3server.CommandHandler#onCommand(POP3Session)
@@ -44,7 +53,7 @@
     private void doRSET(POP3Session session,String argument) {
         String responseString = null;
         if (session.getHandlerState() == POP3Handler.TRANSACTION) {
-            session.stat();
+            stat(session, getLogger());
             responseString = POP3Handler.OK_RESPONSE;
         } else {
             responseString = POP3Handler.ERR_RESPONSE;
@@ -52,5 +61,38 @@
         session.writeResponse(responseString);
     }
 
+
+    /**
+     * Implements a "stat".  If the handler is currently in
+     * a transaction state, this amounts to a rollback of the
+     * mailbox contents to the beginning of the transaction.
+     * This method is also called when first entering the
+     * transaction state to initialize the handler copies of the
+     * user inbox.
+     *
+     */
+    public static void stat(POP3Session session, Logger logger) {
+        ArrayList userMailbox = new ArrayList();
+        userMailbox.add(POP3Handler.DELETED);
+        try {
+            for (Iterator it = session.getUserInbox().list(); it.hasNext(); ) {
+                String key = (String) it.next();
+                Mail mc = session.getUserInbox().retrieve(key);
+                // Retrieve can return null if the mail is no longer in the 
store.
+                // In this case we simply continue to the next key
+                if (mc == null) {
+                    continue;
+                }
+                userMailbox.add(mc);
+            }
+        } catch(MessagingException e) {
+            // In the event of an exception being thrown there may or may not 
be anything in userMailbox
+            logger.error("Unable to STAT mail box ", e);
+        }
+        finally {
+            session.setUserMailbox(userMailbox);
+            session.setBackupUserMailbox((ArrayList) userMailbox.clone());
+        }
+    }
 
 }



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

Reply via email to