Package org.globus.ftp

# Class FTPClient

java.lang.Object
org.globus.ftp.FTPClient

Direct Known Subclasses:
  `GridFTPClient`

public class FTPClient extends Object
This is the main user interface for FTP operations. Use this class for client - server or third party transfers that do not require GridFTP extensions. Consult the manual for general usage.
Note: If using with GridFTP servers operations like `setMode()`, `setType()` that affect data channel settings must be called before passive or active data channel mode is set.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected List<String>`
`algorithms`
List of the checksum algorithms supported by the server as described in GridFTP v2 Protocol Description
`protected FTPControlChannel`
`controlChannel`
`protected SimpleDateFormat`
`dateFormat`
`protected FTPServerFacade`
`localServer`
`static final Pattern`
`portPattern`
Regular expression for matching the port information of a GFD.47 127 reply.
`protected Session`
`session`
`protected boolean`
`useAllo`
Whether to use ALLO with put()/asyncPut() or not
`protected String`
`username`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`FTPClient()`
``
`FTPClient(String host, int port)`
Constructs client and connects it to the remote server.

## Method Summary

Modifier and Type
Method
Description
`void`
`abort()`
Aborts the current transfer.
`protected void`
`actualSetMode(int mode, String modeStr)`
`void`
`allocate(long size)`
Reserve sufficient storage to accommodate the new file to be transferred.
`TransferState`
`asynchGet(String remoteFileName, DataSink sink, MarkerListener mListener)`
Retrieves the file from the remote server.
`TransferState`
`asynchGet2(String remoteFileName, boolean passive, DataSink sink, MarkerListener mListener)`
Retrieves a file asynchronously using the GFD.47 (a.k.a GridFTP2) GET command.
`TransferState`
`asynchPut(String remoteFileName, DataSource source, MarkerListener mListener)`
Stores file at the remote server.
`TransferState`
`asynchPut(String remoteFileName, DataSource source, MarkerListener mListener, boolean append)`
Stores file at the remote server.
`TransferState`
`asynchPut2(String remoteFileName, boolean passive, DataSource source, MarkerListener mListener)`
Stores a file at the remote server using the GFD.47 (a.k.a GridFTP2) PUT command.
`void`
`authorize(String user, String password)`
Performs user authorization with specified user and password.
`void`
`changeDir(String dir)`
Changes the remote current working directory.
`protected void`
`checkGETPUTSupport()`
Throws ServerException if GFD.47 GETPUT is not supported or cannot be used.
`protected void`
`checkTransferParams()`
`protected void`
`checkTransferParamsGet()`
`protected void`
`checkTransferParamsPut()`
`void`
`close()`
Closes connection.
`void`
`close(boolean ignoreQuitReply)`
Closes connection.
`void`
`deleteDir(String dir)`
Deletes the remote directory.
`void`
`deleteFile(String filename)`
Deletes the remote file.
`boolean`
`exists(String filename)`
Checks if given file/directory exists on the server.
`void`
`get(String remoteFileName, File localFile)`
`void`
`get(String remoteFileName, DataSink sink, MarkerListener mListener)`
Retrieves the file from the remote server.
`protected HostPort`
`get127Reply()`
Reads a GFD.47 compliant 127 reply and extracts the port information from it.
`void`
`get2(String remoteFileName, boolean passive, DataSink sink, MarkerListener mListener)`
Retrieves a file using the GFD.47 (a.k.a GridFTP2) GET command.
`String`
`getChecksum(String algorithm, long offset, long length, String path)`
implement GridFTP v2 CKSM command from GridFTP v2 Protocol Description
`String`
`getChecksum(String algorithm, String path)`
GridFTP v2 CKSM command for the whole file
`String`
`getCurrentDir()`
Returns remote current working directory.
`FeatureList`
`getFeatureList()`
Returns list of features supported by remote server.
`String`
`getHost()`
`Date`
`getLastModified(String filename)`
Returns last modification time of the specifed file.
`Reply`
`getLastReply()`
Returns the last reply received from the server.
`protected String`
`getModeStr(int mode)`
`int`
`getPort()`
`long`
`getSize(String filename)`
Returns the remote file size.
`List<String>`
`getSupportedCksumAlgorithms()`
According to GridFTP v2 Protocol Description checksum feature has the following syntax:
`boolean`
`getUseAllo()`
Determines whether this client is configured to send an ALLO command before a STOR request in the put/asyncPut methods.
`String`
`getUserName()`
`void`
`goUpDir()`
Changes remote current working directory to the higher level.
`boolean`
`isActiveMode()`
`boolean`
`isCksumAlgorithmSupported(String algorithm)`
`boolean`
`isFeatureSupported(String feature)`
Returns true if the given feature is supported by remote server, false otherwise.
`boolean`
`isPassiveMode()`
`Date`
`lastModified(String filename)`
`Vector`
`list()`
Performs remote directory listing.
`Vector`
`list(String filter)`
Performs remote directory listing with the specified filter.
`Vector`
`list(String filter, String modifier)`
Performs remote directory listing with the specified filter and modifier.
`void`
`list(String filter, String modifier, DataSink sink)`
Performs directory listing and writes the result to the supplied data sink.
`protected void`
`listCheck()`
check performed at the beginning of list()
`void`
`makeDir(String dir)`
Creates remote directory.
`Vector`
`mlsd()`
Performs remote directory listing of the current directory.
`Vector`
`mlsd(String path)`
Performs remote directory listing on the given path.
`void`
`mlsd(String path, DataSink sink)`
Performs remote directory listing on the given path.
`MlsxEntry`
`mlst(String fileName)`
Get info of a certain remote file in Mlsx format.
`Vector`
`nlist()`
Performs remote directory listing of the current directory.
`Vector`
`nlist(String path)`
Performs remote directory listing on the given path.
`void`
`nlist(String path, DataSink sink)`
Performs remote directory listing on the given path.
`protected void`
`performTransfer(Command cmd, DataSink sink)`
`void`
`put(File localFile, String remoteFileName, boolean append)`
`void`
`put(String remoteFileName, DataSource source, MarkerListener mListener)`
Stores file at the remote server.
`void`
`put(String remoteFileName, DataSource source, MarkerListener mListener, boolean append)`
Stores file at the remote server.
`void`
`put2(String remoteFileName, boolean passive, DataSource source, MarkerListener mListener)`
Stores a file at the remote server using the GFD.47 (a.k.a GridFTP2) PUT command.
`Reply`
`quote(String command)`
Executes arbitrary operation on the server.
`void`
`rename(String oldName, String newName)`
Renames remote directory.
`void`
`setActive()`
Sets remote server active, telling it to connect to the client.
`void`
`setActive(HostPort hostPort)`
Sets remote server active, telling it to connect to the given address.
`void`
`setChecksum(String algorithm, String value)`
implement GridFTP v2 SCKS command as described in GridFTP v2 Protocol Description
`void`
`setClientWaitParams(int maxWait, int waitDelay)`
Changes the default client timeout parameters.
`void`
`setLocalActive()`
Starts local server in active server mode.
`HostPort`
`setLocalPassive()`
Starts local server in passive server mode, with default parameters.
`HostPort`
`setLocalPassive(int port, int queue)`
Starts the local server in passive server mode.
`void`
`setMode(int mode)`
Sets transfer mode.
`void`
`setOptions(Options opts)`
Sets the supplied options to the server.
`HostPort`
`setPassive()`
Sets remote server to passive server mode.
`void`
`setPassiveMode(boolean passiveMode)`
Enables/disables passive data connections.
`void`
`setProtectionBufferSize(int size)`
Sets protection buffer size (defined in RFC 2228)
`void`
`setRestartMarker(RestartData restartData)`
Sets restart parameter of the next transfer.
`void`
`setType(int type)`
Sets transfer type.
`void`
`setUseAllo(boolean useAllo)`
Controls whether the client attempts to send an ALLO command before a STOR request during the put/asyncPut calls.
`Reply`
`site(String args)`
Executes site-specific operation (using the SITE command).
`long`
`size(String filename)`
`void`
`transfer(String remoteSrcFile, FTPClient destination, String remoteDstFile, boolean append, MarkerListener mListener)`
Performs third-party transfer between two servers.
`static void`
`transfer(FTPClient source, String remoteSrcFile, FTPClient destination, String remoteDstFile, int mode, MarkerListener mListener)`
Performs third-party transfer between two servers.
`protected TransferState`
`transferBegin(BasicClientControlChannel other, MarkerListener mListener)`
`protected void`
`transferRun(BasicClientControlChannel other, MarkerListener mListener)`
Actual transfer management.
`protected void`
`transferRunSingleThread(BasicClientControlChannel other, MarkerListener mListener)`
`protected TransferState`
`transferStart(BasicClientControlChannel other, MarkerListener mListener)`
`protected void`
`transferWait(TransferState transferState)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### session

