@Override
public String call() throws TransferFailedException
{
LOG.debug("Starting managed file transfer.");
System.out.println("Starting managed file transfer");
GridFTPClient sourceClient = null;
GridFTPClient targetClient = null;
try
{
sourceClient = new GridFTPClient(mHost, mPort);
sourceClient.setAuthorization(mAuthorization);
sourceClient.authenticate(mCredential, null, mSubject);
sourceClient.setType(GridFTPSession.TYPE_IMAGE);
sourceClient.setMode(GridFTPSession.MODE_EBLOCK);
LOG.debug("Source: " + mHost + ":" + mPort + ", file: " + mFileName);
targetClient = new GridFTPClient(mDestinationHost, mDestinationPort);
targetClient.setAuthorization(mAuthorization);
targetClient.authenticate(mCredential, null, mDestinationSubject);
targetClient.setType(GridFTPSession.TYPE_IMAGE);
targetClient.setMode(GridFTPSession.MODE_EBLOCK);
LOG.debug("Destination: " + mDestinationHost + ":" + mDestinationPort +
", file: " + mDestinationFile);
sourceClient.extendedTransfer(
mFileName,
targetClient,
mDestinationFile,
null);
LOG.debug("Completed file transfer.");
return mDestinationFile;
}
catch (ServerException e)
{
throw new TransferFailedException(e);
}
catch (ClientException e)
{
throw new TransferFailedException(e);
}
catch (IOException e)
{
throw new TransferFailedException(e);
}
finally
{
try
{
if (sourceClient != null)
{
sourceClient.close();
}
if (targetClient != null)
{
targetClient.close();
}
}
catch (Throwable e)
{
LOG.warn(e, true);