|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sshtools.ant.SshSubTask
com.sshtools.ant.Sftp
public class Sftp
Basic SFTP client. Performs the following actions:
Nested Class Summary | |
---|---|
static class |
Sftp.Action
an action to perform, one of "send", "put", "recv", "get", "del", "delete", "list", "mkdir", "chmod" |
protected class |
Sftp.SftpDirectoryScanner
|
Field Summary | |
---|---|
protected static java.lang.String[] |
ACTION_STRS
|
protected static int |
CHMOD
|
protected static java.lang.String[] |
COMPLETED_ACTION_STRS
|
protected static int |
DEL_FILES
|
protected static int |
GET_FILES
|
protected static int |
MK_DIR
|
protected static int |
SEND_FILES
|
Fields inherited from class com.sshtools.ant.SshSubTask |
---|
parent, taskString |
Constructor Summary | |
---|---|
Sftp()
|
Method Summary | |
---|---|
void |
addFileset(org.apache.tools.ant.types.FileSet set)
A set of files to upload or download |
protected void |
checkConfiguration()
Checks to see that all required parameters are set. |
protected void |
chmod(SftpClient sftp,
java.lang.String filename)
|
protected void |
createParents(SftpClient sftp,
java.lang.String filename)
Creates all parent directories specified in a complete relative pathname. |
protected void |
delFile(SftpClient sftp,
java.lang.String filename)
Delete a file from the remote host. |
void |
execute(SshClient ssh)
Runs the task. |
protected void |
executeSFTPTask(SshClient ssh)
|
protected void |
getFile(SftpClient sftp,
java.lang.String dir,
java.lang.String filename)
Retrieve a single file to the remote host. |
protected boolean |
isUpToDate(SftpClient sftp,
java.io.File localFile,
java.lang.String remoteFile)
Checks to see if the remote file is current as compared with the local file. |
protected void |
makeRemoteDir(SftpClient sftp,
java.lang.String dir)
Create the specified directory on the remote host. |
protected java.lang.String |
resolveFile(java.lang.String file)
Correct a file path to correspond to the remote host requirements. |
protected void |
sendFile(SftpClient sftp,
java.lang.String dir,
java.lang.String filename)
Sends a single file to the remote host. |
void |
setAction(Sftp.Action action)
Sets the FTP action to be taken. |
void |
setChmod(java.lang.String theMode)
Sets the file permission mode (Unix only) for files sent to the server. |
void |
setDepends(boolean depends)
Set to true to transmit only files that are new or changed from their remote counterparts. |
void |
setIgnoreNoncriticalErrors(boolean ignoreNoncriticalErrors)
set the flag to skip errors on directory creation. |
void |
setNewer(boolean newer)
A synonym for depends. |
void |
setRemotedir(java.lang.String remotedir)
Sets the remote working directory |
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. |
void |
setVerbose(boolean verbose)
Set to true to receive notification about each file as it is transferred. |
protected void |
transferFiles(SftpClient sftp)
Sends all files specified by the configured filesets to the remote server. |
protected int |
transferFiles(SftpClient sftp,
org.apache.tools.ant.types.FileSet fs)
For each file in the fileset, do the appropriate action: send, get, delete, or list. |
Methods inherited from class com.sshtools.ant.SshSubTask |
---|
log, log, setParent |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int SEND_FILES
protected static final int GET_FILES
protected static final int DEL_FILES
protected static final int MK_DIR
protected static final int CHMOD
protected static final java.lang.String[] ACTION_STRS
protected static final java.lang.String[] COMPLETED_ACTION_STRS
Constructor Detail |
---|
public Sftp()
Method Detail |
---|
public void setVerbose(boolean verbose)
public void setRemotedir(java.lang.String remotedir)
public void setNewer(boolean newer)
public void setDepends(boolean depends)
public void setChmod(java.lang.String theMode)
public void addFileset(org.apache.tools.ant.types.FileSet set)
public void setAction(Sftp.Action action) throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildException
public void setSkipFailedTransfers(boolean skipFailedTransfers)
public void setIgnoreNoncriticalErrors(boolean ignoreNoncriticalErrors)
protected void checkConfiguration() throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildException
protected int transferFiles(SftpClient sftp, org.apache.tools.ant.types.FileSet fs) throws java.io.IOException, org.apache.tools.ant.BuildException
java.io.IOException
org.apache.tools.ant.BuildException
protected void transferFiles(SftpClient sftp) throws java.io.IOException, org.apache.tools.ant.BuildException
java.io.IOException
org.apache.tools.ant.BuildException
protected java.lang.String resolveFile(java.lang.String file)
separator
task parameter. No attempt is made to
determine what syntax is appropriate for the remote host.
protected void createParents(SftpClient sftp, java.lang.String filename) throws java.io.IOException, org.apache.tools.ant.BuildException
java.io.IOException
org.apache.tools.ant.BuildException
protected boolean isUpToDate(SftpClient sftp, java.io.File localFile, java.lang.String remoteFile) throws java.io.IOException, org.apache.tools.ant.BuildException
java.io.IOException
org.apache.tools.ant.BuildException
protected void sendFile(SftpClient sftp, java.lang.String dir, java.lang.String filename) throws java.io.IOException, org.apache.tools.ant.BuildException
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.
java.io.IOException
org.apache.tools.ant.BuildException
protected void delFile(SftpClient sftp, java.lang.String filename) throws java.io.IOException, org.apache.tools.ant.BuildException
java.io.IOException
org.apache.tools.ant.BuildException
protected void chmod(SftpClient sftp, java.lang.String filename) throws java.io.IOException, org.apache.tools.ant.BuildException
java.io.IOException
org.apache.tools.ant.BuildException
protected void getFile(SftpClient sftp, java.lang.String dir, java.lang.String filename) throws java.io.IOException, org.apache.tools.ant.BuildException
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.
java.io.IOException
org.apache.tools.ant.BuildException
protected void makeRemoteDir(SftpClient sftp, java.lang.String dir) throws org.apache.tools.ant.BuildException
sftp
- The SFTP client connectiondir
- The directory to create
org.apache.tools.ant.BuildException
public void execute(SshClient ssh) throws org.apache.tools.ant.BuildException
execute
in class SshSubTask
org.apache.tools.ant.BuildException
protected void executeSFTPTask(SshClient ssh) throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |