Package org.globus.ftp
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.-
Field Summary
FieldsModifier and TypeFieldDescriptionList of the checksum algorithms supported by the server as described in GridFTP v2 Protocol Descriptionprotected FTPControlChannel
protected SimpleDateFormat
protected FTPServerFacade
static final Pattern
Regular expression for matching the port information of a GFD.47 127 reply.protected Session
protected boolean
Whether to use ALLO with put()/asyncPut() or notprotected String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.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.void
Performs user authorization with specified user and password.void
Changes the remote current working directory.protected void
Throws ServerException if GFD.47 GETPUT is not supported or cannot be used.protected void
protected void
protected void
void
close()
Closes connection.void
close
(boolean ignoreQuitReply) Closes connection.void
Deletes the remote directory.void
deleteFile
(String filename) Deletes the remote file.boolean
Checks if given file/directory exists on the server.void
void
get
(String remoteFileName, DataSink sink, MarkerListener mListener) Retrieves the file from the remote server.protected HostPort
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.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 String
getModeStr
(int mode) int
getPort()
long
Returns the remote file size.According to GridFTP v2 Protocol Description checksum feature has the following syntax:boolean
Determines whether this client is configured to send an ALLO command before a STOR request in the put/asyncPut methods.void
goUpDir()
Changes remote current working directory to the higher level.boolean
boolean
isCksumAlgorithmSupported
(String algorithm) boolean
isFeatureSupported
(String feature) Returns true if the given feature is supported by remote server, false otherwise.boolean
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.void
Performs directory listing and writes the result to the supplied data sink.protected void
check performed at the beginning of list()void
Creates remote directory.mlsd()
Performs remote directory listing of the current directory.Performs remote directory listing on the given path.void
Performs 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.void
Performs remote directory listing on the given path.protected void
performTransfer
(Command cmd, DataSink sink) void
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.Executes arbitrary operation on the server.void
Renames remote directory.void
Sets remote server active, telling it to connect to the client.void
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 Descriptionvoid
setClientWaitParams
(int maxWait, int waitDelay) Changes the default client timeout parameters.void
Starts 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.void
setMode
(int mode) Sets transfer mode.void
setOptions
(Options opts) Sets the supplied options to the server.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.Executes site-specific operation (using the SITE command).long
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)
-
Field Details
-
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:
IOException
ServerException
-
-
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:
IOException
ServerException
-
changeDir
Changes the remote current working directory.- Throws:
IOException
ServerException
-
deleteDir
Deletes the remote directory.- Throws:
IOException
ServerException
-
deleteFile
Deletes the remote file.- Throws:
IOException
ServerException
-
makeDir
Creates remote directory.- Throws:
IOException
ServerException
-
rename
Renames remote directory.- Throws:
IOException
ServerException
-
getCurrentDir
Returns remote current working directory.- Returns:
- remote current working directory.
- Throws:
IOException
ServerException
-
goUpDir
Changes remote current working directory to the higher level.- Throws:
IOException
ServerException
-
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
FileInfo
objects, representing remote files - Throws:
ServerException
ClientException
IOException
- 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
FileInfo
objects, representing remote files - Throws:
ServerException
ClientException
IOException
- 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
FileInfo
objects, representing remote files - Throws:
ServerException
ClientException
IOException
- 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:
ServerException
ClientException
IOException
-
nlist
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
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
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
Get info of a certain remote file in Mlsx format.- Throws:
IOException
ServerException
-
mlsd
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
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
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
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:
IOException
ServerException
-
getModeStr
-
setMode
Sets transfer mode.- Parameters:
mode
- should beMODE_STREAM
,MODE_BLOCK
- Throws:
IOException
ServerException
-
actualSetMode
- Throws:
IOException
ServerException
-
setProtectionBufferSize
Sets protection buffer size (defined in RFC 2228)- Parameters:
size
- the size of buffer- Throws:
IOException
ServerException
-
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:
IOException
ServerException
-
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:
IOException
ServerException
-
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 theQUIT
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
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
Returns list of features supported by remote server.- Returns:
- list of features supported by remote server.
- Throws:
IOException
ServerException
-
setPassive
Sets remote server to passive server mode.- Returns:
- the address at which the server is listening.
- Throws:
IOException
ServerException
-
setActive
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
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:
ClientException
IOException
-
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:
IOException
ServerException
-
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:
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 namesink
- sink to which the data will be writtenmListener
- 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 namesource
- data will be read from heremListener
- 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 namesource
- data will be read from heremListener
- 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 namesource
- data will be read from heremListener
- 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 namesource
- data will be read from heremListener
- 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 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:
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. -
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.
-
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:
IOException
ServerException
-
lastModified
- Throws:
IOException
ServerException
-
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:
IOException
ClientException
ServerException
-
isPassiveMode
public boolean isPassiveMode() -
checkGETPUTSupport
Throws ServerException if GFD.47 GETPUT is not supported or cannot be used.- Throws:
ServerException
IOException
-
get127Reply
Reads a GFD.47 compliant 127 reply and extracts the port information from it. -
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:
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 retrievepassive
- whether to configure the server to be passivesink
- data sink to store the filemListener
- 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 retrievepassive
- whether to configure the server to be passivesource
- data will be read from heremListener
- 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 retrievepassive
- whether to configure the server to be passivesource
- data will be read from heremListener
- 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 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:
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, 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:
ClientException
ServerException
IOException
-
isCksumAlgorithmSupported
public boolean isCksumAlgorithmSupported(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:
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 alorithmpath
-- 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 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:
ClientException
ServerException
IOException
-