adams.flow.standalone
Class FTPConnection

java.lang.Object
  extended by adams.core.ConsoleObject
      extended by adams.core.option.AbstractOptionHandler
          extended by adams.flow.core.AbstractActor
              extended by adams.flow.standalone.AbstractStandalone
                  extended by adams.flow.standalone.FTPConnection
All Implemented Interfaces:
AdditionalInformationHandler, CleanUpHandler, Debuggable, DebugOutputHandler, Destroyable, OptionHandler, QuickInfoSupporter, ShallowCopySupporter<AbstractActor>, SizeOfHandler, Stoppable, VariableChangeListener, Actor, ErrorHandler, Serializable, Comparable, EventListener, org.apache.commons.net.ProtocolCommandListener

public class FTPConnection
extends AbstractStandalone
implements org.apache.commons.net.ProtocolCommandListener

Provides access to a FTP host.
If debugging is enabled, the FTP commands issued by other actors will get printed as debug output of this actor.

Valid options are:

-D <int> (property: debugLevel)
    The greater the number the more additional info the scheme may output to
    the console (0 = off).
    default: 0
    minimum: 0
 
-name <java.lang.String> (property: name)
    The name of the actor.
    default: FTPConnection
 
-annotation <adams.core.base.BaseText> (property: annotations)
    The annotations to attach to this actor.
    default:
 
-skip (property: skip)
    If set to true, transformation is skipped and the input token is just forwarded
    as it is.
 
-stop-flow-on-error (property: stopFlowOnError)
    If set to true, the flow gets stopped in case this actor encounters an error;
     useful for critical actors.
 
-host <java.lang.String> (property: host)
    The host (name/IP address) to connect to.
    default:
 
-user <java.lang.String> (property: user)
    The FTP user to use for connecting.
    default: anonymous
 
-password <adams.core.base.BasePassword> (property: password)
    The password of the FTP user to use for connecting.
    default: {}
 
-passive (property: usePassiveMode)
    If enabled, passive mode is used instead.
 
-binary (property: useBinaryMode)
    If enabled, binary mode is used instead of ASCII.
 

Version:
$Revision: 5867 $
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Field Summary
protected  org.apache.commons.net.ftp.FTPClient m_Client
          the FTP client object.
protected  String m_Host
          the FTP host.
protected  BasePassword m_Password
          the FTP password to use.
protected  boolean m_UseBinaryMode
          whether to use binary file transfer mode.
protected  boolean m_UsePassiveMode
          whether to use passive mode.
protected  String m_User
          the FTP user to use.
 
Fields inherited from class adams.flow.core.AbstractActor
m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_Executing, m_FullName, m_Headless, m_Name, m_Parent, m_Root, m_Self, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
 
Fields inherited from class adams.core.option.AbstractOptionHandler
m_DebugLevel, m_OptionManager
 
Fields inherited from interface adams.flow.core.Actor
FILE_EXTENSION, FILE_EXTENSION_GZ
 
Constructor Summary
FTPConnection()
           
 
Method Summary
 void defineOptions()
          Adds options to the internal list of options.
protected  void disconnect()
          Disconnects the FTP session, if necessary.
protected  String doExecute()
          Executes the flow item.
 org.apache.commons.net.ftp.FTPClient getFTPClient()
          Returns the FTP client object.
 String getHost()
          Returns the host to connect to.
 BasePassword getPassword()
          Returns the FTP password to use.
 String getQuickInfo()
          Returns a quick info about the actor, which will be displayed in the GUI.
 boolean getUseBinaryMode()
          Returns whether binary mode is used.
 boolean getUsePassiveMode()
          Returns whether passive mode is used.
 String getUser()
          Returns the FTP user name to use.
 String globalInfo()
          Returns a string describing the object.
 String hostTipText()
          Returns the tip text for this property.
 String passwordTipText()
          Returns the tip text for this property.
 void protocolCommandSent(org.apache.commons.net.ProtocolCommandEvent event)
          This method is invoked by a ProtocolCommandEvent source after sending a protocol command to a server.
 void protocolReplyReceived(org.apache.commons.net.ProtocolCommandEvent event)
          This method is invoked by a ProtocolCommandEvent source after receiving a reply from a server.
