agave-apps/apps-core/src/main/java/org/iplantc/service/apps/queue/actions/CloneAction.java
/**
     * Reliably transfers the zipped {@link Software} archive to the remote {@link StorageSystem} and
     * sets the checksum of the file for future reference.
     * 
     * @param clonedSoftwareDataClient
     * @param localCachedSoftwareDeploymentSystem
     * @throws FileNotFoundException
     * @throws IOException
     * @throws RemoteDataException
     * @throws TransferException
     */
Reliably transfers the zipped  Software archive to the remote  StorageSystem and
sets the checksum of the file for future reference.


Reliably transfers the zipped Software archive to the remote StorageSystem and sets the checksum of the file for future reference .
private void copyLocalCachedDeploymentPathToClonedSoftwareDeploymentSystem(Software clonedSoftware, RemoteDataClient clonedSoftwareDataClient, File localCachedSoftwareDeploymentSystem)
    throws FileNotFoundException, IOException, RemoteDataException, TransferException 
    {
        TransferTask transferTask = new TransferTask(
                "agave://" + getEntity().getStorageSystem().getSystemId() + "/" + getEntity().getDeploymentPath(), 
                "agave://" + clonedSoftware.getStorageSystem().getSystemId() + "/" + clonedSoftware.getDeploymentPath(), 
                clonedSoftware.getOwner(), 
                null, null);
        TransferTaskDao.persist(transferTask);
        try {
            File tempDir = new File(Settings.TEMP_DIRECTORY);
            if (!tempDir.exists() || !tempDir.isDirectory()) {
                tempDir.mkdirs();
            }
            File namedLocalDeploymentPath = new File(tempDir, FilenameUtils.getName(clonedSoftware.getDeploymentPath()));
            localCachedSoftwareDeploymentSystem.renameTo(namedLocalDeploymentPath);
            RemoteTransferListener listener = new RemoteTransferListener(transferTask);
            clonedSoftwareDataClient.put(namedLocalDeploymentPath.getAbsolutePath(), FilenameUtils.getPathNoEndSeparator(clonedSoftware.getDeploymentPath()), listener);
        } catch (Exception e) {
            throw new SoftwareException("Failed to copy the deploymentPath for " + getEntity().getUniqueName() + 
            		" on " +  getEntity().getStorageSystem().getSystemId() + 
            		" to the new deployment folder on " + clonedSoftware.getStorageSystem().getSystemId(), e);
        } finally {
            try {
                if (clonedSoftwareDataClient.isPermissionMirroringRequired()) {
                    if (clonedSoftwareDataClient.doesExist(clonedSoftware.getDeploymentPath())) {
                        clonedSoftwareDataClient.setOwnerPermission(clonedSoftwareDataClient.getUsername(), clonedSoftware.getDeploymentPath(), true);
                        clonedSoftwareDataClient.setOwnerPermission(clonedSoftware.getOwner(), clonedSoftware.getDeploymentPath(), true);
                    }
                }
            } catch (Exception e) {
                log.error("Failed to set app deploymentPath permissions on " + clonedSoftware.getDeploymentPath() + 
                        " for app " + clonedSoftware.getUniqueName() + " on behalf of user " + clonedSoftware.getOwner(), e);
            }
        }
    }
private void copyLocalCachedDeploymentPathToClonedSoftwareDeploymentSystem ( Software clonedSoftware , RemoteDataClient clonedSoftwareDataClient , File localCachedSoftwareDeploymentSystem ) throws FileNotFoundException , IOException , RemoteDataException , TransferException { TransferTask transferTask = new TransferTask ( "agave://" + getEntity ( ) . getStorageSystem ( ) . getSystemId ( ) + "/" + getEntity ( ) . getDeploymentPath ( ) , "agave://" + clonedSoftware . getStorageSystem ( ) . getSystemId ( ) + "/" + clonedSoftware . getDeploymentPath ( ) , clonedSoftware . getOwner ( ) , null , null ) ; TransferTaskDao . persist ( transferTask ) ; try { File tempDir = new File ( Settings . TEMP_DIRECTORY ) ; if ( ! tempDir . exists ( ) || ! tempDir . isDirectory ( ) ) { tempDir . mkdirs ( ) ; } File namedLocalDeploymentPath = new File ( tempDir , FilenameUtils . getName ( clonedSoftware . getDeploymentPath ( ) ) ) ; localCachedSoftwareDeploymentSystem . renameTo ( namedLocalDeploymentPath ) ; RemoteTransferListener listener = new RemoteTransferListener ( transferTask ) ; clonedSoftwareDataClient . put ( namedLocalDeploymentPath . getAbsolutePath ( ) , FilenameUtils . getPathNoEndSeparator ( clonedSoftware . getDeploymentPath ( ) ) , listener ) ; } catch ( Exception e ) { throw new SoftwareException ( "Failed to copy the deploymentPath for " + getEntity ( ) . getUniqueName ( ) + " on " + getEntity ( ) . getStorageSystem ( ) . getSystemId ( ) + " to the new deployment folder on " + clonedSoftware . getStorageSystem ( ) . getSystemId ( ) , e ) ; } finally { try { if ( clonedSoftwareDataClient . isPermissionMirroringRequired ( ) ) { if ( clonedSoftwareDataClient . doesExist ( clonedSoftware . getDeploymentPath ( ) ) ) { clonedSoftwareDataClient . setOwnerPermission ( clonedSoftwareDataClient . getUsername ( ) , clonedSoftware . getDeploymentPath ( ) , true ) ; clonedSoftwareDataClient . setOwnerPermission ( clonedSoftware . getOwner ( ) , clonedSoftware . getDeploymentPath ( ) , true ) ; } } } catch ( Exception e ) { log . error ( "Failed to set app deploymentPath permissions on " + clonedSoftware . getDeploymentPath ( ) + " for app " + clonedSoftware . getUniqueName ( ) + " on behalf of user " + clonedSoftware . getOwner ( ) , e ) ; } } }
Reliably transfers the zipped {@link Software} archive to the remote {@link StorageSystem} and
 sets the checksum of the file for future reference.
Reliably transfers the zipped { @link Software } archive to the remote { @link StorageSystem } and sets the checksum of the file for future reference .
// rename the local folder so it will copy to the remote system with the proper folder name // copy the properly named local cache folder to the parent directory of the deployment path // on the remote system so we guarantee the folder name preserves. //        if (!clonedSoftwareDataClient.doesExist(clonedSoftware.getDeploymentPath()))  //        { //            throw new FileNotFoundException("Failed to copy the deploymentPath for " + getEntity().getUniqueName() +  //            		" on " +  getEntity().getStorageSystem().getSystemId() +  //            		" to the new deployment folder on " + clonedSoftware.getStorageSystem().getSystemId()); //        }