incubator-ftpserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r609446 [2/5] - in /incubator/ftpserver/trunk: core/ core/src/main/java/org/apache/ftpserver/ core/src/main/java/org/apache/ftpserver/command/ core/src/main/java/org/apache/ftpserver/ftplet/ core/src/main/java/org/apache/ftpserver/interface...
Date Sun, 06 Jan 2008 22:24:34 GMT
Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/LANG.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/LANG.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/LANG.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/LANG.java Sun Jan  6 14:24:29 2008
@@ -21,13 +21,12 @@
 
 import java.io.IOException;
 
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.ftplet.FtpException;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
+import org.apache.ftpserver.interfaces.FtpIoSession;
+import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.interfaces.MessageResource;
-import org.apache.ftpserver.listener.Connection;
 import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
@@ -41,10 +40,9 @@
     /**
      * Execute command.
      */
-    public void execute(Connection connection, 
-                        FtpRequest request, 
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException, FtpException {
+    public void execute(FtpIoSession session, 
+                        FtpServerContext context, 
+                        FtpRequest request) throws IOException, FtpException {
         
         // reset state
         session.resetState();
@@ -53,25 +51,25 @@
         String language = request.getArgument();
         if(language == null) {
             session.setLanguage(null);
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_200_COMMAND_OKAY, "LANG", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_200_COMMAND_OKAY, "LANG", null));
             return;
         }
         
         // check and set language
         language = language.toLowerCase();
-        MessageResource msgResource = connection.getServerContext().getMessageResource();
+        MessageResource msgResource = context.getMessageResource();
         String[] availableLanguages = msgResource.getAvailableLanguages();
         if(availableLanguages != null) {
             for(int i=0; i<availableLanguages.length; ++i) {
                 if(availableLanguages[i].equals(language)) {
                     session.setLanguage(language);
-                    out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_200_COMMAND_OKAY, "LANG", null));
+                    session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_200_COMMAND_OKAY, "LANG", null));
                     return;
                 }
             }
         }
         
         // not found - send error message
-        out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "LANG", null));
+        session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "LANG", null));
     }
 }

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/LIST.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/LIST.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/LIST.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/LIST.java Sun Jan  6 14:24:29 2008
@@ -24,15 +24,14 @@
 import java.net.SocketException;
 
 import org.apache.ftpserver.DefaultFtpReply;
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.IODataConnectionFactory;
 import org.apache.ftpserver.ftplet.DataConnection;
 import org.apache.ftpserver.ftplet.DataConnectionFactory;
 import org.apache.ftpserver.ftplet.FtpException;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
-import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.interfaces.FtpIoSession;
+import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.listing.DirectoryLister;
 import org.apache.ftpserver.listing.LISTFileFormater;
 import org.apache.ftpserver.listing.ListArgument;
@@ -64,10 +63,9 @@
     /**
      * Execute command.
      */
-    public void execute(Connection connection,
-                        FtpRequest request, 
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException, FtpException {
+    public void execute(FtpIoSession session,
+                        FtpServerContext context, 
+                        FtpRequest request) throws IOException, FtpException {
         
         try {
         
@@ -79,20 +77,20 @@
             if (connFactory instanceof IODataConnectionFactory) {
                 InetAddress address = ((IODataConnectionFactory)connFactory).getInetAddress();
                 if (address == null) {
-                    out.write(new DefaultFtpReply(FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PORT or PASV must be issued first"));
+                    session.write(new DefaultFtpReply(FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PORT or PASV must be issued first"));
                     return;
                 }
             }
             
             // get data connection
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_150_FILE_STATUS_OKAY, "LIST", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_150_FILE_STATUS_OKAY, "LIST", null));
 
             DataConnection dataConnection;
             try {
                 dataConnection = session.getDataConnection().openConnection();
             } catch (Exception e) {
                 LOG.debug("Exception getting the output data stream", e);
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "LIST", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "LIST", null));
                 return;
             }
             
@@ -109,21 +107,21 @@
             catch(SocketException ex) {
                 LOG.debug("Socket exception during list transfer", ex);
                 failure = true;
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED, "LIST", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED, "LIST", null));
             }
             catch(IOException ex) {
                 LOG.debug("IOException during list transfer", ex);
                 failure = true;
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN, "LIST", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN, "LIST", null));
             } catch(IllegalArgumentException e) {
                 LOG.debug("Illegal list syntax: " + request.getArgument(), e);
                 // if listing syntax error - send message
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "LIST", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "LIST", null));
             }
             
             // if data transfer ok - send transfer complete message
             if(!failure) {
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_226_CLOSING_DATA_CONNECTION, "LIST", null));
+            	session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_226_CLOSING_DATA_CONNECTION, "LIST", null));
             }
         }
         finally {

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MD5.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MD5.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MD5.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MD5.java Sun Jan  6 14:24:29 2008
@@ -25,12 +25,11 @@
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.ftplet.FileObject;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
-import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.interfaces.FtpIoSession;
+import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.util.FtpReplyUtil;
 import org.apache.ftpserver.util.IoUtils;
 import org.slf4j.Logger;
@@ -52,10 +51,9 @@
     /**
      * Execute command.
      */
-    public void execute(Connection connection,
-                        FtpRequest request, 
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException {
+    public void execute(FtpIoSession session,
+                        FtpServerContext context, 
+                        FtpRequest request) throws IOException {
         
         // reset state variables
         session.resetState();
@@ -70,7 +68,7 @@
         String argument = request.getArgument();
         
         if(argument == null || argument.trim().length() == 0) {
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "MD5.invalid", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "MD5.invalid", null));
             return;
         }
 
@@ -96,13 +94,13 @@
             }
             
             if(file == null) {
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "MD5.invalid", fileName));
+            	session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "MD5.invalid", fileName));
                 return;
             }
     
             // check file
             if(!file.isFile()) {
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "MD5.invalid", fileName));
+            	session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "MD5.invalid", fileName));
                 return;
             }
             
