Package com.nt.udc.util
Class FtpTransportSession
java.lang.Object
com.nt.udc.util.FtpTransportSession
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionprotected 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 addressprotected File
Remote ftp host ip addressprotected Logger
Status/alarm loggerprotected String
Ftp login stringprotected String
Password string -
Constructor Summary
ConstructorsConstructorDescriptionFtpTransportSession
(String ip, String login, String pass, File dir, ActionListener al, Logger l) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
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
login()
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
shutdown()
Abstract method to enforce some type of ftp session shutdown mechanisms; This method is called by the FtpTransportHandler object.
-
Field Details
-
FTPSESSION
Identifier used when logging alarms and status with the "logger" member.- See Also:
-
client
protected org.apache.commons.net.ftp.FTPClient clientFtp client, used to connect with the remote host. -
ipAddress
Remote ftp host ip address -
loginStr
Ftp login string -
passStr
Password string -
localDir
Remote ftp host ip address -
logger
Status/alarm logger -
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 directoryal
- 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
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.
-