Package org.globus.io.urlcopy

# Class UrlCopy

java.lang.Object
org.globus.io.urlcopy.UrlCopy

All Implemented Interfaces:
  `Runnable`

public class UrlCopy extends Object implements Runnable

## Field Summary

Fields
Modifier and Type
Field
Description
`protected boolean`
`appendMode`
`static final int`
`BUFF_SIZE`
maximum buffer size to read or write when putting and getting files
`protected int`
`bufferSize`
`protected boolean`
`canceled`
`protected boolean`
`dcau`
`protected long`
`destinationOffset`
`protected boolean`
`disableAllo`
`protected Authorization`
`dstAuth`
`protected GSSCredential`
`dstCreds`
`protected GlobusURL`
`dstUrl`
`protected List`
`listeners`
`protected long`
`sourceLength`
`protected long`
`sourceOffset`
`protected Authorization`
`srcAuth`
`protected GSSCredential`
`srcCreds`
`protected GlobusURL`
`srcUrl`
`protected int`
`tcpBufferSize`
`protected boolean`
`thirdParty`

## Constructor Summary

Constructors
Constructor
Description
`UrlCopy()`

## Method Summary

Modifier and Type
Method
Description
`void`
`addUrlCopyListener(UrlCopyListener listener)`
Adds url copy listener.
`void`
`cancel()`
Cancels the transfer in progress.
`void`
`copy()`
Performs the copy function.
`int`
`getBufferSize()`
Returns buffer size used for transfering data.
`boolean`
`getDCAU()`
`Authorization`
`getDestinationAuthorization()`
Returns authorization type for the destination side for the url copy.
`GSSCredential`
`getDestinationCredentials()`
Returns credentials used for authenticating the destination side for the url copy.
`long`
`getDestinationOffset()`
Gets the offset in the destination file from which data starts to be written
`GlobusURL`
`getDestinationUrl()`
Returns destination url.
`boolean`
`getDisableAllo()`
Can be used to query whether the use of the ALLO command with GridFTP uploads is disabled.
`protected GlobusInputStream`
`getInputStream()`
Returns input stream based on the source url
`protected GlobusOutputStream`
`getOutputStream(long size)`
Returns output stream based on the destination url.
`Authorization`
`getSourceAuthorization()`
Returns authorization type for the source side for the url copy.
`GSSCredential`
`getSourceCredentials()`
Returns credentials used for authenticating the source side for the url copy.
`long`
`getSourceLength()`
Gets the maximum data size that will be transfered.
`long`
`getSourceOffset()`
Gets the offset in the source file from which data starts to be read
`GlobusURL`
`getSourceUrl()`
Returns source url.
`int`
`getTCPBufferSize()`
Returns TCP buffer size used for transfers data.
`boolean`
`isAppendMode()`
Checks if append mode is enabled.
`boolean`
`isCanceled()`
Checks if the transfer was canceled.
`protected void`
`negotiateDCAU(FTPClient src, FTPClient dst)`
`void`
`removeUrlCopyListener(UrlCopyListener listener)`
Remove url copy listener
`void`
`run()`
This method is an implementation of the `Runnable` interface and can be used to perform the copy in a separate thread.
`void`
`setAppendMode(boolean appendMode)`
Enables/disables append mode.
`void`
`setBufferSize(int size)`
Sets buffer size for transfering data.
`void`
`setCredentials(GSSCredential credentials)`
Sets credentials to use for both sides.
`void`
`setDCAU(boolean dcau)`
`void`
`setDestinationAuthorization(Authorization auth)`
Sets destination authorization type
`void`
`setDestinationCredentials(GSSCredential dstCredentials)`
Sets destination url credentials.
`void`
`setDestinationOffset(long destinationOffset)`
Sets the offset in the destination file from which data starts to be written.
`void`
`setDestinationUrl(GlobusURL dest)`
Sets destination url.
`void`
`setDisableAllo(boolean disableAllo)`
Allows disabling of the use of ALLO with GridFTP uploads
`void`
`setSourceAuthorization(Authorization auth)`
Sets source authorization type
`void`
`setSourceCredentials(GSSCredential srcCredentials)`
Sets source url credentials.
`void`
`setSourceFileLength(long sourceLength)`
Allows a partial transfer by setting the maximum number of bytes that will be transfered.
`void`
`setSourceFileOffset(long sourceOffset)`
Sets the offset in the source file from which data starts to be read.
`void`
`setSourceUrl(GlobusURL source)`
Sets source url.
`void`
`setTCPBufferSize(int size)`
Sets the TCP buffer size for GridFTP transfers.
`void`
`setUseThirdPartyCopy(boolean thirdParty)`
Enables/disables usage of third party transfers.

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

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

