lib/src/main/java/edu/utexas/tacc/tapis/files/lib/services/ParentTaskTransferService.java
private TransferTaskParent doParentChevronOne(TransferTaskParent parentTask) throws ServiceException, ForbiddenException {
        log.debug("***** DOING doParentChevronOne ****");
        log.debug(parentTask.toString());
        TapisSystem sourceSystem;
        IRemoteDataClient sourceClient;

        // Make sure its not already cancelled/failed
        if (parentTask.isTerminal()) return parentTask;

        boolean isPermitted = checkPermissionsForParent(parentTask);
        if (!isPermitted) {
            throw new ForbiddenException();
        }

        // Update the top level task first, if it is not already updated with the startTime
        try {
            TransferTask task = dao.getTransferTaskByID(parentTask.getTaskId());
            if (task.isTerminal()) return parentTask;
            if (task.getStartTime() == null) {
                task.setStartTime(Instant.now());
                task.setStatus(TransferTaskStatus.IN_PROGRESS);
                dao.updateTransferTask(task);
            }

            //update parent task status, start time
            parentTask.setStatus(TransferTaskStatus.IN_PROGRESS);
            parentTask.setStartTime(Instant.now());
            parentTask = dao.updateTransferTaskParent(parentTask);

        } catch (DAOException ex) {
            throw new ServiceException(Utils.getMsg("FILES_TXFR_SVC_ERR1", parentTask.getTenantId(), parentTask.getUsername(),
                "doParentChevronOneA", parentTask.getId(), parentTask.getUuid(), ex.getMessage()), ex);
        }

        try {
            TransferURI sourceURI = parentTask.getSourceURI();

            if (sourceURI.toString().startsWith("tapis://")) {
                sourceSystem = systemsCache.getSystem(parentTask.getTenantId(), sourceURI.getSystemId(), parentTask.getUsername());
                if (sourceSystem.getEnabled() == null || !sourceSystem.getEnabled()) {
                    String msg = Utils.getMsg("FILES_TXFR_SYS_NOTENABLED", parentTask.getTenantId(),
                        parentTask.getUsername(), parentTask.getId(), parentTask.getUuid(), sourceSystem.getId());
                    throw new ServiceException(msg);
                }
                sourceClient = remoteDataClientFactory.getRemoteDataClient(parentTask.getTenantId(), parentTask.getUsername(),
                    sourceSystem, parentTask.getUsername());

                //TODO: Retries will break this, should delete anything in the DB if it is a retry?
                List<FileInfo> fileListing;
                fileListing = fileOpsService.lsRecursive(sourceClient, sourceURI.getPath(), 10);
                List<TransferTaskChild> children = new ArrayList<>();
                long totalBytes = 0;
                for (FileInfo f : fileListing) {
                    // Only include the bytes from files. Posix folders are --usually-- 4bytes but not always, so
                    // it can make some weird totals that don't really make sense.
                    if (!f.isDir()) {
                        totalBytes += f.getSize();
                    }
                    TransferTaskChild child = new TransferTaskChild(parentTask, f);
                    children.add(child);
                }
                parentTask.setTotalBytes(totalBytes);
                parentTask.setStatus(TransferTaskStatus.STAGED);
                parentTask = dao.updateTransferTaskParent(parentTask);
                dao.bulkInsertChildTasks(children);
                children = dao.getAllChildren(parentTask);
                transfersService.publishBulkChildMessages(children);
            } else if (sourceURI.toString().startsWith("http://") || sourceURI.toString().startsWith("https://")) {
                TransferTaskChild task = new TransferTaskChild();
                task.setSourceURI(parentTask.getSourceURI());
                task.setParentTaskId(parentTask.getId());
                task.setTaskId(parentTask.getTaskId());
                task.setDestinationURI(parentTask.getDestinationURI());
                task.setStatus(TransferTaskStatus.ACCEPTED);
                task.setTenantId(parentTask.getTenantId());
                task.setUsername(parentTask.getUsername());
                task = dao.insertChildTask(task);
                transfersService.publishChildMessage(task);
                parentTask.setStatus(TransferTaskStatus.STAGED);
                parentTask = dao.updateTransferTaskParent(parentTask);
            }
            return parentTask;
        } catch (DAOException | TapisException | IOException e) {
            throw new ServiceException(Utils.getMsg("FILES_TXFR_SVC_ERR1", parentTask.getTenantId(), parentTask.getUsername(),
                "doParentChevronOneB", parentTask.getId(), parentTask.getUuid(), e.getMessage()), e);
        }
    }
/**
     * We prepare a "bill of materials" for the total transfer task. This includes doing a recursive listing and
     * inserting the records into the DB, then publishing all of the messages to rabbitmq. After that, the child task workers
     * will pick them up and begin the actual transferring of bytes.
     *
     * @param parentTask TransferTaskParent
     * @return Updated task
     * @throws ServiceException When a listing or DAO error occurs
     */
