org.mockftpserver.stub.command
Class ListCommandHandler

java.lang.Object
  extended by org.mockftpserver.core.command.AbstractCommandHandler
      extended by org.mockftpserver.core.command.AbstractTrackingCommandHandler
          extended by org.mockftpserver.stub.command.AbstractStubDataCommandHandler
              extended by org.mockftpserver.stub.command.ListCommandHandler
All Implemented Interfaces:
CommandHandler, InvocationHistory, ReplyTextBundleAware

public class ListCommandHandler
extends AbstractStubDataCommandHandler
implements CommandHandler

CommandHandler for the LIST command. Return the configured directory listing on the data connection, along with two replies on the control connection: a reply code of 150 and another of 226. By default, return an empty directory listing. You can customize the returned directory listing by setting the directoryListing property.

The interpretation of the value returned from this command is dependent upon the value returned by the SYST command. The format of the directory listing should match the format associated with the system named by the SYST command. For example, if the SYST command returns "WINDOWS", then the directory listing value from this command should match the Windows-specific format. See the SystCommandHandler to control the value returned for the SYST command.

Here is an example value for directoryListing when the SystCommandHandler returns "WINDOWS". Note that multiple entries are separated by "\n":

      CommandHandler listCommandHandler = new ListCommandHandler();
      listCommandHandler.setDirectoryListing("11-09-01 12:30PM 406348 File2350.log\n" +
          "11-01-01 1:30PM <DIR>  archive");
 

And here is an example value for directoryListing when the SystCommandHandler returns "UNIX". Note that multiple entries are separated by "\n":

      CommandHandler listCommandHandler = new ListCommandHandler();
      listCommandHandler.setDirectoryListing("drwxrwxrwx  1 none     none                   0 Mar 20  2010 archive\n" +
          "-rwxrwxrwx  1 none     none                  19 Mar 20  2010 abc.txt");
 

Each invocation record stored by this CommandHandler includes the following data element key/values:

Version:
$Revision: 249 $ - $Date: 2010-03-24 19:50:35 -0400 (Wed, 24 Mar 2010) $
Author:
Chris Mair
See Also:
SystCommandHandler

Field Summary
static String PATHNAME_KEY
           
 
Fields inherited from class org.mockftpserver.stub.command.AbstractStubDataCommandHandler
finalReplyCode, finalReplyMessageKey, finalReplyText, preliminaryReplyCode, preliminaryReplyMessageKey, preliminaryReplyText
 
Fields inherited from class org.mockftpserver.core.command.AbstractCommandHandler
LOG
 
Constructor Summary
ListCommandHandler()
           
 
Method Summary
protected  void beforeProcessData(Command command, Session session, InvocationRecord invocationRecord)
          Perform any necessary logic before transferring data across the data connection.
protected  void processData(Command command, Session session, InvocationRecord invocationRecord)
          Abstract method placeholder for subclass transfer of data across the data connection.
 void setDirectoryListing(String directoryListing)
          Set the contents of the directoryListing to send back on the data connection for this command.
 
Methods inherited from class org.mockftpserver.stub.command.AbstractStubDataCommandHandler
afterProcessData, handleCommand, sendFinalReply, setFinalReplyCode, setFinalReplyMessageKey, setFinalReplyText, setPreliminaryReplyCode, setPreliminaryReplyMessageKey, setPreliminaryReplyText
 
Methods inherited from class org.mockftpserver.core.command.AbstractTrackingCommandHandler
clearInvocations, getInvocation, handleCommand, numberOfInvocations, sendReply
 
Methods inherited from class org.mockftpserver.core.command.AbstractCommandHandler
assertValidReplyCode, getReplyTextBundle, quotes, setReplyTextBundle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mockftpserver.core.command.CommandHandler
handleCommand
 

Field Detail

PATHNAME_KEY

public static final String PATHNAME_KEY
See Also:
Constant Field Values
Constructor Detail

ListCommandHandler

public ListCommandHandler()
Method Detail

beforeProcessData

protected void beforeProcessData(Command command,
                                 Session session,
                                 InvocationRecord invocationRecord)
                          throws Exception
Description copied from class: AbstractStubDataCommandHandler
Perform any necessary logic before transferring data across the data connection. Do nothing by default. Subclasses should override to validate command parameters and store information in the InvocationRecord.

Overrides:
beforeProcessData in class AbstractStubDataCommandHandler
Parameters:
command - - the Command to be handled
session - - the session on which the Command was submitted
invocationRecord - - the InvocationRecord; CommandHandlers are expected to add handler-specific data to the InvocationRecord, as appropriate
Throws:
Exception
See Also:
AbstractStubDataCommandHandler.beforeProcessData(org.mockftpserver.core.command.Command, org.mockftpserver.core.session.Session, org.mockftpserver.core.command.InvocationRecord)

processData

protected void processData(Command command,
                           Session session,
                           InvocationRecord invocationRecord)
Description copied from class: AbstractStubDataCommandHandler
Abstract method placeholder for subclass transfer of data across the data connection. Subclasses must override. The data connection is opened before this method and is closed after this method completes.

Specified by:
processData in class AbstractStubDataCommandHandler
Parameters:
command - - the Command to be handled
session - - the session on which the Command was submitted
invocationRecord - - the InvocationRecord; CommandHandlers are expected to add handler-specific data to the InvocationRecord, as appropriate
See Also:
AbstractStubDataCommandHandler.processData(org.mockftpserver.core.command.Command, org.mockftpserver.core.session.Session, org.mockftpserver.core.command.InvocationRecord)

setDirectoryListing

public void setDirectoryListing(String directoryListing)
Set the contents of the directoryListing to send back on the data connection for this command. The passed-in value is trimmed automatically.

Parameters:
directoryListing - - the directoryListing to set


Copyright © 2014. All rights reserved.