goldengate.ftp.core.control
Class BusinessHandler

java.lang.Object
  extended by goldengate.ftp.core.control.BusinessHandler
Direct Known Subclasses:
SimpleBusinessHandler

public abstract class BusinessHandler
extends Object

This class is to be implemented in order to allow Business actions according to FTP service

Author:
Frederic Bregier

Constructor Summary
BusinessHandler()
          Constructor with no argument (mandatory)
 
Method Summary
abstract  void afterRunCommandKo(goldengate.common.command.exception.CommandAbstractException e)
          Run when a FTP exception is catch (the channel is not necessary closed after).
abstract  void afterRunCommandOk()
          This method is called for every received message after the execution of the command but before the final reply to the client.
abstract  void afterTransferDoneBeforeAnswer(FtpTransfer transfer)
          Run when a transfer is finished (eventually in error) but before answering.
abstract  void beforeRunCommand()
          This method is called for every received message before the execution of the command.
protected abstract  void cleanSession()
          To Clean the session attached objects
 void clear()
          Clean the BusinessHandler.
abstract  void exceptionLocalCaught(org.jboss.netty.channel.ExceptionEvent e)
          Run when an exception is get before the channel is closed.
abstract  void executeChannelClosed()
          Is executed when the channel is closed, just before cleaning and just after.
abstract  void executeChannelConnected(org.jboss.netty.channel.Channel channel)
          Is executed when the channel is connected after the handler is on, before answering OK or not on connection, except if the global service is going to shutdown.
abstract  FtpAuth getBusinessNewAuth()
          Create a new AuthInterface according to business choice
abstract  FtpDir getBusinessNewDir()
          Create a new FtpDir according to business choice
abstract  goldengate.common.file.Restart getBusinessNewRestart()
          Create a new Restart according to business choice
protected  String getDefaultFeatMessage()
           
abstract  String getFeatMessage()
           
 FtpSession getFtpSession()
           
abstract  String getHelpMessage(String arg)
           
protected  String getMLSxOptsMessage(String[] args)
           
 NetworkHandler getNetworkHandler()
           
abstract  String getOptsMessage(String[] args)
           
abstract  AbstractCommand getSpecializedSiteCommand(FtpSession session, String line)
          Check if a command pass to SITE command is legal
 void setNetworkHandler(NetworkHandler networkHandler)
          Called when the NetworkHandler is created
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BusinessHandler

public BusinessHandler()
Constructor with no argument (mandatory)

Method Detail

setNetworkHandler

public void setNetworkHandler(NetworkHandler networkHandler)
Called when the NetworkHandler is created

Parameters:
networkHandler - the networkHandler to set

getNetworkHandler

public NetworkHandler getNetworkHandler()
Returns:
the networkHandler

getFtpSession

public FtpSession getFtpSession()
Returns:
the ftpSession

getBusinessNewAuth

public abstract FtpAuth getBusinessNewAuth()
Create a new AuthInterface according to business choice

Returns:
the new FtpAuth

getBusinessNewDir

public abstract FtpDir getBusinessNewDir()
Create a new FtpDir according to business choice

Returns:
the new FtpDir

getBusinessNewRestart

public abstract goldengate.common.file.Restart getBusinessNewRestart()
Create a new Restart according to business choice

Returns:
the new Restart

getHelpMessage

public abstract String getHelpMessage(String arg)
Parameters:
arg - the argument from HELP command
Returns:
the string to return to the client for the HELP command

getFeatMessage

public abstract String getFeatMessage()
Returns:
the string to return to the client for the FEAT command

getDefaultFeatMessage

protected String getDefaultFeatMessage()
Returns:
the string to return to the client for the FEAT command without surrounding by "Extensions supported:\n" and "\nEnd"

getOptsMessage

public abstract String getOptsMessage(String[] args)
                               throws goldengate.common.command.exception.CommandAbstractException
Parameters:
args -
Returns:
the string to return to the client for the FEAT command
Throws:
goldengate.common.command.exception.CommandAbstractException

getSpecializedSiteCommand

public abstract AbstractCommand getSpecializedSiteCommand(FtpSession session,
                                                          String line)
Check if a command pass to SITE command is legal

Parameters:
session -
line -
Returns:
the AbstractCommand to execute if it is a Specialized Command, else Null

getMLSxOptsMessage

protected String getMLSxOptsMessage(String[] args)
Parameters:
args -
Returns:
the string to return to the client for the FEAT command for the MLSx argument

executeChannelClosed

public abstract void executeChannelClosed()
Is executed when the channel is closed, just before cleaning and just after.
Note: In some circumstances, it could be a good idea to call the clean operation on FtpAuth in order to relax constraints on user authentication. It will be called however at least when the session will be clean just after this call.


cleanSession

protected abstract void cleanSession()
To Clean the session attached objects


clear

public void clear()
Clean the BusinessHandler.


executeChannelConnected

public abstract void executeChannelConnected(org.jboss.netty.channel.Channel channel)
Is executed when the channel is connected after the handler is on, before answering OK or not on connection, except if the global service is going to shutdown.

Parameters:
channel -

exceptionLocalCaught

public abstract void exceptionLocalCaught(org.jboss.netty.channel.ExceptionEvent e)
Run when an exception is get before the channel is closed. This must set a correct answer.

Parameters:
e -

beforeRunCommand

public abstract void beforeRunCommand()
                               throws goldengate.common.command.exception.CommandAbstractException
This method is called for every received message before the execution of the command. If an exception is raised, the reply is immediate and no action taken.

Throws:
goldengate.common.command.exception.CommandAbstractException

afterRunCommandOk

public abstract void afterRunCommandOk()
                                throws goldengate.common.command.exception.CommandAbstractException
This method is called for every received message after the execution of the command but before the final reply to the client. If an exception is raised, the reply is immediate. This is the last call before finishing the command.

Throws:
goldengate.common.command.exception.CommandAbstractException

afterRunCommandKo

public abstract void afterRunCommandKo(goldengate.common.command.exception.CommandAbstractException e)
Run when a FTP exception is catch (the channel is not necessary closed after). This must set a correct answer and a correct code of reply. If the code of reply is 421, then the channel will be closed after this call. This is the last call before finishing the command.

Parameters:
e -

afterTransferDoneBeforeAnswer

public abstract void afterTransferDoneBeforeAnswer(FtpTransfer transfer)
                                            throws goldengate.common.command.exception.CommandAbstractException
Run when a transfer is finished (eventually in error) but before answering. Note that this is called only for a Transfer Request (or LIST) but called before afterRunCommandXX is called (Ok or Ko).

Parameters:
transfer -
Throws:
goldengate.common.command.exception.CommandAbstractException


Copyright © 2009-2012 Frederic Bregier. All Rights Reserved.