incubator-ftpserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r498472 [1/2] - in /incubator/ftpserver/trunk: core/src/java/org/apache/ftpserver/ core/src/java/org/apache/ftpserver/command/ core/src/java/org/apache/ftpserver/interfaces/ core/src/java/org/apache/ftpserver/listener/ core/src/java/org/apa...
Date Sun, 21 Jan 2007 22:43:54 GMT
Author: ngn
Date: Sun Jan 21 14:43:52 2007
New Revision: 498472

URL: http://svn.apache.org/viewvc?view=rev&rev=498472
Log:
Moved reply translation out of FtpWriter into a dedicated factory.

Added:
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/interfaces/FtpServerSession.java   (with props)
Modified:
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/ConfigurableFtpServerContext.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpResponseImpl.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpSessionImpl.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpWriter.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/ABOR.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/ACCT.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/APPE.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/AUTH.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/CDUP.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/CWD.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/DELE.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/EPRT.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/EPSV.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/FEAT.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/HELP.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/LANG.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/LIST.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MD5.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MDTM.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MKD.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MLSD.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MLST.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MODE.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/NLST.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/NOOP.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/OPTS.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/OPTS_MLST.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/OPTS_UTF8.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PASS.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PASV.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PBSZ.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PORT.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PROT.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PWD.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/QUIT.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/REIN.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/REST.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/RETR.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/RMD.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/RNFR.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/RNTO.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/SITE.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/SITE_DESCUSER.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/SITE_HELP.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/SITE_STAT.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/SITE_WHO.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/SIZE.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STAT.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STOR.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STOU.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STRU.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/SYST.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/TYPE.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/USER.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/interfaces/FtpServerContext.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/FtpProtocolHandler.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/io/IOConnection.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/io/IOFtpResponseOutput.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina/MinaConnection.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina/MinaFtpProtocolHandler.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/socketfactory/SSLFtpSocketFactory.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/command/AbstractCommandTestTemplate.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/filesystem/NativeFileObjectTest.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/ftplet/FtpLetContainerTestTemplate.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/listing/DirectoryListerTest.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/listing/LISTFileFormaterTest.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/listing/ListArgumentParserTest.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/listing/ListArgumentTest.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/listing/MLSTFileFormaterTest.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/listing/NLSTFileFormaterTest.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/BaseUserTest.java
    incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/FtpSession.java

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/ConfigurableFtpServerContext.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/ConfigurableFtpServerContext.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/ConfigurableFtpServerContext.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/ConfigurableFtpServerContext.java Sun Jan 21 14:43:52 2007
@@ -49,8 +49,8 @@
 import org.apache.ftpserver.socketfactory.FtpSocketFactory;
 import org.apache.ftpserver.usermanager.BaseUser;
 import org.apache.ftpserver.usermanager.ConcurrentLoginPermission;
-import org.apache.ftpserver.usermanager.TransferRatePermission;
 import org.apache.ftpserver.usermanager.PropertiesUserManager;
