Class FTPClient
java.lang.Object
org.globus.ftp.FTPClient
- Direct Known Subclasses:
GridFTPClient
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
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.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionList of the checksum algorithms supported by the server as described in GridFTP v2 Protocol Descriptionprotected FTPControlChannelprotected SimpleDateFormatprotected FTPServerFacadeprivate static org.apache.commons.logging.Logstatic final PatternRegular expression for matching the port information of a GFD.47 127 reply.protected Sessionprotected booleanWhether to use ALLO with put()/asyncPut() or notprotected String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Aborts the current transfer.protected voidactualSetMode(int mode, String modeStr) voidallocate(long size) Reserve sufficient storage to accommodate the new file to be transferred.asynchGet(String remoteFileName, DataSink sink, MarkerListener mListener) Retrieves the file from the remote server.asynchGet2(String remoteFileName, boolean passive, DataSink sink, MarkerListener mListener) Retrieves a file asynchronously using the GFD.47 (a.k.a GridFTP2) GET command.asynchPut(String remoteFileName, DataSource source, MarkerListener mListener) Stores file at the remote server.asynchPut(String remoteFileName, DataSource source, MarkerListener mListener, boolean append) Stores file at the remote server.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.voidPerforms user authorization with specified user and password.voidChanges the remote current working directory.private voidcheckCksumSupport(String algorithm) protected voidThrows ServerException if GFD.47 GETPUT is not supported or cannot be used.protected voidprotected voidprotected voidvoidclose()Closes connection.voidclose(boolean ignoreQuitReply) Closes connection.voidDeletes the remote directory.voiddeleteFile(String filename) Deletes the remote file.private ReplybooleanChecks if given file/directory exists on the server.voidvoidget(String remoteFileName, DataSink sink, MarkerListener mListener) Retrieves the file from the remote server.protected HostPortReads a GFD.47 compliant 127 reply and extracts the port information from it.voidget2(String remoteFileName, boolean passive, DataSink sink, MarkerListener mListener) Retrieves a file using the GFD.47 (a.k.a GridFTP2) GET command.getChecksum(String algorithm, long offset, long length, String path) implement GridFTP v2 CKSM command from GridFTP v2 Protocol DescriptiongetChecksum(String algorithm, String path) GridFTP v2 CKSM command for the whole fileReturns remote current working directory.Returns list of features supported by remote server.getHost()getLastModified(String filename) Returns last modification time of the specifed file.Returns the last reply received from the server.protected StringgetModeStr(int mode) intgetPort()longReturns the remote file size.According to GridFTP v2 Protocol Description checksum feature has the following syntax:booleanDetermines whether this client is configured to send an ALLO command before a STOR request in the put/asyncPut methods.voidgoUpDir()Changes remote current working directory to the higher level.booleanbooleanisCksumAlgorithmSupported(String algorithm) booleanisFeatureSupported(String feature) Returns true if the given feature is supported by remote server, false otherwise.booleanprivate voidissueGETPUT(String command, boolean passive, HostPort port, int mode, String path) Writes a GFD.47 compliant GET or PUT command to the control channel.lastModified(String filename) list()Performs remote directory listing.Performs remote directory listing with the specified filter.Performs remote directory listing with the specified filter and modifier.voidPerforms directory listing and writes the result to the supplied data sink.protected voidcheck performed at the beginning of list()voidCreates remote directory.mlsd()Performs remote directory listing of the current directory.Performs remote directory listing on the given path.voidPerforms remote directory listing on the given path.Get info of a certain remote file in Mlsx format.nlist()Performs remote directory listing of the current directory.Performs remote directory listing on the given path.voidPerforms remote directory listing on the given path.protected voidperformTransfer(Command cmd, DataSink sink) voidvoidput(String remoteFileName, DataSource source, MarkerListener mListener) Stores file at the remote server.voidput(String remoteFileName, DataSource source, MarkerListener mListener, boolean append) Stores file at the remote server.voidput2(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.Executes arbitrary operation on the server.voidRenames remote directory.voidSets remote server active, telling it to connect to the client.voidSets remote server active, telling it to connect to the given address.voidsetChecksum(String algorithm, String value) implement GridFTP v2 SCKS command as described in GridFTP v2 Protocol DescriptionvoidsetClientWaitParams(int maxWait, int waitDelay) Changes the default client timeout parameters.voidStarts local server in active server mode.Starts local server in passive server mode, with default parameters.setLocalPassive(int port, int queue) Starts the local server in passive server mode.voidsetMode(int mode) Sets transfer mode.voidsetOptions(Options opts) Sets the supplied options to the server.Sets remote server to passive server mode.voidsetPassiveMode(boolean passiveMode) Enables/disables passive data connections.voidsetProtectionBufferSize(int size) Sets protection buffer size (defined in RFC 2228)voidsetRestartMarker(RestartData restartData) Sets restart parameter of the next transfer.voidsetType(int type) Sets transfer type.voidsetUseAllo(boolean useAllo) Controls whether the client attempts to send an ALLO command before a STOR request during the put/asyncPut calls.Executes site-specific operation (using the SITE command).longvoidtransfer(String remoteSrcFile, FTPClient destination, String remoteDstFile, boolean append, MarkerListener mListener) Performs third-party transfer between two servers.static voidtransfer(FTPClient source, String remoteSrcFile, FTPClient destination, String remoteDstFile, int mode, MarkerListener mListener) Performs third-party transfer between two servers.protected TransferStatetransferBegin(BasicClientControlChannel other, MarkerListener mListener) protected voidtransferRun(BasicClientControlChannel other, MarkerListener mListener) Actual transfer management.protected voidtransferRunSingleThread(BasicClientControlChannel other, MarkerListener mListener) protected TransferStatetransferStart(BasicClientControlChannel other, MarkerListener mListener) protected voidtransferWait(TransferState transferState)
-
Field Details
-
logger
private static org.apache.commons.logging.Log logger -
session
-
controlChannel
-
localServer
-
dateFormat
-
username
-
useAllo
protected boolean useAlloWhether to use ALLO with put()/asyncPut() or not -
algorithms
List of the checksum algorithms supported by the server as described in GridFTP v2 Protocol Description -
portPattern
Regular expression for matching the port information of a GFD.47 127 reply.
-
-
Constructor Details
-
FTPClient
protected FTPClient() -
FTPClient
Constructs client and connects it to the remote server.- Parameters:
host- remote server hostport- remote server port- Throws:
IOExceptionServerException
-
-
Method Details
-
getHost
-
getPort
public int getPort() -
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
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
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
Checks if given file/directory exists on the server.- Parameters:
filename- file or directory name- Returns:
- true if the file exists, false otherwise.
- Throws:
IOExceptionServerException
-
changeDir
Changes the remote current working directory.- Throws:
IOExceptionServerException
-
deleteDir
Deletes the remote directory.- Throws:
IOExceptionServerException
-
deleteFile
Deletes the remote file.- Throws:
IOExceptionServerException
-
makeDir
Creates remote directory.- Throws:
IOExceptionServerException
-
rename
Renames remote directory.- Throws:
IOExceptionServerException
-
getCurrentDir
Returns remote current working directory.- Returns:
- remote current working directory.
- Throws:
IOExceptionServerException
-
goUpDir
Changes remote current working directory to the higher level.- Throws:
IOExceptionServerException
-
list
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 usemlsd()function instead.- Returns:
- Vector list of
FileInfoobjects, representing remote files - Throws:
ServerExceptionClientExceptionIOException- See Also:
-
list
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 usemlsd()function instead.- Parameters:
filter- "*" for example, can be null.- Returns:
- Vector list of
FileInfoobjects, representing remote files - Throws:
ServerExceptionClientExceptionIOException- See Also:
-
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 usemlsd()function instead.- Parameters:
filter- "*" for example, can be null.modifier- "-d" for example, can be null.- Returns:
- Vector list of
FileInfoobjects, representing remote files - Throws:
ServerExceptionClientExceptionIOException- See Also:
-
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 usemlsd()function instead.- Parameters:
filter- remote list command file filter, eg. "*"modifier- remote list command modifier, eg. "-d"sink- data destination- Throws:
ServerExceptionClientExceptionIOException
-
nlist
Performs remote directory listing of the current directory. Sends 'NLST' command.- Returns:
- Vector list of
FileInfoobjects, representing remote files - Throws:
ServerExceptionClientExceptionIOException
-
nlist
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
FileInfoobjects, representing remote files - Throws:
ServerExceptionClientExceptionIOException
-
nlist
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:
ServerExceptionClientExceptionIOException
-
mlst
Get info of a certain remote file in Mlsx format.- Throws:
IOExceptionServerException
-
mlsd
Performs remote directory listing of the current directory. Sends 'MLSD' command.- Returns:
- Vector list of
MlsxEntryobjects, representing remote files - Throws:
ServerExceptionClientExceptionIOException
-
mlsd
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
MlsxEntryobjects, representing remote files - Throws:
ServerExceptionClientExceptionIOException
-
mlsd
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:
ServerExceptionClientExceptionIOException
-
listCheck
check performed at the beginning of list()- Throws:
ClientException
-
checkTransferParamsGet
-
checkTransferParamsPut
-
checkTransferParams
-
performTransfer
protected void performTransfer(Command cmd, DataSink sink) throws ServerException, ClientException, IOException -
setType
Sets transfer type.- Parameters:
type- should beTYPE_IMAGE,TYPE_ASCII,TYPE_LOCAL,TYPE_EBCDIC- Throws:
IOExceptionServerException
-
getModeStr
-
setMode
Sets transfer mode.- Parameters:
mode- should beMODE_STREAM,MODE_BLOCK- Throws:
IOExceptionServerException
-
actualSetMode
- Throws:
IOExceptionServerException
-
setProtectionBufferSize
Sets protection buffer size (defined in RFC 2228)- Parameters:
size- the size of buffer- Throws:
IOExceptionServerException
-
abort
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:
IOExceptionServerException
-
close
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:
IOExceptionServerException
-
close
Closes connection. Sends QUIT and closes connection even if the server reply was not positive. Also, closes the local server.- Parameters:
ignoreQuitReply- if true theQUITcommand 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:
IOExceptionServerException
-
isFeatureSupported
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:
IOExceptionServerException
-
getFeatureList
Returns list of features supported by remote server.- Returns:
- list of features supported by remote server.
- Throws:
IOExceptionServerException
-
setPassive
Sets remote server to passive server mode.- Returns:
- the address at which the server is listening.
- Throws:
IOExceptionServerException
-
setActive
Sets remote server active, telling it to connect to the given address.- Parameters:
hostPort- the address to which the server should connect- Throws:
IOExceptionServerException
-
setActive
Sets remote server active, telling it to connect to the client. setLocalPassive() must be called beforehand. -
setLocalActive
Starts local server in active server mode.- Throws:
ClientExceptionIOException
-
setLocalPassive
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
Starts the local server in passive server mode.- Parameters:
port- port at which local server should be listening; can be set to FTPServerFacade.ANY_PORTqueue- 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 milisecondswaitDelay- polling period
-
setOptions
Sets the supplied options to the server.- Throws:
IOExceptionServerException
-
setRestartMarker
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
Performs user authorization with specified user and password.- Parameters:
user- usernamepassword- user password- Throws:
ServerException- on server refusalIOException
-
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 namesink- sink to which the data will be writtenmListener- restart marker listener (currently not used)- Throws:
IOExceptionClientExceptionServerException
-
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 namesink- sink to which the data will be writtenmListener- restart marker listener (currently not used)- Throws:
IOExceptionClientExceptionServerException
-
put
public void put(String remoteFileName, DataSource source, MarkerListener mListener) throws IOException, ServerException, ClientException Stores file at the remote server.- Parameters:
remoteFileName- remote file namesource- data will be read from heremListener- restart marker listener (currently not used)- Throws:
IOExceptionServerExceptionClientException
-
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 namesource- data will be read from heremListener- restart marker listener (currently not used)append- append to the end of file or overwrite- Throws:
IOExceptionServerExceptionClientException
-
asynchPut
public TransferState asynchPut(String remoteFileName, DataSource source, MarkerListener mListener) throws IOException, ServerException, ClientException Stores file at the remote server.- Parameters:
remoteFileName- remote file namesource- data will be read from heremListener- restart marker listener (currently not used)- Throws:
IOExceptionServerExceptionClientException
-
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 namesource- data will be read from heremListener- restart marker listener (currently not used)append- append to the end of file or overwrite- Throws:
IOExceptionServerExceptionClientException
-
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 filenamedestination- another client connected to destination serverremoteDstFile- destination filenameappend- 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:
IOExceptionServerExceptionClientException
-
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. -
transferBegin
-
transferStart
protected TransferState transferStart(BasicClientControlChannel other, MarkerListener mListener) throws IOException, ServerException, ClientException -
transferWait
protected void transferWait(TransferState transferState) throws IOException, ServerException, ClientException -
transferRunSingleThread
protected void transferRunSingleThread(BasicClientControlChannel other, MarkerListener mListener) throws IOException, ServerException, ClientException -
quote
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
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 errorServerException- if operation failed.
-
doCommand
- Throws:
IOExceptionServerException
-
allocate
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
- Throws:
IOExceptionServerException
-
lastModified
- Throws:
IOExceptionServerException
-
get
public void get(String remoteFileName, File localFile) throws IOException, ClientException, ServerException -
put
public void put(File localFile, String remoteFileName, boolean append) 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:
IOExceptionClientExceptionServerException
-
isPassiveMode
public boolean isPassiveMode() -
checkGETPUTSupport
Throws ServerException if GFD.47 GETPUT is not supported or cannot be used.- Throws:
ServerExceptionIOException
-
get127Reply
Reads a GFD.47 compliant 127 reply and extracts the port information from it. -
issueGETPUT
private void issueGETPUT(String command, boolean passive, HostPort port, int mode, String path) throws IOException Writes a GFD.47 compliant GET or PUT command to the control channel.- Parameters:
command- Either "GET" or "PUT", depending on the command to issuepassive- True if the "pasv" parameter should be usedport- If passive is false, this is the port for the "port" parametermode- The value for the "mode" parameter, or 0 if the parameter should not be specifiedpath- The value for the "path" parameter- Throws:
IOException
-
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 retrievepassive- whether to configure the server to be passivesink- data sink to store the filemListener- marker listener- Throws:
IOExceptionClientExceptionServerException
-
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 retrievepassive- whether to configure the server to be passivesink- data sink to store the filemListener- marker listener- Throws:
IOExceptionClientExceptionServerException
-
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 retrievepassive- whether to configure the server to be passivesource- data will be read from heremListener- marker listener- Throws:
IOExceptionClientExceptionServerException
-
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 retrievepassive- whether to configure the server to be passivesource- data will be read from heremListener- marker listener- Throws:
IOExceptionClientExceptionServerException
-
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 serverremoteSrcFile- source filenamedestination- client connected to destination serverremoteDstFile- destination filenamemode- data channel mode or 0 to use the current modemListener- marker listener. Can be set to null.- Throws:
IOExceptionServerExceptionClientException
-
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-trueif 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, IOExceptionAccording 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:
ClientExceptionServerExceptionIOException
-
isCksumAlgorithmSupported
public boolean isCksumAlgorithmSupported(String algorithm) throws ClientException, ServerException, IOException -
checkCksumSupport
private void checkCksumSupport(String algorithm) 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 Description5.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 alorithmoffset-length-path-- Returns:
- ckecksum value returned by the server
- Throws:
ClientExceptionServerExceptionIOException
-
getChecksum
public String getChecksum(String algorithm, String path) throws ClientException, ServerException, IOException GridFTP v2 CKSM command for the whole file- Parameters:
algorithm- ckeckum alorithmpath-- Returns:
- ckecksum value returned by the server
- Throws:
ClientExceptionServerExceptionIOException
-
setChecksum
public void setChecksum(String algorithm, String value) throws ClientException, ServerException, IOException implement GridFTP v2 SCKS command as described in GridFTP v2 Protocol Description5.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:
ClientExceptionServerExceptionIOException
-