protected Session session

### controlChannel

protected FTPControlChannel controlChannel

### localServer

protected FTPServerFacade localServer

### dateFormat

protected SimpleDateFormat dateFormat

### username

protected String username

### useAllo

protected boolean useAllo
Whether to use ALLO with put()/asyncPut() or not

### algorithms

protected List<String> algorithms
List of the checksum algorithms supported by the server as described in GridFTP v2 Protocol Description

### portPattern

public static final Pattern portPattern
Regular expression for matching the port information of a GFD.47 127 reply.

## Constructor Details

### FTPClient

protected FTPClient()

### FTPClient

public FTPClient(String host, int port) throws IOException, ServerException
Constructs client and connects it to the remote server.

Parameters:
  `host` - remote server host
  `port` - remote server port
Throws:
  `IOException`
  `ServerException`

## Method Details

### getHost

public String getHost()

### getPort

public int getPort()

### getLastReply

public Reply getLastReply()
Returns the last reply received from the server. This could be used immediately after the call to the constructor to get the initial server reply

### getSize

public long getSize(String filename) throws IOException, ServerException
Returns the remote file size.

Parameters:
  `filename` - filename get the size for.
Returns:
  size of the file.
Throws:
  `ServerException` - if the file does not exist or an error occured.
  `IOException`