@@ -121,15 +119,15 @@
                 
             } catch(NoSuchAlgorithmException e) {
                 LOG.debug("MD5 algorithm not available", e);
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_502_COMMAND_NOT_IMPLEMENTED, "MD5.notimplemened", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_502_COMMAND_NOT_IMPLEMENTED, "MD5.notimplemened", null));
             } finally {
                 IoUtils.close(is);
             }
         }
         if(isMMD5) {
-            out.write(FtpReplyUtil.translate(session, 252, "MMD5", sb.toString()));
+        	session.write(FtpReplyUtil.translate(session, request, context, 252, "MMD5", sb.toString()));
         } else {
-            out.write(FtpReplyUtil.translate(session, 251, "MD5", sb.toString()));
+        	session.write(FtpReplyUtil.translate(session, request,  context, 251, "MD5", sb.toString()));
         }
     }
 

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MDTM.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MDTM.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MDTM.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MDTM.java Sun Jan  6 14:24:29 2008
@@ -21,13 +21,12 @@
 
 import java.io.IOException;
 
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.ftplet.FileObject;
 import org.apache.ftpserver.ftplet.FtpException;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
-import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.interfaces.FtpIoSession;
+import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.util.DateUtils;
 import org.apache.ftpserver.util.FtpReplyUtil;
 import org.slf4j.Logger;
@@ -46,10 +45,9 @@
     /**
      * Execute command
      */
-    public void execute(Connection connection,
-                        FtpRequest request, 
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException, FtpException {
+    public void execute(FtpIoSession session,
+                        FtpServerContext context, 
+                        FtpRequest request) throws IOException, FtpException {
         
         // reset state
         session.resetState();
@@ -57,7 +55,7 @@
         // argument check
         String fileName = request.getArgument();
         if(fileName == null) {
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MDTM", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MDTM", null));
             return;  
         }
         
@@ -70,7 +68,7 @@
             LOG.debug("Exception getting file object", ex);
         }
         if(file == null) {
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MDTM", fileName));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MDTM", fileName));
             return;
         }
         
@@ -78,10 +76,10 @@
         fileName = file.getFullName();
         if(file.doesExist()) {
             String dateStr = DateUtils.getFtpDate( file.getLastModified() );
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_213_FILE_STATUS, "MDTM", dateStr));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_213_FILE_STATUS, "MDTM", dateStr));
         }
         else {
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MDTM", fileName));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MDTM", fileName));
         }
     } 
 }

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MKD.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MKD.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MKD.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MKD.java Sun Jan  6 14:24:29 2008
@@ -22,17 +22,15 @@
 import java.io.File;
 import java.io.IOException;
 
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.ftplet.FileObject;
 import org.apache.ftpserver.ftplet.FtpException;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.ftplet.Ftplet;
 import org.apache.ftpserver.ftplet.FtpletEnum;
+import org.apache.ftpserver.interfaces.FtpIoSession;
 import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.interfaces.ServerFtpStatistics;
-import org.apache.ftpserver.listener.Connection;
 import org.apache.ftpserver.util.FtpReplyUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -53,27 +51,25 @@
     /**
      * Execute command.
      */
-    public void execute(Connection connection,
-                        FtpRequest request, 
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException, FtpException {
+    public void execute(FtpIoSession session,
+                        FtpServerContext context, 
+                        FtpRequest request) throws IOException, FtpException {
         
         // reset state
         session.resetState(); 
-        FtpServerContext serverContext = connection.getServerContext();
         
         // argument check
         String fileName = request.getArgument();
         if(fileName == null || fileName.indexOf(File.pathSeparatorChar) > -1) {
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MKD", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MKD", null));
             return;  	
         }
         
         // call Ftplet.onMkdirStart() method
-        Ftplet ftpletContainer = serverContext.getFtpletContainer();
+        Ftplet ftpletContainer = context.getFtpletContainer();
         FtpletEnum ftpletRet;
         try{
-            ftpletRet = ftpletContainer.onMkdirStart(session, request, out);
+            ftpletRet = ftpletContainer.onMkdirStart(session.getFtpletSession(), request);
         } catch(Exception e) {
             LOG.debug("Ftplet container threw exception", e);
             ftpletRet = FtpletEnum.RET_DISCONNECT;
@@ -82,7 +78,7 @@
             return;
         }
         else if(ftpletRet == FtpletEnum.RET_DISCONNECT) {
-            serverContext.getConnectionManager().closeConnection(connection);
+            session.closeOnFlush();
             return;
         }
         
@@ -95,50 +91,50 @@
             LOG.debug("Exception getting file object", ex);
         }
         if(file == null) {
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD.invalid", fileName));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD.invalid", fileName));
             return;
         }
         
         // check permission
         fileName = file.getFullName();
         if( !file.hasWritePermission() ) {
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD.permission", fileName));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD.permission", fileName));
             return;
         }
         
         // check file existance
         if(file.doesExist()) {
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD.exists", fileName));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD.exists", fileName));
             return;
         }
         
         // now create directory
         if(file.mkdir()) {
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_257_PATHNAME_CREATED, "MKD", fileName));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_257_PATHNAME_CREATED, "MKD", fileName));
             
             // write log message
             String userName = session.getUser().getName();
             LOG.info("Directory create : " + userName + " - " + fileName);
             
             // notify statistics object
-            ServerFtpStatistics ftpStat = (ServerFtpStatistics)connection.getServerContext().getFtpStatistics();
-            ftpStat.setMkdir(connection, file);
+            ServerFtpStatistics ftpStat = (ServerFtpStatistics)context.getFtpStatistics();
+            ftpStat.setMkdir(session, file);
             
             // call Ftplet.onMkdirEnd() method
             try{
-                ftpletRet = ftpletContainer.onMkdirEnd(session, request, out);
+                ftpletRet = ftpletContainer.onMkdirEnd(session.getFtpletSession(), request);
             } catch(Exception e) {
                 LOG.debug("Ftplet container threw exception", e);
                 ftpletRet = FtpletEnum.RET_DISCONNECT;
             }
             if(ftpletRet == FtpletEnum.RET_DISCONNECT) {
-                serverContext.getConnectionManager().closeConnection(connection);
+                session.closeOnFlush();
                 return;
             }
 
         }
         else {
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD", fileName));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD", fileName));
         }
     }
 }

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MLSD.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MLSD.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MLSD.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MLSD.java Sun Jan  6 14:24:29 2008
@@ -24,15 +24,14 @@
 import java.net.SocketException;
 
 import org.apache.ftpserver.DefaultFtpReply;
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.IODataConnectionFactory;
 import org.apache.ftpserver.ftplet.DataConnection;
 import org.apache.ftpserver.ftplet.DataConnectionFactory;
 import org.apache.ftpserver.ftplet.FtpException;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
