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 no...@apache.org on 2006/07/04 13:30:15 UTC

svn commit: r418982 - in /james/server/sandbox/handlerapi/src: java/org/apache/james/smtpserver/ java/org/apache/james/smtpserver/fastfailfilter/ test/org/apache/james/smtpserver/

Author: norman
Date: Tue Jul  4 04:30:14 2006
New Revision: 418982

URL: http://svn.apache.org/viewvc?rev=418982&view=rev
Log:
Move method getRcptCount() to SMTPSession.

Modified:
    james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPHandler.java
    james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPSession.java
    james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/MaxRcptHandler.java
    james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/TarpitHandler.java
    james/server/sandbox/handlerapi/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java
    james/server/sandbox/handlerapi/src/test/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.java

Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPHandler.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPHandler.java?rev=418982&r1=418981&r2=418982&view=diff
==============================================================================
--- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPHandler.java (original)
+++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPHandler.java Tue Jul  4 04:30:14 2006
@@ -28,6 +28,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -553,6 +554,20 @@
      */
     public void abortMessage() {
         mode = MESSAGE_ABORT_MODE;
+    }
+    
+    /**
+     * @see org.apache.james.smtpserver.SMTPSession#getRcptCount()
+     */
+    public int getRcptCount() {
+        int count = 0;
+
+        // check if the key exists
+        if (state.get(SMTPSession.RCPT_LIST) != null) {
+            count = ((Collection) state.get(SMTPSession.RCPT_LIST)).size();
+        }
+
+        return count;
     }
 
 }

Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPSession.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPSession.java?rev=418982&r1=418981&r2=418982&view=diff
==============================================================================
--- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPSession.java (original)
+++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPSession.java Tue Jul  4 04:30:14 2006
@@ -235,6 +235,13 @@
      * @return SMTP session id
      */
     String getSessionID();
+    
+    /**
+     * Returns the recipient count
+     * 
+     * @return recipient count
+     */
+    int getRcptCount();
 
 }
 

Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/MaxRcptHandler.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/MaxRcptHandler.java?rev=418982&r1=418981&r2=418982&view=diff
==============================================================================
--- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/MaxRcptHandler.java (original)
+++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/MaxRcptHandler.java Tue Jul  4 04:30:14 2006
@@ -18,7 +18,6 @@
 package org.apache.james.smtpserver.fastfailfilter;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 
 import org.apache.avalon.framework.configuration.Configurable;
@@ -59,19 +58,6 @@
         this.maxRcpt = maxRcpt;
     }
 
-    // TODO: move this to a util class or something simular
-    private int getRcptCount(SMTPSession session) {
-        int startCount = 0;
-
-        // check if the key exists
-        if (session.getState().get(SMTPSession.RCPT_LIST) != null) {
-            return ((Collection) session.getState().get(SMTPSession.RCPT_LIST))
-                    .size();
-        } else {
-            return startCount;
-        }
-    }
-
     /**
      * @see org.apache.james.smtpserver.CommandHandler#onCommand(SMTPSession)
      */
@@ -79,7 +65,7 @@
         String responseString = null;
         int rcptCount = 0;
 
-        rcptCount = getRcptCount(session) + 1;
+        rcptCount = session.getRcptCount() + 1;
 
         // check if the max recipients has reached
         if (rcptCount > maxRcpt) {

Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/TarpitHandler.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/TarpitHandler.java?rev=418982&r1=418981&r2=418982&view=diff
==============================================================================
--- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/TarpitHandler.java (original)
+++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/TarpitHandler.java Tue Jul  4 04:30:14 2006
@@ -18,7 +18,6 @@
 package org.apache.james.smtpserver.fastfailfilter;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 
 import org.apache.avalon.framework.configuration.Configurable;
@@ -82,19 +81,6 @@
         this.tarpitSleepTime = tarpitSleepTime;
     }
 
-    //TODO: Move to util class
-    private int getRcptCount(SMTPSession session) {
-        int startCount = 0;
-
-        // check if the key exists
-        if (session.getState().get(SMTPSession.RCPT_LIST) != null) {
-            return ((Collection) session.getState().get(SMTPSession.RCPT_LIST))
-                    .size();
-        } else {
-            return startCount;
-        }
-    }
-
     /**
      * Add a sleep for the given milliseconds
      * 
@@ -112,7 +98,7 @@
     public void onCommand(SMTPSession session) {
 
         int rcptCount = 0;
-        rcptCount = getRcptCount(session);
+        rcptCount = session.getRcptCount();
         rcptCount++;
 
         if (rcptCount > tarpitRcptCount) {

Modified: james/server/sandbox/handlerapi/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java?rev=418982&r1=418981&r2=418982&view=diff
==============================================================================
--- james/server/sandbox/handlerapi/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java (original)
+++ james/server/sandbox/handlerapi/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java Tue Jul  4 04:30:14 2006
@@ -258,6 +258,11 @@
                         "Unimplemented mock service");
             }
 
+            public int getRcptCount() {
+                throw new UnsupportedOperationException(
+                        "Unimplemented mock service");
+            }
+
         };
     }
 

Modified: james/server/sandbox/handlerapi/src/test/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/test/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.java?rev=418982&r1=418981&r2=418982&view=diff
==============================================================================
--- james/server/sandbox/handlerapi/src/test/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.java (original)
+++ james/server/sandbox/handlerapi/src/test/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.java Tue Jul  4 04:30:14 2006
@@ -204,6 +204,11 @@
                 throw new UnsupportedOperationException(
                         "Unimplemented mock service");
             }
+
+            public int getRcptCount() {
+                throw new UnsupportedOperationException(
+                        "Unimplemented mock service");
+            }
         };
     }
 



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