We prepare a "bill of materials" for the total transfer task. This includes doing a recursive listing and
inserting the records into the DB, then publishing all of the messages to rabbitmq. After that, the child task workers
will pick them up and begin the actual transferring of bytes.

@param parentTask TransferTaskParent
@return Updated task
@throws ServiceException When a listing or DAO error occurs
We prepare a " bill of materials " for the total transfer task . This includes doing a recursive listing and inserting the records into the DB then publishing all of the messages to rabbitmq . After that the child task workers will pick them up and begin the actual transferring of bytes . @param parentTask TransferTaskParent @return Updated task @throws ServiceException When a listing or DAO error occurs
private TransferTaskParent doParentChevronOne(TransferTaskParent parentTask) throws ServiceException, ForbiddenException {
        log.debug("***** DOING doParentChevronOne ****");
        log.debug(parentTask.toString());
        TapisSystem sourceSystem;
        IRemoteDataClient sourceClient;
        if (parentTask.isTerminal()) return parentTask;
        boolean isPermitted = checkPermissionsForParent(parentTask);
        if (!isPermitted) {
            throw new ForbiddenException();
        }
        try {
            TransferTask task = dao.getTransferTaskByID(parentTask.getTaskId());
            if (task.isTerminal()) return parentTask;
            if (task.getStartTime() == null) {
                task.setStartTime(Instant.now());
                task.setStatus(TransferTaskStatus.IN_PROGRESS);
                dao.updateTransferTask(task);
            }
            parentTask.setStatus(TransferTaskStatus.IN_PROGRESS);
            parentTask.setStartTime(Instant.now());
            parentTask = dao.updateTransferTaskParent(parentTask);
        } catch (DAOException ex) {
            throw new ServiceException(Utils.getMsg("FILES_TXFR_SVC_ERR1", parentTask.getTenantId(), parentTask.getUsername(),
                "doParentChevronOneA", parentTask.getId(), parentTask.getUuid(), ex.getMessage()), ex);
        }
        try {
            TransferURI sourceURI = parentTask.getSourceURI();
            if (sourceURI.toString().startsWith("tapis://")) {
                sourceSystem = systemsCache.getSystem(parentTask.getTenantId(), sourceURI.getSystemId(), parentTask.getUsername());
                if (sourceSystem.getEnabled() == null || !sourceSystem.getEnabled()) {
                    String msg = Utils.getMsg("FILES_TXFR_SYS_NOTENABLED", parentTask.getTenantId(),
                        parentTask.getUsername(), parentTask.getId(), parentTask.getUuid(), sourceSystem.getId());
                    throw new ServiceException(msg);
                }
                sourceClient = remoteDataClientFactory.getRemoteDataClient(parentTask.getTenantId(), parentTask.getUsername(),
                    sourceSystem, parentTask.getUsername());
                List<FileInfo> fileListing;
                fileListing = fileOpsService.lsRecursive(sourceClient, sourceURI.getPath(), 10);
                List<TransferTaskChild> children = new ArrayList<>();
                long totalBytes = 0;
                for (FileInfo f : fileListing) {
                    if (!f.isDir()) {
                        totalBytes += f.getSize();
                    }
                    TransferTaskChild child = new TransferTaskChild(parentTask, f);
                    children.add(child);
                }
                parentTask.setTotalBytes(totalBytes);
                parentTask.setStatus(TransferTaskStatus.STAGED);
                parentTask = dao.updateTransferTaskParent(parentTask);
                dao.bulkInsertChildTasks(children);
                children = dao.getAllChildren(parentTask);
                transfersService.publishBulkChildMessages(children);
            } else if (sourceURI.toString().startsWith("http://") || sourceURI.toString().startsWith("https://")) {
                TransferTaskChild task = new TransferTaskChild();
                task.setSourceURI(parentTask.getSourceURI());
                task.setParentTaskId(parentTask.getId());
                task.setTaskId(parentTask.getTaskId());
                task.setDestinationURI(parentTask.getDestinationURI());
                task.setStatus(TransferTaskStatus.ACCEPTED);
                task.setTenantId(parentTask.getTenantId());
                task.setUsername(parentTask.getUsername());
                task = dao.insertChildTask(task);
                transfersService.publishChildMessage(task);
                parentTask.setStatus(TransferTaskStatus.STAGED);
                parentTask = dao.updateTransferTaskParent(parentTask);
            }
            return parentTask;
        } catch (DAOException | TapisException | IOException e) {
            throw new ServiceException(Utils.getMsg("FILES_TXFR_SVC_ERR1", parentTask.getTenantId(), parentTask.getUsername(),
                "doParentChevronOneB", parentTask.getId(), parentTask.getUuid(), e.getMessage()), e);
        }
    }