-import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.interfaces.FtpIoSession;
+import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.listing.DirectoryLister;
 import org.apache.ftpserver.listing.FileFormater;
 import org.apache.ftpserver.listing.ListArgument;
@@ -61,10 +60,9 @@
     /**
      * Execute command.
      */
-    public void execute(Connection connection, 
-                        FtpRequest request,
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException, FtpException {
+    public void execute(FtpIoSession session, 
+                        FtpServerContext context,
+                        FtpRequest request) throws IOException, FtpException {
         
         try {
             
@@ -76,13 +74,13 @@
             if (connFactory instanceof IODataConnectionFactory) {
                 InetAddress address = ((IODataConnectionFactory)connFactory).getInetAddress();
                 if (address == null) {
-                    out.write(new DefaultFtpReply(FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PORT or PASV must be issued first"));
+                    session.write(new DefaultFtpReply(FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PORT or PASV must be issued first"));
                     return;
                 }
             }
             
             // get data connection
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_150_FILE_STATUS_OKAY, "MLSD", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_150_FILE_STATUS_OKAY, "MLSD", null));
 
             
             // print listing data
@@ -91,7 +89,7 @@
                 dataConnection = session.getDataConnection().openConnection();
             } catch (Exception e) {
                 LOG.debug("Exception getting the output data stream", e);
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "MLSD", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "MLSD", null));
                 return;
             }
             
@@ -107,21 +105,21 @@
             catch(SocketException ex) {
                 LOG.debug("Socket exception during data transfer", ex);
                 failure = true;
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED, "MLSD", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED, "MLSD", null));
             }
             catch(IOException ex) {
                 LOG.debug("IOException during data transfer", ex);
                 failure = true;
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN, "MLSD", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN, "MLSD", null));
             } catch(IllegalArgumentException e) {
                 LOG.debug("Illegal listing syntax: " + request.getArgument(), e);
                 // if listing syntax error - send message
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MLSD", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MLSD", null));
             }
             
             // if data transfer ok - send transfer complete message
             if(!failure) {
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_226_CLOSING_DATA_CONNECTION, "MLSD", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_226_CLOSING_DATA_CONNECTION, "MLSD", null));
             }
         }
         finally {

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MLST.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MLST.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MLST.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MLST.java Sun Jan  6 14:24:29 2008
@@ -21,13 +21,12 @@
 
 import java.io.IOException;
 
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.ftplet.FileObject;
 import org.apache.ftpserver.ftplet.FtpException;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
-import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.interfaces.FtpIoSession;
+import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.listing.FileFormater;
 import org.apache.ftpserver.listing.ListArgument;
 import org.apache.ftpserver.listing.ListArgumentParser;
@@ -49,10 +48,9 @@
     /**
      * Execute command.
      */
-    public void execute(Connection connection,
-                        FtpRequest request,
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException {
+    public void execute(FtpIoSession session,
+                        FtpServerContext context,
+                        FtpRequest request) throws IOException {
         
         // reset state variables
         session.resetState();
@@ -65,14 +63,14 @@
             file = session.getFileSystemView().getFileObject(parsedArg.getFile());
             if(file != null && file.doesExist()) {
                 FileFormater formater = new MLSTFileFormater((String[])session.getAttribute("MLST.types"));
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "MLST", formater.format(file)));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "MLST", formater.format(file)));
             } else {            
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MLST", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MLST", null));
             }
         }
         catch(FtpException ex) {
             LOG.debug("Exception sending the file listing", ex);
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MLST", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MLST", null));
         }     
     }   
 }

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MODE.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MODE.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MODE.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/MODE.java Sun Jan  6 14:24:29 2008
@@ -21,11 +21,10 @@
 
 import java.io.IOException;
 
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
-import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.interfaces.FtpIoSession;
+import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
@@ -41,17 +40,16 @@
     /**
      * Execute command
      */
-    public void execute(Connection connection,
-                       FtpRequest request,
-                       FtpSessionImpl session, 
-                       FtpReplyOutput out) throws IOException {
+    public void execute(FtpIoSession session,
+                       FtpServerContext context,
+                       FtpRequest request) throws IOException {
         
         // reset state
         session.resetState();
         
         // argument check
         if(!request.hasArgument()) {
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MODE", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MODE", null));
             return;  
         }
         
@@ -59,15 +57,15 @@
         char md = request.getArgument().charAt(0);
         md = Character.toUpperCase(md);
         if(md == 'S') {
-            session.getServerDataConnection().setZipMode(false);
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_200_COMMAND_OKAY, "MODE", "S"));
+            session.getDataConnection().setZipMode(false);
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_200_COMMAND_OKAY, "MODE", "S"));
         }
         else if(md == 'Z') {
-            session.getServerDataConnection().setZipMode(true);
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_200_COMMAND_OKAY, "MODE", "Z"));
+            session.getDataConnection().setZipMode(true);
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_200_COMMAND_OKAY, "MODE", "Z"));
         }
         else {
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "MODE", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "MODE", null));
         }
     }
 }

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/NLST.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/NLST.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/NLST.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/NLST.java Sun Jan  6 14:24:29 2008
@@ -24,15 +24,14 @@
 import java.net.SocketException;
 
 import org.apache.ftpserver.DefaultFtpReply;
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.IODataConnectionFactory;
 import org.apache.ftpserver.ftplet.DataConnection;
 import org.apache.ftpserver.ftplet.DataConnectionFactory;
 import org.apache.ftpserver.ftplet.FtpException;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
-import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.interfaces.FtpIoSession;
+import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.listing.DirectoryLister;
 import org.apache.ftpserver.listing.FileFormater;
 import org.apache.ftpserver.listing.LISTFileFormater;