### getLastModified

public Date getLastModified(String filename) throws IOException, ServerException
Returns last modification time of the specifed file.

Parameters:
  `filename` - filename get the last modification time for.
Returns:
  the time and date of the last modification.
Throws:
  `ServerException` - if the file does not exist or an error occured.
  `IOException`

### exists

public boolean exists(String filename) throws IOException, ServerException
Checks if given file/directory exists on the server.

Parameters:
  `filename` - file or directory name
Returns:
  true if the file exists, false otherwise.
Throws:
  `IOException`
  `ServerException`

### changeDir

public void changeDir(String dir) throws IOException, ServerException
Changes the remote current working directory.

Throws:
  `IOException`
  `ServerException`

### deleteDir

public void deleteDir(String dir) throws IOException, ServerException
Deletes the remote directory.

Throws:
  `IOException`
  `ServerException`

### deleteFile

public void deleteFile(String filename) throws IOException, ServerException
Deletes the remote file.

Throws:
  `IOException`
  `ServerException`

### makeDir

public void makeDir(String dir) throws IOException, ServerException
Creates remote directory.

Throws:
  `IOException`
  `ServerException`

### rename

public void rename(String oldName, String newName) throws IOException, ServerException
Renames remote directory.

Throws:
  `IOException`
  `ServerException`

### getCurrentDir

public String getCurrentDir() throws IOException, ServerException
Returns remote current working directory.

Returns:
  remote current working directory.
Throws:
  `IOException`
  `ServerException`

### goUpDir

public void goUpDir() throws IOException, ServerException
Changes remote current working directory to the higher level.

Throws:
  `IOException`
  `ServerException`

### list

public Vector list() throws ServerException, ClientException, IOException
Performs remote directory listing. Sends 'LIST -d *' command.
Note: This function can only parse Unix ls -d like output. Please note that the LIST output is unspecified in the FTP standard and each server might return slightly different output causing the parsing to fail. Also, if the ftp server does not accept -d option or support wildcards, this method might fail. For example, this command will fail on GridFTP server distributed with GT 4.0.0. It is strongly recommended to use `mlsd()` function instead.

Returns:
  Vector list of `FileInfo` objects, representing remote files
Throws:
  `ServerException`
  `ClientException`
  `IOException`
See Also:
  - `mlsd()`

### list

public Vector list(String filter) throws ServerException, ClientException, IOException
Performs remote directory listing with the specified filter. Sends 'LIST -d <filter>' command.
Note: This function can only parse Unix ls -d like output. Please note that the LIST output is unspecified in the FTP standard and each server might return slightly different output causing the parsing to fail. Also, if the ftp server does not accept -d option or support wildcards, this method might fail. For example, this command will fail on GridFTP server distributed with GT 4.0.0. It is strongly recommended to use `mlsd()` function instead.

Parameters:
  `filter` - "*" for example, can be null.
Returns:
  Vector list of `FileInfo` objects, representing remote files
Throws:
  `ServerException`
  `ClientException`
  `IOException`
See Also:
  - `mlsd(String)`

### list

