Save This Page
Home » apache-ant-1.7.1-src » org.apache.tools » ant » taskdefs » optional » net » [javadoc | source]
org.apache.tools.ant.taskdefs.optional.net
public class: FTP [javadoc | source]
java.lang.Object
   org.apache.tools.ant.ProjectComponent
      org.apache.tools.ant.Task
         org.apache.tools.ant.taskdefs.optional.net.FTP

All Implemented Interfaces:
    Cloneable

Direct Known Subclasses:
    myFTP

Basic FTP client. Performs the following actions: Note: Some FTP servers - notably the Solaris server - seem to hold data ports open after a "retr" operation, allowing them to timeout instead of shutting them down cleanly. This happens in active or passive mode, and the ports will remain open even after ending the FTP session. FTP "send" operations seem to close ports immediately. This behavior may cause problems on some systems when downloading large sets of files.
Nested Class Summary:
protected class  FTP.FTPDirectoryScanner  internal 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 false 
public static class  FTP.Action  an action to perform, one of "send", "put", "recv", "get", "del", "delete", "list", "mkdir", "chmod", "rmdir" 
public static class  FTP.Granularity  represents one of the valid timestamp adjustment values recognized by the timestampGranularity attribute.

A timestamp adjustment may be used in file transfers for checking uptodateness. MINUTE means to add one minute to the server timestamp. This is done because FTP servers typically list timestamps HH:mm and client FileSystems typically use HH:mm:ss. The default is to use MINUTE for PUT actions and NONE for GET actions, since GETs have the preserveLastModified option, which takes care of the problem in most use cases where this level of granularity is an issue. 