@@ -65,10 +64,9 @@
     /**
      * Execute command
      */
-    public void execute(Connection connection, 
-                        FtpRequest request,
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException, FtpException {
+    public void execute(FtpIoSession session, 
+                        FtpServerContext context,
+                        FtpRequest request) throws IOException, FtpException {
         
         try {
             
@@ -80,13 +78,13 @@
             if (connFactory instanceof IODataConnectionFactory) {
                 InetAddress address = ((IODataConnectionFactory)connFactory).getInetAddress();
                 if (address == null) {
-                    out.write(new DefaultFtpReply(FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PORT or PASV must be issued first"));
+                    session.write(new DefaultFtpReply(FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PORT or PASV must be issued first"));
                     return;
                 }
             }
             
             // get data connection
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_150_FILE_STATUS_OKAY, "NLST", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_150_FILE_STATUS_OKAY, "NLST", null));
 
             
             // print listing data
@@ -95,7 +93,7 @@
                 dataConnection = session.getDataConnection().openConnection();
             } catch (Exception e) {
                 LOG.debug("Exception getting the output data stream", e);
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "NLST", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "NLST", null));
                 return;
             }
             
@@ -116,21 +114,21 @@
             catch(SocketException ex) {
                 LOG.debug("Socket exception during data transfer", ex);
                 failure = true;
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED, "NLST", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED, "NLST", null));
             }
             catch(IOException ex) {
                 LOG.debug("IOException during data transfer", ex);
                 failure = true;
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN, "NLST", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN, "NLST", null));
             } catch(IllegalArgumentException e) {
                 LOG.debug("Illegal listing syntax: " + request.getArgument(), e);
                 // if listing syntax error - send message
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "LIST", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "LIST", null));
             }
             
             // if data transfer ok - send transfer complete message
             if(!failure) {
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_226_CLOSING_DATA_CONNECTION, "NLST", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_226_CLOSING_DATA_CONNECTION, "NLST", null));
             }
         }
         finally {

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/NOOP.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/NOOP.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/NOOP.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/NOOP.java Sun Jan  6 14:24:29 2008
@@ -21,12 +21,11 @@
 
 import java.io.IOException;
 
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.ftplet.FtpException;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
-import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.interfaces.FtpIoSession;
+import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
@@ -42,12 +41,11 @@
     /**
      * Execute command
      */
-    public void execute(Connection connection, 
-                        FtpRequest request, 
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException, FtpException {
+    public void execute(FtpIoSession session, 
+                        FtpServerContext context, 
+                        FtpRequest request) throws IOException, FtpException {
         
         session.resetState();
-        out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_200_COMMAND_OKAY, "NOOP", null));
+        session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_200_COMMAND_OKAY, "NOOP", null));
     }
 }

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS.java Sun Jan  6 14:24:29 2008
@@ -22,13 +22,12 @@
 import java.io.IOException;
 import java.util.HashMap;
 
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.ftplet.FtpException;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.interfaces.Command;
-import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.interfaces.FtpIoSession;
+import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.util.FtpReplyUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -45,16 +44,15 @@
 
     private final Logger LOG = LoggerFactory.getLogger(OPTS.class);
     
-    private static final HashMap COMMAND_MAP = new HashMap(16);
+    private static final HashMap<String, Command> COMMAND_MAP = new HashMap<String, Command>(16);
     
     
     /**
      * Execute command.
      */
-    public void execute(Connection connection,
-                        FtpRequest request,
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException, FtpException {
+    public void execute(FtpIoSession session,
+                        FtpServerContext context,
+                        FtpRequest request) throws IOException, FtpException {
         
         // reset state
         session.resetState();
@@ -62,7 +60,7 @@
         // no params
         String argument = request.getArgument();
         if(argument == null) {
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "OPTS", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "OPTS", null));
             return;
         }
         
@@ -78,17 +76,17 @@
         Command command = (Command)COMMAND_MAP.get( optsRequest );
         try {
             if(command != null) {
-                command.execute(connection, request, session, out);
+                command.execute(null, null, request);
             }
             else {
                 session.resetState();
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_502_COMMAND_NOT_IMPLEMENTED, "OPTS.not.implemented", argument));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_502_COMMAND_NOT_IMPLEMENTED, "OPTS.not.implemented", argument));
             }
         }
         catch(Exception ex) {
             LOG.warn("OPTS.execute()", ex);
             session.resetState();
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_500_SYNTAX_ERROR_COMMAND_UNRECOGNIZED, "OPTS", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_500_SYNTAX_ERROR_COMMAND_UNRECOGNIZED, "OPTS", null));
         }
     }
     

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS_MLST.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS_MLST.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS_MLST.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS_MLST.java Sun Jan  6 14:24:29 2008
@@ -22,12 +22,11 @@
 import java.io.IOException;
 import java.util.StringTokenizer;
 
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.ftplet.FtpException;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
-import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.interfaces.FtpIoSession;
+import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
@@ -48,10 +47,9 @@
     /**
      * Execute command.
      */
-    public void execute(Connection connection,
-                        FtpRequest request, 
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException, FtpException {
+    public void execute(FtpIoSession session,
+                        FtpServerContext context, 
+                        FtpRequest request) throws IOException, FtpException {
         
         // reset state
         session.resetState();
@@ -60,7 +58,7 @@
         String argument = request.getArgument();
         int spIndex = argument.indexOf(' ');
         if(spIndex == -1) {
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "OPTS.MLST", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "OPTS.MLST", null));
             return;
         }
         String listTypes = argument.substring(spIndex + 1);
@@ -76,10 +74,10 @@
         String[] validatedTypes = validateSelectedTypes(types);
         if(validatedTypes != null) {
             session.setAttribute("MLST.types", validatedTypes);
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_200_COMMAND_OKAY, "OPTS.MLST", listTypes));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_200_COMMAND_OKAY, "OPTS.MLST", listTypes));
         }
         else {
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "OPTS.MLST", listTypes));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "OPTS.MLST", listTypes));
         }
     }
     

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS_UTF8.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS_UTF8.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS_UTF8.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS_UTF8.java Sun Jan  6 14:24:29 2008
@@ -21,12 +21,11 @@
 
 import java.io.IOException;
 
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.ftplet.FtpException;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
-import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.interfaces.FtpIoSession;
+import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.util.FtpReplyUtil;
 
 
@@ -42,15 +41,14 @@
     /**
      * Execute command.
      */