public Vector list(String filter, String modifier) throws ServerException, ClientException, IOException
Performs remote directory listing with the specified filter and modifier. Sends 'LIST <modifier> <filter>' command.
Note: This function can only parse Unix ls -d like output. Please note that the LIST output is unspecified in the FTP standard and each server might return slightly different output causing the parsing to fail. Also, please keep in mind that the ftp server might not recognize or support all the different modifiers or filters. In fact, some servers such as GridFTP server distributed with GT 4.0.0 does not support any modifiers or filters (strict RFC 959 compliance). It is strongly recommended to use `mlsd()` function instead.

Parameters:
  `filter` - "*" for example, can be null.
  `modifier` - "-d" for example, can be null.
Returns:
  Vector list of `FileInfo` objects, representing remote files
Throws:
  `ServerException`
  `ClientException`
  `IOException`
See Also:
  - `mlsd(String)`

### list

public void list(String filter, String modifier, DataSink sink) throws ServerException, ClientException, IOException
Performs directory listing and writes the result to the supplied data sink. This method is allowed in ASCII mode only.
Note: Please keep in mind that the ftp server might not recognize or support all the different modifiers or filters. In fact, some servers such as GridFTP server distributed with GT 4.0.0 does not support any modifiers or filters (strict RFC 959 compliance). It is strongly recommended to use `mlsd()` function instead.

Parameters:
  `filter` - remote list command file filter, eg. "*"
  `modifier` - remote list command modifier, eg. "-d"
  `sink` - data destination
Throws:
  `ServerException`
  `ClientException`
  `IOException`

### nlist

public Vector nlist() throws ServerException, ClientException, IOException
Performs remote directory listing of the current directory. Sends 'NLST' command.

Returns:
  Vector list of `FileInfo` objects, representing remote files
Throws:
  `ServerException`
  `ClientException`
  `IOException`

### nlist

public Vector nlist(String path) throws ServerException, ClientException, IOException
Performs remote directory listing on the given path. Sends 'NLST <path>' command.

Parameters:
  `path` - directory to perform listing of. If null, listing of current directory will be performed.
Returns:
  Vector list of `FileInfo` objects, representing remote files
Throws:
  `ServerException`
  `ClientException`
  `IOException`

### nlist

public void nlist(String path, DataSink sink) throws ServerException, ClientException, IOException
Performs remote directory listing on the given path. Sends 'NLST <path>' command.

Parameters:
  `path` - directory to perform listing of. If null, listing of current directory will be performed.
  `sink` - sink to which the listing data will be written.
Throws:
  `ServerException`
  `ClientException`
  `IOException`

### mlst

public MlsxEntry mlst(String fileName) throws IOException, ServerException
Get info of a certain remote file in Mlsx format.

Throws:
  `IOException`
  `ServerException`

### mlsd

public Vector mlsd() throws ServerException, ClientException, IOException
Performs remote directory listing of the current directory. Sends 'MLSD' command.

Returns:
  Vector list of `MlsxEntry` objects, representing remote files
Throws:
  `ServerException`
  `ClientException`
  `IOException`

### mlsd

public Vector mlsd(String path) throws ServerException, ClientException, IOException
Performs remote directory listing on the given path. Sends 'MLSD <path>' command.

Parameters:
  `path` - directory to perform listing of. If null, listing of current directory will be performed.
Returns:
  Vector list of `MlsxEntry` objects, representing remote files
Throws:
  `ServerException`
  `ClientException`
  `IOException`

### mlsd

public void mlsd(String path, DataSink sink) throws ServerException, ClientException, IOException
Performs remote directory listing on the given path. Sends 'MLSD <path>' command.

Parameters:
  `path` - directory to perform listing of. If null, listing of current directory will be performed.
  `sink` - sink to which the listing data will be written.
Throws:
  `ServerException`
  `ClientException`
  `IOException`

### listCheck

protected void listCheck() throws ClientException
check performed at the beginning of list()

Throws:
  `ClientException`

### checkTransferParamsGet

protected void checkTransferParamsGet() throws ServerException, IOException, ClientException

Throws:
  `ServerException`
  `IOException`
  `ClientException`

### checkTransferParamsPut

protected void checkTransferParamsPut() throws ServerException, IOException, ClientException

Throws:
  `ServerException`
  `IOException`
  `ClientException`

### checkTransferParams

protected void checkTransferParams() throws ServerException, IOException, ClientException

Throws:
  `ServerException`
  `IOException`
  `ClientException`

### performTransfer

protected void performTransfer(Command cmd, DataSink sink) throws ServerException, ClientException, IOException

Throws:
  `ServerException`
  `ClientException`
  `IOException`

### setType

public void setType(int type) throws IOException, ServerException
Sets transfer type.

