Class FTPTaskMirrorImpl
java.lang.Object
org.apache.tools.ant.taskdefs.optional.net.FTPTaskMirrorImpl
- All Implemented Interfaces:
- FTPTaskMirror
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected classinternal class allowing to read the contents of a remote file system using the FTP protocol used in particular for ftp get operations differences with DirectoryScanner "" (the root of the fileset) is never included in the included directories followSymlinks defaults to falseprotected static classinternal class providing a File-like interface to some of the information available from the FTP server
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidcreateParents(org.apache.commons.net.ftp.FTPClient ftp, String filename) Creates all parent directories specified in a complete relative pathname.protected voidDelete a file from the remote host.voiddoFTP()protected voiddoSiteCommand(org.apache.commons.net.ftp.FTPClient ftp, String theCMD) Sends a site command to the ftp serverprotected voidexecuteRetryable(RetryHandler h, Retryable r, String descr) Executable a retryable object.protected voidRetrieve a single file from the remote host.protected booleanisUpToDate(org.apache.commons.net.ftp.FTPClient ftp, File localFile, String remoteFile) Checks to see if the remote file is current as compared with the local file.protected voidlistFile(org.apache.commons.net.ftp.FTPClient ftp, BufferedWriter bw, String filename) List information about a single file from the remote host.protected voidmakeRemoteDir(org.apache.commons.net.ftp.FTPClient ftp, String dir) Create the specified directory on the remote host.protected StringresolveFile(String file) Correct a file path to correspond to the remote host requirements.protected voidDelete a directory, if empty, from the remote host.protected voidSends a single file to the remote host.protected voidtransferFiles(org.apache.commons.net.ftp.FTPClient ftp) Sends all files specified by the configured filesets to the remote server.protected inttransferFiles(org.apache.commons.net.ftp.FTPClient ftp, FileSet fs) For each file in the fileset, do the appropriate action: send, get, delete, or list.
- 
Constructor Details- 
FTPTaskMirrorImplConstructor.- Parameters:
- task- the FTPTask that uses this mirror.
 
 
- 
- 
Method Details- 
executeRetryableExecutable a retryable object.- Parameters:
- h- the retry handler.
- r- the object that should be retried until it succeeds or the number of retries is reached.
- descr- a description of the command that is being run.
- Throws:
- IOException- if there is a problem.
 
- 
transferFilesprotected int transferFiles(org.apache.commons.net.ftp.FTPClient ftp, FileSet fs) throws IOException, BuildException For each file in the fileset, do the appropriate action: send, get, delete, or list.- Parameters:
- ftp- the FTPClient instance used to perform FTP actions
- fs- the fileset on which the actions are performed.
- Returns:
- the number of files to be transferred.
- Throws:
- IOException- if there is a problem reading a file
- BuildException- if there is a problem in the configuration.
 
- 
transferFilesprotected void transferFiles(org.apache.commons.net.ftp.FTPClient ftp) throws IOException, BuildException Sends all files specified by the configured filesets to the remote server.- Parameters:
- ftp- the FTPClient instance used to perform FTP actions
- Throws:
- IOException- if there is a problem reading a file
- BuildException- if there is a problem in the configuration.
 
- 
resolveFileCorrect a file path to correspond to the remote host requirements. This implementation currently assumes that the remote end can handle Unix-style paths with forward-slash separators. This can be overridden with theseparatortask parameter. No attempt is made to determine what syntax is appropriate for the remote host.- Parameters:
- file- the remote file name to be resolved
- Returns:
- the filename as it will appear on the server.
 
- 
createParentsprotected void createParents(org.apache.commons.net.ftp.FTPClient ftp, String filename) throws IOException, BuildException Creates all parent directories specified in a complete relative pathname. Attempts to create existing directories will not cause errors.- Parameters:
- ftp- the FTP client instance to use to execute FTP actions on the remote server.
- filename- the name of the file whose parents should be created.
- Throws:
- IOException- under non documented circumstances
- BuildException- if it is impossible to cd to a remote directory
 