public static class  FTP.FTPSystemType  one of the valid system type keys recognized by the systemTypeKey attribute. 
public static class  FTP.LanguageCode  Enumerated class for languages. 
Field Summary
protected static final  int SEND_FILES     
protected static final  int GET_FILES     
protected static final  int DEL_FILES     
protected static final  int LIST_FILES     
protected static final  int MK_DIR     
protected static final  int CHMOD     
protected static final  int RM_DIR     
protected static final  int SITE_CMD     
public static final  int DEFAULT_FTP_PORT    Default port for FTP 
protected static final  String[] ACTION_STRS     
protected static final  String[] COMPLETED_ACTION_STRS     
protected static final  String[] ACTION_TARGET_STRS     
Fields inherited from org.apache.tools.ant.Task:
target,  taskName,  taskType,  wrapper
Fields inherited from org.apache.tools.ant.ProjectComponent:
project,  location,  description
Method from org.apache.tools.ant.taskdefs.optional.net.FTP Summary:
addFileset,   checkAttributes,   createParents,   delFile,   doSiteCommand,   execute,   executeRetryable,   getDefaultDateFormatConfig,   getFile,   getRecentDateFormatConfig,   getServerLanguageCodeConfig,   getServerTimeZoneConfig,   getShortMonthNamesConfig,   getSystemTypeKey,   getTimestampGranularity,   isUpToDate,   listFile,   makeRemoteDir,   resolveFile,   rmDir,   sendFile,   setAccount,   setAction,   setAction,   setBinary,   setChmod,   setDefaultDateFormatConfig,   setDepends,   setIgnoreNoncriticalErrors,   setInitialSiteCommand,   setListing,   setNewer,   setPassive,   setPassword,   setPort,   setPreserveLastModified,   setRecentDateFormatConfig,   setRemotedir,   setRetriesAllowed,   setSeparator,   setServer,   setServerLanguageCodeConfig,   setServerTimeZoneConfig,   setShortMonthNamesConfig,   setSiteCommand,   setSkipFailedTransfers,   setSystemTypeKey,   setTimeDiffAuto,   setTimeDiffMillis,   setTimestampGranularity,   setUmask,   setUserid,   setVerbose,   transferFiles,   transferFiles
Methods from org.apache.tools.ant.Task:
bindToOwner,   execute,   getOwningTarget,   getRuntimeConfigurableWrapper,   getTaskName,   getTaskType,   getWrapper,   handleErrorFlush,   handleErrorOutput,   handleFlush,   handleInput,   handleOutput,   init,   isInvalid,   log,   log,   log,   log,   markInvalid,   maybeConfigure,   perform,   reconfigure,   setOwningTarget,   setRuntimeConfigurableWrapper,   setTaskName,   setTaskType
Methods from org.apache.tools.ant.ProjectComponent:
clone,   getDescription,   getLocation,   getProject,   log,   log,   setDescription,   setLocation,   setProject
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.tools.ant.taskdefs.optional.net.FTP Detail:
 public  void addFileset(FileSet set) 
    A set of files to upload or download
 protected  void checkAttributes() throws BuildException 
    Checks to see that all required parameters are set.
 protected  void createParents(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.
 protected  void delFile(FTPClient ftp,
    String filename) throws IOException, BuildException 
    Delete a file from the remote host.
 protected  void doSiteCommand(FTPClient ftp,
    String theCMD) throws IOException, BuildException 
    Sends a site command to the ftp server
 public  void execute() throws BuildException 
    Runs the task.
 protected  void executeRetryable(RetryHandler h,
    Retryable r,
    String descr) throws IOException 
    Executable a retryable object.
 String getDefaultDateFormatConfig() 
 protected  void getFile(FTPClient ftp,
    String dir,
    String filename) throws IOException, BuildException 
    Retrieve a single file from the remote host. filename may contain a relative path specification.

    The file will then be retreived 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.

 String getRecentDateFormatConfig() 
 String getServerLanguageCodeConfig() 
 String getServerTimeZoneConfig() 
 String getShortMonthNamesConfig() 
 String getSystemTypeKey() 
 FTP.Granularity getTimestampGranularity() 
 protected boolean isUpToDate(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.
 protected  void listFile(FTPClient ftp,
    BufferedWriter bw,
    String filename) throws IOException, BuildException 
    List information about a single file from the remote host. filename may 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.

 protected  void makeRemoteDir(FTPClient ftp,
    String dir) throws IOException, BuildException 
    Create the specified directory on the remote host.
 protected String resolveFile(String file) 
    Correct 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 the separator task parameter. No attempt is made to determine what syntax is appropriate for the remote host.
 protected  void rmDir(FTPClient ftp,
    String dirname) throws IOException, BuildException 
    Delete a directory, if empty, from the remote host.
 protected  void sendFile(FTPClient ftp,
    String dir,
    String filename) throws IOException, BuildException 
    Sends a single file to the remote host. filename may contain a relative path specification. When this is the case, sendFile will 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.
 public  void setAccount(String pAccount) 
    Sets the login account to use on the specified server.
 public  void setAction(String action) throws BuildException 
Deprecated! since - 1.5.x. setAction(String) is deprecated and is replaced with setAction(FTP.Action) to make Ant's Introspection mechanism do the work and also to encapsulate operations on the type in its own class.

    Sets the FTP action to be taken. Currently accepts "put", "get", "del", "mkdir", "chmod", "list", and "site".
 public  void setAction(FTP.Action action) throws BuildException 
    Sets the FTP action to be taken. Currently accepts "put", "get", "del", "mkdir", "chmod", "list", and "site".
 public  void setBinary(boolean binary) 
    If true, uses binary mode, otherwise text mode (default is binary).
 public  void setChmod(String theMode) 
    Sets the file permission mode (Unix only) for files sent to the server.
 public  void setDefaultDateFormatConfig(String defaultDateFormat) 
    Sets the defaultDateFormatConfig attribute.
 public  void setDepends(boolean depends) 
    Set to true to transmit only files that are new or changed from their remote counterparts. The default is to transmit all files.
 public  void setIgnoreNoncriticalErrors(boolean ignoreNoncriticalErrors) 
    set the flag to skip errors on directory creation. (and maybe later other server specific errors)
 public  void setInitialSiteCommand(String initialCommand) 
    Sets the initialSiteCommand attribute. This attribute names a site command that will be executed immediately after connection.
 public  void setListing(File listing) 
    The output file for the "list" action. This attribute is ignored for any other actions.
 public  void setNewer(boolean newer) 
    A synonym for depends. Set to true to transmit only new or changed files. See the related attributes timediffmillis and timediffauto.
 public  void setPassive(boolean passive) 
    Specifies whether to use passive mode. Set to true if you are behind a firewall and cannot connect without it. Passive mode is disabled by default.
 public  void setPassword(String password) 
    Sets the login password for the given user id.
 public  void setPort(int port) 
    Sets the FTP port used by the remote server.
 public  void setPreserveLastModified(boolean preserveLastModified) 
    Set to true to preserve modification times for "gotten" files.
 public  void setRecentDateFormatConfig(String recentDateFormat) 
    Sets the recentDateFormatConfig attribute.
 public  void setRemotedir(String dir) 
    Sets the remote directory where files will be placed. This may be a relative or absolute path, and must be in the path syntax expected by the remote server. No correction of path syntax will be performed.
 public  void setRetriesAllowed(String retriesAllowed) 
    Defines how many times to retry executing FTP command before giving up. Default is 0 - try once and if failure then give up.
 public  void setSeparator(String separator) 
    Sets the remote file separator character. This normally defaults to the Unix standard forward slash, but can be manually overridden using this call if the remote server requires some other separator. Only the first character of the string is used.
 public  void setServer(String server) 
    Sets the FTP server to send files to.
 public  void setServerLanguageCodeConfig(FTP.LanguageCode serverLanguageCode) 
    Sets the serverLanguageCode attribute.
 public  void setServerTimeZoneConfig(String serverTimeZoneId) 
    Sets the serverTimeZoneConfig attribute.
 public  void setShortMonthNamesConfig(String shortMonthNames) 
    Sets the shortMonthNamesConfig attribute
 public  void setSiteCommand(String siteCommand) 
    Sets the siteCommand attribute. This attribute names the command that will be executed if the action is "site".
 public  void setSkipFailedTransfers(boolean skipFailedTransfers) 
    If true, enables unsuccessful file put, delete and get operations to be skipped with a warning and the remainder of the files still transferred.
 public  void setSystemTypeKey(FTP.FTPSystemType systemKey) 
    Sets the systemTypeKey attribute. Method for setting FTPClientConfig remote system key.
 public  void setTimeDiffAuto(boolean timeDiffAuto) 
    "true" to find out automatically the time difference between local and remote machine. This requires right to create and delete a temporary file in the remote directory.
 public  void setTimeDiffMillis(long timeDiffMillis) 
    number of milliseconds to add to the time on the remote machine to get the time on the local machine. use in conjunction with newer
 public  void setTimestampGranularity(FTP.Granularity timestampGranularity) 
    Sets the timestampGranularity attribute
 public  void setUmask(String theUmask) 
    Sets the default mask for file creation on a unix server.
 public  void setUserid(String userid) 
    Sets the login user id to use on the specified server.
 public  void setVerbose(boolean verbose) 
    Set to true to receive notification about each file as it is transferred.
 protected  void transferFiles(FTPClient ftp) throws IOException, BuildException 
    Sends all files specified by the configured filesets to the remote server.
 protected int transferFiles(FTPClient ftp,
    FileSet fs) throws IOException, BuildException 
    For each file in the fileset, do the appropriate action: send, get, delete, or list.