|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openadaptor.adaptor.ftp.ApacheFTP
public class ApacheFTP
This component will provide basic File Transfer Protocol (FTP) connunication to allow the adaptor to GET a file from or PUT a file onto a remote machine.
The methods return FTP input/output streams to the caller which can then be used to either read a file from or write a file to the remote server. NB: while this component will happily write file in any format, the other componets (eg. FileSink, FileSource, ...) will only handle files that correspond to DOXML standards (eg. DOXML, csv, fixed width, etc. ) Uses the org.apache.commons.net.ftp classes to perform the actual file transfer. Now allows you to set the file encoding for the i/o streams via the TextEncoding property Properties:UseReaderThread if true then a separate reader thread is used to perform the data transfers. On some platforms this is known to cause deadlocks! Default is false
Field Summary | |
---|---|
(package private) static org.apache.log4j.Logger |
log
|
Fields inherited from interface org.openadaptor.adaptor.ftp.FTP |
---|
_DEFAULT_DIR, _DEFAULT_FTP_PORT, _DEFAULT_SFTP_PORT, _SUN |
Constructor Summary | |
---|---|
ApacheFTP()
basic constructor for those that want it |
Method Summary | |
---|---|
java.io.OutputStreamWriter |
append(java.lang.String fileName)
Transfers a file to the remote server but appends the output stream the remote file rather than overwriting it. |
void |
close()
close the connection to the remote server |
void |
connect(java.lang.String hostName,
int port)
takes the supplied hostname and port of the target machine and attempts to connect to it. |
void |
delete(java.lang.String fileName)
deletes supplied file from the remote server |
boolean |
directoryExists(java.lang.String dirName)
check for directory on remote server. |
java.lang.String[] |
fileList(java.lang.String filePattern)
retrieves a list of file names on the remote server that match the supplied pattern. |
java.io.InputStreamReader |
get(java.lang.String fileName)
This method creates a FTP input stream in the shape of an InputStreamReader that the caller can use to perform the GET function. |
java.lang.String |
getCurrentWorkingDirectory()
returns the current working directory or null if there was an error |
int |
getDefaultPort()
returns the default FTP communications port to use |
void |
init(java.util.Properties props,
java.lang.String prefix)
allows for library specific initialisation (eg. |
void |
initSession(java.lang.String workDir,
boolean binaryTransfer)
sets up the FTP session. |
boolean |
isConnected()
returns flag to indicate if the FTPClient object has successfully connected to the remote server |
boolean |
isLoggedIn()
returns flag to indicate if the FTPClient object has successfully logged into the remote server |
void |
logon(java.lang.String userName,
java.lang.String password)
attempt to log into the remote server using the supplied credentials. |
java.io.OutputStreamWriter |
put(java.lang.String fileName)
This method creates a FTP output stream in the shape of an OutputStreamWriter that the caller can use to perform the PUT function. |
void |
setTextEncoding(java.lang.String enc)
sets the file encoding to use when reading from the input stream |
boolean |
verifyFileTransfer()
There are a few FTPClient methods that do not complete the entire sequence of FTP commands to complete a transaction. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static org.apache.log4j.Logger log
Constructor Detail |
---|
public ApacheFTP()
Method Detail |
---|
public void init(java.util.Properties props, java.lang.String prefix) throws IbafException
init
in interface FTP
props
- - reference to the Java properties fileprefix
- - the component prefix in the properties file (eg. A.C1)
IbafException
- - if mandatory properties are not found or the properties
cannot be converted into the right formatpublic void initSession(java.lang.String workDir, boolean binaryTransfer) throws IbafException
initSession
in interface FTP
workDir
- - the working directory for the sessionbinaryTransfer
- - true if binary transfer mode is to be used
IbafException
public void connect(java.lang.String hostName, int port) throws IbafException
connect
in interface FTP
hostName
- - The name of the server you wish to connect toport
- - The FTP control port to connect on
IbafException
public boolean isConnected()
isConnected
in interface FTP
public boolean isLoggedIn()
isLoggedIn
in interface FTP
public void logon(java.lang.String userName, java.lang.String password) throws IbafException
logon
in interface FTP
userName
- - The username to use to authenticate the connectionpassword
- - The password to use to authenticate the connection
IbafException
public java.io.InputStreamReader get(java.lang.String fileName) throws IbafException
get
in interface FTP
fileName
- - The name of the file to retrieve
IbafException
public java.io.OutputStreamWriter put(java.lang.String fileName) throws IbafException
put
in interface FTP
fileName
- - The name of the file to transfer
IbafException
- - if the client is not conected and logged into the remote
server or the FTP output stream cannot be created
(eg. does not have permission)public java.io.OutputStreamWriter append(java.lang.String fileName) throws IbafException
append
in interface FTP
fileName
- - The name of the file to transfer
IbafException
- - if the client is not conected and logged into the remote
server or the FTP output stream cannot be created
(eg. does not have permission)public void close() throws IbafException
close
in interface FTP
IbafException
public boolean directoryExists(java.lang.String dirName) throws IbafException
directoryExists
in interface FTP
dirName
- - the directory to check for
IbafException
- - if the client is not connected and logged into the remote serverpublic void delete(java.lang.String fileName) throws IbafException
delete
in interface FTP
fileName
- - the file to delete
IbafException
- - if the client is not logged into the remote
server or there was a problem with the deletionpublic java.lang.String[] fileList(java.lang.String filePattern) throws IbafException
fileList
in interface FTP
filePattern
- - the pattern the match file names against
IbafException
- - if there was an communications errorpublic int getDefaultPort()
getDefaultPort
in interface FTP
public java.lang.String getCurrentWorkingDirectory()
getCurrentWorkingDirectory
in interface FTP
public boolean verifyFileTransfer() throws IbafException
verifyFileTransfer
in interface FTP
IbafException
public void setTextEncoding(java.lang.String enc)
setTextEncoding
in interface FTP
enc
- - String representing the file encoding to use (eg. ISO-8859-1)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |