public class FtpEITransport extends EITransport
This class also relies on an object of type SynchronizedDirectory, which provides the synchronization capability for this transport class and any class which consumes (processes) the files that are retrieved via objects of this class.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
FTP_TYPE_PASSIVE |
static java.lang.String |
FTP_TYPE_REGULAR |
static java.lang.String |
FTP_TYPE_SECURE |
protected FtpSupportIntf |
ftpSession |
protected static java.lang.String |
HOSTS_FILE |
protected static int |
SFTP_PORT |
dataReceiver, fdChecked, filedataReceiver, fileduplicateCheck, fileToProcess, inputCount, lockFile, movedFile, node, pollingInterval, processing, processingData, running
Constructor and Description |
---|
FtpEITransport(java.lang.String ip,
java.lang.String l,
java.lang.String pw,
EINode node)
This form of the constructor establishes the minimum FTP
parameters for this transport.
|
FtpEITransport(java.lang.String ip,
java.lang.String l,
java.lang.String pw,
int st,
boolean flag,
java.lang.String rp,
java.lang.String suffix,
java.lang.String lSuffix,
SynchronizedDirectory dir,
DCNode node,
boolean binary)
This form of the constructor is used when you need to retrieve
multiple files at a time, such as all the files ending in 'dat'
in a given path on the FTP server.
|
FtpEITransport(java.lang.String ip,
java.lang.String l,
java.lang.String pw,
int st,
boolean flag,
java.lang.String rp,
java.lang.String suffix,
java.lang.String lSuffix,
SynchronizedDirectory dir,
DCNode node,
boolean binary,
boolean rRenameflag)
This form of the constructor is used when you need to retrieve
multiple files at a time, such as all the files ending in 'dat'
in a given path on the FTP server.
|
FtpEITransport(java.lang.String ip,
java.lang.String l,
java.lang.String pw,
int st,
boolean flag,
java.lang.String rp,
java.lang.String suffix,
java.lang.String lSuffix,
SynchronizedDirectory dir,
DCNode node,
boolean binary,
boolean rRenameflag,
java.lang.String ftpType)
This constructor is used when the ftpType needs to be specified
|
FtpEITransport(java.lang.String ip,
java.lang.String l,
java.lang.String pw,
int st,
boolean flag,
java.lang.String rp,
java.lang.String suffix,
java.lang.String lSuffix,
SynchronizedDirectory dir,
DCNode node,
boolean binary,
java.lang.String ftpType)
This constructor is used when the ftpType needs to be specified
|
FtpEITransport(java.lang.String ip,
java.lang.String l,
java.lang.String pw,
int st,
boolean flag,
java.lang.String file,
java.lang.String lSuffix,
SynchronizedDirectory dir,
DCNode node,
boolean binary)
This form of the constructor is used when you need to retrieve
just a single file periodically.
|
FtpEITransport(java.lang.String ip,
java.lang.String l,
java.lang.String pw,
int st,
boolean flag,
java.lang.String file,
java.lang.String lSuffix,
SynchronizedDirectory dir,
DCNode node,
boolean binary,
boolean rRenameFlag)
This form of the constructor is used when you need to retrieve
just a single file periodically.
|
FtpEITransport(java.lang.String ip,
java.lang.String l,
java.lang.String pw,
int st,
boolean flag,
java.lang.String file,
java.lang.String lSuffix,
SynchronizedDirectory dir,
DCNode node,
boolean binary,
boolean rRenameFlag,
java.lang.String ftpType)
This constructor is used when the ftpType needs to be specified
|
FtpEITransport(java.lang.String ip,
java.lang.String l,
java.lang.String pw,
int st,
boolean flag,
java.lang.String file,
java.lang.String lSuffix,
SynchronizedDirectory dir,
DCNode node,
boolean binary,
java.lang.String ftpType)
This constructor is used when the ftpType needs to be specified
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
connectAndGetFiles()
This method actually creates the connection, retrieves the files
and notifies the consumer of the files via the SynchronizedDirectory.
|
protected boolean |
connectAndGetSingleFile()
This method actually creates the connection, retrieves a file
and notifies the consumer of the file via the SynchronizedDirectory.
|
void |
enablePassiveFTP(boolean passive)
Enable the use of Passive FTP.
|
DCFieldContainer[] |
getBulkData()
Not used.
|
DCFieldContainer |
getData()
Not used.
|
boolean |
getDeleteRemoteFiles()
Access flag for deleting remote files.
|
boolean |
getFlattenDirs() |
java.lang.String |
getIPAddress()
Accesses the IP address of the FTP server.
|
protected java.lang.String |
getLocalName(java.lang.String remoteFile) |
java.lang.String |
getLocalSuffix()
Accesses the local suffix.
|
java.lang.String |
getPassword()
Retrieves the password for the FTP session.
|
java.lang.String |
getRemoteFile()
Accesses the name of the remote file to be retrieved.
|
java.lang.String |
getRemotePath()
Accesses the path from which to retrieve file(s) on the
FTP server.
|
java.lang.String |
getRemoteSuffix()
Accesses the remote suffix.
|
boolean |
getRenameRemoteSuffix()
Gets the flag for renaming remote files
|
protected java.util.ArrayList |
getRetrivalList() |
int |
getSleepTime()
Accesses the time to wait before subsequent retrievals.
|
SynchronizedDirectory |
getSynchronizedDirectory()
Accesses the "common" local directory into which files
are retrieved and from which files are processed.
|
java.lang.String |
getUsername()
Retrieves the login name for the FTP session.
|
boolean |
isDataAvailable()
Not used.
|
boolean |
isHealthy()
This method is used to check if the transport is fully functional.
|
void |
run()
Workhorse of this class: Continuously retrieve the files and process them
until it's time to shut down.
|
void |
setASCIIMode()
Sets the FTP retrieval mode to ASCII Call this
after constructing the transport, or ftpSession will
be null and this method will have no effect.
|
void |
setBinaryMode()
Sets the FTP retrieval mode to binary.
|
void |
setDeleteRemoteFiles(boolean flag)
Sets flag for deleting remote files once retrieved.
|
void |
setFlattenDirs(boolean value) |
void |
setLocalSuffix(java.lang.String suffix)
Sets the suffix of files that need to be processed.
|
void |
setOverwriteExisting(boolean flag)
Sets flag that determines if files should be
overwritten via FTP.
|
void |
setRemoteFile(java.lang.String filespec)
Sets the name of the remote file to be retrieved.
|
void |
setRemotePath(java.lang.String path)
Sets the path from which to retrieve file(s) on the
FTP server.
|
void |
setRemoteSuffix(java.lang.String suffix)
Sets the suffix of files to retrieve from the FTP server.
|
void |
setRenameRemoteSuffix(boolean flag)
Sets the flag for renaming Remote Files
|
void |
setSleepTime(int time)
Sets the time to wait before subsequent retrievals.
|
void |
setSynchronizedDirectory(SynchronizedDirectory dir)
Establishes the "common" local directory into which files
are retrieved and from which files are processed.
|
void |
setUseTimestampInLocalName(boolean flag)
Sets flag that determines if timestamp is
used to form part of the local file name of
a retrieved file.
|
void |
shutdown()
This method is used to provide a means of shutting down the transport
in an orderly fashion.
|
protected void |
sleep(int sleepSecs)
Sleep for a given interval
|
getDataReceiver, getDubCheckObj, getDupCheckFlag, getFileBulkData, getFileData, getFileDataReceiver, getMovedFileStatus, getNode, getPollingInterval, handleRejectOfFile, incrementIn, incrementIn, isEndOfFile, isFileDataAvailable, isProcessing, isProcessingData, isStartOfFile, openInputFile, rejectFile, setCountsSuspect, setDataReceiver, setFileDataReceiver, setFileToProcess, setMovedFileStatus, setNode, setPollingInterval, setProcessing
protected FtpSupportIntf ftpSession
public static final java.lang.String FTP_TYPE_REGULAR
public static final java.lang.String FTP_TYPE_SECURE
public static final java.lang.String FTP_TYPE_PASSIVE
protected static final int SFTP_PORT
protected static final java.lang.String HOSTS_FILE
public FtpEITransport(java.lang.String ip, java.lang.String l, java.lang.String pw, EINode node)
ip
- The IP address of the FTP serverl
- The username to use for loggin inpw
- The password for the given usernamenode
- The EI Node that is using this transport objectpublic FtpEITransport(java.lang.String ip, java.lang.String l, java.lang.String pw, int st, boolean flag, java.lang.String rp, java.lang.String suffix, java.lang.String lSuffix, SynchronizedDirectory dir, DCNode node, boolean binary)
ip
- The IP address of the FTP serverl
- The username to use for loggin inpw
- The password for the given usernamest
- The number of milliseconds to wait between successive retrievalsflag
- Determines whether to delete the remote files once they are retrievedrp
- The path or directory on the FTP server that contains the filessuffix
- Specifies the suffix for the files that will be retrievedlSuffix
- Specifies the suffix for the files on the local machine after they're retrieveddir
- The local directory into which files will be placednode
- The EI Node that is using this transport objectbinary
- Determines if files should be retrieved in binary mode (false = ASCII mode)public FtpEITransport(java.lang.String ip, java.lang.String l, java.lang.String pw, int st, boolean flag, java.lang.String rp, java.lang.String suffix, java.lang.String lSuffix, SynchronizedDirectory dir, DCNode node, boolean binary, java.lang.String ftpType)
ftpType
- Determines the type of FTP to usepublic FtpEITransport(java.lang.String ip, java.lang.String l, java.lang.String pw, int st, boolean flag, java.lang.String file, java.lang.String lSuffix, SynchronizedDirectory dir, DCNode node, boolean binary)
ip
- The IP address of the FTP serverl
- The username to use for logging inpw
- The password for the given usernamest
- The number of milliseconds to wait between successive retrievalsflag
- Determines whether to delete the remote files once they are retrievedfile
- Specifies the file that will be retrieved (including path)dir
- The local directory into which files will be placednode
- The EI Node that is using this transport objectbinary
- Determines if files should be retrieved in binary mode (or ASCII mode)public FtpEITransport(java.lang.String ip, java.lang.String l, java.lang.String pw, int st, boolean flag, java.lang.String file, java.lang.String lSuffix, SynchronizedDirectory dir, DCNode node, boolean binary, java.lang.String ftpType)
ftpType
- Determines the type of FTP to usepublic FtpEITransport(java.lang.String ip, java.lang.String l, java.lang.String pw, int st, boolean flag, java.lang.String rp, java.lang.String suffix, java.lang.String lSuffix, SynchronizedDirectory dir, DCNode node, boolean binary, boolean rRenameflag)
ip
- The IP address of the FTP serverl
- The username to use for loggin inpw
- The password for the given usernamest
- The number of milliseconds to wait between successive retrievalsflag
- Determines whether to delete the remote files once they are retrievedrp
- The path or directory on the FTP server that contains the filessuffix
- Specifies the suffix for the files that will be retrievedlSuffix
- Specifies the suffix for the files on the local machine after they're retrieveddir
- The local directory into which files will be placednode
- The EI Node that is using this transport objectbinary
- Determines if files should be retrieved in binary mode (false = ASCII mode)rRenameflag
- flag for Renaming Remote Filepublic FtpEITransport(java.lang.String ip, java.lang.String l, java.lang.String pw, int st, boolean flag, java.lang.String rp, java.lang.String suffix, java.lang.String lSuffix, SynchronizedDirectory dir, DCNode node, boolean binary, boolean rRenameflag, java.lang.String ftpType)
ftpType
- Determines the type of FTP to usepublic FtpEITransport(java.lang.String ip, java.lang.String l, java.lang.String pw, int st, boolean flag, java.lang.String file, java.lang.String lSuffix, SynchronizedDirectory dir, DCNode node, boolean binary, boolean rRenameFlag)
ip
- The IP address of the FTP serverl
- The username to use for logging inpw
- The password for the given usernamest
- The number of milliseconds to wait between successive retrievalsflag
- Determines whether to delete the remote files once they are retrievedfile
- Specifies the file that will be retrieved (including path)dir
- The local directory into which files will be placednode
- The EI Node that is using this transport objectbinary
- Determines if files should be retrieved in binary mode (or ASCII mode)rRenameFlag
- flag for Renaming Remote Filepublic FtpEITransport(java.lang.String ip, java.lang.String l, java.lang.String pw, int st, boolean flag, java.lang.String file, java.lang.String lSuffix, SynchronizedDirectory dir, DCNode node, boolean binary, boolean rRenameFlag, java.lang.String ftpType)
ftpType
- Determines the type of FTP to usepublic void run()
run
in interface java.lang.Runnable
run
in class EITransport
protected boolean connectAndGetFiles()
remoteFile
is null, which indicates we need to retrieve multiple files at a time.protected boolean connectAndGetSingleFile()
remoteFile
is not null, which indicates we need to retrieve just a single file.protected void sleep(int sleepSecs) throws java.lang.InterruptedException
java.lang.InterruptedException
public void shutdown()
EITransport
shutdown
in interface DCTransport
shutdown
in class EITransport
protected java.util.ArrayList getRetrivalList() throws java.io.IOException
java.io.IOException
public DCFieldContainer getData()
getData
in interface DataProviderIfc
getData
in class EITransport
public DCFieldContainer[] getBulkData()
getBulkData
in interface DataProviderIfc
getBulkData
in class EITransport
public boolean isDataAvailable()
isDataAvailable
in interface DataProviderIfc
isDataAvailable
in class EITransport
true
, if data is availablepublic void setUseTimestampInLocalName(boolean flag)
public void setOverwriteExisting(boolean flag)
public void setBinaryMode()
public void setASCIIMode()
public void setRemotePath(java.lang.String path)
path
- remote pathpublic java.lang.String getRemotePath()
public void setLocalSuffix(java.lang.String suffix)
suffix
- local suffixpublic java.lang.String getLocalSuffix()
public void setRemoteSuffix(java.lang.String suffix)
suffix
- remote suffixpublic boolean getFlattenDirs()
public void setFlattenDirs(boolean value)
public java.lang.String getRemoteSuffix()
public void setSleepTime(int time)
time
- number of seconds to waitpublic int getSleepTime()
public void setSynchronizedDirectory(SynchronizedDirectory dir)
dir
- encapsulation of the local directorypublic SynchronizedDirectory getSynchronizedDirectory()
public void setDeleteRemoteFiles(boolean flag)
flag
- true = delete remote filespublic boolean getDeleteRemoteFiles()
public void setRemoteFile(java.lang.String filespec)
filespec
- remote path and filenamepublic java.lang.String getRemoteFile()
public void setRenameRemoteSuffix(boolean flag)
flag
- true will set itpublic boolean getRenameRemoteSuffix()
public java.lang.String getUsername() throws java.lang.NullPointerException
java.lang.NullPointerException
- if ftpSession hasn't been establishedpublic java.lang.String getPassword() throws java.lang.NullPointerException
java.lang.NullPointerException
- if ftpSession hasn't been establishedpublic java.lang.String getIPAddress() throws java.lang.NullPointerException
java.lang.NullPointerException
- if ftpSession hasn't been establishedpublic void enablePassiveFTP(boolean passive)
passive
- true
is Passive FTP is desired.protected java.lang.String getLocalName(java.lang.String remoteFile)
public boolean isHealthy()
isHealthy
in interface DCTransport
isHealthy
in class EITransport