|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.openadaptor.adaptor.ftp.SunFTP
public class SunFTP
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 standard sun.net.ftp.FtpClient and sun.net.TelnetInputStream classes to perform the actual file transfer. NB: the Sun libraries are subject to change between JDK releases. A case in point is - if you specify a wildcard in the filename. Under JDK 1.4 the source will retrieve each file that matches the file pattern on subsequent polls pretty much as you would expect. However, if you use JDK 1.3 then it will only retrieve the first file that matches and then empty files for the rest. Upshot, only use JDK 1.3 if you are getting single files! Now allows you to set the file encoding for the i/o streams via the TextEncoding property
| 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 | |
|---|---|
SunFTP()
basic constructor for those that want it |
|
| Method Summary | |
|---|---|
java.io.OutputStreamWriter |
append(java.lang.String fileName)
the append() functionality requires JDK 1.4 and therefore we don't implement it here. |
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 SunFTP 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 is 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 SunFTP 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 is no way to check that all is ok so we return true anyway!! |
| 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 SunFTP()
| Method Detail |
|---|
public void init(java.util.Properties props,
java.lang.String prefix)
throws IbafException
init in interface FTPprops - - 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 format
public void initSession(java.lang.String workDir,
boolean binaryTransfer)
throws IbafException
initSession in interface FTPworkDir - - 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 FTPhostName - The name of the server you wish to connect toport - The SunFTP control port to connect on
IbafExceptionpublic boolean isConnected()
isConnected in interface FTPpublic boolean isLoggedIn()
isLoggedIn in interface FTP
public void logon(java.lang.String userName,
java.lang.String password)
throws IbafException
logon in interface FTPuserName - 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 FTPfileName - The name of the file to retrieve
IbafException
public java.io.OutputStreamWriter put(java.lang.String fileName)
throws IbafException
put in interface FTPfileName - The name of the file to transfer
IbafException - if the client is not conected and logged into the remote server
or the SunFTP output stream cannot be created (eg. does not have permission)
public java.io.OutputStreamWriter append(java.lang.String fileName)
throws IbafException
append in interface FTPfileName - - The name of the file to transfer
IbafException - - if the client is not conected and logged into the
remote server or the SunFTP output stream cannot
be created (eg. does not have permission)
public void close()
throws IbafException
close in interface FTPIbafException
public boolean directoryExists(java.lang.String dirName)
throws IbafException
directoryExists in interface FTPdirName - the directory to check for
IbafException - if the client is not connected and logged into the remote server
public void delete(java.lang.String fileName)
throws IbafException
delete in interface FTPfileName - - the file to delete
IbafException - - if the client is not logged into the remote
server or there was a problem with the deletion
public java.lang.String[] fileList(java.lang.String filePattern)
throws IbafException
fileList in interface FTPfilePattern - - the pattern the match file names against
IbafException - - if there was an communications errorpublic int getDefaultPort()
getDefaultPort in interface FTPpublic java.lang.String getCurrentWorkingDirectory()
getCurrentWorkingDirectory in interface FTP
public boolean verifyFileTransfer()
throws IbafException
verifyFileTransfer in interface FTPIbafExceptionpublic void setTextEncoding(java.lang.String enc)
setTextEncoding in interface FTPenc - - 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 | ||||||||