org.mockftpserver.stub.command
Class FileRetrCommandHandler
java.lang.Object
org.mockftpserver.core.command.AbstractCommandHandler
org.mockftpserver.core.command.AbstractTrackingCommandHandler
org.mockftpserver.stub.command.AbstractStubDataCommandHandler
org.mockftpserver.stub.command.FileRetrCommandHandler
- All Implemented Interfaces:
- CommandHandler, InvocationHistory, ReplyTextBundleAware
public class FileRetrCommandHandler
- extends AbstractStubDataCommandHandler
- implements CommandHandler
CommandHandler for the RETR command. Returns the contents of the specified file on the
data connection, along with two replies on the control connection: a reply code of 150 and
another of 226.
The file property specifies the pathname for the file whose contents should
be returned from this command. The file path is relative to the CLASSPATH (using the
ClassLoader for this class).
An exception is thrown if the file property has not been set or if the specified
file does not exist or cannot be read.
Each invocation record stored by this CommandHandler includes the following data element key/values:
PATHNAME_KEY ("pathname") - the pathname of the file submitted on the invocation (the first command parameter)
- Version:
- $Revision: 194 $ - $Date: 2008-12-07 08:53:58 -0500 (Sun, 07 Dec 2008) $
- Author:
- Chris Mair
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PATHNAME_KEY
public static final String PATHNAME_KEY
- See Also:
- Constant Field Values
FileRetrCommandHandler
public FileRetrCommandHandler()
- Create new uninitialized instance
FileRetrCommandHandler
public FileRetrCommandHandler(String file)
- Create new instance using the specified file pathname
- Parameters:
file - - the path to the file
- Throws:
AssertFailedException - - if the file is null
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 handledsession - - the session on which the Command was submittedinvocationRecord - - 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 handledsession - - the session on which the Command was submittedinvocationRecord - - 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)
setFile
public void setFile(String file)
- Set the path of the file whose contents should be returned when this command is
invoked. The path is relative to the CLASSPATH.
- Parameters:
file - - the path to the file
- Throws:
AssertFailedException - - if the file is null
Copyright © 2014. All rights reserved.