-    public void execute(Connection connection,
-                        FtpRequest request,
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException, FtpException {
+    public void execute(FtpIoSession session,
+                        FtpServerContext context,
+                        FtpRequest request) throws IOException, FtpException {
         
         // reset state
         session.resetState();
         
         // send default message
-        out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_200_COMMAND_OKAY, "OPTS.UTF8", null));
+        session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_200_COMMAND_OKAY, "OPTS.UTF8", null));
     }
 }

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PASS.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PASS.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PASS.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PASS.java Sun Jan  6 14:24:29 2008
@@ -20,23 +20,22 @@
 package org.apache.ftpserver.command;
 
 import java.io.IOException;
+import java.net.InetSocketAddress;
 
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.ftplet.Authentication;
 import org.apache.ftpserver.ftplet.AuthenticationFailedException;
 import org.apache.ftpserver.ftplet.FileSystemManager;
 import org.apache.ftpserver.ftplet.FileSystemView;
 import org.apache.ftpserver.ftplet.FtpException;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.ftplet.Ftplet;
 import org.apache.ftpserver.ftplet.FtpletEnum;
 import org.apache.ftpserver.ftplet.User;
 import org.apache.ftpserver.ftplet.UserManager;
+import org.apache.ftpserver.interfaces.FtpIoSession;
 import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.interfaces.ServerFtpStatistics;
-import org.apache.ftpserver.listener.Connection;
 import org.apache.ftpserver.listener.ConnectionManager;
 import org.apache.ftpserver.usermanager.AnonymousAuthentication;
 import org.apache.ftpserver.usermanager.UserMetadata;
@@ -60,16 +59,14 @@
     /**
      * Execute command.
      */
-    public void execute(Connection connection, 
-                        FtpRequest request,
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException, FtpException {
+    public void execute(FtpIoSession session, 
+                        FtpServerContext context,
+                        FtpRequest request) throws IOException, FtpException {
     
         boolean success = false;
-        FtpServerContext serverContext = connection.getServerContext();
         
-        ConnectionManager conManager = serverContext.getConnectionManager();
-        ServerFtpStatistics stat = (ServerFtpStatistics)serverContext.getFtpStatistics();
+        ConnectionManager conManager = context.getConnectionManager();
+        ServerFtpStatistics stat = (ServerFtpStatistics)context.getFtpStatistics();
         try {
             
             // reset state variables
@@ -78,7 +75,7 @@
             // argument check
             String password = request.getArgument();
             if(password == null) {
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "PASS", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "PASS", null));
                 return; 
             }
             
@@ -86,13 +83,13 @@
             String userName = session.getUserArgument();
 
             if(userName == null && session.getUser() == null) {
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PASS", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PASS", null));
                 return;
             }
             
             // already logged-in
             if(session.isLoggedIn()) {
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_202_COMMAND_NOT_IMPLEMENTED, "PASS", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_202_COMMAND_NOT_IMPLEMENTED, "PASS", null));
                 return;
             }
             
@@ -103,7 +100,7 @@
 	            int currAnonLogin = stat.getCurrentAnonymousLoginNumber();
 	            int maxAnonLogin = conManager.getMaxAnonymousLogins();
 	            if( currAnonLogin >= maxAnonLogin ) {
-	                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_421_SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION, "PASS.anonymous", null));
+	                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_421_SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION, "PASS.anonymous", null));
 	                return;
 	            }
             }
@@ -112,16 +109,19 @@
             int currLogin = stat.getCurrentLoginNumber();
             int maxLogin = conManager.getMaxLogins();
             if(maxLogin != 0 && currLogin >= maxLogin) {
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_421_SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION, "PASS.login", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_421_SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION, "PASS.login", null));
                 return;
             }
             
             // authenticate user
-            UserManager userManager = serverContext.getUserManager();
+            UserManager userManager = context.getUserManager();
             User authenticatedUser = null;
             try {
                 UserMetadata userMetadata = new UserMetadata();
-                userMetadata.setInetAddress(session.getClientAddress());
+                
+                if(session.getRemoteAddress() instanceof InetSocketAddress) {
+                	userMetadata.setInetAddress(((InetSocketAddress)session.getRemoteAddress()).getAddress());
+                }
                 userMetadata.setCertificateChain(session.getClientCertificates());
                 
                 Authentication auth;
@@ -159,17 +159,17 @@
             }
             
             // call Ftplet.onLogin() method
-            Ftplet ftpletContainer = serverContext.getFtpletContainer();
+            Ftplet ftpletContainer = context.getFtpletContainer();
             if(ftpletContainer != null) {
                 FtpletEnum ftpletRet;
                 try{
-                    ftpletRet = ftpletContainer.onLogin(session, request, out);
+                    ftpletRet = ftpletContainer.onLogin(session.getFtpletSession(), request);
                 } catch(Exception e) {
                     LOG.debug("Ftplet container threw exception", e);
                     ftpletRet = FtpletEnum.RET_DISCONNECT;
                 }
                 if(ftpletRet == FtpletEnum.RET_DISCONNECT) {
-                    serverContext.getConnectionManager().closeConnection(connection);
+                    session.closeOnFlush();
                     return;
                 } else if(ftpletRet == FtpletEnum.RET_SKIP) {
                     success = false;
@@ -185,8 +185,8 @@
                 delayAfterLoginFailure(conManager);
                 
                 LOG.warn("Login failure - " + userName);
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_530_NOT_LOGGED_IN, "PASS", userName));
-                stat.setLoginFail(connection);
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_530_NOT_LOGGED_IN, "PASS", userName));
+                stat.setLoginFail(session);
 
                 session.increaseFailedLogins();
 
@@ -194,20 +194,20 @@
                 int maxAllowedLoginFailues = conManager.getMaxLoginFailures(); 
                 if(maxAllowedLoginFailues != 0 && 
                         session.getFailedLogins() >= maxAllowedLoginFailues) {
-                    connection.close();
+                    session.closeOnFlush();
                 }
                 
                 return;
             }
             
             // update different objects
