org.mockftpserver.fake.command
Class RetrCommandHandler

java.lang.Object
  extended by org.mockftpserver.core.command.AbstractCommandHandler
      extended by org.mockftpserver.fake.command.AbstractFakeCommandHandler
          extended by org.mockftpserver.fake.command.RetrCommandHandler
All Implemented Interfaces:
CommandHandler, ReplyTextBundleAware, ServerConfigurationAware

public class RetrCommandHandler
extends AbstractFakeCommandHandler

CommandHandler for the RETR command. Handler logic:

  1. If the user has not logged in, then reply with 530 and terminate
  2. If the required pathname parameter is missing, then reply with 501 and terminate
  3. If the pathname parameter does not specify a valid, existing filename, then reply with 550 and terminate
  4. If the current user does not have read access to the file at the specified path or execute permission to its directory, then reply with 550 and terminate
  5. Send an initial reply of 150
  6. Send the contents of the named file across the data connection
  7. If there is an error reading the file, then reply with 550 and terminate
  8. Send a final reply with 226

Version:
$Revision: 214 $ - $Date: 2008-12-26 20:00:19 -0500 (Fri, 26 Dec 2008) $
Author:
Chris Mair

Field Summary
 
Fields inherited from class org.mockftpserver.fake.command.AbstractFakeCommandHandler
INTERNAL_ERROR_KEY, replyCodeForFileSystemException
 
Fields inherited from class org.mockftpserver.core.command.AbstractCommandHandler
LOG
 
Constructor Summary
RetrCommandHandler()
           
 
Method Summary
protected  byte[] convertLfToCrLf(byte[] bytes)
          Within the specified byte array, replace all LF (\n) that are NOT preceded by a CR (\r) into CRLF (\r\n).
protected  void handle(Command command, Session session)
          Handle the specified command for the session.
 
Methods inherited from class org.mockftpserver.fake.command.AbstractFakeCommandHandler
defaultIfNullOrEmpty, endOfLine, getFileSystem, getRealPath, getRequiredSessionAttribute, getServerConfiguration, getUserAccount, handleCommand, list, list, login, notNullOrEmpty, sendReply, sendReply, sendReply, sendReply, setServerConfiguration, validateUserAccount, verifyExecutePermission, verifyFileSystemCondition, verifyLoggedIn, verifyReadPermission, verifyWritePermission
 
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
 

Constructor Detail

RetrCommandHandler

public RetrCommandHandler()
Method Detail

handle

protected void handle(Command command,
                      Session session)
Description copied from class: AbstractFakeCommandHandler
Handle the specified command for the session. All checked exceptions are expected to be wrapped or handled by the caller.

Specified by:
handle in class AbstractFakeCommandHandler
Parameters:
command - - the Command to be handled
session - - the session on which the Command was submitted

convertLfToCrLf

protected byte[] convertLfToCrLf(byte[] bytes)
Within the specified byte array, replace all LF (\n) that are NOT preceded by a CR (\r) into CRLF (\r\n).

Parameters:
bytes - - the bytes to be converted
Returns:
the result of converting LF to CRLF


Copyright © 2014. All rights reserved.