Parameters:
  `type` - should be `TYPE_IMAGE`, `TYPE_ASCII`, `TYPE_LOCAL`, `TYPE_EBCDIC`
Throws:
  `IOException`
  `ServerException`

### getModeStr

protected String getModeStr(int mode)

### setMode

public void setMode(int mode) throws IOException, ServerException
Sets transfer mode.

Parameters:
  `mode` - should be `MODE_STREAM`, `MODE_BLOCK`
Throws:
  `IOException`
  `ServerException`

### actualSetMode

protected void actualSetMode(int mode, String modeStr) throws IOException, ServerException

Throws:
  `IOException`
  `ServerException`

### setProtectionBufferSize

public void setProtectionBufferSize(int size) throws IOException, ServerException
Sets protection buffer size (defined in RFC 2228)

Parameters:
  `size` - the size of buffer
Throws:
  `IOException`
  `ServerException`

### abort

public void abort() throws IOException, ServerException
Aborts the current transfer. FTPClient is not thread safe so be careful with using this procedure, which will typically happen in multi threaded environment. Especially during client-server two party transfer, calling abort() may result with exceptions being thrown in the thread that currently perform the transfer.

Throws:
  `IOException`
  `ServerException`

### close

public void close() throws IOException, ServerException
Closes connection. Sends QUIT command and closes connection even if the server reply was not positive. Also, closes the local server. This function will block until the server sends a reply to the QUIT command.

Throws:
  `IOException`
  `ServerException`

### close

public void close(boolean ignoreQuitReply) throws IOException, ServerException
Closes connection. Sends QUIT and closes connection even if the server reply was not positive. Also, closes the local server.

Parameters:
  `ignoreQuitReply` - if true the `QUIT` command will be sent but the client will not wait for the server's reply. If false, the client will block for the server's reply.
Throws:
  `IOException`
  `ServerException`

### isFeatureSupported

public boolean isFeatureSupported(String feature) throws IOException, ServerException
Returns true if the given feature is supported by remote server, false otherwise.

Returns:
  true if the given feature is supported by remote server, false otherwise.
Throws:
  `IOException`
  `ServerException`

### getFeatureList

public FeatureList getFeatureList() throws IOException, ServerException
Returns list of features supported by remote server.

Returns:
  list of features supported by remote server.
Throws:
  `IOException`
  `ServerException`

### setPassive

public HostPort setPassive() throws IOException, ServerException
Sets remote server to passive server mode.

Returns:
  the address at which the server is listening.
Throws:
  `IOException`
  `ServerException`

### setActive

public void setActive(HostPort hostPort) throws IOException, ServerException
Sets remote server active, telling it to connect to the given address.

Parameters:
  `hostPort` - the address to which the server should connect
Throws:
  `IOException`
  `ServerException`

### setActive

public void setActive() throws IOException, ServerException, ClientException
Sets remote server active, telling it to connect to the client. setLocalPassive() must be called beforehand.

Throws:
  `IOException`
  `ServerException`
  `ClientException`

### setLocalActive

public void setLocalActive() throws ClientException, IOException
Starts local server in active server mode.

Throws:
  `ClientException`
  `IOException`

### setLocalPassive

public HostPort setLocalPassive() throws IOException
Starts local server in passive server mode, with default parameters. In other words, behaves like setLocalPassive(FTPServerFacade.ANY_PORT, FTPServerFacade.DEFAULT_QUEUE)

Throws:
  `IOException`

### setLocalPassive

public HostPort setLocalPassive(int port, int queue) throws IOException
Starts the local server in passive server mode.

Parameters:
  `port` - port at which local server should be listening; can be set to FTPServerFacade.ANY_PORT
  `queue` - max size of queue of awaiting new connection requests
Returns:
  the server address
Throws:
  `IOException`

### setClientWaitParams

public void setClientWaitParams(int maxWait, int waitDelay)
Changes the default client timeout parameters. In the beginning of the transfer, the critical moment is the wait for the initial server reply. If it does not arrive after timeout, client assumes that the transfer could not start for some reason and aborts the operation. Default timeout in miliseconds is Session.DEFAULT_MAX_WAIT. During the waiting period, client polls the control channel once a certain period, which is by default set to Session.DEFAULT_WAIT_DELAY.
Use this method to change these parameters.

Parameters:
  `maxWait` - timeout in miliseconds
  `waitDelay` - polling period

### setOptions

public void setOptions(Options opts) throws IOException, ServerException
Sets the supplied options to the server.

Throws:
  `IOException`
  `ServerException`

### setRestartMarker