- 
isUpToDateprotected boolean isUpToDate(org.apache.commons.net.ftp.FTPClient ftp, File localFile, String remoteFile) throws IOException, BuildException Checks to see if the remote file is current as compared with the local file. Returns true if the target file is up to date.- Parameters:
- ftp- ftpclient
- localFile- local file
- remoteFile- remote file
- Returns:
- true if the target file is up to date
- Throws:
- IOException- in unknown circumstances
- BuildException- if the date of the remote files cannot be found and the action is GET_FILES
 
- 
doSiteCommandprotected void doSiteCommand(org.apache.commons.net.ftp.FTPClient ftp, String theCMD) throws IOException, BuildException Sends a site command to the ftp server- Parameters:
- ftp- ftp client
- theCMD- command to execute
- Throws:
- IOException- in unknown circumstances
- BuildException- in unknown circumstances
 
- 
sendFileprotected void sendFile(org.apache.commons.net.ftp.FTPClient ftp, String dir, String filename) throws IOException, BuildException Sends a single file to the remote host.filenamemay contain a relative path specification. When this is the case,sendFilewill attempt to create any necessary parent directories before sending the file. The file will then be sent using the entire relative path spec - no attempt is made to change directories. It is anticipated that this may eventually cause problems with some FTP servers, but it simplifies the coding.- Parameters:
- ftp- ftp client
- dir- base directory of the file to be sent (local)
- filename- relative path of the file to be send locally relative to dir remotely relative to the remotedir attribute
- Throws:
- IOException- in unknown circumstances
- BuildException- in unknown circumstances
 
- 
delFileprotected void delFile(org.apache.commons.net.ftp.FTPClient ftp, String filename) throws IOException, BuildException Delete a file from the remote host.- Parameters:
- ftp- ftp client
- filename- file to delete
- Throws:
- IOException- in unknown circumstances
- BuildException- if skipFailedTransfers is set to false and the deletion could not be done
 
- 
rmDirprotected void rmDir(org.apache.commons.net.ftp.FTPClient ftp, String dirname) throws IOException, BuildException Delete a directory, if empty, from the remote host.- Parameters:
- ftp- ftp client
- dirname- directory to delete
- Throws:
- IOException- in unknown circumstances
- BuildException- if skipFailedTransfers is set to false and the deletion could not be done
 
- 
getFileprotected void getFile(org.apache.commons.net.ftp.FTPClient ftp, String dir, String filename) throws IOException, BuildException Retrieve a single file from the remote host.filenamemay contain a relative path specification.The file will then be retrieved using the entire relative path spec - no attempt is made to change directories. It is anticipated that this may eventually cause problems with some FTP servers, but it simplifies the coding. - Parameters:
- ftp- the ftp client
- dir- local base directory to which the file should go back
- filename- relative path of the file based upon the ftp remote directory and/or the local base directory (dir)
- Throws:
- IOException- in unknown circumstances
- BuildException- if skipFailedTransfers is false and the file cannot be retrieved.
 
- 
listFileprotected void listFile(org.apache.commons.net.ftp.FTPClient ftp, BufferedWriter bw, String filename) throws IOException, BuildException List information about a single file from the remote host.filenamemay contain a relative path specification.The file listing will then be retrieved using the entire relative path spec - no attempt is made to change directories. It is anticipated that this may eventually cause problems with some FTP servers, but it simplifies the coding. - Parameters:
- ftp- ftp client
- bw- buffered writer
- filename- the directory one wants to list
- Throws:
- IOException- in unknown circumstances
- BuildException- in unknown circumstances
 
- 
makeRemoteDirprotected void makeRemoteDir(org.apache.commons.net.ftp.FTPClient ftp, String dir) throws IOException, BuildException Create the specified directory on the remote host.- Parameters:
- ftp- The FTP client connection
- dir- The directory to create (format must be correct for host type)
- Throws:
- IOException- in unknown circumstances
- BuildException- if ignoreNoncriticalErrors has not been set to true and a directory could not be created, for instance because it was already existing. Precisely, the codes 521, 550 and 553 will trigger a BuildException
 
- 
doFTP- Specified by:
- doFTPin interface- FTPTaskMirror
- Throws:
- BuildException
 
 
-