org.mockftpserver.fake.command
Class AbstractStoreFileCommandHandler

java.lang.Object
  extended by org.mockftpserver.core.command.AbstractCommandHandler
      extended by org.mockftpserver.fake.command.AbstractFakeCommandHandler
          extended by org.mockftpserver.fake.command.AbstractStoreFileCommandHandler
All Implemented Interfaces:
CommandHandler, ReplyTextBundleAware, ServerConfigurationAware
Direct Known Subclasses:
AppeCommandHandler, StorCommandHandler, StouCommandHandler

public abstract class AbstractStoreFileCommandHandler
extends AbstractFakeCommandHandler

Abstract superclass for CommandHandlers that that store a file (STOR, STOU, APPE). Handler logic:

  1. If the user has not logged in, then reply with 530 and terminate
  2. If the pathname parameter is required but missing, then reply with 501 and terminate
  3. If the required pathname parameter does not specify a valid filename, then reply with 553 and terminate
  4. If the current user does not have write access to the named file, if it already exists, or else to its parent directory, then reply with 553 and terminate
  5. If the current user does not have execute access to the parent directory, then reply with 553 and terminate
  6. Send an initial reply of 150
  7. Read all available bytes from the data connection and store/append to the named file in the server file system
  8. If file write/store fails, then reply with 553 and terminate
  9. Send a final reply with 226

Version:
$Revision: 201 $ - $Date: 2008-12-11 19:39:48 -0500 (Thu, 11 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
AbstractStoreFileCommandHandler()
           
 
Method Summary
protected  boolean appendToOutputFile()
           
protected abstract  String getMessageKey()
           
protected  String getOutputFile(Command command)
          Return the path (absolute or relative) for the output file.
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

AbstractStoreFileCommandHandler

public AbstractStoreFileCommandHandler()
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

getOutputFile

protected String getOutputFile(Command command)
Return the path (absolute or relative) for the output file. The default behavior is to return the required first parameter for the specified Command. Subclasses may override the default behavior.

Parameters:
command - - the Command
Returns:
the output file name

appendToOutputFile

protected boolean appendToOutputFile()
Returns:
true if this command should append the transferred contents to the output file; false means overwrite an existing file. This default implentation returns false.

getMessageKey

protected abstract String getMessageKey()
Returns:
the message key for the reply message sent with the final (226) reply


Copyright © 2014. All rights reserved.