agave-systems/systems-core/src/main/java/org/iplantc/service/transfer/URLCopy.java
/**
     * Performs the transfer by streaming data from one system to another through
     * the local server. This option honors range requests, so only 
     *
     * @param srcPath agave source path of the file on the remote system
     * @param srcRangeOffset offset to start reading from the source file
     * @param srcRangeSize length of the range to read, -1 represents remainder of file
     * @param destPath the destination agave path of the transfer on the remote system  
     * @param destRangeOffset offset to start writing to the dest file
     * @param transferTask the transfer task tracking the transfer
     * @return transferTask updated with results of the transfer
     * @throws RemoteDataException
     * @throws IOException
     * @throws TransferException
     * @throws ClosedByInterruptException
     */
Performs the transfer by streaming data from one system to another through
the local server. This option honors range requests, so only


Performs the transfer by streaming data from one system to another through the local server . This option honors range requests so only
public TransferTask copyRange(String srcPath, long srcRangeOffset, long srcRangeSize,
                                  String destPath, long destRangeOffset, TransferTask transferTask)
            throws RemoteDataException, IOException, TransferException, ClosedByInterruptException {
        if (transferTask == null) {
            throw new TransferException("TransferTask cannot be null. Please provide"
                    + "a valid transfer task to track this operation.");
        } else if (transferTask.getId() == null) {
            throw new TransferException("TransferTask does not have a valid id. "
                    + "Please persiste the transfer taks and attempt the operation again.");
        }
        try {
            if (sourceClient.isDirectory(srcPath)) {
                throw new TransferException("Range transfers are not supported on directories");
            } else {
                RemoteTransferListener listener = null;
                listener = new RemoteTransferListener(transferTask);
                if (StringUtils.equals(FilenameUtils.getName(srcPath), ".") ||
                        StringUtils.equals(FilenameUtils.getName(srcPath), "..")) {
                }
                else {
                    RangeValidator sourceRangeValidator = new RangeValidator(srcRangeOffset, srcRangeSize, sourceClient.length(srcPath));
                    RangeValidator destRangeValidator = new RangeValidator(destRangeOffset, Range.SIZE_MAX, sourceClient.length(srcPath));
                    try {
                        long absoluteSourceIndex = sourceRangeValidator.getAbsoluteIndex();
                        long absoluteDestIndex = destRangeValidator.getAbsoluteIndex();
                        proxyRangeTransfer(srcPath, absoluteSourceIndex, srcRangeSize, destPath, absoluteDestIndex, listener);
                    } catch (ClosedByInterruptException e) {
                        try {
                            TransferTaskDao.cancelAllRelatedTransfers(transferTask.getId());
                        } catch (TransferException e1) {
                            throw new RemoteDataException("Failed to cancel related transfer tasks.", e1);
                        } finally {
                            Thread.currentThread().interrupt();
                        }
                        throw e;
                    } catch (RangeValidationException e) {
                        throw new RemoteDataException(e.getMessage(), e);
                    } catch (TransferException e) {
                        throw new RemoteDataException("Failed to udpate transfer record.", e);
                    }
                }
                return listener.getTransferTask();
            }
        } finally {
            try {
                if (destClient.isPermissionMirroringRequired()) {
                    destClient.setOwnerPermission(destClient.getUsername(), destPath, true);
                    destClient.setOwnerPermission(transferTask.getOwner(), destPath, true);
                }
            } catch (Exception e) {
                log.error("Failed to set permissions on " + destClient.getHost() + " for user " + transferTask.getOwner(), e);
            }
        }
    }
public TransferTask copyRange ( String srcPath , long srcRangeOffset , long srcRangeSize , String destPath , long destRangeOffset , TransferTask transferTask ) throws RemoteDataException , IOException , TransferException , ClosedByInterruptException { if ( transferTask == null ) { throw new TransferException ( "TransferTask cannot be null. Please provide" + "a valid transfer task to track this operation." ) ; } else if ( transferTask . getId ( ) == null ) { throw new TransferException ( "TransferTask does not have a valid id. " + "Please persiste the transfer taks and attempt the operation again." ) ; } try { if ( sourceClient . isDirectory ( srcPath ) ) { throw new TransferException ( "Range transfers are not supported on directories" ) ; } else { RemoteTransferListener listener = null ; listener = new RemoteTransferListener ( transferTask ) ; if ( StringUtils . equals ( FilenameUtils . getName ( srcPath ) , "." ) || StringUtils . equals ( FilenameUtils . getName ( srcPath ) , ".." ) ) { } else { RangeValidator sourceRangeValidator = new RangeValidator ( srcRangeOffset , srcRangeSize , sourceClient . length ( srcPath ) ) ; RangeValidator destRangeValidator = new RangeValidator ( destRangeOffset , Range . SIZE_MAX , sourceClient . length ( srcPath ) ) ; try { long absoluteSourceIndex = sourceRangeValidator . getAbsoluteIndex ( ) ; long absoluteDestIndex = destRangeValidator . getAbsoluteIndex ( ) ; proxyRangeTransfer ( srcPath , absoluteSourceIndex , srcRangeSize , destPath , absoluteDestIndex , listener ) ; } catch ( ClosedByInterruptException e ) { try { TransferTaskDao . cancelAllRelatedTransfers ( transferTask . getId ( ) ) ; } catch ( TransferException e1 ) { throw new RemoteDataException ( "Failed to cancel related transfer tasks." , e1 ) ; } finally { Thread . currentThread ( ) . interrupt ( ) ; } throw e ; } catch ( RangeValidationException e ) { throw new RemoteDataException ( e . getMessage ( ) , e ) ; } catch ( TransferException e ) { throw new RemoteDataException ( "Failed to udpate transfer record." , e ) ; } } return listener . getTransferTask ( ) ; } } finally { try { if ( destClient . isPermissionMirroringRequired ( ) ) { destClient . setOwnerPermission ( destClient . getUsername ( ) , destPath , true ) ; destClient . setOwnerPermission ( transferTask . getOwner ( ) , destPath , true ) ; } } catch ( Exception e ) { log . error ( "Failed to set permissions on " + destClient . getHost ( ) + " for user " + transferTask . getOwner ( ) , e ) ; } } }
Performs the transfer by streaming data from one system to another through
 the local server.
Performs the transfer by streaming data from one system to another through the local server .
// if we are transferring a directory // skip current directory and parent to avoid infinite loops and // full file system copies. //                else if (sourceClient.isThirdPartyTransferSupported() && //                        destClient.isThirdPartyTransferSupported() && //                        sourceClient.getClass().equals(destClient.getClass())) //                { //                    dothirdPartyTransfer(srcPath, srcRangeOffset, srcRangeSize, destPath, destRangeOffset, listener); //                }