protected  void reset()
          Resets the actor.
 void setHost(String value)
          Sets the host to connect to.
 void setPassword(BasePassword value)
          Sets the FTP password to use.
 void setUseBinaryMode(boolean value)
          Sets whether to use binary mode.
 void setUsePassiveMode(boolean value)
          Sets whether to use passive mode.
 void setUser(String value)
          Sets the FTP user to use.
 String useBinaryModeTipText()
          Returns the tip text for this property.
 String usePassiveModeTipText()
          Returns the tip text for this property.
 String userTipText()
          Returns the tip text for this property.
 void wrapUp()
          Cleans up after the execution has finished.
 
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, backupState, canInspectOptions, canPerformSetUpCheck, cleanUp, compareTo, debug, destroy, equals, execute, findVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFullName, getName, getNextSibling, getParent, getPreviousSibling, getRoot, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, initialize, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, postExecute, preExecute, pruneBackup, pruneBackup, restoreState, setAnnotations, setErrorHandler, setHeadless, setName, setParent, setSkip, setStopFlowOnError, setUp, setVariables, shallowCopy, shallowCopy, sizeOf, skipTipText, stopExecution, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
 
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, debug, debugLevelTipText, finishInit, getDebugLevel, getOptionManager, isDebugOn, newOptionManager, setDebugLevel, toCommandLine, toString
 
Methods inherited from class adams.core.ConsoleObject
getDebugging, getSystemErr, getSystemOut
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager
 

Field Detail

m_Host

protected String m_Host
the FTP host.


m_User

protected String m_User
the FTP user to use.


m_Password

protected BasePassword m_Password
the FTP password to use.


m_UsePassiveMode

protected boolean m_UsePassiveMode
whether to use passive mode.


m_UseBinaryMode

protected boolean m_UseBinaryMode
whether to use binary file transfer mode.


m_Client

protected org.apache.commons.net.ftp.FTPClient m_Client
the FTP client object.

Constructor Detail

FTPConnection

public FTPConnection()
Method Detail

globalInfo

public String globalInfo()
Returns a string describing the object.

Specified by:
globalInfo in class AbstractOptionHandler
Returns:
a description suitable for displaying in the gui

defineOptions

public void defineOptions()
Adds options to the internal list of options.

Specified by:
defineOptions in interface OptionHandler
Overrides:
defineOptions in class AbstractActor

reset

protected void reset()
Resets the actor.

Overrides:
reset in class AbstractActor

getQuickInfo

public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.

Specified by:
getQuickInfo in interface QuickInfoSupporter
Specified by:
getQuickInfo in interface Actor
Overrides:
getQuickInfo in class AbstractActor
Returns:
null if no info available, otherwise short string

setHost

public void setHost(String value)
Sets the host to connect to.

Parameters:
value - the host name/ip

getHost

public String getHost()
Returns the host to connect to.

Returns:
the host name/ip

hostTipText

public String hostTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setUser

public void setUser(String value)
Sets the FTP user to use.

Parameters:
value - the user name

getUser

public String getUser()
Returns the FTP user name to use.

Returns:
the user name

userTipText

public String userTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setPassword

public void setPassword(BasePassword value)
Sets the FTP password to use.

Parameters:
value - the password

getPassword

public BasePassword getPassword()
Returns the FTP password to use.

Returns:
the password

passwordTipText

public String passwordTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setUsePassiveMode

public void setUsePassiveMode(boolean value)
Sets whether to use passive mode.

Parameters:
value - if true passive mode is used

getUsePassiveMode

public boolean getUsePassiveMode()
Returns whether passive mode is used.

Returns:
true if passive mode is used

usePassiveModeTipText

public String usePassiveModeTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setUseBinaryMode

public void setUseBinaryMode(boolean value)
Sets whether to use binary mode.

Parameters:
value - if true binary mode is used

getUseBinaryMode

public boolean getUseBinaryMode()
Returns whether binary mode is used.

Returns:
true if binary mode is used

useBinaryModeTipText

public String useBinaryModeTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

getFTPClient

public org.apache.commons.net.ftp.FTPClient getFTPClient()
Returns the FTP client object.

Returns:
the FTP client, null if not connected

doExecute

protected String doExecute()
Executes the flow item.

Specified by:
doExecute in class AbstractActor
Returns:
null if ok, otherwise error message

disconnect

protected void disconnect()
Disconnects the FTP session, if necessary.


wrapUp

public void wrapUp()
Cleans up after the execution has finished.

Specified by:
wrapUp in interface Actor
Overrides:
wrapUp in class AbstractActor

protocolCommandSent

public void protocolCommandSent(org.apache.commons.net.ProtocolCommandEvent event)
This method is invoked by a ProtocolCommandEvent source after sending a protocol command to a server.

Specified by:
protocolCommandSent in interface org.apache.commons.net.ProtocolCommandListener
Parameters:
event - The ProtocolCommandEvent fired.

protocolReplyReceived

public void protocolReplyReceived(org.apache.commons.net.ProtocolCommandEvent event)
This method is invoked by a ProtocolCommandEvent source after receiving a reply from a server.

Specified by:
protocolReplyReceived in interface org.apache.commons.net.ProtocolCommandListener
Parameters:
event - The ProtocolCommandEvent fired.


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.