private TransferTaskParent doParentChevronOne ( TransferTaskParent parentTask ) throws ServiceException , ForbiddenException { log . debug ( "***** DOING doParentChevronOne ****" ) ; log . debug ( parentTask . toString ( ) ) ; TapisSystem sourceSystem ; IRemoteDataClient sourceClient ; if ( parentTask . isTerminal ( ) ) return parentTask ; boolean isPermitted = checkPermissionsForParent ( parentTask ) ; if ( ! isPermitted ) { throw new ForbiddenException ( ) ; } try { TransferTask task = dao . getTransferTaskByID ( parentTask . getTaskId ( ) ) ; if ( task . isTerminal ( ) ) return parentTask ; if ( task . getStartTime ( ) == null ) { task . setStartTime ( Instant . now ( ) ) ; task . setStatus ( TransferTaskStatus . IN_PROGRESS ) ; dao . updateTransferTask ( task ) ; } parentTask . setStatus ( TransferTaskStatus . IN_PROGRESS ) ; parentTask . setStartTime ( Instant . now ( ) ) ; parentTask = dao . updateTransferTaskParent ( parentTask ) ; } catch ( DAOException ex ) { throw new ServiceException ( Utils . getMsg ( "FILES_TXFR_SVC_ERR1" , parentTask . getTenantId ( ) , parentTask . getUsername ( ) , "doParentChevronOneA" , parentTask . getId ( ) , parentTask . getUuid ( ) , ex . getMessage ( ) ) , ex ) ; } try { TransferURI sourceURI = parentTask . getSourceURI ( ) ; if ( sourceURI . toString ( ) . startsWith ( "tapis://" ) ) { sourceSystem = systemsCache . getSystem ( parentTask . getTenantId ( ) , sourceURI . getSystemId ( ) , parentTask . getUsername ( ) ) ; if ( sourceSystem . getEnabled ( ) == null || ! sourceSystem . getEnabled ( ) ) { String msg = Utils . getMsg ( "FILES_TXFR_SYS_NOTENABLED" , parentTask . getTenantId ( ) , parentTask . getUsername ( ) , parentTask . getId ( ) , parentTask . getUuid ( ) , sourceSystem . getId ( ) ) ; throw new ServiceException ( msg ) ; } sourceClient = remoteDataClientFactory . getRemoteDataClient ( parentTask . getTenantId ( ) , parentTask . getUsername ( ) , sourceSystem , parentTask . getUsername ( ) ) ; List < FileInfo > fileListing ; fileListing = fileOpsService . lsRecursive ( sourceClient , sourceURI . getPath ( ) , 10 ) ; List < TransferTaskChild > children = new ArrayList < > ( ) ; long totalBytes = 0 ; for ( FileInfo f : fileListing ) { if ( ! f . isDir ( ) ) { totalBytes += f . getSize ( ) ; } TransferTaskChild child = new TransferTaskChild ( parentTask , f ) ; children . add ( child ) ; } parentTask . setTotalBytes ( totalBytes ) ; parentTask . setStatus ( TransferTaskStatus . STAGED ) ; parentTask = dao . updateTransferTaskParent ( parentTask ) ; dao . bulkInsertChildTasks ( children ) ; children = dao . getAllChildren ( parentTask ) ; transfersService . publishBulkChildMessages ( children ) ; } else if ( sourceURI . toString ( ) . startsWith ( "http://" ) || sourceURI . toString ( ) . startsWith ( "https://" ) ) { TransferTaskChild task = new TransferTaskChild ( ) ; task . setSourceURI ( parentTask . getSourceURI ( ) ) ; task . setParentTaskId ( parentTask . getId ( ) ) ; task . setTaskId ( parentTask . getTaskId ( ) ) ; task . setDestinationURI ( parentTask . getDestinationURI ( ) ) ; task . setStatus ( TransferTaskStatus . ACCEPTED ) ; task . setTenantId ( parentTask . getTenantId ( ) ) ; task . setUsername ( parentTask . getUsername ( ) ) ; task = dao . insertChildTask ( task ) ; transfersService . publishChildMessage ( task ) ; parentTask . setStatus ( TransferTaskStatus . STAGED ) ; parentTask = dao . updateTransferTaskParent ( parentTask ) ; } return parentTask ; } catch ( DAOException | TapisException | IOException e ) { throw new ServiceException ( Utils . getMsg ( "FILES_TXFR_SVC_ERR1" , parentTask . getTenantId ( ) , parentTask . getUsername ( ) , "doParentChevronOneB" , parentTask . getId ( ) , parentTask . getUuid ( ) , e . getMessage ( ) ) , e ) ; } }
We prepare a "bill of materials" for the total transfer task.
We prepare a " bill of materials " for the total transfer task .
// Make sure its not already cancelled/failed // Update the top level task first, if it is not already updated with the startTime //update parent task status, start time //TODO: Retries will break this, should delete anything in the DB if it is a retry? // Only include the bytes from files. Posix folders are --usually-- 4bytes but not always, so // it can make some weird totals that don't really make sense.