public void setRestartMarker(RestartData restartData) throws IOException, ServerException
Sets restart parameter of the next transfer.

Parameters:
  `restartData` - marker to use
Throws:
  `ServerException` - if the file does not exist or an error occured.
  `IOException`

### authorize

public void authorize(String user, String password) throws IOException, ServerException
Performs user authorization with specified user and password.

Parameters:
  `user` - username
  `password` - user password
Throws:
  `ServerException` - on server refusal
  `IOException`

### getUserName

public String getUserName()

### get

public void get(String remoteFileName, DataSink sink, MarkerListener mListener) throws IOException, ClientException, ServerException
Retrieves the file from the remote server.

Parameters:
  `remoteFileName` - remote file name
  `sink` - sink to which the data will be written
  `mListener` - restart marker listener (currently not used)
Throws:
  `IOException`
  `ClientException`
  `ServerException`

### asynchGet

public TransferState asynchGet(String remoteFileName, DataSink sink, MarkerListener mListener) throws IOException, ClientException, ServerException
Retrieves the file from the remote server.

Parameters:
  `remoteFileName` - remote file name
  `sink` - sink to which the data will be written
  `mListener` - restart marker listener (currently not used)
Throws:
  `IOException`
  `ClientException`
  `ServerException`

### put

public void put(String remoteFileName, DataSource source, MarkerListener mListener) throws IOException, ServerException, ClientException
Stores file at the remote server.

Parameters:
  `remoteFileName` - remote file name
  `source` - data will be read from here
  `mListener` - restart marker listener (currently not used)
Throws:
  `IOException`
  `ServerException`
  `ClientException`

### put

public void put(String remoteFileName, DataSource source, MarkerListener mListener, boolean append) throws IOException, ServerException, ClientException
Stores file at the remote server.

Parameters:
  `remoteFileName` - remote file name
  `source` - data will be read from here
  `mListener` - restart marker listener (currently not used)
  `append` - append to the end of file or overwrite
Throws:
  `IOException`
  `ServerException`
  `ClientException`

### asynchPut

public TransferState asynchPut(String remoteFileName, DataSource source, MarkerListener mListener) throws IOException, ServerException, ClientException
Stores file at the remote server.

Parameters:
  `remoteFileName` - remote file name
  `source` - data will be read from here
  `mListener` - restart marker listener (currently not used)
Throws:
  `IOException`
  `ServerException`
  `ClientException`

### asynchPut

public TransferState asynchPut(String remoteFileName, DataSource source, MarkerListener mListener, boolean append) throws IOException, ServerException, ClientException
Stores file at the remote server.

Parameters:
  `remoteFileName` - remote file name
  `source` - data will be read from here
  `mListener` - restart marker listener (currently not used)
  `append` - append to the end of file or overwrite
Throws:
  `IOException`
  `ServerException`
  `ClientException`

### transfer

public void transfer(String remoteSrcFile, FTPClient destination, String remoteDstFile, boolean append, MarkerListener mListener) throws IOException, ServerException, ClientException
Performs third-party transfer between two servers.

Parameters:
  `remoteSrcFile` - source filename
  `destination` - another client connected to destination server
  `remoteDstFile` - destination filename
  `append` - enables append mode; if true, data will be appened to the remote file, otherwise file will be overwritten.
  `mListener` - marker listener. Can be set to null.
Throws:
  `IOException`
  `ServerException`
  `ClientException`

### transferRun

protected void transferRun(BasicClientControlChannel other, MarkerListener mListener) throws IOException, ServerException, ClientException
Actual transfer management. Transfer is controlled by two new threads listening to the two servers.

Throws:
  `IOException`
  `ServerException`
  `ClientException`

### transferBegin

protected TransferState transferBegin(BasicClientControlChannel other, MarkerListener mListener)

### transferStart

protected TransferState transferStart(BasicClientControlChannel other, MarkerListener mListener) throws IOException, ServerException, ClientException

Throws:
  `IOException`
  `ServerException`
  `ClientException`

### transferWait

protected void transferWait(TransferState transferState) throws IOException, ServerException, ClientException

Throws:
  `IOException`
  `ServerException`
  `ClientException`

### transferRunSingleThread

protected void transferRunSingleThread(BasicClientControlChannel other, MarkerListener mListener) throws IOException, ServerException, ClientException

Throws:
  `IOException`
  `ServerException`
  `ClientException`

### quote

public Reply quote(String command) throws IOException, ServerException
Executes arbitrary operation on the server.
Note: This is potentially dangerous operation. Depending on the command executed it might put the server in a different state from the state the client is expecting.

