UrlCopy (Java Globus API)

org.globus.io.urlcopy
Class UrlCopy

java.lang.Object
  |
  +--org.globus.io.urlcopy.UrlCopy
All Implemented Interfaces:
java.lang.Runnable

public class UrlCopy
extends java.lang.Object
implements java.lang.Runnable


Field Summary
protected  boolean appendMode
           
static int BUFF_SIZE
          maximum buffer size to read or write when putting and getting files
protected  int bufferSize
           
protected  boolean canceled
           
protected  GlobusProxy dstCreds
           
protected  GlobusURL dstUrl
           
protected  java.util.List listeners
           
protected  GlobusProxy srcCreds
           
protected  GlobusURL srcUrl
           
protected  boolean thirdParty
           
 
Constructor Summary
UrlCopy()
           
 
Method Summary
 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.
 GlobusProxy getDestinationCredentials()
          Returns credentials used for authenticating the destination side for the url copy.
 GlobusURL getDestinationUrl()
          Returns destination url.
protected  GlobusInputStream getInputStream()
          Returns input stream based on the source url
protected  GlobusOutputStream getOutputStream(int size)
          Returns output stream based on the destination url.
 GlobusProxy getSourceCredentials()
          Returns credentials used for authenticating the source side for the url copy.
 GlobusURL getSourceUrl()
          Returns source url.
 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()
          Used for as a thread.
 void setAppendMode(boolean appendMode)
          Enables/disables append mode.
 void setBufferSize(int size)
          Sets buffer size for transfering data.
 void setCredentials(GlobusProxy credentials)
          Sets credentials to use for both sides.
 void setDestinationCredentials(GlobusProxy dstCredentials)
          Sets destination url credentials.
 void setDestinationUrl(GlobusURL dest)
          Sets destination url.
 void setSourceCredentials(GlobusProxy srcCredentials)
          Sets source url credentials.
 void setSourceUrl(GlobusURL source)
          Sets source url.
 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 Detail

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 GlobusProxy srcCreds

dstCreds

protected GlobusProxy dstCreds

appendMode

protected boolean appendMode

srcUrl

protected GlobusURL srcUrl

dstUrl

protected GlobusURL dstUrl

canceled

protected boolean canceled

thirdParty

protected boolean thirdParty

listeners

protected java.util.List listeners
Constructor Detail

UrlCopy

public UrlCopy()
Method Detail

setCredentials

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

Parameters:
credentials - user credentials

setSourceCredentials

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

Parameters:
srcCredentials - source url credentials.

setDestinationCredentials

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

Parameters:
dstCredentials - destination url credentials.

getSourceCredentials

public GlobusProxy getSourceCredentials()
                                 throws GlobusProxyException
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.
GlobusProxyException

getDestinationCredentials

public GlobusProxy getDestinationCredentials()
                                      throws GlobusProxyException
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.
GlobusProxyException

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

Returns:
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

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.

setSourceUrl

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

Parameters:
source - source url.
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
UrlCopyException

getDestinationUrl

public GlobusURL getDestinationUrl()
Returns destination url.

Returns:
url

setUseThirdPartyCopy

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


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()
Used for as a thread.

Specified by:
run in interface java.lang.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.

Throws:
UrlCopyException - in case of an error.

getInputStream

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

java.lang.Exception

getOutputStream

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

java.lang.Exception

negotiateDCAU

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