-            FileSystemManager fmanager = serverContext.getFileSystemManager(); 
+            FileSystemManager fmanager = context.getFileSystemManager(); 
             FileSystemView fsview = fmanager.createFileSystemView(authenticatedUser);
             session.setLogin(fsview);
-            stat.setLogin(connection);
+            stat.setLogin(session);
 
             // everything is fine - send login ok message
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_230_USER_LOGGED_IN, "PASS", userName));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_230_USER_LOGGED_IN, "PASS", userName));
             if(anonymous) {
                 LOG.info("Anonymous login success - " + password);
             }

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PASV.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PASV.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PASV.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PASV.java Sun Jan  6 14:24:29 2008
@@ -24,13 +24,12 @@
 import java.net.InetSocketAddress;
 
 import org.apache.ftpserver.DataConnectionException;
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.ServerDataConnectionFactory;
 import org.apache.ftpserver.ftplet.FtpException;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
-import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.interfaces.FtpIoSession;
+import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.util.FtpReplyUtil;
 import org.apache.ftpserver.util.SocketAddressEncoder;
 import org.slf4j.Logger;
@@ -53,16 +52,15 @@
     /**
      * Execute command
      */
-    public void execute(Connection connection, 
-                        FtpRequest request,
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException, FtpException {
+    public void execute(FtpIoSession session, 
+                        FtpServerContext context,
+                        FtpRequest request) throws IOException, FtpException {
         
         // reset state variables
         session.resetState();
         
         // set data connection
-        ServerDataConnectionFactory dataCon = session.getServerDataConnection();
+        ServerDataConnectionFactory dataCon = session.getDataConnection();
         InetAddress externalPassiveAddress = session.getListener().getDataConnectionConfig().getPassiveExernalAddress();
         
         try {
@@ -77,14 +75,18 @@
                 servAddr = dataConAddress.getAddress();
             }
             
+            System.out.println("############" + dataConAddress);
+            System.out.println("############" + dataConAddress.getAddress());
+            System.out.println("############" + servAddr);
+            
             // send connection info to client
             InetSocketAddress externalDataConAddress = new InetSocketAddress(servAddr, dataConAddress.getPort());
             
             String addrStr = SocketAddressEncoder.encode(externalDataConAddress);
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_227_ENTERING_PASSIVE_MODE, "PASV", addrStr));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_227_ENTERING_PASSIVE_MODE, "PASV", addrStr));
         } catch(DataConnectionException e) {
             LOG.warn("Failed to open passive data connection", e);
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "PASV", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "PASV", null));
             return;   
         }
         

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PBSZ.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PBSZ.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PBSZ.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PBSZ.java Sun Jan  6 14:24:29 2008
@@ -21,12 +21,11 @@
 
 import java.io.IOException;
 
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.ftplet.FtpException;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
-import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.interfaces.FtpIoSession;
+import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
@@ -38,12 +37,11 @@
     /**
      * Execute command.
      */
-    public void execute(Connection connection,
-                        FtpRequest request,
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException, FtpException {
+    public void execute(FtpIoSession session,
+                        FtpServerContext context,
+                        FtpRequest request) throws IOException, FtpException {
         
         session.resetState();
-        out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_200_COMMAND_OKAY, "PBSZ", null));
+        session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_200_COMMAND_OKAY, "PBSZ", null));
     }
 }

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PORT.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PORT.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PORT.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PORT.java Sun Jan  6 14:24:29 2008
@@ -24,12 +24,11 @@
 import java.net.InetSocketAddress;
 import java.net.UnknownHostException;
 
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.interfaces.DataConnectionConfig;
-import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.interfaces.FtpIoSession;
+import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.util.FtpReplyUtil;
 import org.apache.ftpserver.util.IllegalInetAddressException;
 import org.apache.ftpserver.util.IllegalPortException;
@@ -63,24 +62,23 @@
     /**
      * Execute command.
      */
-    public void execute(Connection connection,
-                        FtpRequest request,
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException {
+    public void execute(FtpIoSession session,
+                        FtpServerContext context,
+                        FtpRequest request) throws IOException {
         
         // reset state variables
         session.resetState();
         
         // argument check
         if(!request.hasArgument()) {
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "PORT", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "PORT", null));
             return;  
         }
 
         // is port enabled
         DataConnectionConfig dataCfg = session.getListener().getDataConnectionConfig();
         if(!dataCfg.isActiveEnabled()) {
-            out.write(FtpReplyUtil.translate(session, 510, "PORT.disabled", null));
+            session.write(FtpReplyUtil.translate(session, request, context, 510, "PORT.disabled", null));
             return;
         } 
         
@@ -88,29 +86,31 @@
         try {
             address = SocketAddressEncoder.decode(request.getArgument());
         } catch(IllegalInetAddressException e) {
-            out.write(FtpReplyUtil.translate(session, 510, "PORT", null));
+            session.write(FtpReplyUtil.translate(session, request, context, 510, "PORT", null));
             return;
         } catch(IllegalPortException e) {
             LOG.debug("Invalid data port: " + request.getArgument(), e);
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_552_REQUESTED_FILE_ACTION_ABORTED_EXCEEDED_STORAGE, "PORT.invalid", null)); 
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_552_REQUESTED_FILE_ACTION_ABORTED_EXCEEDED_STORAGE, "PORT.invalid", null)); 
             return; 
         } catch(UnknownHostException e) {
             LOG.debug("Unknown host", e);
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED, "PORT.host", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED, "PORT.host", null));
             return;
         }
         
         // check IP
         if(dataCfg.isActiveIpCheck()) {
-            InetAddress clientAddr = session.getClientAddress();
-            if(!address.getAddress().equals(clientAddr)) {
-                out.write(FtpReplyUtil.translate(session, 510, "PORT.mismatch", null));
-                return;
-            }
+        	if(session.getRemoteAddress() instanceof InetSocketAddress) {
+        		InetAddress clientAddr = ((InetSocketAddress)session.getRemoteAddress()).getAddress();
+        		if(!address.getAddress().equals(clientAddr)) {
+        			session.write(FtpReplyUtil.translate(session, request, context, 510, "PORT.mismatch", null));
+        			return;
+        		}
+        	}
         }
         