Parameters:
  `command` - command to execute
Returns:
  the Reply to the operation.
Throws:
  `IOException` - in case of I/O error.
  `ServerException` - if operation failed.

### site

public Reply site(String args) throws IOException, ServerException
Executes site-specific operation (using the SITE command).
Note: This is potentially dangerous operation. Depending on the command executed it might put the server in a different state from the state the client is expecting.

Parameters:
  `args` - parameters for the SITE operation.
Returns:
  the Reply to the operation.
Throws:
  `IOException` - in case of I/O error
  `ServerException` - if operation failed.

### allocate

public void allocate(long size) throws IOException, ServerException
Reserve sufficient storage to accommodate the new file to be transferred.

Parameters:
  `size` - the amount of space to reserve
Throws:
  `ServerException` - if an error occured.
  `IOException`

### size

public long size(String filename) throws IOException, ServerException

Throws:
  `IOException`
  `ServerException`

### lastModified

public Date lastModified(String filename) throws IOException, ServerException

Throws:
  `IOException`
  `ServerException`

### get

public void get(String remoteFileName, File localFile) throws IOException, ClientException, ServerException

Throws:
  `IOException`
  `ClientException`
  `ServerException`

### put

public void put(File localFile, String remoteFileName, boolean append) throws IOException, ServerException, ClientException

Throws:
  `IOException`
  `ServerException`
  `ClientException`

### setPassiveMode

public void setPassiveMode(boolean passiveMode) throws IOException, ClientException, ServerException
Enables/disables passive data connections.

Parameters:
  `passiveMode` - if true passive connections will be established. If false, they will not.
Throws:
  `IOException`
  `ClientException`
  `ServerException`

### isPassiveMode

public boolean isPassiveMode()

### checkGETPUTSupport

protected void checkGETPUTSupport() throws ServerException, IOException
Throws ServerException if GFD.47 GETPUT is not supported or cannot be used.

Throws:
  `ServerException`
  `IOException`

### get127Reply

protected HostPort get127Reply() throws ServerException, IOException, FTPReplyParseException
Reads a GFD.47 compliant 127 reply and extracts the port information from it.

Throws:
  `ServerException`
  `IOException`
  `FTPReplyParseException`

### get2

public void get2(String remoteFileName, boolean passive, DataSink sink, MarkerListener mListener) throws IOException, ClientException, ServerException
Retrieves a file using the GFD.47 (a.k.a GridFTP2) GET command. Notice that as a side effect this method may change the local server facade passive/active mode setting. The caller should not rely on this setting after call to get2. Even though the active/passive status of the current session is ignored for the actual transfer, it still has to be in a consistent state prior to calling gridftp2Get.

Parameters:
  `remoteFileName` - file to retrieve
  `passive` - whether to configure the server to be passive
  `sink` - data sink to store the file
  `mListener` - marker listener
Throws:
  `IOException`
  `ClientException`
  `ServerException`

### asynchGet2

public TransferState asynchGet2(String remoteFileName, boolean passive, DataSink sink, MarkerListener mListener) throws IOException, ClientException, ServerException
Retrieves a file asynchronously using the GFD.47 (a.k.a GridFTP2) GET command. Notice that as a side effect this method may change the local server facade passive/active mode setting. The caller should not rely on this setting after call to gridftp2Get. Even though the active/passive status of the current session is ignored for the actual transfer, it still has to be in a consistent state prior to calling gridftp2Get.

Parameters:
  `remoteFileName` - file to retrieve
  `passive` - whether to configure the server to be passive
  `sink` - data sink to store the file
  `mListener` - marker listener
Throws:
  `IOException`
  `ClientException`
  `ServerException`

### put2

public void put2(String remoteFileName, boolean passive, DataSource source, MarkerListener mListener) throws IOException, ClientException, ServerException
Stores a file at the remote server using the GFD.47 (a.k.a GridFTP2) PUT command. Notice that as a side effect this method may change the local server facade passive/active mode setting. The caller should not rely on this setting after call to gridftp2Get. Even though the active/passive status of the current session is ignored for the actual transfer, it still has to be in a consistent state prior to calling gridftp2Get.

Parameters:
  `remoteFileName` - file to retrieve
  `passive` - whether to configure the server to be passive
  `source` - data will be read from here
  `mListener` - marker listener
Throws:
  `IOException`
  `ClientException`
  `ServerException`

### asynchPut2