## Field Details

### BUFF_SIZE

public static final int BUFF_SIZE
maximum buffer size to read or write when putting and getting files

See Also:
  - Constant Field Values

### bufferSize

protected int bufferSize

### srcCreds

protected GSSCredential srcCreds

### srcAuth

protected Authorization srcAuth

### dstCreds

protected GSSCredential dstCreds

### dstAuth

protected Authorization dstAuth

### dcau

protected boolean dcau

### appendMode

protected boolean appendMode

### srcUrl

protected GlobusURL srcUrl

### dstUrl

protected GlobusURL dstUrl

### canceled

protected boolean canceled

### thirdParty

protected boolean thirdParty

### listeners

protected List listeners

### sourceOffset

protected long sourceOffset

### destinationOffset

protected long destinationOffset

### sourceLength

protected long sourceLength

### tcpBufferSize

protected int tcpBufferSize

### disableAllo

protected boolean disableAllo

## Constructor Details

### UrlCopy

public UrlCopy()

## Method Details

### setDCAU

public void setDCAU(boolean dcau)

### getDCAU

public boolean getDCAU()

### setCredentials

public void setCredentials(GSSCredential credentials)
Sets credentials to use for both sides.

Parameters:
  `credentials` - user credentials

### setSourceCredentials

public void setSourceCredentials(GSSCredential srcCredentials)
Sets source url credentials.

Parameters:
  `srcCredentials` - source url credentials.

### setDestinationCredentials

public void setDestinationCredentials(GSSCredential dstCredentials)
Sets destination url credentials.

Parameters:
  `dstCredentials` - destination url credentials.

### setSourceAuthorization

public void setSourceAuthorization(Authorization auth)
Sets source authorization type

Parameters:
  `auth` - authorization type to perform for source

### setDestinationAuthorization

public void setDestinationAuthorization(Authorization auth)
Sets destination authorization type

Parameters:
  `auth` - authorization type to perform for destination

### getSourceCredentials

public GSSCredential getSourceCredentials()
Returns credentials used for authenticating the source side for the url copy. If no source credentials are set, the default user credentials will used.

Returns:
  source credentials.

### getDestinationCredentials

public GSSCredential getDestinationCredentials()
Returns credentials used for authenticating the destination side for the url copy. If no destination credentials are set, the default user credentials will used.

Returns:
  destination credentials.

### getSourceAuthorization

public Authorization getSourceAuthorization()
Returns authorization type for the source side for the url copy. If no authorization type is set, the default authorization will be performed for a given protocol.

Returns:
  source authorization type

### getDestinationAuthorization

public Authorization getDestinationAuthorization()
Returns authorization type for the destination side for the url copy. If no authorization type is set, the default authorization will be performed for a given protocol.

Returns:
  destination authorization type

### addUrlCopyListener

public void addUrlCopyListener(UrlCopyListener listener)
Adds url copy listener.

Parameters:
  `listener` - url copy listener

### removeUrlCopyListener

public void removeUrlCopyListener(UrlCopyListener listener)
Remove url copy listener

Parameters:
  `listener` - url copy listener

### setBufferSize

public void setBufferSize(int size)
Sets buffer size for transfering data. It does not set the TCP buffers.

Parameters:
  `size` - size of the data buffer

### getBufferSize

public int getBufferSize()
Returns buffer size used for transfering data.

Returns:
  data buffer size

### setTCPBufferSize

public void setTCPBufferSize(int size)
Sets the TCP buffer size for GridFTP transfers.

Parameters:
  `size` - size of TCP buffer

### getTCPBufferSize

public int getTCPBufferSize()
Returns TCP buffer size used for transfers data.

Returns:
  TCP buffer size