-        session.getServerDataConnection().initActiveDataConnection(address);
-        out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_200_COMMAND_OKAY, "PORT", null));
+        session.getDataConnection().initActiveDataConnection(address);
+        session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_200_COMMAND_OKAY, "PORT", null));
     }
     
 }

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PROT.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PROT.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PROT.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PROT.java Sun Jan  6 14:24:29 2008
@@ -22,12 +22,11 @@
 import java.io.IOException;
 
 import org.apache.ftpserver.ServerDataConnectionFactory;
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.ftplet.FtpException;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
-import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.interfaces.FtpIoSession;
+import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
@@ -39,10 +38,9 @@
     /**
      * Execute command.
      */
-    public void execute(Connection connection,
-                        FtpRequest request,
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException, FtpException {
+    public void execute(FtpIoSession session,
+                        FtpServerContext context,
+                        FtpRequest request) throws IOException, FtpException {
     
         // reset state variables
         session.resetState();
@@ -50,28 +48,28 @@
         // check argument
         String arg = request.getArgument();
         if(arg == null) {
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "PROT", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "PROT", null));
             return;
         }
         
         // check argument
         arg = arg.toUpperCase();
-        ServerDataConnectionFactory dcon = session.getServerDataConnection();
+        ServerDataConnectionFactory dcon = session.getDataConnection();
         if(arg.equals("C")) {
             dcon.setSecure(false);
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_200_COMMAND_OKAY, "PROT", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_200_COMMAND_OKAY, "PROT", null));
         }
         else if(arg.equals("P")) {
             if(session.getListener().getDataConnectionConfig().getSSL() == null) {
-                out.write(FtpReplyUtil.translate(session, 431, "PROT", null));
+                session.write(FtpReplyUtil.translate(session, request, context, 431, "PROT", null));
             }
             else {
                 dcon.setSecure(true);
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_200_COMMAND_OKAY, "PROT", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_200_COMMAND_OKAY, "PROT", null));
             }
         }
         else {
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "PROT", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "PROT", null));
         }
     }
     

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PWD.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PWD.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PWD.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PWD.java Sun Jan  6 14:24:29 2008
@@ -21,13 +21,12 @@
 
 import java.io.IOException;
 
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.ftplet.FileSystemView;
 import org.apache.ftpserver.ftplet.FtpException;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
-import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.interfaces.FtpIoSession;
+import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
@@ -42,14 +41,13 @@
     /**
      * Execute command
      */
-    public void execute(Connection connection, 
-                        FtpRequest request,
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException, FtpException {
+    public void execute(FtpIoSession session, 
+                        FtpServerContext context,
+                        FtpRequest request) throws IOException, FtpException {
         session.resetState();
         FileSystemView fsview = session.getFileSystemView();
         String currDir = fsview.getCurrentDirectory().getFullName();
-        out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_257_PATHNAME_CREATED, "PWD", currDir));
+        session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_257_PATHNAME_CREATED, "PWD", currDir));
     }
     
 }

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/QUIT.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/QUIT.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/QUIT.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/QUIT.java Sun Jan  6 14:24:29 2008
@@ -21,11 +21,10 @@
 
 import java.io.IOException;
 
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
-import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.interfaces.FtpIoSession;
+import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
@@ -40,13 +39,12 @@
     /**
      * Execute command
      */
-    public void execute(Connection connection, 
-                        FtpRequest request,
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException {
+    public void execute(FtpIoSession session, 
+                        FtpServerContext context,
+                        FtpRequest request) throws IOException {
         session.resetState();
-        out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_221_CLOSING_CONTROL_CONNECTION, "QUIT", null));
-        connection.getServerContext().getConnectionManager().closeConnection(connection);
+        session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_221_CLOSING_CONTROL_CONNECTION, "QUIT", null));
+		session.closeOnFlush();
     }
 
 }

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/REIN.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/REIN.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/REIN.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/REIN.java Sun Jan  6 14:24:29 2008
@@ -21,11 +21,10 @@
 
 import java.io.IOException;
 
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
-import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.interfaces.FtpIoSession;
+import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
@@ -40,13 +39,12 @@
     /**
      * Execute command.
      */
-    public void execute(Connection connection,
-                        FtpRequest request,
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException {
+    public void execute(FtpIoSession session,
+                        FtpServerContext context,
+                        FtpRequest request) throws IOException {
         
         session.reinitialize();
         session.setLanguage(null);
-        out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_220_SERVICE_READY, "REIN", null));
+        session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_220_SERVICE_READY, "REIN", null));
     }   
 }

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/REST.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/REST.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/REST.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/REST.java Sun Jan  6 14:24:29 2008
@@ -21,11 +21,10 @@
 
 import java.io.IOException;
 
-import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
-import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.interfaces.FtpIoSession;
+import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.util.FtpReplyUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -48,15 +47,14 @@
     /**
      * Execute command
      */
-    public void execute(Connection connection, 
-                        FtpRequest request,
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException {
+    public void execute(FtpIoSession session, 
+                        FtpServerContext context,
+                        FtpRequest request) throws IOException {
         
         // argument check
         String argument = request.getArgument();
         if(argument == null) {
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "REST", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "REST", null));
             return;  
         }
         
@@ -69,15 +67,15 @@
             // check offset number
             if(skipLen < 0L) {
                 skipLen = 0L;
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "REST.negetive", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "REST.negetive", null));
             }
             else {
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_350_REQUESTED_FILE_ACTION_PENDING_FURTHER_INFORMATION, "REST", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_350_REQUESTED_FILE_ACTION_PENDING_FURTHER_INFORMATION, "REST", null));
             }
         }
         catch(NumberFormatException ex) {
             LOG.debug("Invalid restart position: " + argument, ex);
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "REST.invalid", null)); 
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "REST.invalid", null)); 
         }
         
         session.setFileOffset(skipLen);

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/RETR.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/RETR.java?rev=609446&r1=609445&r2=609446&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/RETR.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/RETR.java Sun Jan  6 14:24:29 2008
@@ -34,10 +34,10 @@
 import org.apache.ftpserver.ftplet.DataConnection;
 import org.apache.ftpserver.ftplet.FtpException;
 import org.apache.ftpserver.ftplet.FtpReply;