public TransferState asynchPut2(String remoteFileName, boolean passive, DataSource source, MarkerListener mListener) throws IOException, ClientException, ServerException
Stores a file at the remote server using the GFD.47 (a.k.a GridFTP2) PUT command. Notice that as a side effect this method may change the local server facade passive/active mode setting. The caller should not rely on this setting after call to gridftp2Get. Even though the active/passive status of the current session is ignored for the actual transfer, it still has to be in a consistent state prior to calling gridftp2Get.

Parameters:
  `remoteFileName` - file to retrieve
  `passive` - whether to configure the server to be passive
  `source` - data will be read from here
  `mListener` - marker listener
Throws:
  `IOException`
  `ClientException`
  `ServerException`

### transfer

public static void transfer(FTPClient source, String remoteSrcFile, FTPClient destination, String remoteDstFile, int mode, MarkerListener mListener) throws IOException, ServerException, ClientException
Performs third-party transfer between two servers. If possibly, GFD.47 (a.k.a GridFTP2) GET and PUT commands are used.

Parameters:
  `source` - client connected to source server
  `remoteSrcFile` - source filename
  `destination` - client connected to destination server
  `remoteDstFile` - destination filename
  `mode` - data channel mode or 0 to use the current mode
  `mListener` - marker listener. Can be set to null.
Throws:
  `IOException`
  `ServerException`
  `ClientException`

### isActiveMode

public boolean isActiveMode()

### setUseAllo

public void setUseAllo(boolean useAllo)
Controls whether the client attempts to send an ALLO command before a STOR request during the put/asyncPut calls. This is disabled by default in the FTP client and enabled by default in the GridFTP client. This setting will apply to all subsequent transfers.

Parameters:
  `useAllo` - `true` if the client should try to send an ALLO command before a STOR request

### getUseAllo

public boolean getUseAllo()
Determines whether this client is configured to send an ALLO command before a STOR request in the put/asyncPut methods.

### getSupportedCksumAlgorithms

public List<String> getSupportedCksumAlgorithms() throws ClientException, ServerException, IOException
According to GridFTP v2 Protocol Description checksum feature has the following syntax:

     CKSUM <algorithm>[, …]

getSupportedCksumAlgorithms parses checsum feauture parms and form a list of checksum algorithms supported by the server

Returns:
  a list of checksum algorithms supported by the server in the order specified by the server
Throws:
  `ClientException`
  `ServerException`
  `IOException`

### isCksumAlgorithmSupported

public boolean isCksumAlgorithmSupported(String algorithm) throws ClientException, ServerException, IOException

Throws:
  `ClientException`
  `ServerException`
  `IOException`

### getChecksum

public String getChecksum(String algorithm, long offset, long length, String path) throws ClientException, ServerException, IOException
implement GridFTP v2 CKSM command from GridFTP v2 Protocol Description

     5.1 CKSM
     This command is used by the client to request checksum calculation over a portion or
     whole file existing on the server. The syntax is:
     CKSM <algorithm> <offset> <length> <path> CRLF
     Server executes this command by calculating specified type of checksum over
     portion of the file starting at the offset and of the specified length. If length is –1,
     the checksum will be calculated through the end of the file. On success, the server
     replies with
     2xx <checksum value>
     Actual format of checksum value depends on the algorithm used, but generally,
     hexadecimal representation should be used.

Parameters:
  `algorithm` - ckeckum alorithm
  `offset` -
  `length` -
  `path` -
Returns:
  ckecksum value returned by the server
Throws:
  `ClientException`
  `ServerException`
  `IOException`

### getChecksum

public String getChecksum(String algorithm, String path) throws ClientException, ServerException, IOException
GridFTP v2 CKSM command for the whole file

Parameters:
  `algorithm` - ckeckum alorithm
  `path` -
Returns:
  ckecksum value returned by the server
Throws:
  `ClientException`
  `ServerException`
  `IOException`

### setChecksum

public void setChecksum(String algorithm, String value) throws ClientException, ServerException, IOException
implement GridFTP v2 SCKS command as described in GridFTP v2 Protocol Description

     5.2 SCKS
     This command is sent prior to upload command such as STOR, ESTO, PUT. It is used
     to convey to the server that the checksum value for the file which is about to be
     uploaded. At the end of transfer, server will calculate checksum for the received file,
     and if it does not match, will consider the transfer to have failed. Syntax of the
     command is:
     SCKS <algorithm> <value> CRLF
     Actual format of checksum value depends on the algorithm used, but generally,
     hexadecimal representation should be used.

Parameters:
  `algorithm` -
  `value` -
Throws:
  `ClientException`
  `ServerException`
  `IOException`