+import org.apache.ftpserver.usermanager.TransferRatePermission;
 import org.apache.ftpserver.usermanager.WritePermission;
 
 /**

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpResponseImpl.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpResponseImpl.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpResponseImpl.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpResponseImpl.java Sun Jan 21 14:43:52 2007
@@ -54,7 +54,8 @@
      * @see java.lang.Object#toString()
      */
     public String toString() {
-        String notNullMessage = message;
+        int code = getCode();
+        String notNullMessage = getMessage();
         if(notNullMessage == null) {
             notNullMessage = "";
         }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpSessionImpl.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpSessionImpl.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpSessionImpl.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpSessionImpl.java Sun Jan 21 14:43:52 2007
@@ -28,14 +28,15 @@
 import org.apache.ftpserver.ftplet.FileObject;
 import org.apache.ftpserver.ftplet.FileSystemView;
 import org.apache.ftpserver.ftplet.FtpRequest;
-import org.apache.ftpserver.ftplet.FtpSession;
 import org.apache.ftpserver.ftplet.Structure;
 import org.apache.ftpserver.ftplet.User;
+import org.apache.ftpserver.interfaces.FtpServerContext;
+import org.apache.ftpserver.interfaces.FtpServerSession;
 
 /**
  * FTP session
  */
-public class FtpSessionImpl implements FtpSession {
+public class FtpSessionImpl implements FtpServerSession {
 
     
     /**
@@ -45,6 +46,7 @@
     private User user;
     private HashMap attributeMap;
     private InetAddress remoteAddr;
+    private InetAddress serverAddr;
     private String language;
     private Certificate[] clientCertificates;
     
@@ -62,11 +64,13 @@
     
     private DataType dataType    = DataType.ASCII;
     private Structure structure  = Structure.FILE;
+    private FtpServerContext serverContext;
     
     /**
      * Default constructor.
      */
-    public FtpSessionImpl() {
+    public FtpSessionImpl(FtpServerContext serverContext) {
+        this.serverContext = serverContext;
         attributeMap = new HashMap();
         userArgument = null;
         user = null;
@@ -352,5 +356,17 @@
     
     public void setClientCertificates(Certificate[] certificates) {
         this.clientCertificates = certificates;
+    }
+
+    public InetAddress getServerAddress() {
+        return serverAddr;
+    }
+
+    public void setServerAddress(InetAddress adress) {
+        this.serverAddr = adress;
+    }
+
+    public FtpServerContext getServerContext() {
+        return serverContext;
     }
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpWriter.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpWriter.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpWriter.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpWriter.java Sun Jan 21 14:43:52 2007
@@ -19,19 +19,9 @@
 
 package org.apache.ftpserver;
 
-import java.io.IOException;
-import java.net.InetAddress;
-
 import org.apache.commons.logging.Log;
-import org.apache.ftpserver.ftplet.FileSystemView;
-import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.ftplet.FtpResponseOutput;
-import org.apache.ftpserver.ftplet.FtpSession;
-import org.apache.ftpserver.ftplet.FtpStatistics;
-import org.apache.ftpserver.interfaces.FtpServerContext;
-import org.apache.ftpserver.interfaces.MessageResource;
 import org.apache.ftpserver.listener.ConnectionObserver;
-import org.apache.ftpserver.util.DateUtils;
 
 /**
  * FTP response object. The server uses this to send server messages
@@ -40,67 +30,9 @@
  */
 public abstract class FtpWriter implements FtpResponseOutput {
 
-    ///////////////////////// All Server Vatiables /////////////////////////
-    public static final String SERVER_IP   = "server.ip";
-    public static final String SERVER_PORT = "server.port";
-    
-    public static final String REQUEST_LINE = "request.line";
-    public static final String REQUEST_CMD  = "request.cmd";
-    public static final String REQUEST_ARG  = "request.arg";
-    
-    public static final String STAT_START_TIME = "stat.start.time";
-    
-    public static final String STAT_CON_TOTAL = "stat.con.total";
-    public static final String STAT_CON_CURR  = "stat.con.curr";
-    
-    public static final String STAT_LOGIN_TOTAL = "stat.login.total";
-    public static final String STAT_LOGIN_CURR  = "stat.login.curr";
-    
-    public static final String STAT_LOGIN_ANON_TOTAL = "stat.login.anon.total";
-    public static final String STAT_LOGIN_ANON_CURR  = "stat.login.anon.curr";
-    
-    public static final String STAT_FILE_UPLOAD_COUNT = "stat.file.upload.count";
-    public static final String STAT_FILE_UPLOAD_BYTES = "stat.file.upload.bytes";
-    
-    public static final String STAT_FILE_DOWNLOAD_COUNT = "stat.file.download.count";
-    public static final String STAT_FILE_DOWNLOAD_BYTES = "stat.file.download.bytes";
-    
-    public static final String STAT_FILE_DELETE_COUNT = "stat.file.delete.count";
-    
-    public static final String STAT_DIR_CREATE_COUNT  = "stat.dir.create.count";
-    public static final String STAT_DIR_DELETE_COUNT  = "stat.dir.delete.count";
-    
-    public static final String OUTPUT_CODE = "output.code";
-    public static final String OUTPUT_MSG  = "output.msg";
-    
-    public static final String CLIENT_IP          = "client.ip";
-    public static final String CLIENT_CON_TIME    = "client.con.time";
-    public static final String CLIENT_LOGIN_NAME  = "client.login.name";
-    public static final String CLIENT_LOGIN_TIME  = "client.login.time";
-    public static final String CLIENT_ACCESS_TIME = "client.access.time"; 
-    public static final String CLIENT_HOME        = "client.home";
-    public static final String CLIENT_DIR         = "client.dir";
-    
-    /////////////////////////////////////////////////////////////////////////////
-    
     protected Log log;
     private ConnectionObserver observer;
-    private FtpServerContext serverContext;
-    private FtpSession session;
-    /**
-     * Set ftp config.
-     */
-    public void setServerContext(FtpServerContext serverContext) {
-        this.serverContext = serverContext;
-        log = this.serverContext.getLogFactory().getInstance(getClass());
-    }
-
-    /**
-     * Set ftp request.
-     */
-    public void setFtpSession(FtpSession session) {
-        this.session = session;
-    }
+    
     
     /**
      * Get the observer object to get what the server response.
@@ -117,374 +49,6 @@
         if(observer != null) {
             observer.response(str);
         }
-    }
-    
-    /**
-     * Generate and send ftp server response.
-     */
-    public void send(int code, String subId, String basicMsg) throws IOException {
-        MessageResource resource = serverContext.getMessageResource();
-        String lang = session.getLanguage();
-        
-        String msg = null;
-        if(resource != null ) {
-            msg = resource.getMessage(code, subId, lang);
-        }
-        if(msg == null) {
-            log.error("Message not found : " + code + ',' + subId + ',' + lang);
-            msg = "";
-        }
-        msg = replaceVariables(code, basicMsg, msg);
-        
-        write(new FtpResponseImpl(code, msg));
-    }
-    
-    /**
-     * Replace server variables.
-     */
-    private String replaceVariables(int code, String basicMsg, String str) {
-        
-        int startIndex = 0;
-        int openIndex = str.indexOf('{', startIndex);
-        if (openIndex == -1) {
-            return str;
-        }
-        
-        int closeIndex = str.indexOf('}', startIndex);
-        if( (closeIndex == -1) || (openIndex > closeIndex) ) {
-            return str;
-        }
-        
-        StringBuffer sb = new StringBuffer(128);
-        sb.append(str.substring(startIndex, openIndex));
-        while(true) {
-            String varName = str.substring(openIndex+1, closeIndex);
-            sb.append( getVariableValue(code, basicMsg, varName) );
-            
-            startIndex = closeIndex + 1;
-            openIndex = str.indexOf('{', startIndex);
-            if (openIndex == -1) {
-                sb.append(str.substring(startIndex));
-                break;
-            }
-            
-            closeIndex = str.indexOf('}', startIndex);
-            if( (closeIndex == -1) || (openIndex > closeIndex) ) {
-               sb.append(str.substring(startIndex));
-               break;
-            }
-            sb.append(str.substring(startIndex, openIndex));
-        }
-        return sb.toString();
-    } 
-    
-    /**
-     * Get the variable value.
-     */
-    private String getVariableValue(int code, String basicMsg, String varName) {
-        
-        String varVal = null;
-        
-        // all output variables
-        if(varName.startsWith("output.")) {
-            varVal = getOutputVariableValue(code, basicMsg, varName);
-        }
-
-        // all server variables
-        else if(varName.startsWith("server.")) {
-            varVal = getServerVariableValue(varName);
-        }
-        
-        // all request variables
-        else if(varName.startsWith("request.")) {
-            varVal = getRequestVariableValue(varName);
-        }
-        
-        // all statistical variables
-        else if(varName.startsWith("stat.")) {
-            varVal = getStatisticalVariableValue(varName);
-        }
-                
-        // all client variables
-        else if(varName.startsWith("client.")) {
-            varVal = getClientVariableValue(varName);
-        }
-        
-        if(varVal == null) {
-            varVal = "";
-        }
-        return varVal;
-    } 
-    
-    protected abstract InetAddress getFallbackServerAddress();
-    
-    /**
-     * Get server variable value.
-     */
-    private String getServerVariableValue(String varName) {
-        
-        String varVal = null;
-        
-        // server address
-        if(varName.equals(SERVER_IP)) {
-            InetAddress addr = serverContext.getDataConnectionConfig().getPassiveAddress();
-            if(addr == null) {
-                addr = getFallbackServerAddress();
-            }
-            if(addr != null) {
-                varVal = addr.getHostAddress();
-            }
-        }
-        
-        // server port
-        else if(varName.equals(SERVER_PORT)) {
-            varVal = String.valueOf(serverContext.getServerPort());
-        }
-        
-        return varVal;
-    }
-
-    /**
-     * Get request variable value.
-     */
-    private String getRequestVariableValue(String varName) {
-        
-        String varVal = null;
-        
-        FtpRequest request = session.getCurrentRequest();
-        
-        if(request == null) {
-            return "";
-        }
-        
-        // request line
-        if(varName.equals(REQUEST_LINE)) {
-            varVal = request.getRequestLine();
-        }
-        
-        // request command
-        else if(varName.equals(REQUEST_CMD)) {
-            varVal = request.getCommand();
-        }
-        
-        // request argument
-        else if(varName.equals(REQUEST_ARG)) {
-            varVal = request.getArgument();
-        }
-        
-        return varVal;
-    }
-    
-    /**
-     * Get statistical variable value. 
-     */
-    private String getStatisticalVariableValue(String varName) {
-    
-        String varVal = null;
-        FtpStatistics stat = serverContext.getFtpStatistics();
-        
-        // server start time
-        if(varName.equals(STAT_START_TIME)) {
-            varVal = DateUtils.getISO8601Date(stat.getStartTime().getTime());
-        }
-        
-        // connection statistical variables
-        else if(varName.startsWith("stat.con")) {
-            varVal = getStatisticalConnectionVariableValue(varName);
-        }
-        
-        // login statistical variables
-        else if(varName.startsWith("stat.login.")) {
-            varVal = getStatisticalLoginVariableValue(varName);
-        }
-        
-        // file statistical variable
-        else if(varName.startsWith("stat.file")) {
-            varVal = getStatisticalFileVariableValue(varName);
-        }
-        
-        // directory statistical variable
-        else if(varName.startsWith("stat.dir.")) {
-            varVal = getStatisticalDirectoryVariableValue(varName);
-        }
-        
-        return varVal;
-    }
-    
-    /**
-     * Get statistical connection variable value.
-     */
-    private String getStatisticalConnectionVariableValue(String varName) {
-        String varVal = null;
-        FtpStatistics stat = serverContext.getFtpStatistics();
-        
-        // total connection number
-        if(varName.equals(STAT_CON_TOTAL)) {
-            varVal = String.valueOf(stat.getTotalConnectionNumber());
-        }
-        
-        // current connection number
-        else if(varName.equals(STAT_CON_CURR)) {
-            varVal = String.valueOf(stat.getCurrentConnectionNumber());
-        }
-        
-        return varVal;
-    }
-    
-    /**
-     * Get statistical login variable value.
-     */
-    private String getStatisticalLoginVariableValue(String varName) {
-        String varVal = null;
-        FtpStatistics stat = serverContext.getFtpStatistics();
-        
-        // total login number
-        if(varName.equals(STAT_LOGIN_TOTAL)) {
-            varVal = String.valueOf(stat.getTotalLoginNumber());
-        }
-        
-        // current login number
-        else if(varName.equals(STAT_LOGIN_CURR)) {
-            varVal = String.valueOf(stat.getCurrentLoginNumber());
-        }
-        
-        // total anonymous login number
-        else if(varName.equals(STAT_LOGIN_ANON_TOTAL)) {
-            varVal = String.valueOf(stat.getTotalAnonymousLoginNumber());
-        }
-        
-        // current anonymous login number
-        else if(varName.equals(STAT_LOGIN_ANON_CURR)) {
-            varVal = String.valueOf(stat.getCurrentAnonymousLoginNumber());
-        }
-        
-        return varVal; 
-    }
-    
-    /**
-     * Get statistical file variable value.
-     */
-    private String getStatisticalFileVariableValue(String varName) {
-        String varVal = null;
-        FtpStatistics stat = serverContext.getFtpStatistics();
-        
-        // total number of file upload
-        if(varName.equals(STAT_FILE_UPLOAD_COUNT)) {
-            varVal = String.valueOf(stat.getTotalUploadNumber());
-        }
-        
-        // total bytes uploaded
-        else if(varName.equals(STAT_FILE_UPLOAD_BYTES)) {
-            varVal = String.valueOf(stat.getTotalUploadSize());
-        }
-        
-        // total number of file download
-        else if(varName.equals(STAT_FILE_DOWNLOAD_COUNT)) {
-            varVal = String.valueOf(stat.getTotalDownloadNumber());
-        }
-        
-        // total bytes downloaded
-        else if(varName.equals(STAT_FILE_DOWNLOAD_BYTES)) {
-            varVal = String.valueOf(stat.getTotalDownloadSize());
-        }
-        
-        // total number of files deleted
-        else if(varName.equals(STAT_FILE_DELETE_COUNT)) {
-            varVal = String.valueOf(stat.getTotalDeleteNumber());
-        }
-        
-        return varVal;
-    }
-    
-    /**
-     * Get statistical directory variable value.
-     */
-    private String getStatisticalDirectoryVariableValue(String varName) {
-        String varVal = null;
-        FtpStatistics stat = serverContext.getFtpStatistics();
-        
-        // total directory created
-        if(varName.equals(STAT_DIR_CREATE_COUNT)) {
-            varVal = String.valueOf(stat.getTotalDirectoryCreated());
-        }
-        
-        // total directory removed
-        else if(varName.equals(STAT_DIR_DELETE_COUNT)) {
-            varVal = String.valueOf(stat.getTotalDirectoryRemoved());
-        }
-        
-        return varVal;
-    }
-    
-    /**
-     * Get output variable value.
-     */
-    private String getOutputVariableValue(int code, String basicMsg, String varName) {
-        String varVal = null;
-        
-        // output code
-        if(varName.equals(OUTPUT_CODE)) {
-            varVal = String.valueOf(code);
-        }
-        
-        // output message
-        else if(varName.equals(OUTPUT_MSG)) {
-            varVal = basicMsg;
-        }
-        
-        return varVal;
-    }
-
-    /**
-     * Get client variable value.
-     */
-    private String getClientVariableValue(String varName) {
-        
-        String varVal = null;
-        
-        // client ip
-        if(varName.equals(CLIENT_IP)) {
-            varVal = session.getClientAddress().getHostAddress();
-        }
-        
-        // client connection time
-        else if(varName.equals(CLIENT_CON_TIME)) {
-            varVal = DateUtils.getISO8601Date(session.getConnectionTime().getTime());
-        }
-        
-        // client login name
-        else if(varName.equals(CLIENT_LOGIN_NAME)) {
-            varVal = session.getUserArgument();
-        }
-        
-        // client login time
-        else if(varName.equals(CLIENT_LOGIN_TIME)) {
-            varVal = DateUtils.getISO8601Date(session.getLoginTime().getTime());
-        }
-        
-        // client last access time
-        else if(varName.equals(CLIENT_ACCESS_TIME)) {
-            varVal = DateUtils.getISO8601Date(session.getLastAccessTime().getTime());
-        }
-        
-        // client home
-        else if(varName.equals(CLIENT_HOME)) {
-            varVal = session.getUser().getHomeDirectory();
-        }
-        
-        // client directory
-        else if(varName.equals(CLIENT_DIR)) {
-            FileSystemView fsView = session.getFileSystemView();
-            if(fsView != null) {
-                try {
-                    varVal = fsView.getCurrentDirectory().getFullName();
-                }
-                catch(Exception ex) {
-                    log.debug("Exception getting name of file object", ex);
-                }
-            }
-        }
-        return varVal; 
     }
     
     public abstract void close();

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/ABOR.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/ABOR.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/ABOR.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/ABOR.java Sun Jan 21 14:43:52 2007
@@ -26,6 +26,7 @@
 import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.ftplet.FtpResponse;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * <code>ABOR &lt;CRLF&gt;</code><br>
@@ -57,6 +58,6 @@
         
         // and abort any data connection
         session.getFtpDataConnection().closeDataSocket();
-        out.send(FtpResponse.REPLY_226_CLOSING_DATA_CONNECTION, "ABOR", null);
+        out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_226_CLOSING_DATA_CONNECTION, "ABOR", null));
     }   
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/ACCT.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/ACCT.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/ACCT.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/ACCT.java Sun Jan 21 14:43:52 2007
@@ -26,6 +26,7 @@
 import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.ftplet.FtpResponse;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * <code>ACCT &lt;CRLF&gt;</code><br>
@@ -50,7 +51,7 @@
         session.resetState();
         
         // and abort any data connection
-        out.send(FtpResponse.REPLY_202_COMMAND_NOT_IMPLEMENTED, "ACCT", null);
+        out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_202_COMMAND_NOT_IMPLEMENTED, "ACCT", null));
     }   
 }
 

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/APPE.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/APPE.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/APPE.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/APPE.java Sun Jan 21 14:43:52 2007
@@ -36,6 +36,7 @@
 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.apache.ftpserver.util.IoUtils;
 
 /**
@@ -70,7 +71,7 @@
             // argument check
             String fileName = request.getArgument();
             if(fileName == null) {
-                out.send(FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "APPE", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "APPE", null));
                 return;  
             }
             
@@ -100,32 +101,32 @@
                 log.debug("File system threw exception", e);
             }
             if(file == null) {
-                out.send(FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "APPE.invalid", fileName);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "APPE.invalid", fileName));
                 return;
             }
             fileName = file.getFullName();
             
             // check file existance
             if(file.doesExist() && !file.isFile()) {
-                out.send(FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "APPE.invalid", fileName);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "APPE.invalid", fileName));
                 return;
             }
             
             // check permission
             if( !file.hasWritePermission()) {
-                out.send(FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "APPE.permission", fileName);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "APPE.permission", fileName));
                 return;
             }
             
             // get data connection
-            out.send(FtpResponse.REPLY_150_FILE_STATUS_OKAY, "APPE", fileName);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_150_FILE_STATUS_OKAY, "APPE", fileName));
             
             FtpDataConnection dataConnection;
             try {
                 dataConnection = session.getFtpDataConnection().openConnection();
             } catch (Exception e) {
                 log.debug("Exception when getting data input stream", e);
-                out.send(FtpResponse.REPLY_425_CANT_OPEN_DATA_CONNECTION, "APPE", fileName);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_425_CANT_OPEN_DATA_CONNECTION, "APPE", fileName));
                 return;
             }
              
@@ -158,12 +159,12 @@
             catch(SocketException e) {
                 log.debug("SocketException during file upload", e);
                 failure = true;
-                out.send(FtpResponse.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED, "APPE", fileName);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED, "APPE", fileName));
             }
             catch(IOException e) {
                 log.debug("IOException during file upload", e);
                 failure = true;
-                out.send(FtpResponse.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN, "APPE", fileName);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN, "APPE", fileName));
             }
             finally {
                 IoUtils.close(os);
@@ -171,7 +172,7 @@
             
             // if data transfer ok - send transfer complete message
             if(!failure) {
-                out.send(FtpResponse.REPLY_226_CLOSING_DATA_CONNECTION, "APPE", fileName);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_226_CLOSING_DATA_CONNECTION, "APPE", fileName));
                 
                 // call Ftplet.onAppendEnd() method
                 try {

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/AUTH.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/AUTH.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/AUTH.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/AUTH.java Sun Jan 21 14:43:52 2007
@@ -29,6 +29,7 @@
 import org.apache.ftpserver.ftplet.FtpResponse;
 import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * This server supports explicit SSL support.
@@ -52,7 +53,7 @@
         
         // argument check
         if(!request.hasArgument()) {
-            out.send(FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "AUTH", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "AUTH", null));
             return;  
         }
         
@@ -60,7 +61,7 @@
         FtpServerContext serverContext = connection.getServerContext();
         Log log = serverContext.getLogFactory().getInstance(getClass());
         if(serverContext.getSocketFactory().getSSL() == null) {
-            out.send(431, "AUTH", null);
+            out.write(FtpReplyUtil.translate(session, 431, "AUTH", null));
             return;
         }
         
@@ -69,7 +70,7 @@
         if(authType.equals("SSL")) {
             try {
                 connection.beforeSecureControlChannel("SSL");
-                out.send(234, "AUTH.SSL", null);
+                out.write(FtpReplyUtil.translate(session, 234, "AUTH.SSL", null));
                 connection.afterSecureControlChannel("SSL");
             } catch(FtpException ex) {
                 throw ex;
@@ -81,7 +82,7 @@
         else if(authType.equals("TLS")) {
             try {
                 connection.beforeSecureControlChannel("TLS");
-                out.send(234, "AUTH.TLS", null);
+                out.write(FtpReplyUtil.translate(session, 234, "AUTH.TLS", null));
                 connection.afterSecureControlChannel("TLS");
             } catch(FtpException ex) {
                 throw ex;
@@ -91,7 +92,7 @@
             }
         }
         else {
-            out.send(FtpResponse.REPLY_502_COMMAND_NOT_IMPLEMENTED, "AUTH", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_502_COMMAND_NOT_IMPLEMENTED, "AUTH", null));
         }
     }
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/CDUP.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/CDUP.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/CDUP.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/CDUP.java Sun Jan 21 14:43:52 2007
@@ -28,6 +28,7 @@
 import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.ftplet.FtpResponse;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * <code>CDUP &lt;CRLF&gt;</code><br>
@@ -65,10 +66,10 @@
         }
         if(success) {
             String dirName = fsview.getCurrentDirectory().getFullName();
-            out.send(FtpResponse.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "CDUP", dirName);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "CDUP", dirName));
         }
         else {
-            out.send(FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "CDUP", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "CDUP", null));
         }
     }
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/CWD.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/CWD.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/CWD.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/CWD.java Sun Jan 21 14:43:52 2007
@@ -28,6 +28,7 @@
 import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.ftplet.FtpResponse;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * <code>CWD  &lt;SP&gt; &lt;pathname&gt; &lt;CRLF&gt;</code><br>
@@ -71,10 +72,10 @@
         }
         if(success) {
             dirName = fsview.getCurrentDirectory().getFullName();
-            out.send(FtpResponse.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "CWD", dirName);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "CWD", dirName));
         }
         else {
-            out.send(FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "CWD", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "CWD", null));
         }
     }
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/DELE.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/DELE.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/DELE.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/DELE.java Sun Jan 21 14:43:52 2007
@@ -33,6 +33,7 @@
 import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.interfaces.ServerFtpStatistics;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * <code>DELE &lt;SP&gt; &lt;pathname&gt; &lt;CRLF&gt;</code><br>
@@ -61,7 +62,7 @@
         // argument check
         String fileName = request.getArgument();
         if(fileName == null) {
-            out.send(FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "DELE", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "DELE", null));
             return;  
         }
         
@@ -75,7 +76,7 @@
             ftpletRet = FtpletEnum.RET_DISCONNECT;
         }
         if(ftpletRet == FtpletEnum.RET_SKIP) {
-            out.send(FtpResponse.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN, "DELE", fileName);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN, "DELE", fileName));
             return;
         }
         else if(ftpletRet == FtpletEnum.RET_DISCONNECT) {
@@ -93,7 +94,7 @@
             log.debug("Could not get file " + fileName, ex);
         }
         if(file == null) {
-            out.send(FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "DELE.invalid", fileName);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "DELE.invalid", fileName));
             return;
         }
 
@@ -101,13 +102,13 @@
         fileName = file.getFullName();
 
         if( !file.hasDeletePermission() ) {
-            out.send(FtpResponse.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN, "DELE.permission", fileName);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN, "DELE.permission", fileName));
             return;
         }
         
         // now delete
         if(file.delete()) {
-            out.send(FtpResponse.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "DELE", fileName); 
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "DELE", fileName)); 
             
             // log message
             String userName = session.getUser().getName();
@@ -132,7 +133,7 @@
 
         }
         else {
-            out.send(FtpResponse.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN, "DELE", fileName);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN, "DELE", fileName));
         }
     }
 

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/EPRT.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/EPRT.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/EPRT.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/EPRT.java Sun Jan 21 14:43:52 2007
@@ -29,6 +29,7 @@
 import org.apache.ftpserver.ftplet.FtpResponse;
 import org.apache.ftpserver.interfaces.DataConnectionConfig;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * The EPRT command allows for the specification of an extended address
@@ -57,14 +58,14 @@
         // argument check
         String arg = request.getArgument();
         if(arg == null) {
-            out.send(FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "EPRT", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "EPRT", null));
             return;  
         }
         
         // is port enabled
         DataConnectionConfig dataCfg = connection.getServerContext().getDataConnectionConfig();
         if(!dataCfg.isActiveEnabled()) {
-            out.send(510, "EPRT.disabled", null);
+            out.write(FtpReplyUtil.translate(session, 510, "EPRT.disabled", null));
             return;
         }
         
@@ -79,7 +80,7 @@
         }
         catch(Exception ex) {
             log.debug("Exception parsing host and port: " + arg, ex);
-            out.send(510, "EPRT", null);
+            out.write(FtpReplyUtil.translate(session, 510, "EPRT", null));
             return;
         }
         
@@ -90,7 +91,7 @@
         }
         catch(UnknownHostException ex) {
             log.debug("Unknown host: " + host, ex);
-            out.send(FtpResponse.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED, "EPRT.host", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED, "EPRT.host", null));
             return;
         }
         
@@ -98,7 +99,7 @@
         if(dataCfg.isActiveIpCheck()) {
             InetAddress clientAddr = session.getClientAddress();
             if(!dataAddr.equals(clientAddr)) {
-                out.send(510, "EPRT.mismatch", null);
+                out.write(FtpReplyUtil.translate(session, 510, "EPRT.mismatch", null));
                 return;
             }
         }
@@ -110,11 +111,11 @@
         }
         catch(NumberFormatException ex) {
             log.debug("Invalid port: " + port, ex);
-            out.send(FtpResponse.REPLY_552_REQUESTED_FILE_ACTION_ABORTED_EXCEEDED_STORAGE, "EPRT.invalid", null); 
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_552_REQUESTED_FILE_ACTION_ABORTED_EXCEEDED_STORAGE, "EPRT.invalid", null)); 
             return; 
         }
         
         session.getFtpDataConnection().setPortCommand(dataAddr, dataPort);
-        out.send(FtpResponse.REPLY_200_COMMAND_OKAY, "EPRT", null);
+        out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_200_COMMAND_OKAY, "EPRT", null));
     }
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/EPSV.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/EPSV.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/EPSV.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/EPSV.java Sun Jan 21 14:43:52 2007
@@ -27,6 +27,7 @@
 import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.ftplet.FtpResponse;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * The EPSV command requests that a server listen on a data port and
@@ -59,7 +60,7 @@
         // set data connection
         FtpDataConnectionFactory dataCon = session.getFtpDataConnection();
         if (!dataCon.setPasvCommand()) {
-            out.send(FtpResponse.REPLY_425_CANT_OPEN_DATA_CONNECTION, "EPSV", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_425_CANT_OPEN_DATA_CONNECTION, "EPSV", null));
             return;   
         }
         
@@ -68,6 +69,6 @@
         
         // send connection info to client
         String portStr = "|||" + servPort + '|';
-        out.send(229, "EPSV", portStr);
+        out.write(FtpReplyUtil.translate(session, 229, "EPSV", portStr));
     }
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/FEAT.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/FEAT.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/FEAT.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/FEAT.java Sun Jan 21 14:43:52 2007
@@ -27,6 +27,7 @@
 import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.ftplet.FtpResponse;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * The FEAT command (introduced in [RFC-2389]) allows servers with
@@ -47,6 +48,6 @@
         // reset state variables
         session.resetState();
         
-        out.send(FtpResponse.REPLY_211_SYSTEM_STATUS_REPLY, "FEAT", null);
+        out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_211_SYSTEM_STATUS_REPLY, "FEAT", null));
     }
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/HELP.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/HELP.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/HELP.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/HELP.java Sun Jan 21 14:43:52 2007
@@ -27,6 +27,7 @@
 import org.apache.ftpserver.ftplet.FtpResponse;
 import org.apache.ftpserver.interfaces.MessageResource;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * <code>HELP [&lt;SP&gt; <string>] &lt;CRLF&gt;</code><br>
@@ -55,7 +56,7 @@
         
         // print global help
         if(!request.hasArgument()) {
-            out.send(FtpResponse.REPLY_214_HELP_MESSAGE, null, null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_214_HELP_MESSAGE, null, null));
             return;
         }
         
@@ -65,6 +66,6 @@
         if(resource.getMessage(FtpResponse.REPLY_214_HELP_MESSAGE, ftpCmd, session.getLanguage()) == null) {
             ftpCmd = null;
         }
-        out.send(FtpResponse.REPLY_214_HELP_MESSAGE, ftpCmd, null);
+        out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_214_HELP_MESSAGE, ftpCmd, null));
     }
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/LANG.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/LANG.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/LANG.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/LANG.java Sun Jan 21 14:43:52 2007
@@ -28,6 +28,7 @@
 import org.apache.ftpserver.ftplet.FtpResponse;
 import org.apache.ftpserver.interfaces.MessageResource;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * A new command "LANG" is added to the FTP command set to allow
@@ -54,7 +55,7 @@
         String language = request.getArgument();
         if(language == null) {
             session.setLanguage(null);
-            out.send(FtpResponse.REPLY_200_COMMAND_OKAY, "LANG", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_200_COMMAND_OKAY, "LANG", null));
             return;
         }
         
@@ -66,13 +67,13 @@
             for(int i=0; i<availableLanguages.length; ++i) {
                 if(availableLanguages[i].equals(language)) {
                     session.setLanguage(language);
-                    out.send(FtpResponse.REPLY_200_COMMAND_OKAY, "LANG", null);
+                    out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_200_COMMAND_OKAY, "LANG", null));
                     return;
                 }
             }
         }
         
         // not found - send error message
-        out.send(FtpResponse.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "LANG", null);
+        out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "LANG", null));
     }
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/LIST.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/LIST.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/LIST.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/LIST.java Sun Jan 21 14:43:52 2007
@@ -33,6 +33,7 @@
 import org.apache.ftpserver.listing.LISTFileFormater;
 import org.apache.ftpserver.listing.ListArgument;
 import org.apache.ftpserver.listing.ListArgumentParser;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * <code>LIST [&lt;SP&gt; &lt;pathname&gt;] &lt;CRLF&gt;</code><br>
@@ -68,14 +69,14 @@
             session.resetState();
             
             // get data connection
-            out.send(FtpResponse.REPLY_150_FILE_STATUS_OKAY, "LIST", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_150_FILE_STATUS_OKAY, "LIST", null));
 
             FtpDataConnection dataConnection;
             try {
                 dataConnection = session.getFtpDataConnection().openConnection();
             } catch (Exception e) {
                 log.debug("Exception getting the output data stream", e);
-                out.send(FtpResponse.REPLY_425_CANT_OPEN_DATA_CONNECTION, "LIST", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_425_CANT_OPEN_DATA_CONNECTION, "LIST", null));
                 return;
             }
             
@@ -92,21 +93,21 @@
             catch(SocketException ex) {
                 log.debug("Socket exception during list transfer", ex);
                 failure = true;
-                out.send(FtpResponse.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED, "LIST", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED, "LIST", null));
             }
             catch(IOException ex) {
                 log.debug("IOException during list transfer", ex);
                 failure = true;
-                out.send(FtpResponse.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN, "LIST", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.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.send(FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "LIST", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "LIST", null));
             }
             
             // if data transfer ok - send transfer complete message
             if(!failure) {
-                out.send(FtpResponse.REPLY_226_CLOSING_DATA_CONNECTION, "LIST", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_226_CLOSING_DATA_CONNECTION, "LIST", null));
             }
         }
         finally {

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MD5.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MD5.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MD5.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MD5.java Sun Jan 21 14:43:52 2007
@@ -31,6 +31,7 @@
 import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.ftplet.FtpResponse;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 import org.apache.ftpserver.util.IoUtils;
 
 /**
@@ -65,7 +66,7 @@
         String argument = request.getArgument();
         
         if(argument == null || argument.trim().length() == 0) {
-            out.send(FtpResponse.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "MD5.invalid", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "MD5.invalid", null));
             return;
         }
 
@@ -91,13 +92,13 @@
             }
             
             if(file == null) {
-                out.send(FtpResponse.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "MD5.invalid", fileName);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "MD5.invalid", fileName));
                 return;
             }
     
             // check file
             if(!file.isFile()) {
-                out.send(FtpResponse.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "MD5.invalid", fileName);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "MD5.invalid", fileName));
                 return;
             }
             
@@ -116,15 +117,15 @@
                 
             } catch(NoSuchAlgorithmException e) {
                 log.debug("MD5 algorithm not available", e);
-                out.send(FtpResponse.REPLY_502_COMMAND_NOT_IMPLEMENTED, "MD5.notimplemened", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_502_COMMAND_NOT_IMPLEMENTED, "MD5.notimplemened", null));
             } finally {
                 IoUtils.close(is);
             }
         }
         if(isMMD5) {
-            out.send(252, "MMD5", sb.toString());
+            out.write(FtpReplyUtil.translate(session, 252, "MMD5", sb.toString()));
         } else {
-            out.send(251, "MD5", sb.toString());
+            out.write(FtpReplyUtil.translate(session, 251, "MD5", sb.toString()));
         }
     }
 

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MDTM.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MDTM.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MDTM.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MDTM.java Sun Jan 21 14:43:52 2007
@@ -29,6 +29,7 @@
 import org.apache.ftpserver.ftplet.FtpResponse;
 import org.apache.ftpserver.listener.Connection;
 import org.apache.ftpserver.util.DateUtils;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * <code>MDTM &lt;SP&gt; &lt;pathname&gt; &lt;CRLF&gt;</code><br>
@@ -54,7 +55,7 @@
         // argument check
         String fileName = request.getArgument();
         if(fileName == null) {
-            out.send(FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MDTM", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MDTM", null));
             return;  
         }
         
@@ -67,7 +68,7 @@
             log.debug("Exception getting file object", ex);
         }
         if(file == null) {
-            out.send(FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MDTM", fileName);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MDTM", fileName));
             return;
         }
         
@@ -75,10 +76,10 @@
         fileName = file.getFullName();
         if(file.doesExist()) {
             String dateStr = DateUtils.getFtpDate( file.getLastModified() );
-            out.send(FtpResponse.REPLY_213_FILE_STATUS, "MDTM", dateStr);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_213_FILE_STATUS, "MDTM", dateStr));
         }
         else {
-            out.send(FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MDTM", fileName);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MDTM", fileName));
         }
     } 
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MKD.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MKD.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MKD.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MKD.java Sun Jan 21 14:43:52 2007
@@ -33,6 +33,7 @@
 import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.interfaces.ServerFtpStatistics;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * <code>MKD  &lt;SP&gt; &lt;pathname&gt; &lt;CRLF&gt;</code><br>
@@ -63,7 +64,7 @@
         // argument check
         String fileName = request.getArgument();
         if(fileName == null) {
-            out.send(FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MKD", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MKD", null));
             return;  
         }
         
@@ -93,26 +94,26 @@
             log.debug("Exception getting file object", ex);
         }
         if(file == null) {
-            out.send(FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD.invalid", fileName);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD.invalid", fileName));
             return;
         }
         
         // check permission
         fileName = file.getFullName();
         if( !file.hasWritePermission() ) {
-            out.send(FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD.permission", fileName);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD.permission", fileName));
             return;
         }
         
         // check file existance
         if(file.doesExist()) {
-            out.send(FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD.exists", fileName);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD.exists", fileName));
             return;
         }
         
         // now create directory
         if(file.mkdir()) {
-            out.send(FtpResponse.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "MKD", fileName);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "MKD", fileName));
             
             // write log message
             String userName = session.getUser().getName();
@@ -137,7 +138,7 @@
 
         }
         else {
-            out.send(FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD", fileName);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD", fileName));
         }
     }
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MLSD.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MLSD.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MLSD.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MLSD.java Sun Jan 21 14:43:52 2007
@@ -34,6 +34,7 @@
 import org.apache.ftpserver.listing.ListArgument;
 import org.apache.ftpserver.listing.ListArgumentParser;
 import org.apache.ftpserver.listing.MLSTFileFormater;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * <code>MLSD [&lt;SP&gt; &lt;pathname&gt;] &lt;CRLF&gt;</code><br>
@@ -65,7 +66,7 @@
             session.resetState();
             
             // get data connection
-            out.send(FtpResponse.REPLY_150_FILE_STATUS_OKAY, "MLSD", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_150_FILE_STATUS_OKAY, "MLSD", null));
 
             
             // print listing data
@@ -74,7 +75,7 @@
                 dataConnection = session.getFtpDataConnection().openConnection();
             } catch (Exception e) {
                 log.debug("Exception getting the output data stream", e);
-                out.send(FtpResponse.REPLY_425_CANT_OPEN_DATA_CONNECTION, "MLSD", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_425_CANT_OPEN_DATA_CONNECTION, "MLSD", null));
                 return;
             }
             
@@ -90,21 +91,21 @@
             catch(SocketException ex) {
                 log.debug("Socket exception during data transfer", ex);
                 failure = true;
-                out.send(FtpResponse.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED, "MLSD", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED, "MLSD", null));
             }
             catch(IOException ex) {
                 log.debug("IOException during data transfer", ex);
                 failure = true;
-                out.send(FtpResponse.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN, "MLSD", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.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.send(FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MLSD", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MLSD", null));
             }
             
             // if data transfer ok - send transfer complete message
             if(!failure) {
-                out.send(FtpResponse.REPLY_226_CLOSING_DATA_CONNECTION, "MLSD", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_226_CLOSING_DATA_CONNECTION, "MLSD", null));
             }
         }
         finally {

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MLST.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MLST.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MLST.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MLST.java Sun Jan 21 14:43:52 2007
@@ -32,6 +32,7 @@
 import org.apache.ftpserver.listing.ListArgument;
 import org.apache.ftpserver.listing.ListArgumentParser;
 import org.apache.ftpserver.listing.MLSTFileFormater;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * <code>MLST &lt;SP&gt; &lt;pathname&gt; &lt;CRLF&gt;</code><br>
@@ -62,14 +63,14 @@
             file = session.getFileSystemView().getFileObject(parsedArg.getFile());
             if(file != null && file.doesExist()) {
                 FileFormater formater = new MLSTFileFormater((String[])session.getAttribute("MLST.types"));
-                out.send(FtpResponse.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "MLST", formater.format(file));
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "MLST", formater.format(file)));
             } else {            
-                out.send(FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MLST", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MLST", null));
             }
         }
         catch(FtpException ex) {
             log.debug("Exception sending the file listing", ex);
-            out.send(FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MLST", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MLST", null));
         }     
     }   
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MODE.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MODE.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MODE.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MODE.java Sun Jan 21 14:43:52 2007
@@ -26,6 +26,7 @@
 import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.ftplet.FtpResponse;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * <code>MODE &lt;SP&gt; <mode-code> &lt;CRLF&gt;</code><br>
@@ -52,7 +53,7 @@
         
         // argument check
         if(!request.hasArgument()) {
-            out.send(FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MODE", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "MODE", null));
             return;  
         }
         
@@ -61,14 +62,14 @@
         md = Character.toUpperCase(md);
         if(md == 'S') {
             session.getFtpDataConnection().setZipMode(false);
-            out.send(FtpResponse.REPLY_200_COMMAND_OKAY, "MODE", "S");
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_200_COMMAND_OKAY, "MODE", "S"));
         }
         else if(md == 'Z') {
             session.getFtpDataConnection().setZipMode(true);
-            out.send(FtpResponse.REPLY_200_COMMAND_OKAY, "MODE", "Z");
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_200_COMMAND_OKAY, "MODE", "Z"));
         }
         else {
-            out.send(FtpResponse.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "MODE", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER, "MODE", null));
         }
     }
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/NLST.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/NLST.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/NLST.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/NLST.java Sun Jan 21 14:43:52 2007
@@ -35,6 +35,7 @@
 import org.apache.ftpserver.listing.ListArgument;
 import org.apache.ftpserver.listing.ListArgumentParser;
 import org.apache.ftpserver.listing.NLSTFileFormater;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * <code>NLST [&lt;SP&gt; &lt;pathname&gt;] &lt;CRLF&gt;</code><br>
@@ -69,7 +70,7 @@
             session.resetState();
             
             // get data connection
-            out.send(FtpResponse.REPLY_150_FILE_STATUS_OKAY, "NLST", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_150_FILE_STATUS_OKAY, "NLST", null));
 
             
             // print listing data
@@ -78,7 +79,7 @@
                 dataConnection = session.getFtpDataConnection().openConnection();
             } catch (Exception e) {
                 log.debug("Exception getting the output data stream", e);
-                out.send(FtpResponse.REPLY_425_CANT_OPEN_DATA_CONNECTION, "NLST", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_425_CANT_OPEN_DATA_CONNECTION, "NLST", null));
                 return;
             }
             
@@ -99,21 +100,21 @@
             catch(SocketException ex) {
                 log.debug("Socket exception during data transfer", ex);
                 failure = true;
-                out.send(FtpResponse.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED, "NLST", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED, "NLST", null));
             }
             catch(IOException ex) {
                 log.debug("IOException during data transfer", ex);
                 failure = true;
-                out.send(FtpResponse.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN, "NLST", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.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.send(FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "LIST", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "LIST", null));
             }
             
             // if data transfer ok - send transfer complete message
             if(!failure) {
-                out.send(FtpResponse.REPLY_226_CLOSING_DATA_CONNECTION, "NLST", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_226_CLOSING_DATA_CONNECTION, "NLST", null));
             }
         }
         finally {

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/NOOP.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/NOOP.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/NOOP.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/NOOP.java Sun Jan 21 14:43:52 2007
@@ -27,6 +27,7 @@
 import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.ftplet.FtpResponse;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * <code>NOOP &lt;CRLF&gt;</code><br>
@@ -49,6 +50,6 @@
                         FtpWriter out) throws IOException, FtpException {
         
         session.resetState();
-        out.send(FtpResponse.REPLY_200_COMMAND_OKAY, "NOOP", null);
+        out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_200_COMMAND_OKAY, "NOOP", null));
     }
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/OPTS.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/OPTS.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/OPTS.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/OPTS.java Sun Jan 21 14:43:52 2007
@@ -29,6 +29,7 @@
 import org.apache.ftpserver.ftplet.FtpResponse;
 import org.apache.ftpserver.interfaces.Command;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 
 /**
@@ -59,7 +60,7 @@
         // no params
         String argument = request.getArgument();
         if(argument == null) {
-            out.send(FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "OPTS", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "OPTS", null));
             return;
         }
         
@@ -79,13 +80,13 @@
             }
             else {
                 session.resetState();
-                out.send(FtpResponse.REPLY_502_COMMAND_NOT_IMPLEMENTED, "OPTS.not.implemented", argument);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_502_COMMAND_NOT_IMPLEMENTED, "OPTS.not.implemented", argument));
             }
         }
         catch(Exception ex) {
             log.warn("OPTS.execute()", ex);
             session.resetState();
-            out.send(FtpResponse.REPLY_500_SYNTAX_ERROR_COMMAND_UNRECOGNIZED, "OPTS", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_500_SYNTAX_ERROR_COMMAND_UNRECOGNIZED, "OPTS", null));
         }
     }
     

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/OPTS_MLST.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/OPTS_MLST.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/OPTS_MLST.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/OPTS_MLST.java Sun Jan 21 14:43:52 2007
@@ -28,6 +28,7 @@
 import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.ftplet.FtpResponse;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * Client-Server listing negotation.
@@ -61,7 +62,7 @@
         String argument = request.getArgument();
         int spIndex = argument.indexOf(' ');
         if(spIndex == -1) {
-            out.send(FtpResponse.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "OPTS.MLST", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "OPTS.MLST", null));
             return;
         }
         String listTypes = argument.substring(spIndex + 1);
@@ -77,10 +78,10 @@
         String[] validatedTypes = validateSelectedTypes(types);
         if(validatedTypes != null) {
             session.setAttribute("MLST.types", validatedTypes);
-            out.send(FtpResponse.REPLY_200_COMMAND_OKAY, "OPTS.MLST", listTypes);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_200_COMMAND_OKAY, "OPTS.MLST", listTypes));
         }
         else {
-            out.send(FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "OPTS.MLST", listTypes);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "OPTS.MLST", listTypes));
         }
     }
     

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/OPTS_UTF8.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/OPTS_UTF8.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/OPTS_UTF8.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/OPTS_UTF8.java Sun Jan 21 14:43:52 2007
@@ -27,6 +27,7 @@
 import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.ftplet.FtpResponse;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 
 /**
@@ -52,6 +53,6 @@
         session.resetState();
         
         // send default message
-        out.send(FtpResponse.REPLY_200_COMMAND_OKAY, "OPTS.UTF8", null);
+        out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_200_COMMAND_OKAY, "OPTS.UTF8", null));
     }
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PASS.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PASS.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PASS.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PASS.java Sun Jan 21 14:43:52 2007
@@ -42,6 +42,7 @@
 import org.apache.ftpserver.usermanager.AnonymousAuthentication;
 import org.apache.ftpserver.usermanager.UserMetadata;
 import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * <code>PASS &lt;SP&gt; <password> &lt;CRLF&gt;</code><br>
@@ -76,7 +77,7 @@
             // argument check
             String password = request.getArgument();
             if(password == null) {
-                out.send(FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "PASS", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "PASS", null));
                 return; 
             }
             
@@ -84,13 +85,13 @@
             String userName = session.getUserArgument();
 
             if(userName == null && session.getUser() == null) {
-                out.send(FtpResponse.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PASS", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PASS", null));
                 return;
             }
             
             // already logged-in
             if(session.isLoggedIn()) {
-                out.send(FtpResponse.REPLY_202_COMMAND_NOT_IMPLEMENTED, "PASS", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_202_COMMAND_NOT_IMPLEMENTED, "PASS", null));
                 success = true;
                 return;
             }
@@ -100,7 +101,7 @@
             int currAnonLogin = stat.getCurrentAnonymousLoginNumber();
             int maxAnonLogin = conManager.getMaxAnonymousLogins();
             if( anonymous && (currAnonLogin >= maxAnonLogin) ) {
-                out.send(FtpResponse.REPLY_421_SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION, "PASS.anonymous", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_421_SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION, "PASS.anonymous", null));
                 return;
             }
             
@@ -108,7 +109,7 @@
             int currLogin = stat.getCurrentLoginNumber();
             int maxLogin = conManager.getMaxLogins();
             if(maxLogin != 0 && currLogin >= maxLogin) {
-                out.send(FtpResponse.REPLY_421_SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION, "PASS.login", null);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_421_SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION, "PASS.login", null));
                 return;
             }
             
@@ -181,7 +182,7 @@
                 session.setMaxIdleTime(oldMaxIdleTime);
                 
                 log.warn("Login failure - " + userName);
-                out.send(FtpResponse.REPLY_530_NOT_LOGGED_IN, "PASS", userName);
+                out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_530_NOT_LOGGED_IN, "PASS", userName));
                 stat.setLoginFail(connection);
                 return;
             }
@@ -193,7 +194,7 @@
             stat.setLogin(connection);
 
             // everything is fine - send login ok message
-            out.send(FtpResponse.REPLY_230_USER_LOGGED_IN, "PASS", userName);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_230_USER_LOGGED_IN, "PASS", userName));
             if(anonymous) {
                 log.info("Anonymous login success - " + password);
             }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PASV.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PASV.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PASV.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PASV.java Sun Jan 21 14:43:52 2007
@@ -29,6 +29,7 @@
 import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.ftplet.FtpResponse;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * <code>PASV &lt;CRLF&gt;</code><br>
@@ -58,7 +59,7 @@
         // set data connection
         FtpDataConnectionFactory dataCon = session.getFtpDataConnection();
         if (!dataCon.setPasvCommand()) {
-            out.send(FtpResponse.REPLY_425_CANT_OPEN_DATA_CONNECTION, "PASV", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_425_CANT_OPEN_DATA_CONNECTION, "PASV", null));
             return;   
         }
         
@@ -68,6 +69,6 @@
         
         // send connection info to client
         String addrStr = servAddr.getHostAddress().replace( '.', ',' ) + ',' + (servPort>>8) + ',' + (servPort&0xFF);
-        out.send(FtpResponse.REPLY_227_ENTERING_PASSIVE_MODE, "PASV", addrStr);
+        out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_227_ENTERING_PASSIVE_MODE, "PASV", addrStr));
     }
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PBSZ.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PBSZ.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PBSZ.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PBSZ.java Sun Jan 21 14:43:52 2007
@@ -27,6 +27,7 @@
 import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.ftplet.FtpResponse;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * Protection buffer size.
@@ -45,6 +46,6 @@
                         FtpWriter out) throws IOException, FtpException {
         
         session.resetState();
-        out.send(FtpResponse.REPLY_200_COMMAND_OKAY, "PBSZ", null);
+        out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_200_COMMAND_OKAY, "PBSZ", null));
     }
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PORT.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PORT.java?view=diff&rev=498472&r1=498471&r2=498472
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PORT.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PORT.java Sun Jan 21 14:43:52 2007
@@ -30,6 +30,7 @@
 import org.apache.ftpserver.ftplet.FtpResponse;
 import org.apache.ftpserver.interfaces.DataConnectionConfig;
 import org.apache.ftpserver.listener.Connection;
+import org.apache.ftpserver.util.FtpReplyUtil;
 
 /**
  * <code>PORT &lt;SP&gt; <host-port> &lt;CRLF&gt;</code><br>
@@ -67,20 +68,20 @@
         
         // argument check
         if(!request.hasArgument()) {
-            out.send(FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "PORT", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "PORT", null));
             return;  
         }
         
         StringTokenizer st = new StringTokenizer(request.getArgument(), ",");
         if(st.countTokens() != 6) {
-            out.send(510, "PORT", null);
+            out.write(FtpReplyUtil.translate(session, 510, "PORT", null));
             return;
         }
         
         // is port enabled
         DataConnectionConfig dataCfg = connection.getServerContext().getDataConnectionConfig();
         if(!dataCfg.isActiveEnabled()) {
-            out.send(510, "PORT.disabled", null);
+            out.write(FtpReplyUtil.translate(session, 510, "PORT.disabled", null));
             return;
         } 
         
@@ -93,7 +94,7 @@
         }
         catch(UnknownHostException ex) {
             log.debug("Unknown host: " + dataSrvName, ex);
-            out.send(FtpResponse.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED, "PORT.host", null);
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED, "PORT.host", null));
             return;
         }
         
@@ -101,7 +102,7 @@
         if(dataCfg.isActiveIpCheck()) {
             InetAddress clientAddr = session.getClientAddress();
             if(!dataAddr.equals(clientAddr)) {
-                out.send(510, "PORT.mismatch", null);
+                out.write(FtpReplyUtil.translate(session, 510, "PORT.mismatch", null));
                 return;
             }
         }
@@ -115,12 +116,12 @@
         }
         catch(NumberFormatException ex) {
             log.debug("Invalid data port: " + request.getArgument(), ex);
-            out.send(FtpResponse.REPLY_552_REQUESTED_FILE_ACTION_ABORTED_EXCEEDED_STORAGE, "PORT.invalid", null); 
+            out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_552_REQUESTED_FILE_ACTION_ABORTED_EXCEEDED_STORAGE, "PORT.invalid", null)); 
             return; 
         }
         
         session.getFtpDataConnection().setPortCommand(dataAddr, dataPort);
-        out.send(FtpResponse.REPLY_200_COMMAND_OKAY, "PORT", null);
+        out.write(FtpReplyUtil.translate(session, FtpResponse.REPLY_200_COMMAND_OKAY, "PORT", null));
     }
     
 }



Mime
View raw message