-import org.apache.ftpserver.ftplet.FtpReplyOutput;
 import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.ftplet.Ftplet;
 import org.apache.ftpserver.ftplet.FtpletEnum;
+import org.apache.ftpserver.interfaces.FtpIoSession;
 import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.interfaces.ServerFtpStatistics;
 import org.apache.ftpserver.listener.Connection;
@@ -62,29 +62,27 @@
     /**
      * Execute command.
      */
-    public void execute(Connection connection,
-                        FtpRequest request,
-                        FtpSessionImpl session, 
-                        FtpReplyOutput out) throws IOException, FtpException {
+    public void execute(FtpIoSession session,
+                        FtpServerContext context,
+                        FtpRequest request) throws IOException, FtpException {
         
         try {
         
             // get state variable
             long skipLen = session.getFileOffset();
-            FtpServerContext serverContext = connection.getServerContext();
             
             // argument check
             String fileName = request.getArgument();
             if(fileName == null) {
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "RETR", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "RETR", null));
                 return;  
             }
     
             // call Ftplet.onDownloadStart() method
-            Ftplet ftpletContainer = serverContext.getFtpletContainer();
+            Ftplet ftpletContainer = context.getFtpletContainer();
             FtpletEnum ftpletRet;
             try {
-                ftpletRet = ftpletContainer.onDownloadStart(session, request, out);
+                ftpletRet = ftpletContainer.onDownloadStart(session.getFtpletSession(), request);
             } catch(Exception e) {
                 LOG.debug("Ftplet container threw exception", e);
                 ftpletRet = FtpletEnum.RET_DISCONNECT;
@@ -93,7 +91,7 @@
                 return;
             }
             else if(ftpletRet == FtpletEnum.RET_DISCONNECT) {
-                serverContext.getConnectionManager().closeConnection(connection);
+                session.closeOnFlush();
                 return;
             }
             
@@ -106,26 +104,26 @@
                 LOG.debug("Exception getting file object", ex);
             }
             if(file == null) {
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "RETR.missing", fileName));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "RETR.missing", fileName));
                 return;
             }
             fileName = file.getFullName();
             
             // check file existance
             if(!file.doesExist()) {
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "RETR.missing", fileName));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "RETR.missing", fileName));
                 return;
             }
             
             // check valid file
             if(!file.isFile()) {
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "RETR.invalid", fileName));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "RETR.invalid", fileName));
                 return;
             }
             
             // check permission
             if(!file.hasReadPermission()) {
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "RETR.permission", fileName));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "RETR.permission", fileName));
                 return;
             }
 
@@ -134,13 +132,13 @@
             if (connFactory instanceof IODataConnectionFactory) {
                 InetAddress address = ((IODataConnectionFactory)connFactory).getInetAddress();
                 if (address == null) {
-                    out.write(new DefaultFtpReply(FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PORT or PASV must be issued first"));
+                    session.write(new DefaultFtpReply(FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PORT or PASV must be issued first"));
                     return;
                 }
             }
             
             // get data connection
-            out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_150_FILE_STATUS_OKAY, "RETR", null));
+            session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_150_FILE_STATUS_OKAY, "RETR", null));
 
             
             // send file data to client
@@ -152,14 +150,14 @@
                 dataConnection = session.getDataConnection().openConnection();
             } catch (Exception e) {
                 LOG.debug("Exception getting the output data stream", e);
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "RETR", null));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "RETR", null));
                 return;
             }
             
             try {
                 
                 // open streams
-                is = openInputStream(connection, session, file, skipLen);
+                is = openInputStream(session, file, skipLen);
                 
                 // transfer data
                 long transSz = dataConnection.transferToClient(is);
@@ -169,20 +167,20 @@
                 LOG.info("File download : " + userName + " - " + fileName);
                 
                 // notify the statistics component
-                ServerFtpStatistics ftpStat = (ServerFtpStatistics)serverContext.getFtpStatistics();
+                ServerFtpStatistics ftpStat = (ServerFtpStatistics)context.getFtpStatistics();
                 if(ftpStat != null)  {
-                    ftpStat.setDownload(connection, file, transSz);
+                    ftpStat.setDownload(session, file, transSz);
                 }
             }
             catch(SocketException ex) {
                 LOG.debug("Socket exception during data transfer", ex);
                 failure = true;
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED, "RETR", fileName));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED, "RETR", fileName));
             }
             catch(IOException ex) {
                 LOG.debug("IOException during data transfer", ex);
                 failure = true;
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN, "RETR", fileName));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN, "RETR", fileName));
             }
             finally {
                 IoUtils.close(is);
@@ -190,17 +188,17 @@
             
             // if data transfer ok - send transfer complete message
             if(!failure) {
-                out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_226_CLOSING_DATA_CONNECTION, "RETR", fileName));
+                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_226_CLOSING_DATA_CONNECTION, "RETR", fileName));
                 
                 // call Ftplet.onDownloadEnd() method
                 try {
-                    ftpletRet = ftpletContainer.onDownloadEnd(session, request, out);
+                    ftpletRet = ftpletContainer.onDownloadEnd(session.getFtpletSession(), request);
                 } catch(Exception e) {
                     LOG.debug("Ftplet container threw exception", e);
                     ftpletRet = FtpletEnum.RET_DISCONNECT;
                 }
                 if(ftpletRet == FtpletEnum.RET_DISCONNECT) {
-                    serverContext.getConnectionManager().closeConnection(connection);
+                    session.closeOnFlush();
                     return;
                 }
 
@@ -215,8 +213,7 @@
     /**
      * Skip length and open input stream.
      */
-    public InputStream openInputStream(Connection connection,
-                                       FtpSessionImpl session, 
+    public InputStream openInputStream(FtpIoSession session, 
                                        FileObject file, 
                                        long skipLen) throws IOException {
         InputStream in;



Mime
View raw message