Class FtpTransportSession

java.lang.Object
com.nt.udc.util.FtpTransportSession
All Implemented Interfaces:
Runnable

public abstract class FtpTransportSession extends Object implements Runnable
Handles some common methods and variables that are used in a single Ftp session; However, the actual set of procedures needed in a given ftp session must be defined in the sub-class.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.apache.commons.net.ftp.FTPClient
    Ftp client, used to connect with the remote host.
    protected ActionListener
    Object notified when the file has been successfully transferred; The notification must be done by the sub-class at the appropriate location, using the ActionListener "notifyListener" method.
    protected static final String
    Identifier used when logging alarms and status with the "logger" member.
    protected String
    Remote ftp host ip address
    protected File
    Remote ftp host ip address
    protected Logger
    Status/alarm logger
    protected String
    Ftp login string
    protected String
    Password string
  • Constructor Summary

    Constructors
    Constructor
    Description
    FtpTransportSession(String ip, String login, String pass, File dir, ActionListener al, Logger l)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    get(File localFile, String remoteFile, int fileType)
    Get the remote file, of type ascii or binary, to the local file; "fileType" must be the ascii or binary file type constants, as defined in the FTP class in the commons-net-ftp package.
    protected boolean
    Logs into the remote host, using the "ipAddress", "loginStr" and "passStr".
    abstract void
    run()
    Implements the Runnable interface, and must be defined by the subclass; This method should do the actual procedures needed to transport the file from the remote host to the local host, as well as fulfill other device-specific conditions.
    protected abstract void
    Abstract method to enforce some type of ftp session shutdown mechanisms; This method is called by the FtpTransportHandler object.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • FTPSESSION

      protected static final String FTPSESSION
      Identifier used when logging alarms and status with the "logger" member.
      See Also:
    • client

      protected org.apache.commons.net.ftp.FTPClient client
      Ftp client, used to connect with the remote host.
    • ipAddress

      protected String ipAddress
      Remote ftp host ip address
    • loginStr

      protected String loginStr
      Ftp login string
    • passStr

      protected String passStr
      Password string
    • localDir

      protected File localDir
      Remote ftp host ip address
    • logger

      protected Logger logger
      Status/alarm logger
    • fileProcessor

      protected ActionListener fileProcessor
      Object notified when the file has been successfully transferred; The notification must be done by the sub-class at the appropriate location, using the ActionListener "notifyListener" method.
  • Constructor Details

    • FtpTransportSession

      public FtpTransportSession(String ip, String login, String pass, File dir, ActionListener al, Logger l)
      Parameters:
      ip - Ip Address.
      login - Login string.
      pass - Password string.
      dir - Local directory
      al - Object notified when file transfer is completed.
      l - Logging object, used for alarms/status.
  • Method Details

    • login

      protected boolean login()
      Logs into the remote host, using the "ipAddress", "loginStr" and "passStr".

      Returns:
      true, if login is successful. false, otherwise.
    • get

      protected boolean get(File localFile, String remoteFile, int fileType) throws IOException
      Get the remote file, of type ascii or binary, to the local file; "fileType" must be the ascii or binary file type constants, as defined in the FTP class in the commons-net-ftp package.

      Parameters:
      localFile - Local file name.
      remoteFile - Remote file name.
      fileType - Determines whether ascii or binary file, as defined by FTP.BINARY_FILE_TYPE/FTP.ASCII_FILE_TYPE.

      Returns:
      true, if get was successful. false, otherwise.
      Throws:
      IOException
    • shutdown

      protected abstract void shutdown()
      Abstract method to enforce some type of ftp session shutdown mechanisms; This method is called by the FtpTransportHandler object.
    • run

      public abstract void run()
      Implements the Runnable interface, and must be defined by the subclass; This method should do the actual procedures needed to transport the file from the remote host to the local host, as well as fulfill other device-specific conditions.
      Specified by:
      run in interface Runnable