### setAppendMode

public void setAppendMode(boolean appendMode)
Enables/disables append mode.

Parameters:
  `appendMode` - if true, destination file will be appended.

### isAppendMode

public boolean isAppendMode()
Checks if append mode is enabled.

Returns:
  true if appending will be performed, false otherwise.

### getDestinationOffset

public long getDestinationOffset()
Gets the offset in the destination file from which data starts to be written

Returns:
  a value indicating the offset in bytes

### setDestinationOffset

public void setDestinationOffset(long destinationOffset)
Sets the offset in the destination file from which data starts to be written. The default offset is 0 (the beginning of the file)

Parameters:
  `destinationOffset` - the offset in bytes

### getSourceLength

public long getSourceLength()
Gets the maximum data size that will be transfered.

Returns:
  the size in bytes

### setSourceFileLength

public void setSourceFileLength(long sourceLength)
Allows a partial transfer by setting the maximum number of bytes that will be transfered. By default the entire source file is transfered.

Parameters:
  `sourceLength` - the size of the transfer in bytes

### getSourceOffset

public long getSourceOffset()
Gets the offset in the source file from which data starts to be read

Returns:
  a value indicating the offset in bytes

### setSourceFileOffset

public void setSourceFileOffset(long sourceOffset)
Sets the offset in the source file from which data starts to be read. The default offset is 0 (the beginning of the file)

Parameters:
  `sourceOffset` - the offset in bytes

### setSourceUrl

public void setSourceUrl(GlobusURL source) throws UrlCopyException
Sets source url.

Parameters:
  `source` - source url.
Throws:
  `UrlCopyException`

### getSourceUrl

public GlobusURL getSourceUrl()
Returns source url.

Returns:
  url

### setDestinationUrl

public void setDestinationUrl(GlobusURL dest) throws UrlCopyException
Sets destination url.

Parameters:
  `dest` - destination url
Throws:
  `UrlCopyException`

### getDestinationUrl

public GlobusURL getDestinationUrl()
Returns destination url.

Returns:
  url

### setUseThirdPartyCopy

public void setUseThirdPartyCopy(boolean thirdParty)
Enables/disables usage of third party transfers.

Parameters:
  `thirdParty` - if true enable, false disable

### getDisableAllo

public boolean getDisableAllo()
Can be used to query whether the use of the ALLO command with GridFTP uploads is disabled.

### setDisableAllo

public void setDisableAllo(boolean disableAllo)
Allows disabling of the use of ALLO with GridFTP uploads

### cancel

public void cancel()
Cancels the transfer in progress. If no transfer is in progress it is ignored.

### isCanceled

public boolean isCanceled()
Checks if the transfer was canceled.

Returns:
  true if transfer was canceled

### run

public void run()
This method is an implementation of the `Runnable` interface and can be used to perform the copy in a separate thread.

This method will perform the transfer and signal completion and errors through the `UrlCopyListener.transferCompleted()` and `UrlCopyListener.transferError(Exception)` of any registered listeners (see `addUrlCopyListener(UrlCopyListener)`).

Specified by:
  `run` in interface `Runnable`

### copy

public void copy() throws UrlCopyException
Performs the copy function. Source and destination urls must be specified otherwise a exception is thrown. Also, if source and destination url are ftp urls and thirdPartyCopy is enabled, third party transfer will be performed. Urls, of course, must be of supported protocol. Currently, gsiftp, ftp, https, http, and file are supported.

This method does not cause the `UrlCopyListener.transferCompleted()` and `UrlCopyListener.transferError(Exception)` to be called. If you want completion/failures to be signaled asynchronously, either call the `run()` method or wrap this object in a `Thread`.

Throws:
  `UrlCopyException` - in case of an error.

### getInputStream

protected GlobusInputStream getInputStream() throws Exception
Returns input stream based on the source url

Throws:
  `Exception`

### getOutputStream

protected GlobusOutputStream getOutputStream(long size) throws Exception
Returns output stream based on the destination url.

Throws:
  `Exception`

### negotiateDCAU

protected void negotiateDCAU(FTPClient src, FTPClient dst) throws IOException, FTPException

Throws:
  `IOException`
  `FTPException`