diff --git a/.gitignore b/.gitignore index 653e2b9c7..88ba84c29 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ bin *.war *.log */nbactions.xml +*.eml nbactions.xml testing.properties */test-output diff --git a/README.md b/README.md index 39dfa638c..8e71cc96a 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,6 @@ Jargon-core consists of the following libraries * jargon-data-utils - additional functionality for dealing with iRODS data, such as building trees, storing information in iRODS on behalf of applications, and doing diffs between local and iRODS * jargon-user-tagging - code for using free tagging and other metadata metaphors on top of iRODS * jargon-user-profile - allows management of user profile and related configuration data in a user home directory -* jargon-conveyor - transfer manager for managing and synchronizing data with iRODS * jargon-ticket - support for ticket processing * jargon-httpstream - stream http content into iRODS via Jargon * jargon-ruleservice - support for running and managing rules from interfaces @@ -44,19 +43,3 @@ Note that the following bug and feature requests are logged in GitHub with relat ## Changes -<<<<<<< HEAD -======= -### Integration misc with CyberDuck #101 - -Misc small changes as we test Cyberduck integration with iRODS. This is a catch-all issue for many minor changes. - -### Authenticates as the proxy instead of client #100 - -Handle authentication with proxy user, per a patch supplied by Tony Edgin at iPlant (Thanks!) - -### Option to obtain MD5 from server after upload is complete #89 - -Breaking out checksum utilities to its own service object (DataObjectChecksumUtilitiesAO) and beginning to add richer hooks for -various checksum management scenarios. This was originally done to have simpler hooks for CyberDuck. Eventually checksum code in various places will be deprecated and will point to these consolidated services. - ->>>>>>> master diff --git a/jargon-conveyor/groovy/fileBundle.groovy b/jargon-conveyor/groovy/fileBundle.groovy deleted file mode 100644 index 638718558..000000000 --- a/jargon-conveyor/groovy/fileBundle.groovy +++ /dev/null @@ -1,27 +0,0 @@ -import org.irods.jargon.conveyor.flowmanager.flow.* -import org.irods.jargon.conveyor.flowmanager.flow.Selector.FlowActionEnum -import org.irods.jargon.conveyor.flowmanager.flow.dsl.* -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.CancelOperationMicroservice -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.EnqueueTransferMicroservice -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.InspectForBundleOperationMicroservice -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.TarCollectionMicroservice - -String bundleConditionMicroservice = InspectForBundleOperationMicroservice.class.getName() -String tarMicroservice = TarCollectionMicroservice.class.getName() -String enqueueMicroservice = EnqueueTransferMicroservice.class.getName() -String cancelMicroservice = CancelOperationMicroservice.class.getName() - -FlowSpec flowSpec = Flow.define().forAction(FlowActionEnum.PUT) - .forAnyHost() - .forAnyZone() - .when(bundleConditionMicroservice) - .addPreOperationMicroservice(tarMicroservice) - .addPreOperationMicroservice(enqueueMicroservice) - .addPreOperationMicroservice(cancelMicroservice) - .endPreOperationChain() - .endPreFileChain() - .endPostFileChain() - .endPostOperationChain() - .endFlowWithoutErrorHandler() - -return flowSpec diff --git a/jargon-conveyor/groovy/fileUnbundle.groovy b/jargon-conveyor/groovy/fileUnbundle.groovy deleted file mode 100644 index 57df86149..000000000 --- a/jargon-conveyor/groovy/fileUnbundle.groovy +++ /dev/null @@ -1,21 +0,0 @@ -import org.irods.jargon.conveyor.flowmanager.flow.* -import org.irods.jargon.conveyor.flowmanager.flow.Selector.FlowActionEnum -import org.irods.jargon.conveyor.flowmanager.flow.dsl.* -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.ExtractBundleMicroservice -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.InspectForUnbundleOperationMicroservice - -String bundleConditionMicroservice = InspectForUnbundleOperationMicroservice.class.getName() -String unbundle = ExtractBundleMicroservice.class.getName() - -FlowSpec flowSpec = Flow.define().forAction(FlowActionEnum.PUT) - .forAnyHost() - .forAnyZone() - .when(bundleConditionMicroservice) - .endPreOperationChain() - .endPreFileChain() - .addPostFileMicroservice(unbundle) - .endPostFileChain() - .endPostOperationChain() - .endFlowWithoutErrorHandler() - -return flowSpec diff --git a/jargon-conveyor/pom.xml b/jargon-conveyor/pom.xml deleted file mode 100644 index 3d71e811f..000000000 --- a/jargon-conveyor/pom.xml +++ /dev/null @@ -1,230 +0,0 @@ - - - 4.0.0 - - jargon - org.irods - 4.0.3.1-SNAPSHOT - - org.irods.jargon - jargon-conveyor - Jargon Conveyor - http://maven.apache.org - - UTF-8 - - - - org.codehaus.groovy - groovy-all - 2.1.8 - - - org.irods.jargon - jargon-data-utils - - - - javassist - javassist - - - org.apache.derby - derby - - - org.springframework - spring-test - - - org.springframework - spring-context - - - org.springframework - spring-beans - - - org.springframework - spring-orm - - - org.hibernate - hibernate-core - - - org.hibernate - hibernate-annotations - - - org.springframework - spring-core - - - org.springframework - spring-aop - - - org.springframework - spring-jdbc - - - org.springframework - spring-tx - - - javax.persistence - persistence-api - - - c3p0 - c3p0 - - - dom4j - dom4j - - - commons-collections - commons-collections - - - cglib - cglib-nodep - - - javax.transaction - jta - - - antlr - antlr - - - - - - maven-antrun-plugin - - - 0 - validate - - - - - - test.confirm=${jargon.test.confirm} - test.data.directory=${jargon.test.data.directory} - test.irods.admin=${jargon.test.irods.admin} - test.irods.admin.password=${jargon.test.irods.admin.password} - test.irods.user=${jargon.test.irods.user} - test.irods.password=${jargon.test.irods.password} - test.irods.resource=${jargon.test.irods.resource} - test2.irods.user=${jargon.test.irods.user2} - test2.irods.password=${jargon.test.irods.password2} - test2.irods.resource=${jargon.test.irods.resource2} - test3.irods.user=${jargon.test.irods.user3} - test3.irods.password=${jargon.test.irods.password3} - test3.irods.resource=${jargon.test.irods.resource3} - test.irods.host=${jargon.test.irods.host} - test.irods.port=${jargon.test.irods.port} - test.irods.zone=${jargon.test.irods.zone} - jargon.test.kerberos.user=${jargon.test.kerberos.user} - test.resource.group=${jargon.test.resource.group} - test.irods.userDN=${jargon.test.irods.userDN} - test.irods.scratch.subdir=${jargon.test.irods.scratch.subdir} - test.mac.icommand.path=${jargon.test.mac.icommand.path} - test.option.exercise.remoteexecstream=${jargon.test.option.exercise.remoteexecstream} - test.option.exercise.audit=${jargon.test.option.exercise.audit} - test.option.distributed.resources=${test.option.distributed.resources} - test.option.registration=${test.option.registration} - test.option.strictACL=${test.option.strictACL} - test.option.federated.zone=${test.option.federated.zone} - test.option.kerberos=${test.option.kerberos} - test.option.pam=${test.option.pam} - jargon.test.pam.user=${jargon.test.pam.user} - jargon.test.pam.password=${jargon.test.pam.password} - test.federated.irods.admin=${jargon.test.federated.irods.admin} - test.federated.irods.admin.password=${jargon.test.federated.irods.admin.password} - test.federated.irods.user=${jargon.test.federated.irods.user} - test.federated.irods.password=${jargon.test.federated.irods.password} - test.federated.irods.resource=${jargon.test.federated.irods.resource} - test.federated.irods.host=${jargon.test.federated.irods.host} - test.federated.irods.port=${jargon.test.federated.irods.port} - test.federated.irods.zone=${jargon.test.federated.irods.zone} - test.option.gsi=${test.option.gsi} - test.option.gsi.host=${test.option.gsi.host} - test.option.gsi.port=${test.option.gsi.port} - test.option.gsi.zone=${test.option.gsi.zone} - test.option.gsi.dn=${test.option.gsi.dn} - test.option.gsi.user=${test.option.gsi.user} - test.option.gsi.file=${test.option.gsi.file} - - - - - run - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - true - - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - - org.apache.maven.plugins - - - maven-antrun-plugin - - - [1.3,) - - - run - - - - - - - - - - - - - - diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/BasicConveyorBootstrapperImpl.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/BasicConveyorBootstrapperImpl.java deleted file mode 100644 index e1aa64ca3..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/BasicConveyorBootstrapperImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.basic; - -import org.irods.jargon.conveyor.core.BootstrapperException; -import org.irods.jargon.conveyor.core.ConveyorBootstrapper; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.core.pub.IRODSAccessObjectFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -/** - * Initial bootstrapper process that can later be factored into a more - * sophisticated processor. This class will wire together a basic functional - * conveyor processor with the default Derby database. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class BasicConveyorBootstrapperImpl implements ConveyorBootstrapper { - - private final Logger log = LoggerFactory - .getLogger(BasicConveyorBootstrapperImpl.class); - - private final ConveyorBootstrapConfiguration conveyorBootstrapConfiguration; - - private BeanFactory beanFactory; - - public BasicConveyorBootstrapperImpl( - final ConveyorBootstrapConfiguration conveyorBootstrapConfiguration) { - if (conveyorBootstrapConfiguration == null) { - throw new IllegalArgumentException( - "null conveyorBootstrapConfiguration"); - } - - this.conveyorBootstrapConfiguration = conveyorBootstrapConfiguration; - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.basic.ConveyorBootstrapper#bootstrap() - */ - @Override - public ConveyorService bootstrap( - final IRODSAccessObjectFactory irodsAccessObjectFactory) - throws BootstrapperException { - - log.info("bootstrapping..."); - - if (irodsAccessObjectFactory == null) { - throw new IllegalArgumentException("null irodsAccessObjectFactory"); - } - - try { - ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext( - new String[] { "classpath:transfer-dao-beans.xml", - "classpath:transfer-dao-hibernate-spring.cfg.xml" }); - // of course, an ApplicationContext is just a BeanFactory - beanFactory = appContext; - } catch (Exception e) { - log.error("error starting app context", e); - throw new BootstrapperException(e.getMessage()); - } - log.info("bootstrap complete..."); - ConveyorService conveyorService = (ConveyorService) beanFactory - .getBean("conveyorService"); - - conveyorService.setIrodsAccessObjectFactory(irodsAccessObjectFactory); - return conveyorService; - } - - /** - * @return the conveyorBootstrapConfiguration - */ - public ConveyorBootstrapConfiguration getConveyorBootstrapConfiguration() { - return conveyorBootstrapConfiguration; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/BasicFlowManagerService.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/BasicFlowManagerService.java deleted file mode 100644 index 314e14151..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/BasicFlowManagerService.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.basic; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.conveyor.core.FlowManagerService; -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpec; -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpecCacheService; -import org.irods.jargon.conveyor.flowmanager.flow.SelectorProcessor; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Flow Manager service handles client-side actions and workflows - * - * @author Mike Conway - DICE - * - */ -public class BasicFlowManagerService implements FlowManagerService { - - private static final Logger log = LoggerFactory - .getLogger(BasicFlowManagerService.class); - - /** - * Required dependency on conveyor service - */ - private ConveyorService conveyorService; - - /** - * Required dependency on a service to extract a cache of {@link FlowSpec} - * objects - */ - private FlowSpecCacheService flowSpecCacheService; - - /* - * eventually this could be injectable, right now it's just a simple deal - */ - private final SelectorProcessor selectorProcessor = new SelectorProcessor(); - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.FlowManagerService#setFlowSpecCacheService - * (org.irods.jargon.conveyor.flowmanager.flow.FlowSpecCacheService) - */ - @Override - public void setFlowSpecCacheService( - final FlowSpecCacheService flowSpecCacheService) - throws ConveyorExecutionException { - if (flowSpecCacheService == null) { - throw new IllegalArgumentException("null flowSpecCacheService"); - } - - this.flowSpecCacheService = flowSpecCacheService; - - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.FlowManagerService#retrieveCandidateFlowSpecs - * (org.irods.jargon.transfer.dao.domain.TransferAttempt) - */ - @Override - public List retrieveCandidateFlowSpecs( - final TransferAttempt transferAttempt) - throws ConveyorExecutionException { - - log.info("retrieveCandidateFlowSpecs()"); - if (transferAttempt == null) { - throw new IllegalArgumentException("null transfer attempt"); - } - - List candidateFlowSpecs = new ArrayList(); - - List flowSpecs = flowSpecCacheService.getFlowSpecs(); - for (FlowSpec flowSpec : flowSpecs) { - if (selectorProcessor.evaluateSelectorForTransfer(flowSpec, - transferAttempt)) { - log.info("added candidate flow spec:{}", flowSpec); - candidateFlowSpecs.add(flowSpec); - } - } - - return Collections.unmodifiableList(candidateFlowSpecs); - - } - - /** - * @return the conveyorService - */ - public ConveyorService getConveyorService() { - return conveyorService; - } - - /** - * @param conveyorService - * the conveyorService to set - */ - public void setConveyorService(final ConveyorService conveyorService) { - this.conveyorService = conveyorService; - } -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/BasicQueueManagerServiceImpl.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/BasicQueueManagerServiceImpl.java deleted file mode 100644 index 8b857a691..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/BasicQueueManagerServiceImpl.java +++ /dev/null @@ -1,771 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.basic; - -import java.sql.Timestamp; -import java.util.Date; -import java.util.List; - -import org.irods.jargon.conveyor.core.AbstractConveyorComponentService; -import org.irods.jargon.conveyor.core.ConveyorBusyException; -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.ConveyorExecutorService.ErrorStatus; -import org.irods.jargon.conveyor.core.ConveyorExecutorService.RunningStatus; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.conveyor.core.GridAccountService; -import org.irods.jargon.conveyor.core.QueueManagerService; -import org.irods.jargon.conveyor.core.RejectedTransferException; -import org.irods.jargon.conveyor.core.TransferNotFoundException; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.transfer.dao.TransferAttemptDAO; -import org.irods.jargon.transfer.dao.TransferDAO; -import org.irods.jargon.transfer.dao.TransferDAOException; -import org.irods.jargon.transfer.dao.domain.GridAccount; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.irods.jargon.transfer.dao.domain.TransferItem; -import org.irods.jargon.transfer.dao.domain.TransferStateEnum; -import org.irods.jargon.transfer.dao.domain.TransferStatusEnum; -import org.irods.jargon.transfer.dao.domain.TransferType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; - -/** - * Basic implementation of a queue manager service - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -@Transactional(rollbackFor = { ConveyorExecutionException.class }, noRollbackFor = { JargonException.class }, propagation = Propagation.REQUIRED) -public class BasicQueueManagerServiceImpl extends - AbstractConveyorComponentService implements QueueManagerService { - - /** - * Injected dependency - */ - private TransferDAO transferDAO; - - /** - * Injected dependency - */ - private TransferAttemptDAO transferAttemptDAO; - - /** - * Injected dependency - */ - private ConveyorService conveyorService; - - /** - * Injected dependency - */ - private GridAccountService gridAccountService; - - private static final Logger log = LoggerFactory - .getLogger(BasicQueueManagerServiceImpl.class); - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.QueueManagerService#preprocessQueueAtStartup - * () - */ - @Override - public void preprocessQueueAtStartup() throws ConveyorExecutionException { - - log.info("preprocessQueueAtStartup()"); - List transfers = listAllTransfersInQueue(); - - for (Transfer transfer : transfers) { - if (transfer.getTransferState() == TransferStateEnum.PROCESSING) { - log.info("found a processing transfer, set it to enqueued:{}", - transfer); - reenqueueTransferAtBootstrapTime(transfer.getId()); - } - } - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.QueueManagerService# - * enqueueRestartOfTransferOperation(long) - */ - @Override - public void enqueueRestartOfTransferOperation(final long transferId) - throws TransferNotFoundException, RejectedTransferException, - ConveyorExecutionException { - - log.info("enqueueTransferOperation()"); - - reenqueueTransfer(transferId); - - log.info("restart enqueued, will trigger the queue"); - dequeueNextOperation(); - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.QueueManagerService# - * reenqueueTransferAtBootstrapTime(long) - */ - @Override - public void reenqueueTransferAtBootstrapTime(final long transferId) - throws TransferNotFoundException, RejectedTransferException, - ConveyorExecutionException { - - log.info("reenqueueTransferAtBootstrapTime()"); - - conveyorService.getTransferAccountingManagementService() - .restartProcessingTransferAtStartup(transferId); - - log.info("restart enqueued, queue is not yet triggered..."); - - } - - /** - * @param transferId - * @throws TransferNotFoundException - * @throws ConveyorExecutionException - * @throws RejectedTransferException - */ - private void reenqueueTransfer(final long transferId) - throws TransferNotFoundException, ConveyorExecutionException, - RejectedTransferException { - if (transferId <= 0) { - throw new IllegalArgumentException("illegal transferId"); - } - - Transfer existingTransfer; - try { - existingTransfer = transferDAO.findById(transferId); - if (existingTransfer == null) { - log.error("cannot find tranfser to restart"); - throw new TransferNotFoundException("unable to find transfer"); - } - } catch (TransferDAOException e) { - throw new ConveyorExecutionException(); - } - - conveyorService.getTransferAccountingManagementService() - .prepareTransferForRestart(transferId); - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.QueueManagerService# - * enqueueRestartOfTransferOperation(long) - */ - @Override - public void enqueueResubmitOfTransferOperation(final long transferId) - throws TransferNotFoundException, RejectedTransferException, - ConveyorExecutionException { - - log.info("enqueueTransferOperation()"); - - if (transferId <= 0) { - throw new IllegalArgumentException("illegal transferId"); - } - - Transfer existingTransfer; - try { - existingTransfer = transferDAO.findById(transferId); - if (existingTransfer == null) { - log.error("cannot find tranfser to restart"); - throw new TransferNotFoundException("unable to find transfer"); - } - } catch (TransferDAOException e) { - throw new ConveyorExecutionException(); - } - // evaluateTransferForExecution(existingTransfer); - - conveyorService.getTransferAccountingManagementService() - .prepareTransferForResubmit(transferId); - - log.info("restart enqueued, will trigger the queue"); - dequeueNextOperation(); - - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.QueueManagerService#enqueueTransferOperation - * (org.irods.jargon.transfer.dao.domain.Transfer, - * org.irods.jargon.core.connection.IRODSAccount) - */ - @Override - public void enqueueTransferOperation(final Transfer transfer, - final IRODSAccount irodsAccount) throws RejectedTransferException, - ConveyorExecutionException { - - log.info("enqueueTransferOperation()"); - - if (transfer == null) { - throw new IllegalArgumentException("null transfer"); - } - - if (irodsAccount == null) { - throw new IllegalArgumentException("null irodsAccount"); - } - - log.info("transfer:{}", transfer); - log.info("irodsAccount:{}", irodsAccount); - - log.info("looking up corresponding GridAccount..."); - GridAccount gridAccount = gridAccountService - .findGridAccountByIRODSAccount(irodsAccount); - if (gridAccount == null) { - log.error("error finding grid account for irodsAccount:{}", - irodsAccount); - throw new ConveyorExecutionException( - "unable to resolve gridAccount from given irodsAccount"); - } - - log.info("building transfer..."); - - /* - * Check to see if there is any reason to reject this transfer - * (malformed, duplicate). The evaluate method will throw a rejected - * exception if appropriate - */ - long currentTime = System.currentTimeMillis(); - Date currentDate = new Date(currentTime); - - transfer.setGridAccount(gridAccount); - transfer.setTransferState(TransferStateEnum.ENQUEUED); - transfer.setUpdatedAt(currentDate); - transfer.setCreatedAt(currentDate); - - /* - * Enqueue triggers a dequeue - */ - - try { - transferDAO.save(transfer); - conveyorService.getTransferAccountingManagementService() - .prepareTransferForProcessing(transfer); - dequeueNextOperation(); - } catch (TransferDAOException e) { - log.error("error saving transfer", e); - throw new ConveyorExecutionException("error saving transfer", e); - } - - log.info("transfer added:{}", transfer); - - } - - @Override - @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) - public List listAllTransfersInQueue() - throws ConveyorExecutionException { - log.info("listAllTransfersInQueue"); - - try { - return transferDAO.findAll(); - } catch (TransferDAOException e) { - log.error("error listing all transfers", e); - throw new ConveyorExecutionException("error listing transfers", e); - } - - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.QueueManagerService#dequeueNextOperation() - */ - @Override - public void dequeueNextOperation() throws ConveyorExecutionException { - log.info("dequeueNextOperation()"); - - try { - if (getConveyorExecutorService().getRunningStatus() == RunningStatus.PAUSED - || getConveyorExecutorService().getRunningStatus() == RunningStatus.PAUSED_BUSY) { - log.info("paused, do not dequeue"); - return; - } - - getConveyorExecutorService().setBusyForAnOperation(); - } catch (ConveyorBusyException e) { - log.info("busy, ignore.."); - return; - } - - TransferAttempt transferAttempt = null; - - try { - - List transfers = transferDAO - .findByTransferState(TransferStateEnum.ENQUEUED); - - if (transfers.isEmpty()) { - log.info("nothing to process..."); - getConveyorExecutorService().setOperationCompleted(); - return; - } - - Transfer transfer = transfers.get(0); - log.info("have transfer to run... setting up the new attempt:{}", - transfer); - - // upon dequeue clear the error status - getConveyorExecutorService().setErrorStatus(ErrorStatus.OK); - transferAttempt = transferAttemptDAO - .findLastTransferAttemptForTransferByTransferId(transfer - .getId()); - - if (transferAttempt == null) { - log.error( - "transfer attempt is not available in the transfer:{}, \nwill delete [this is an error recovery step]", - transfer); - // transferDAO.delete(transfer); - // FIXME: what to do here? S - getConveyorExecutorService().setOperationCompleted(); - return; - - // throw new - // ConveyorExecutionException("cannot find transfer attempt for transfer"); - } - - transferAttempt.setAttemptStart(new Timestamp(System - .currentTimeMillis())); - transfer.setTransferState(TransferStateEnum.PROCESSING); - transfer.setUpdatedAt(new Timestamp(System.currentTimeMillis())); - transferDAO.save(transfer); - transferAttemptDAO.save(transferAttempt); - - getConveyorExecutorService().processTransfer(transferAttempt, - conveyorService); - } catch (JargonException je) { - log.error("jargon exception dequeue operation, will unlock queue"); - - if (transferAttempt != null) { - log.info("updating transfer with exception", je); - getConveyorService().getTransferAccountingManagementService() - .updateTransferAttemptWithConveyorException( - transferAttempt, je); - - } - - getConveyorExecutorService().setOperationCompleted(); - getConveyorService().getConveyorCallbackListener() - .signalUnhandledConveyorException(je); - // dequeueNextOperation(); - } catch (Exception e) { - log.error("jargon exception dequeue operation, will unlock queue"); - - if (transferAttempt != null) { - log.info("updating transfer with exception", e); - getConveyorService().getTransferAccountingManagementService() - .updateTransferAttemptWithConveyorException( - transferAttempt, e); - - } - - getConveyorExecutorService().setOperationCompleted(); - getConveyorService().getConveyorCallbackListener() - .signalUnhandledConveyorException(e); - // dequeueNextOperation(); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.QueueManagerService#processTransfer(java - * .lang.String, java.lang.String, - * org.irods.jargon.core.connection.IRODSAccount, - * org.irods.jargon.transfer.dao.domain.TransferType) - */ - @Override - public void enqueueTransferOperation(final String irodsFile, - final String localFile, final IRODSAccount irodsAccount, - final TransferType type) throws ConveyorExecutionException { - log.info("processTransfer()"); - Transfer transfer = new Transfer(); - transfer.setCreatedAt(new Timestamp(System.currentTimeMillis())); - transfer.setIrodsAbsolutePath(irodsFile); - transfer.setLocalAbsolutePath(localFile); - transfer.setTransferType(type); - log.info("ready to enqueue transfer:{}", transfer); - enqueueTransferOperation(transfer, irodsAccount); - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.QueueManagerService#purgeAllFromQueue() - */ - @Override - public void purgeAllFromQueue() throws ConveyorBusyException, - ConveyorExecutionException { - log.info("purgeAllFromQueue()"); - - log.info("see if conveyor is busy"); - - try { - getConveyorExecutorService().setBusyForAnOperation(); - } catch (ConveyorBusyException e) { - log.info("conveyor is busy, cannot purge"); - throw e; - } - - log.info("purge..."); - - try { - transferDAO.purgeEntireQueue(); - } catch (TransferDAOException e) { - log.error("jargon exception dequeue operation, will unlock queue"); - throw new ConveyorExecutionException(e); - } finally { - getConveyorExecutorService().setOperationCompleted(); - - } - - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.QueueManagerService#purgeSuccessfulFromQueue - * () - */ - @Override - public void purgeSuccessfulFromQueue() throws ConveyorBusyException, - ConveyorExecutionException { - log.info("purgeSuccessfulFromQueue()"); - - log.info("see if conveyor is busy"); - - try { - getConveyorExecutorService().setBusyForAnOperation(); - } catch (ConveyorBusyException e) { - log.info("conveyor is busy, cannot purge"); - throw e; - } - - log.debug("entering purgeSuccessful()"); - try { - List transfers = transferDAO.findAll(); - - for (Transfer transfer : transfers) { - if ((transfer.getTransferState() == TransferStateEnum.COMPLETE || transfer - .getTransferState() == TransferStateEnum.CANCELLED) - && (transfer.getLastTransferStatus() == TransferStatusEnum.OK)) { - log.info("deleting...{}", transfer); - transferDAO.delete(transfer); - } - } - - } catch (TransferDAOException e) { - log.error("jargon exception dequeue operation, will unlock queue"); - throw new ConveyorExecutionException(e); - } finally { - getConveyorExecutorService().setOperationCompleted(); - - } - - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.QueueManagerService#deleteTransferFromQueue - * (org.irods.jargon.transfer.dao.domain.Transfer) - */ - @Override - public void deleteTransferFromQueue(final Transfer transfer) - throws ConveyorBusyException, ConveyorExecutionException { - log.info("deleteTransferFromQueue()"); - - log.info("see if conveyor is busy"); - - try { - getConveyorExecutorService().setBusyForAnOperation(); - } catch (ConveyorBusyException e) { - log.info("conveyor is busy, cannot purge"); - throw e; - } - - log.info("delete transfer id:{} ...", transfer.getId()); - - try { - transferDAO.delete(transfer); - } catch (TransferDAOException e) { - log.error("jargon exception deleting transfer"); - throw new ConveyorExecutionException(e); - } finally { - getConveyorExecutorService().setOperationCompleted(); - - } - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.QueueManagerService#cancelTransfer(long) - */ - @Override - public void cancelTransfer(final long transferId) - throws TransferNotFoundException, ConveyorExecutionException { - - TransferAttempt transferAttemptToCancel; - try { - transferAttemptToCancel = transferAttemptDAO - .findLastTransferAttemptForTransferByTransferId(transferId); - if (transferAttemptToCancel == null) { - log.error("cannot find transfer to cancel"); - throw new TransferNotFoundException("unable to find transfer"); - } - - } catch (TransferDAOException e) { - log.error("error in dao finding transfer attempt by id"); - throw new ConveyorExecutionException(e); - } - - // check state of transfer attempt - if (transferAttemptToCancel.getTransfer().getTransferState() == TransferStateEnum.PROCESSING) { - - TransferAttempt current = getConveyorService() - .getConveyorExecutorService().getCurrentTransferAttempt(); - // check to see if this is the currently processing transfer attempt - if (current != null - && transferAttemptToCancel.getId().longValue() == getConveyorService() - .getConveyorExecutorService() - .getCurrentTransferAttempt().getId().longValue()) { - log.info("matched currently running transfer attempt - cancelling transfer"); - getConveyorService().getConveyorExecutorService() - .requestCancel(transferAttemptToCancel); - } else { - log.info("no current seen, but go ahead and update the database indicating that the transfer is cancelled"); - conveyorService.getTransferAccountingManagementService() - .updateTransferAfterCancellation(current); - } - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.QueueManagerService# - * initializeGivenTransferByLoadingChildren - * (org.irods.jargon.transfer.dao.domain.Transfer) - */ - @Override - @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) - public Transfer initializeGivenTransferByLoadingChildren( - final Transfer transfer) throws ConveyorExecutionException { - log.info("initializeGivenTransferByLoadingChildren"); - try { - return transferDAO.initializeChildrenForTransfer(transfer); - } catch (TransferDAOException e) { - log.error("jargon exception dequeue operation, will unlock queue"); - throw new ConveyorExecutionException(e); - } - } - - /** - * @param transferDAO - * the transferDAO to set - */ - public void setTransferDAO(final TransferDAO transferDAO) { - this.transferDAO = transferDAO; - } - - /** - * @param transferAttemptDAO - * the transferAttemptDAO to set - */ - public void setTransferAttemptDAO( - final TransferAttemptDAO transferAttemptDAO) { - this.transferAttemptDAO = transferAttemptDAO; - } - - /** - * @param gridAccountService - * the gridAccountService to set - */ - public void setGridAccountService( - final GridAccountService gridAccountService) { - this.gridAccountService = gridAccountService; - } - - /** - * @return the conveyorService - */ - public ConveyorService getConveyorService() { - return conveyorService; - } - - /** - * @param conveyorService - * the conveyorService to set - */ - public void setConveyorService(final ConveyorService conveyorService) { - this.conveyorService = conveyorService; - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.QueueManagerService#findTransferByTransferId - * (long) - */ - @Override - @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) - public Transfer findTransferByTransferId(final long transferId) - throws ConveyorExecutionException { - log.info("initializeGivenTransferByLoadingChildren"); - try { - return transferDAO.findInitializedById(transferId); - } catch (TransferDAOException e) { - log.error("error in dao finding transfer by id"); - throw new ConveyorExecutionException(e); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.QueueManagerService#saveOrUpdateTransfer - * (org.irods.jargon.transfer.dao.domain.Transfer) - */ - @Override - public void saveOrUpdateTransfer(final Transfer transfer) - throws TransferNotFoundException, ConveyorExecutionException { - log.info("saveOrUpdateTransfer()"); - - if (transfer == null) { - throw new IllegalArgumentException("null transfer"); - } - - log.info("saving transfer:{}", transfer); - - try { - transferDAO.save(transfer); - } catch (TransferDAOException e) { - log.error("error saving transfer", e); - throw new ConveyorExecutionException("error saving transfer", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.QueueManagerService# - * addTransferAttemptToTransfer(long, - * org.irods.jargon.transfer.dao.domain.TransferAttempt) - */ - @Override - public void addTransferAttemptToTransfer(final long transferId, - final TransferAttempt transferAttempt) - throws TransferNotFoundException, ConveyorExecutionException { - log.info("addTransferAttemptToTransfer"); - if (transferAttempt == null) { - throw new IllegalArgumentException("null transferAttempt"); - } - - log.info("looking up transfer by id..."); - - Transfer transfer; - - try { - transfer = transferDAO.findById(new Long(transferId)); - } catch (TransferDAOException e) { - log.error("exception finding transfer", e); - throw new ConveyorExecutionException("error finding transfe", e); - } - - if (transfer == null) { - log.error("transfer could not be found"); - throw new TransferNotFoundException("unable to find transfer"); - } - - transferAttempt.setCreatedAt(new Timestamp(System.currentTimeMillis())); - transferAttempt.setSequenceNumber(System.currentTimeMillis()); - transferAttempt.setUpdatedAt(transferAttempt.getCreatedAt()); - transferAttempt.setTransfer(transfer); - transfer.getTransferAttempts().add(transferAttempt); - log.info("attempt added"); - - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.QueueManagerService#getNextTransferItems - * (long, int, int) - */ - @Override - @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) - public List getNextTransferItems( - final long transferAttemptId, final int start, final int length) - throws ConveyorExecutionException { - List items = null; - - log.info("getNextTransferItems"); - if (transferAttemptId <= 0) { - throw new IllegalArgumentException("invalid transferId"); - } - try { - items = transferAttemptDAO.listTransferItemsInTransferAttempt( - transferAttemptId, start, length); - } catch (TransferDAOException e) { - log.error("exception retrieving transfer items", e); - throw new ConveyorExecutionException( - "error finding transfer items", e); - } - - return items; - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.QueueManagerService#getNextTransferItems - * (java.lang.Long, int, int, boolean, boolean) - */ - @Override - @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) - public List getNextTransferItems( - final Long transferAttemptId, final int start, final int length, - final boolean showSuccess, final boolean showSkipped) - throws ConveyorExecutionException { - List items = null; - - log.info("getNextTransferItems"); - if (transferAttemptId <= 0) { - throw new IllegalArgumentException("invalid transferId"); - } - try { - items = transferAttemptDAO.listTransferItemsInTransferAttempt( - transferAttemptId, start, length, showSuccess, showSkipped); - } catch (TransferDAOException e) { - log.error("exception retrieving transfer items", e); - throw new ConveyorExecutionException( - "error finding transfer items", e); - } - - return items; - } -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/BasicSychronizationManagerServiceImpl.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/BasicSychronizationManagerServiceImpl.java deleted file mode 100644 index 3bddf1088..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/BasicSychronizationManagerServiceImpl.java +++ /dev/null @@ -1,539 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.basic; - -import java.io.File; -import java.sql.Timestamp; -import java.util.Date; -import java.util.List; -import java.util.Set; - -import org.irods.jargon.conveyor.core.AbstractConveyorComponentService; -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.conveyor.core.RejectedTransferException; -import org.irods.jargon.conveyor.core.SynchronizationManagerService; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.DataNotFoundException; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.io.IRODSFile; -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.transfer.dao.SynchronizationDAO; -import org.irods.jargon.transfer.dao.TransferAttemptDAO; -import org.irods.jargon.transfer.dao.TransferDAO; -import org.irods.jargon.transfer.dao.TransferDAOException; -import org.irods.jargon.transfer.dao.domain.Synchronization; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.irods.jargon.transfer.dao.domain.TransferStateEnum; -import org.irods.jargon.transfer.dao.domain.TransferStatusEnum; -import org.irods.jargon.transfer.dao.domain.TransferType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; - -/** - * - * @author Mike Conway - DICE (www.irods.org) see - * https://code.renci.org/gf/project/jargon/ - * - */ -@Transactional(rollbackFor = { ConveyorExecutionException.class }, noRollbackFor = { JargonException.class }, propagation = Propagation.REQUIRED) -public class BasicSychronizationManagerServiceImpl extends - AbstractConveyorComponentService implements - SynchronizationManagerService { - - /** - * Injected dependency - */ - private SynchronizationDAO synchronizationDAO; - - /** - * injected dependency - */ - private TransferDAO transferDAO; - - public TransferDAO getTransferDAO() { - return transferDAO; - } - - public void setTransferDAO(final TransferDAO transferDAO) { - this.transferDAO = transferDAO; - } - - public TransferAttemptDAO getTransferAttemptDAO() { - return transferAttemptDAO; - } - - public void setTransferAttemptDAO( - final TransferAttemptDAO transferAttemptDAO) { - this.transferAttemptDAO = transferAttemptDAO; - } - - /** - * injected dependency - */ - private TransferAttemptDAO transferAttemptDAO; - - /** - * Injected dependency - */ - private ConveyorService conveyorService; - - private static final Logger log = LoggerFactory - .getLogger(BasicSychronizationManagerServiceImpl.class); - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.SynchronizationManagerService# - * listAllSynchronizations() - */ - @Override - @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) - public List listAllSynchronizations() - throws ConveyorExecutionException { - log.info("listAllSynchronizations()"); - try { - return synchronizationDAO.findAll(); - } catch (TransferDAOException e) { - log.error("error finding all", e); - throw new ConveyorExecutionException("error finding all", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.SynchronizationManagerService# - * triggerExecutionOfAnyNextPendingSynchronization() - */ - @Override - public void triggerExecutionOfAnyNextPendingSynchronization() - throws ConveyorExecutionException { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.SynchronizationManagerService# - * addOrUpdateSynchronization - * (org.irods.jargon.transfer.dao.domain.Synchronization) - */ - @Override - public void addOrUpdateSynchronization(final Synchronization synchronization) - throws ConveyorExecutionException { - - log.info("addOrUpdateSynchronization()"); - - if (synchronization == null) { - throw new IllegalArgumentException("null synchronization"); - } - - validateSynchronization(synchronization); - Date now = new Date(); - - synchronization.setUpdatedAt(now); - if (synchronization.getId() == null) { - synchronization.setCreatedAt(now); - } - - try { - synchronizationDAO.save(synchronization); - } catch (TransferDAOException e) { - log.error("error saving synchronization", e); - throw new ConveyorExecutionException( - "error saving synchronization", e); - } - - } - - /** - * Check files in synch to make sure they exist, will also verify the iRODS - * account - * - * @param synchronization - * @throws ConveyorExecutionException - */ - private void validateSynchronization(final Synchronization synchronization) - throws ConveyorExecutionException { - log.info("validateSynchronization()"); - assert synchronization != null; - - IRODSAccount irodsAccount = conveyorService.getGridAccountService() - .irodsAccountForGridAccount(synchronization.getGridAccount()); - - if (synchronization.getIrodsSynchDirectory() == null - || synchronization.getIrodsSynchDirectory().isEmpty()) { - throw new ConveyorExecutionException( - "no irods synch directory found"); - } - - IRODSFile irodsFile; - - try { - irodsFile = conveyorService - .getIrodsAccessObjectFactory() - .getIRODSFileFactory(irodsAccount) - .instanceIRODSFile(synchronization.getIrodsSynchDirectory()); - - if (!irodsFile.exists()) { - throw new ConveyorExecutionException("irodsFile does not exist"); - } - - if (!irodsFile.isDirectory()) { - throw new ConveyorExecutionException("irodsFile not collection"); - } - - } catch (JargonException e) { - throw new ConveyorExecutionException( - "jargonException checking irods synch directory"); - } - - if (synchronization.getLocalSynchDirectory() == null - || synchronization.getLocalSynchDirectory().isEmpty()) { - throw new ConveyorExecutionException( - "no local synch directory found"); - } - - File localFile = new File(synchronization.getLocalSynchDirectory()); - - if (!localFile.exists()) { - throw new ConveyorExecutionException("localFile does not exist"); - } - - if (!localFile.isDirectory()) { - throw new ConveyorExecutionException("localFile not collection"); - } - - log.info("we're valid"); - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.SynchronizationManagerService# - * deleteSynchronization - * (org.irods.jargon.transfer.dao.domain.Synchronization) - */ - @Override - public void deleteSynchronization(final Synchronization synchronization) - throws ConveyorExecutionException { - log.info("deleteSynchronization()"); - - if (synchronization == null) { - throw new IllegalArgumentException("null synchronization"); - } - - try { - synchronizationDAO.delete(synchronization); - } catch (TransferDAOException e) { - log.error("error deleting", e); - throw new ConveyorExecutionException("error deleting", e); - } - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.SynchronizationManagerService# - * purgeSynchronizationHistory - * (org.irods.jargon.transfer.dao.domain.Synchronization) - */ - @Override - public void purgeSynchronizationHistory( - final Synchronization synchronization) - throws DataNotFoundException, ConveyorExecutionException { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.SynchronizationManagerService# - * triggerSynchronizationNow - * (org.irods.jargon.transfer.dao.domain.Synchronization) - */ - @Override - public void triggerSynchronizationNow(final Synchronization synchronization) - throws RejectedTransferException, ConveyorExecutionException { - - log.info(" triggerSynchronizationNow()"); - - if (synchronization == null) { - throw new IllegalArgumentException("null synchronization"); - } - - log.info("scheduling..."); - scheduleASynchronization(synchronization); - } - - private void scheduleASynchronization(Synchronization synchronization) - throws RejectedTransferException, ConveyorExecutionException { - log.info("scheduling a synchronization:{}", synchronization); - boolean alreadyInQueue = false; - try { - synchronization = synchronizationDAO.findById(synchronization - .getId()); - synchronization.getTransfers(); - } catch (TransferDAOException e) { - log.error("error looking up synchronization data", e); - throw new ConveyorExecutionException("error looking up a synch", e); - } - Set transfers = synchronization.getTransfers(); - for (Transfer transfer : transfers) { - if (transfer.getTransferState() == TransferStateEnum.ENQUEUED - || transfer.getTransferState() == TransferStateEnum.PROCESSING - || transfer.getTransferState() == TransferStateEnum.PAUSED) { - log.info( - "will not schedule this synch, as this synch transfer is already in the queue:{}", - transfer); - alreadyInQueue = true; - break; - } - } - - if (alreadyInQueue) { - return; - } - - log.info("no conflicting synch in queue, go ahead and schedule"); - - Transfer transfer = new Transfer(); - Date now = new Date(); - transfer.setCreatedAt(now); - transfer.setGridAccount(synchronization.getGridAccount()); - transfer.setIrodsAbsolutePath(synchronization.getIrodsSynchDirectory()); - transfer.setLocalAbsolutePath(synchronization.getLocalSynchDirectory()); - transfer.setResourceName(synchronization.getGridAccount() - .getDefaultResource()); - transfer.setSynchronization(synchronization); - synchronization.getTransfers().add(transfer); - transfer.setTransferState(TransferStateEnum.ENQUEUED); - transfer.setTransferType(TransferType.SYNCH); - transfer.setUpdatedAt(now); - try { - - // transferDAO.save(transfer); - synchronizationDAO.save(synchronization); - } catch (TransferDAOException ex) { - log.error("error saving synch", ex); - throw new ConveyorExecutionException("error savign synch", ex); - } - - log.info("built transfer for synch:{}", transfer); - - IRODSAccount irodsAccount = conveyorService.getGridAccountService() - .irodsAccountForGridAccount(synchronization.getGridAccount()); - conveyorService.getQueueManagerService().enqueueTransferOperation( - transfer, irodsAccount); - - log.info("synchronization enqueued"); - - } - - /** - * @return the synchronizationDAO - */ - public SynchronizationDAO getSynchronizationDAO() { - return synchronizationDAO; - } - - /** - * @param synchronizationDAO - * the synchronizationDAO to set - */ - public void setSynchronizationDAO( - final SynchronizationDAO synchronizationDAO) { - this.synchronizationDAO = synchronizationDAO; - } - - /** - * @return the conveyorService - */ - public ConveyorService getConveyorService() { - return conveyorService; - } - - /** - * @param conveyorService - * the conveyorService to set - */ - public void setConveyorService(final ConveyorService conveyorService) { - this.conveyorService = conveyorService; - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.SynchronizationManagerService#findById - * (long) - */ - @Override - @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) - public Synchronization findById(final long id) - throws ConveyorExecutionException { - try { - return synchronizationDAO.findById(id); - } catch (TransferDAOException e) { - log.error("error finding by id", e); - throw new ConveyorExecutionException( - "could not find the synchronization by id", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.SynchronizationManagerService# - * updateSynchronizationWithWarningCompletion - * (org.irods.jargon.core.transfer.TransferStatus, - * org.irods.jargon.transfer.dao.domain.TransferAttempt) - */ - @Override - public void updateSynchronizationWithWarningCompletion( - final TransferStatus transferStatus, - final TransferAttempt transferAttempt) - throws ConveyorExecutionException { - log.info("updateSynchronizationWithWarningCompletion()"); - - if (transferStatus == null) { - throw new IllegalArgumentException("null transferStatus"); - } - - if (transferAttempt == null) { - throw new IllegalArgumentException("null transferAtempt"); - } - - log.info("delegate update of transfer to accounting management service..."); - getConveyorService().getTransferAccountingManagementService() - .updateTransferAfterOverallWarningByFileErrorThreshold( - transferStatus, transferAttempt); - Synchronization synchronization = transferAttempt.getTransfer() - .getSynchronization(); - if (synchronization == null) { - throw new ConveyorExecutionException( - "no synchronization configured for the transfer"); - } - - log.info("updating synchronization for this success..."); - synchronization - .setLastSynchronizationStatus(TransferStatusEnum.WARNING); - synchronization.setLastSynchronized(new Date()); - try { - synchronizationDAO.save(synchronization); - } catch (TransferDAOException e) { - log.info("error saving synchronization"); - throw new ConveyorExecutionException(e); - } - - } - - @Override - public void updateSynchronizationWithSuccessfulCompletion( - final TransferStatus transferStatus, - final TransferAttempt transferAttempt) - throws ConveyorExecutionException { - log.info("updateSynchronizationWithSuccessfulCompletion()"); - - if (transferStatus == null) { - throw new IllegalArgumentException("null transferStatus"); - } - - if (transferAttempt == null) { - throw new IllegalArgumentException("null transferAtempt"); - } - - log.info("update of transfer..."); - - Transfer transfer = transferAttempt.getTransfer(); - - transfer.setLastTransferStatus(TransferStatusEnum.OK); - transfer.setTransferState(TransferStateEnum.COMPLETE); - transfer.setUpdatedAt(new Timestamp(System.currentTimeMillis())); - transferAttempt - .setAttemptEnd(new Timestamp(System.currentTimeMillis())); - transferAttempt.setAttemptStatus(TransferStatusEnum.OK); - transferAttempt.setUpdatedAt(transferAttempt.getAttemptEnd()); - transferAttempt.setErrorMessage(""); - Synchronization synchronization = transfer.getSynchronization(); - if (synchronization == null) { - throw new ConveyorExecutionException( - "no synchronization configured for the transfer"); - } - - log.info("updating synchronization for this success..."); - synchronization.setLastSynchronizationStatus(TransferStatusEnum.OK); - synchronization.setLastSynchronized(new Date()); - - log.info("updated transfer attempt:{}", transferAttempt); - - try { - synchronizationDAO.save(synchronization); - // transferAttemptDAO.save(transferAttempt); - // transferDAO.save(transfer); - } catch (TransferDAOException ex) { - log.error("transferDAOException on save of transfer data", ex); - throw new ConveyorExecutionException( - "error saving transfer attempt", ex); - } - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.SynchronizationManagerService# - * updateSynchronizationWithFailure - * (org.irods.jargon.core.transfer.TransferStatus, - * org.irods.jargon.transfer.dao.domain.TransferAttempt) - */ - @Override - public void updateSynchronizationWithFailure( - final TransferStatus transferStatus, - final TransferAttempt transferAttempt) - throws ConveyorExecutionException { - log.info("updateSynchronizationWithFailure()"); - - if (transferStatus == null) { - throw new IllegalArgumentException("null transferStatus"); - } - - if (transferAttempt == null) { - throw new IllegalArgumentException("null transferAtempt"); - } - - log.info("delegate update of transfer to accounting management service..."); - getConveyorService().getTransferAccountingManagementService() - .updateTransferAfterOverallFailure(transferStatus, - transferAttempt); - Synchronization synchronization = transferAttempt.getTransfer() - .getSynchronization(); - if (synchronization == null) { - throw new ConveyorExecutionException( - "no synchronization configured for the transfer"); - } - - log.info("updating synchronization for this success..."); - synchronization.setLastSynchronizationStatus(TransferStatusEnum.ERROR); - synchronization.setLastSynchronized(new Date()); - synchronization.setLastSynchronizationMessage(transferAttempt - .getErrorMessage()); - try { - synchronizationDAO.save(synchronization); - } catch (TransferDAOException e) { - log.info("error saving synchronization"); - throw new ConveyorExecutionException(e); - } - - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/ConfigurationServiceImpl.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/ConfigurationServiceImpl.java deleted file mode 100644 index 7a0dad08d..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/ConfigurationServiceImpl.java +++ /dev/null @@ -1,402 +0,0 @@ -package org.irods.jargon.conveyor.basic; - -import java.util.Date; -import java.util.List; -import java.util.Properties; - -import org.irods.jargon.conveyor.core.AbstractConveyorComponentService; -import org.irods.jargon.conveyor.core.CachedConveyorConfigurationProperties; -import org.irods.jargon.conveyor.core.ConfigurationPropertyConstants; -import org.irods.jargon.conveyor.core.ConfigurationService; -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.IRODSAccessObjectFactory; -import org.irods.jargon.core.transfer.TransferControlBlock; -import org.irods.jargon.transfer.dao.ConfigurationPropertyDAO; -import org.irods.jargon.transfer.dao.TransferDAOException; -import org.irods.jargon.transfer.dao.domain.ConfigurationProperty; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.transaction.annotation.Transactional; - -/** - * Service to manage configuration information for transfer engine. The - * configuration is maintained as key/value pair properties. As such, it is - * intended that clients that are built on top of the transfer engine library - * can utilize this for application specific configuration storage. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -@Transactional(rollbackFor = { ConveyorExecutionException.class }) -public class ConfigurationServiceImpl extends AbstractConveyorComponentService - implements ConfigurationService { - - private ConfigurationPropertyDAO configurationPropertyDAO; - private CachedConveyorConfigurationProperties cachedConveyorConfigurationProperties = null; - private final Object propsLockObject = new Object(); - public static final String TEAR_OFF_MODE = "tear.off.mode"; - - private final Logger log = LoggerFactory - .getLogger(ConfigurationServiceImpl.class); - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.ConfigurationService#isInTearOffMode() - */ - @Override - public boolean isInTearOffMode() throws ConveyorExecutionException { - ConfigurationProperty property = findConfigurationPropertyByKey(TEAR_OFF_MODE); - boolean inTearOff = false; - if (property != null) { - inTearOff = Boolean.parseBoolean(property.getPropertyValue()); - } - - return inTearOff; - } - - /** - * @return the configurationPropertyDAO - */ - public ConfigurationPropertyDAO getConfigurationPropertyDAO() { - return configurationPropertyDAO; - } - - /** - * @param configurationPropertyDAO - * the configurationPropertyDAO to set - */ - public void setConfigurationPropertyDAO( - final ConfigurationPropertyDAO configurationPropertyDAO) { - this.configurationPropertyDAO = configurationPropertyDAO; - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.ConfigurationService# - * listConfigurationProperties() - */ - @Override - public List listConfigurationProperties() - throws ConveyorExecutionException { - log.info("listConfigurationProperties()"); - try { - return configurationPropertyDAO.findAll(); - } catch (TransferDAOException e) { - log.error("DAO exception", e); - throw new ConveyorExecutionException(e); - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.ConfigurationService# - * findConfigurationServiceByKey(java.lang.String) - */ - @Override - public ConfigurationProperty findConfigurationPropertyByKey( - final String configurationKey) throws ConveyorExecutionException { - if (configurationKey == null || configurationKey.isEmpty()) { - throw new IllegalArgumentException( - "configurationKey is null or empty"); - } - log.info("findConfigurationServiceByKey() key = {}", configurationKey); - try { - return configurationPropertyDAO.findByPropertyKey(configurationKey); - } catch (TransferDAOException e) { - log.error("DAO exception", e); - throw new ConveyorExecutionException(e); - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.ConfigurationService# - * deleteConfigurationProperty - * (org.irods.jargon.transfer.dao.domain.ConfigurationProperty) - */ - @Override - public void deleteConfigurationProperty( - final ConfigurationProperty configurationProperty) - throws ConveyorExecutionException { - - if (configurationProperty == null) { - throw new IllegalArgumentException("null configurationProperty"); - } - - log.info("deleteConfigurationProperty(ConfigurationProperty) with: {}", - configurationProperty); - - try { - configurationPropertyDAO.delete(configurationProperty); - } catch (TransferDAOException e) { - log.error("DAO exception", e); - throw new ConveyorExecutionException(e); - } - - log.info("configuration deleted"); - updateCachedConveyorConfigurationProperties(); - - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.ConfigurationService#addConfigurationProperty - * (org.irods.jargon.transfer.dao.domain.ConfigurationProperty) - */ - @Override - public ConfigurationProperty addConfigurationProperty( - final ConfigurationProperty configurationProperty) - throws ConveyorExecutionException { - - if (configurationProperty == null) { - throw new IllegalArgumentException("null configurationProperty"); - } - - log.info("addConfigurationProperty(ConfigurationProperty) with: {}", - configurationProperty); - - try { - Date theDate = new Date(); - - if (configurationProperty.getCreatedAt() == null) { - configurationProperty.setCreatedAt(theDate); - } - - configurationProperty.setUpdatedAt(theDate); - - configurationPropertyDAO.saveOrUpdate(configurationProperty); - } catch (TransferDAOException e) { - log.error("dao error updating configuration", e); - throw new ConveyorExecutionException(e); - } - - log.info("configuration property added"); - updateCachedConveyorConfigurationProperties(); - - return configurationProperty; - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.ConfigurationService# - * updateConfigurationProperty - * (org.irods.jargon.transfer.dao.domain.ConfigurationProperty) - */ - @Override - public void updateConfigurationProperty( - final ConfigurationProperty configurationProperty) - throws ConveyorExecutionException { - - if (configurationProperty == null) { - throw new IllegalArgumentException("null configurationProperty"); - } - - log.info("updateConfigurationProperty(ConfigurationProperty) with: {}", - configurationProperty); - - try { - configurationPropertyDAO.saveOrUpdate(configurationProperty); - } catch (TransferDAOException e) { - log.error("dao error updating configuration", e); - throw new ConveyorExecutionException(e); - } - - log.info("configuration property updated"); - updateCachedConveyorConfigurationProperties(); - - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.ConfigurationService#exportProperties() - */ - @Override - public Properties exportProperties() throws ConveyorExecutionException { - log.info("exportProperties()"); - Properties properties = new Properties(); - - List configurationProperties = null; - try { - configurationProperties = configurationPropertyDAO.findAll(); - } catch (TransferDAOException e) { - log.error("error finding all", e); - throw new ConveyorExecutionException(e); - } - - for (ConfigurationProperty configurationProperty : configurationProperties) { - log.info("adding configuration property from database: {}", - configurationProperty); - properties.put(configurationProperty.getPropertyKey(), - configurationProperty.getPropertyValue()); - } - - return properties; - - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.ConfigurationService#importProperties( - * java.util.Properties) - */ - @Override - public void importProperties(final Properties propertiesToImport) - throws ConveyorExecutionException { - - if (propertiesToImport == null) { - throw new IllegalArgumentException("null propertiesToImport"); - } - - log.info("importing properties: {}", propertiesToImport); - - ConfigurationProperty configurationProperty = null; - log.info("adding/updating properties based on passed in values"); - - String propVal; - String propKey; - - for (Object key : propertiesToImport.keySet()) { - propVal = (String) propertiesToImport.get(key); - propKey = (String) key; - configurationProperty = findConfigurationPropertyByKey(propKey); - - if (configurationProperty == null) { - configurationProperty = new ConfigurationProperty(); - configurationProperty.setCreatedAt(new Date()); - configurationProperty.setPropertyKey((String) key); - configurationProperty.setPropertyValue(propVal); - } else { - configurationProperty.setPropertyValue(propVal); - configurationProperty.setUpdatedAt(new Date()); - } - try { - configurationPropertyDAO.saveOrUpdate(configurationProperty); - } catch (TransferDAOException e) { - log.error("error adding property: {}", configurationProperty, e); - throw new ConveyorExecutionException(e); - } - - log.debug( - "added/updated configuration property from provided properties:{}", - configurationProperty); - updateCachedConveyorConfigurationProperties(); - - } - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.ConfigurationService# - * buildDefaultTransferControlBlockBasedOnConfiguration(java.lang.String, - * org.irods.jargon.core.pub.IRODSAccessObjectFactory) - */ - @Override - public TransferControlBlock buildDefaultTransferControlBlockBasedOnConfiguration( - final String restartPath, - final IRODSAccessObjectFactory irodsAccessObjectFactory) - throws ConveyorExecutionException { - - log.info("buildDefaultTransferControlBlockBasedOnConfiguration()"); - String myRestartPath; - - if (restartPath == null) { - myRestartPath = ""; - } else { - myRestartPath = restartPath; - } - - if (irodsAccessObjectFactory == null) { - throw new IllegalArgumentException("null irodsAccessObjectFactory"); - } - - try { - TransferControlBlock tcb; - - tcb = irodsAccessObjectFactory - .buildDefaultTransferControlBlockBasedOnJargonProperties(); - tcb.setRestartAbsolutePath(myRestartPath); - - synchronized (propsLockObject) { - tcb.setMaximumErrorsBeforeCanceling(getCachedConveyorConfigurationProperties() - .getMaxErrorsBeforeCancel()); - } - return tcb; - } catch (JargonException e) { - log.error("error building transfer control block", e); - throw new ConveyorExecutionException( - "cannot build transfer control block", e); - } - } - - /** - * This should be called whenever properties are updated or altered, this - * translates the key/value properties into a POJO and caches it for quick - * access - * - * @throws ConveyorExecutionException - */ - private void updateCachedConveyorConfigurationProperties() - throws ConveyorExecutionException { - - List props = listConfigurationProperties(); - CachedConveyorConfigurationProperties cachedProps = new CachedConveyorConfigurationProperties(); - - for (ConfigurationProperty property : props) { - log.info("property:{}", property); - if (property.getPropertyKey().equals( - ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY)) { - cachedProps.setLogSuccessfulTransfers(property - .propertyValueAsBoolean()); - } else if (property - .getPropertyKey() - .equals(ConfigurationPropertyConstants.MAX_ERRORS_BEFORE_CANCEL_KEY)) { - cachedProps.setMaxErrorsBeforeCancel(property - .propertyValueAsInt()); - } - } - - synchronized (propsLockObject) { - cachedConveyorConfigurationProperties = cachedProps; - } - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.ConfigurationService# - * getCachedConveyorConfigurationProperties() - */ - @Override - public synchronized CachedConveyorConfigurationProperties getCachedConveyorConfigurationProperties() - throws ConveyorExecutionException { - - log.info("getCachedConveyorConfigurationProperties"); - synchronized (propsLockObject) { - - if (cachedConveyorConfigurationProperties == null) { - log.info("need to initialize configuration properties"); - updateCachedConveyorConfigurationProperties(); - } - return cachedConveyorConfigurationProperties; - } - - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/ConveyorBootstrapConfiguration.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/ConveyorBootstrapConfiguration.java deleted file mode 100644 index f275d4f03..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/ConveyorBootstrapConfiguration.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.basic; - -/** - * Configuration data for the BasicConveyorBootstrapper that will - * configure the delivered BasicConveyorService. A simple value - * object. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class ConveyorBootstrapConfiguration { - - private String passPhrase = null; - private String databaseURL = null; - private String databaseUser = null; - private String databasePassword = null; - - public String getPassPhrase() { - return passPhrase; - } - - public void setPassPhrase(final String passPhrase) { - this.passPhrase = passPhrase; - } - - public String getDatabaseURL() { - return databaseURL; - } - - public void setDatabaseURL(final String databaseURL) { - this.databaseURL = databaseURL; - } - - public String getDatabaseUser() { - return databaseUser; - } - - public void setDatabaseUser(final String databaseUser) { - this.databaseUser = databaseUser; - } - - public String getDatabasePassword() { - return databasePassword; - } - - public void setDatabasePassword(final String databasePassword) { - this.databasePassword = databasePassword; - } - - /** - * - */ - public ConveyorBootstrapConfiguration() { - - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/GridAccountServiceImpl.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/GridAccountServiceImpl.java deleted file mode 100644 index 5200d5824..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/GridAccountServiceImpl.java +++ /dev/null @@ -1,719 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.basic; - -import java.util.List; - -import org.irods.jargon.conveyor.core.AbstractConveyorComponentService; -import org.irods.jargon.conveyor.core.ConveyorBusyException; -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.GridAccountService; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.connection.auth.AuthResponse; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.utils.MiscIRODSUtils; -import org.irods.jargon.datautils.datacache.CacheEncryptor; -import org.irods.jargon.transfer.dao.GridAccountDAO; -import org.irods.jargon.transfer.dao.KeyStoreDAO; -import org.irods.jargon.transfer.dao.TransferDAOException; -import org.irods.jargon.transfer.dao.domain.GridAccount; -import org.irods.jargon.transfer.dao.domain.KeyStore; -import org.irods.jargon.transfer.exception.PassPhraseInvalidException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.transaction.annotation.Transactional; - -/** - * Manages the underlying grid accounts (user identity) for the transfer manager - *

- * Note that methods that rely on encryption of the password based on the cached - * pass phrase are synchronized. In addition, any methods that could potentially - * impact a running transfer (e.g. changing the password on an account that may - * be referenced by a running transfer) are guarded by a lock on the transfer - * execution queue. Such operations will return a - * ConveyorBusyException as noted in the method signatures when - * operations cannot be completed due to queue status. These operations may be - * retried when the queue is idle. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -@Transactional(rollbackFor = { ConveyorExecutionException.class }) -public class GridAccountServiceImpl extends AbstractConveyorComponentService - implements GridAccountService { - - /** - * Injected dependency on {@link KeyStoreDAO} - */ - private KeyStoreDAO keyStoreDAO; - - /** - * Stored pass phrase, this is accessed in a thread-safe manner. - */ - private String cachedPassPhrase = ""; - - private CacheEncryptor cacheEncryptor = null; - - private static final Logger log = LoggerFactory - .getLogger(GridAccountServiceImpl.class); - - /** - * Injected dependency on {@link GridAccountDAO} - */ - private GridAccountDAO gridAccountDAO; - - public GridAccountDAO getGridAccountDAO() { - return gridAccountDAO; - } - - public void setGridAccountDAO(final GridAccountDAO gridAccountDAO) { - this.gridAccountDAO = gridAccountDAO; - } - - public KeyStoreDAO getKeyStoreDAO() { - return keyStoreDAO; - } - - public void setKeyStoreDAO(final KeyStoreDAO keyStoreDAO) { - this.keyStoreDAO = keyStoreDAO; - } - - /** - * - */ - public GridAccountServiceImpl() { - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.GridAccountService#storePassPhrase(java - * .lang.String) - */ - @Override - public KeyStore changePassPhraseWhenAlreadyValidated(final String passPhrase) - throws ConveyorBusyException, PassPhraseInvalidException, - ConveyorExecutionException { - - log.info("storePassPhrase()"); - if (passPhrase == null || passPhrase.isEmpty()) { - throw new IllegalArgumentException("null passPhrase"); - } - - synchronized (this) { - - if (!isValidated()) { - throw new PassPhraseInvalidException( - "The current pass phrase is not validated, cannot replace"); - } - - try { - getConveyorExecutorService().setBusyForAnOperation(); - return replacePassPhrase(passPhrase); - } finally { - getConveyorExecutorService().setOperationCompleted(); - } - } - - } - - @Override - public void rememberDefaultStorageResource(final String resourceName, - final IRODSAccount irodsAccount) throws ConveyorExecutionException { - - log.info("rememberDefaultStorageResource()"); - - if (resourceName == null) { - throw new IllegalArgumentException("null resourceName"); - } - - if (irodsAccount == null) { - throw new IllegalArgumentException("null irodsAccount"); - } - - log.info("resourceName:{}", resourceName); - log.info("irodsAccount:{}", irodsAccount); - - GridAccount gridAccount = findGridAccountByIRODSAccount(irodsAccount); - - if (gridAccount == null) { - log.error("cannot find grid account for irodsAccount:{}", - irodsAccount); - throw new ConveyorExecutionException( - "cannot find grid account for iRODS account"); - } - - gridAccount.setDefaultResource(resourceName); - log.info("default resource name is set"); - } - - /** - * Replace the current pass phrase with a new one, including resetting all - * stored grid accounts to the new phrase. Note that the queue should be - * locked (set to busy) before calling this operation, and unlocked - * afterwards. - * - * @param passPhrase - * @return - * @throws ConveyorExecutionException - * @throws PassPhraseInvalidException - */ - private KeyStore replacePassPhrase(final String passPhrase) - throws ConveyorExecutionException, PassPhraseInvalidException { - log.info("looking up keyStore.."); - - log.info("storePassPhrase()"); - if (passPhrase == null || passPhrase.isEmpty()) { - throw new IllegalArgumentException("null passPhrase"); - } - - String oldPassPhrase = getCachedPassPhrase(); - - KeyStore keyStore = storeGivenPassPhraseInKeyStoreAndSetAsCached(passPhrase); - - log.info("refreshing cacheEncryptor with the new pass phrase..."); - cacheEncryptor = new CacheEncryptor(getCachedPassPhrase()); - - log.info("updating stored grid accounts with new pass phrase..."); - updateStoredGridAccountsForNewPassPhrase(oldPassPhrase, passPhrase); - log.info("stored grid accounts updated"); - - return keyStore; - } - - /** - * Make the given pass phrase the current one, and - * - * @param passPhrase - * @return - * @throws ConveyorExecutionException - * @throws PassPhraseInvalidException - */ - private KeyStore storeGivenPassPhraseInKeyStoreAndSetAsCached( - final String passPhrase) throws ConveyorExecutionException, - PassPhraseInvalidException { - log.info("looking up keyStore.."); - - KeyStore keyStore; - try { - keyStore = keyStoreDAO.findById(KeyStore.KEY_STORE_PASS_PHRASE); - } catch (TransferDAOException e) { - log.error("unable to look up prior key store", e); - throw new ConveyorExecutionException( - "error looking up prior key store", e); - } - - String hashOfPassPhrase; - try { - hashOfPassPhrase = MiscIRODSUtils - .computeMD5HashOfAStringValue(passPhrase); - } catch (JargonException e) { - log.error("unable to create hash of pass phrase", e); - throw new ConveyorExecutionException( - "error creating hash of pass phrase to store", e); - } - - log.info("update or add the KeyStore"); - if (keyStore == null) { - log.debug("no keyStore found, create a new one"); - keyStore = new KeyStore(); - keyStore.setId(KeyStore.KEY_STORE_PASS_PHRASE); - keyStore.setValue(hashOfPassPhrase); - } else { - // keystore already present, see if I had validated first - if (!isValidated()) { - log.error("cannot store, the pass phrase was never validated"); - throw new PassPhraseInvalidException( - "cannot store pass phrase, need to validate first"); - } - log.info("updating key store with new pass phrase"); - keyStore.setValue(hashOfPassPhrase); - } - - try { - keyStoreDAO.save(keyStore); - } catch (TransferDAOException e) { - log.error("unable to look up prior key store", e); - throw new ConveyorExecutionException( - "error looking up prior key store", e); - } - - log.info("key store saved"); - log.info("new key store, consider it validated and cache it"); - cachedPassPhrase = passPhrase; - return keyStore; - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.GridAccountService# - * addOrUpdateGridAccountBasedOnIRODSAccount - * (org.irods.jargon.core.connection.IRODSAccount) - */ - @Override - public GridAccount addOrUpdateGridAccountBasedOnIRODSAccount( - final IRODSAccount irodsAccount) throws PassPhraseInvalidException, - ConveyorExecutionException { - - log.info("addOrUpdateGridAccountBasedOnIRODSAccount"); - - return addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount, null); - } - - @Override - public GridAccount addOrUpdateGridAccountBasedOnIRODSAccount( - final IRODSAccount irodsAccount, final AuthResponse authResponse) - throws PassPhraseInvalidException, ConveyorExecutionException { - - log.info("addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount, authResponse)"); - - if (irodsAccount == null) { - throw new IllegalArgumentException("null irodsAccount"); - } - log.info("irodsAccount:{}", irodsAccount); - - if (!isValidated()) { - throw new ConveyorExecutionException( - "pass phrase has not been validated"); - } - - log.info("checking if the grid account exists"); - GridAccount gridAccount = null; - try { - gridAccount = gridAccountDAO.findByHostZoneAndUserName( - irodsAccount.getHost(), irodsAccount.getZone(), - irodsAccount.getUserName()); - } catch (TransferDAOException e) { - log.error("exception accessing grid account data", e); - throw new ConveyorExecutionException("error getting grid account", - e); - } - - if (cacheEncryptor == null) { - cacheEncryptor = new CacheEncryptor(getCachedPassPhrase()); - } - - if (gridAccount == null) { - log.info("no grid account, create a new one"); - log.info("creating grid account and enrypting password"); - gridAccount = new GridAccount(irodsAccount); - } - - try { - gridAccount.setPassword(new String(cacheEncryptor - .encrypt(irodsAccount.getPassword()))); - gridAccount.setDefaultResource(irodsAccount - .getDefaultStorageResource()); - gridAccount.setDefaultPath(irodsAccount.getHomeDirectory()); - gridAccount.setAuthScheme(irodsAccount.getAuthenticationScheme()); - gridAccount.setPort(irodsAccount.getPort()); - - if (authResponse != null) { - gridAccount.setRunAsAuthScheme(authResponse - .getAuthenticatedIRODSAccount() - .getAuthenticationScheme()); - gridAccount.setRunAsPassword(authResponse - .getAuthenticatedIRODSAccount().getPassword()); - gridAccount.setRunAsUserName(authResponse - .getAuthenticatedIRODSAccount().getUserName()); - } else { - gridAccount.setRunAsAuthScheme(null); - gridAccount.setRunAsPassword(null); - gridAccount.setRunAsUserName(null); - } - - } catch (JargonException e) { - log.error("error encrypting password with pass phrase", e); - throw new ConveyorExecutionException(e); - } - - try { - gridAccountDAO.save(gridAccount); - } catch (TransferDAOException e) { - log.error("error saving grid account:{}", gridAccount, e); - throw new ConveyorExecutionException("error saving grid account", e); - } - - log.info("grid account saved:{}", gridAccount); - return gridAccount; - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.GridAccountService#validatePassPhrase( - * java.lang.String) - */ - @Override - public void validatePassPhrase(final String passPhrase) - throws ConveyorBusyException, PassPhraseInvalidException, - ConveyorExecutionException { - - log.info("validatePassPhrase()"); - - if (passPhrase == null || passPhrase.isEmpty()) { - throw new IllegalArgumentException("null or empty passPhrase"); - } - - String hashOfPassPhrase; - try { - hashOfPassPhrase = MiscIRODSUtils - .computeMD5HashOfAStringValue(passPhrase); - } catch (JargonException e) { - log.error("error computing hash of supplied passPhrase", e); - throw new ConveyorExecutionException("error computing pass phrase", - e); - } - log.info("hash of supplied pass phrase:{}", hashOfPassPhrase); - - /* - * look up the existing pass phrase, if no pass phrase is found, the new - * pass phrase is used and all accounts are cleared. You should not have - * accounts stored and no key store, but why not just gracefully handle - * a weird situation. - * - * This method requires the queue to be idle and will set it to busy - * while the operation completes. This may be overkill, but seems neater - * conceptually. - */ - - synchronized (this) { - try { - getConveyorExecutorService().setBusyForAnOperation(); - log.info("looking up existing pass phrase"); - KeyStore keyStore = keyStoreDAO - .findById(KeyStore.KEY_STORE_PASS_PHRASE); - if (keyStore == null) { - log.info("no keystore found, save the pass phrase"); - keyStore = storeGivenPassPhraseInKeyStoreAndSetAsCached(passPhrase); - } else { - log.info("keyStore found..."); - if (!keyStore.getValue().equals(hashOfPassPhrase)) { - log.error("pass phrase is invalid"); - cachedPassPhrase = ""; - throw new PassPhraseInvalidException( - "invalid pass phrase"); - } else { - cachedPassPhrase = passPhrase; - } - } - - log.info("refreshing cacheEncryptor with the new pass phrase..."); - cacheEncryptor = new CacheEncryptor(getCachedPassPhrase()); - log.info("cache encrypter refreshed with pass phrase"); - } catch (TransferDAOException e) { - log.error("error finding pass phrase in key store", e); - throw new ConveyorExecutionException( - "unable to find pass phrase in key store"); - } finally { - log.info("ok, now set the operation completed, I've got the pass phrase cached"); - getConveyorExecutorService().setOperationCompleted(); - } - } - - } - - /** - * This method will take a changed pass phrase and re-encrypt the stored - * password information - * - * @param previousPassPhrase - * @param passPhrase - * @throws ConveyorExecutionException - */ - private void updateStoredGridAccountsForNewPassPhrase( - final String previousPassPhrase, final String passPhrase) - throws ConveyorExecutionException { - log.info("updateStoredGridAccountsForNewPassPhrase"); - try { - List gridAccounts = gridAccountDAO.findAll(); - - if (!gridAccounts.isEmpty()) { - if (previousPassPhrase == null || previousPassPhrase.isEmpty()) { - throw new ConveyorExecutionException( - "no cached pass phrase, and accounts already exist"); - } - } - - /* - * Create an deryptor using the 'old' cached pass phrase, the stored - * passwords are decrypted and then re-enrypted using the new pass - * phrase. - * - * Note that the instance level cacheEncryptor should be set to the - * new pass phrase before this method is called. - * - * The methods in this class are synchronized, so we shouldn't have - * issues with multiple simultaneous operations on the cache - * encryptor or stored pass phrase. - */ - CacheEncryptor decryptingCacheEncryptor = new CacheEncryptor( - previousPassPhrase); - - for (GridAccount gridAccount : gridAccounts) { - log.info("updating:{}", gridAccount); - String unencryptedPassword = decryptingCacheEncryptor - .decrypt(gridAccount.getPassword()); - gridAccount.setPassword(cacheEncryptor - .encrypt(unencryptedPassword)); - gridAccountDAO.save(gridAccount); - log.info("password re-encrypted and saved"); - } - - } catch (TransferDAOException e) { - log.error("error updating stored grid accounts with pass phrase", e); - throw new ConveyorExecutionException( - "error updated stored accounts", e); - } catch (JargonException e) { - log.error("error updating stored grid accounts with pass phrase", e); - throw new ConveyorExecutionException( - "error updated stored accounts", e); - } - - } - - /** - * Basic check that determines if the pass phrase used to encrypt cached - * passwords is saved - * - * @return boolean that will be true if the pass - * phrase is validated - */ - private synchronized boolean isValidated() { - if (cachedPassPhrase == null || cachedPassPhrase.isEmpty()) { - return false; - } else { - return true; - } - } - - /** - * @return the cachedPassPhrase which is a String that is used - * to encrypt the passwords stored in the transfer queue. - */ - @Override - public synchronized String getCachedPassPhrase() { - return cachedPassPhrase; - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.GridAccountService# - * findGridAccountByIRODSAccount - * (org.irods.jargon.core.connection.IRODSAccount) - */ - @Override - public GridAccount findGridAccountByIRODSAccount( - final IRODSAccount irodsAccount) throws ConveyorExecutionException { - log.info("findGridAccountByIRODSAccount()"); - if (irodsAccount == null) { - throw new IllegalArgumentException("null irodsAccount"); - } - log.info("irodsAccount:{}", irodsAccount); - - if (!isValidated()) { - throw new ConveyorExecutionException( - "pass phrase has not been validated"); - } - - try { - return gridAccountDAO.findByHostZoneAndUserName( - irodsAccount.getHost(), irodsAccount.getZone(), - irodsAccount.getUserName()); - } catch (TransferDAOException e) { - log.error("exception finding", e); - throw new ConveyorExecutionException("error finding account", e); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.GridAccountService#deleteGridAccount(org - * .irods.jargon.transfer.dao.domain.GridAccount) - */ - @Override - public void deleteGridAccount(final GridAccount gridAccount) - throws ConveyorBusyException, ConveyorExecutionException { - log.info("deleteGridAccount()"); - - if (gridAccount == null) { - throw new IllegalArgumentException("null gridAccount"); - } - - log.info("gridAccount:{}", gridAccount); - - // lock queue so as not to delete an account involved with a running - // transfer, deleting the account would delete the transfer data - try { - getConveyorExecutorService().setBusyForAnOperation(); - gridAccountDAO.delete(gridAccount); - } catch (TransferDAOException e) { - log.error("exception deleting", e); - throw new ConveyorExecutionException("error deleting account", e); - } finally { - getConveyorExecutorService().setOperationCompleted(); - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.GridAccountService#findAll() - */ - @Override - public List findAll() throws ConveyorExecutionException { - log.info("findAll()"); - try { - return gridAccountDAO.findAll(); - } catch (TransferDAOException e) { - log.error("exception deleting", e); - throw new ConveyorExecutionException("error deleting account", e); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.GridAccountService#irodsAccountForGridAccount - * (org.irods.jargon.transfer.dao.domain.GridAccount) - */ - @Override - public synchronized IRODSAccount irodsAccountForGridAccount( - final GridAccount gridAccount) throws ConveyorExecutionException { - - /* - * This method is synchronized as it depends on the cache encryptor - */ - - log.info("irodsAccountForGridAccount()"); - if (gridAccount == null) { - throw new IllegalArgumentException("null gridAccount"); - } - - if (!isValidated()) { - throw new ConveyorExecutionException( - "pass phrase has not been validated"); - } - - String decryptedPassword; - try { - decryptedPassword = cacheEncryptor.decrypt(gridAccount - .getPassword()); - return IRODSAccount.instance(gridAccount.getHost(), - gridAccount.getPort(), gridAccount.getUserName(), - decryptedPassword, gridAccount.getDefaultPath(), - gridAccount.getZone(), gridAccount.getDefaultResource(), - gridAccount.getAuthScheme()); - } catch (JargonException e) { - log.error("exception deleting", e); - throw new ConveyorExecutionException("error decrypting account", e); - } - - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.GridAccountService#deleteAllGridAccounts() - */ - @Override - public void deleteAllGridAccounts() throws ConveyorBusyException, - ConveyorExecutionException { - log.info("deleteAllGridAccounts()"); - - try { - getConveyorExecutorService().setBusyForAnOperation(); - gridAccountDAO.deleteAll(); - } catch (TransferDAOException e) { - log.error("exception deleting", e); - throw new ConveyorExecutionException("error decrypting account", e); - } finally { - getConveyorExecutorService().setOperationCompleted(); - } - - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.GridAccountService#resetPassPhraseAndAccounts - * () - */ - @Override - public synchronized void resetPassPhraseAndAccounts() - throws ConveyorBusyException, ConveyorExecutionException { - log.info("resetPassPhraseAndAccounts()"); - - /* - * This method alters the cached pass phrase and cache encryptor - */ - try { - getConveyorExecutorService().setBusyForAnOperation(); - doDeleteAllWithQueueLocked(); - } catch (TransferDAOException e) { - log.error("exception resetting key store and accounts", e); - throw new ConveyorExecutionException("error resetting", e); - } finally { - getConveyorExecutorService().setOperationCompleted(); - } - - } - - /** - * With the queue already locked, delete all grid accounts - * - * @throws TransferDAOException - */ - private void doDeleteAllWithQueueLocked() throws TransferDAOException { - gridAccountDAO.deleteAll(); - KeyStore keyStore = keyStoreDAO - .findById(KeyStore.KEY_STORE_PASS_PHRASE); - if (keyStore != null) { - log.info("deleting keystore entry for pass phrase"); - keyStoreDAO.delete(keyStore); - } - // deleted account and other info, clear the pass phrase, it will - // need to be reset - cachedPassPhrase = ""; - cacheEncryptor = null; - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.GridAccountService#isPassPhraseStoredAlready - * () - */ - @Override - public boolean isPassPhraseStoredAlready() - throws ConveyorExecutionException { - log.info("isPassPhraseStoredAlready"); - - KeyStore keyStore; - try { - keyStore = keyStoreDAO.findById(KeyStore.KEY_STORE_PASS_PHRASE); - } catch (TransferDAOException e) { - log.error("unable to look up prior key store", e); - throw new ConveyorExecutionException( - "error looking up prior key store", e); - } - - if (keyStore == null) { - log.info("no keystore found, will return false"); - } - - return (keyStore != null); - - } -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/TransferAccountingManagementServiceImpl.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/TransferAccountingManagementServiceImpl.java deleted file mode 100644 index 166c6e7f0..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/TransferAccountingManagementServiceImpl.java +++ /dev/null @@ -1,1008 +0,0 @@ -package org.irods.jargon.conveyor.basic; - -import java.sql.Timestamp; -import java.util.Date; - -import org.irods.jargon.conveyor.core.AbstractConveyorComponentService; -import org.irods.jargon.conveyor.core.ConfigurationService; -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.GridAccountService; -import org.irods.jargon.conveyor.core.RejectedTransferException; -import org.irods.jargon.conveyor.core.TransferAccountingManagementService; -import org.irods.jargon.conveyor.utils.ExceptionUtils; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.transfer.dao.TransferAttemptDAO; -import org.irods.jargon.transfer.dao.TransferDAO; -import org.irods.jargon.transfer.dao.TransferDAOException; -import org.irods.jargon.transfer.dao.TransferItemDAO; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.irods.jargon.transfer.dao.domain.TransferAttemptTypeEnum; -import org.irods.jargon.transfer.dao.domain.TransferItem; -import org.irods.jargon.transfer.dao.domain.TransferStateEnum; -import org.irods.jargon.transfer.dao.domain.TransferStatusEnum; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.transaction.annotation.Transactional; - -/** - * Implementation of a service to manage transfers and update them as they - * execute, based on callbacks and conveyor actions. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -@Transactional(noRollbackFor = { JargonException.class }, rollbackFor = { ConveyorExecutionException.class }) -public class TransferAccountingManagementServiceImpl extends - AbstractConveyorComponentService implements - TransferAccountingManagementService { - - /** - * Injected dependency - */ - private TransferDAO transferDAO; - - /** - * Injected dependency - */ - private TransferAttemptDAO transferAttemptDAO; - - /** - * Injected dependency - */ - private TransferItemDAO transferItemDAO; - - /** - * Injected dependency - */ - @SuppressWarnings("unused") - private GridAccountService gridAccountService; - - /** - * Injected dependency - */ - - private ConfigurationService configurationService; - - private static final Logger log = LoggerFactory - .getLogger(TransferAccountingManagementServiceImpl.class); - - /** - * - */ - public TransferAccountingManagementServiceImpl() { - } - - /** - * @param transferDAO - * the transferDAO to set - */ - public void setTransferDAO(final TransferDAO transferDAO) { - this.transferDAO = transferDAO; - } - - /** - * @param transferAttemptDAO - * the transferAttemptDAO to set - */ - public void setTransferAttemptDAO( - final TransferAttemptDAO transferAttemptDAO) { - this.transferAttemptDAO = transferAttemptDAO; - } - - /** - * @param transferItemDAO - * the transferItemDAO to set - */ - public void setTransferItemDAO(final TransferItemDAO transferItemDAO) { - this.transferItemDAO = transferItemDAO; - } - - /** - * @param gridAccountService - * the gridAccountService to set - */ - public void setGridAccountService( - final GridAccountService gridAccountService) { - this.gridAccountService = gridAccountService; - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.TransferAccountingManagementService# - * prepareTransferForExecution - * (org.irods.jargon.transfer.dao.domain.Transfer) - */ - @Override - public TransferAttempt prepareTransferForExecution(final Transfer transfer) - throws ConveyorExecutionException { - - log.info("building transfer attempt..."); - if (transfer == null) { - throw new IllegalArgumentException("transfer is null"); - } - - if (transfer.getId() == null) { - throw new ConveyorExecutionException( - "transfer does not have an id, it may not be stored in the transfer database"); - } - - transfer.setLastTransferStatus(TransferStatusEnum.OK); - transfer.setTransferState(TransferStateEnum.PROCESSING); - transfer.setUpdatedAt(new Timestamp(System.currentTimeMillis())); - - TransferAttempt transferAttempt = null; - try { - transferAttempt = transferAttemptDAO - .findLastTransferAttemptForTransferByTransferId(transfer - .getId()); - if (transferAttempt == null) { - log.error("couldn't find the transfer attempt in transfer:{}", - transfer); - throw new ConveyorExecutionException( - "Unable to find transfer attempt for execution"); - } - } catch (TransferDAOException e) { - log.error("error saving transfer", e); - throw new ConveyorExecutionException( - "error saving transfer attempt", e); - } - - transferAttempt.setAttemptStart(new Timestamp(System - .currentTimeMillis())); - transferAttempt.setAttemptStatus(TransferStatusEnum.OK); - transferAttempt.setUpdatedAt(transferAttempt.getAttemptStart()); - - try { - transferDAO.save(transfer); - log.info("transfer saved:{}", transfer); - return transferAttempt; - } catch (TransferDAOException e) { - log.error("error saving transfer", e); - throw new ConveyorExecutionException( - "error saving transfer attempt", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.TransferAccountingManagementService# - * prepareTransferForProcessing - * (org.irods.jargon.transfer.dao.domain.Transfer) - */ - @Override - public TransferAttempt prepareTransferForProcessing(final Transfer transfer) - throws ConveyorExecutionException { - - log.info("prepareTransferForProcessing()"); - - if (transfer == null) { - throw new IllegalArgumentException("null transfer"); - } - - log.info("transfer:{}", transfer); - - /* - * Note that the transfer object being passed in is not expected to be - * already persisted, so this will add a new transfer - */ - - log.info("building transfer attempt..."); - - long currentTime = System.currentTimeMillis(); - transfer.setLastTransferStatus(TransferStatusEnum.OK); - transfer.setSequenceNumber(currentTime); - transfer.setTransferState(TransferStateEnum.ENQUEUED); - transfer.setUpdatedAt(new Date(currentTime)); - - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setSequenceNumber(currentTime); - transferAttempt.setTransfer(transfer); - transferAttempt.setTransfer(transfer); - transferAttempt.setAttemptStatus(TransferStatusEnum.OK); - transferAttempt.setCreatedAt(new Date(currentTime)); - transferAttempt.setUpdatedAt(transferAttempt.getCreatedAt()); - - try { - transfer.getTransferAttempts().add(transferAttempt); - // transferAttemptDAO.save(transferAttempt); - log.info("transfer attempt added:{}", transferAttempt); - transferDAO.save(transfer); - log.info("transfer saved:{}", transfer); - return transferAttempt; - } catch (TransferDAOException e) { - log.error("error saving transfer", e); - throw new ConveyorExecutionException( - "error saving transfer attempt", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.TransferAccountingManagementService# - * updateTransferAfterSuccessfulFileTransfer - * (org.irods.jargon.core.transfer.TransferStatus, - * org.irods.jargon.transfer.dao.domain.TransferAttempt) - */ - @Override - public void updateTransferAfterSuccessfulFileTransfer( - final TransferStatus transferStatus, TransferAttempt transferAttempt) - throws ConveyorExecutionException { - - log.info("updateTransferAfterSuccessfulFileTransfer()"); - - if (transferStatus == null) { - throw new IllegalArgumentException("null transferStatus"); - } - - if (transferAttempt == null) { - throw new IllegalArgumentException("null transferAttempt"); - } - - try { - transferAttempt = transferAttemptDAO.load(transferAttempt.getId()); - } catch (TransferDAOException e) { - throw new ConveyorExecutionException( - "error loading transfer attempt", e); - } - - log.info("updated last good path to:{}", - transferStatus.getSourceFileAbsolutePath()); - - long currentTime = System.currentTimeMillis(); - Date currentDate = new Date(currentTime); - - transferAttempt.setLastSuccessfulPath(transferStatus - .getSourceFileAbsolutePath()); - transferAttempt.setTotalFilesTransferredSoFar(transferStatus - .getTotalFilesTransferredSoFar()); - transferAttempt.setTotalFilesSkippedSoFar(transferStatus - .getTotalFilesSkippedSoFar()); - transferAttempt.setTotalFilesCount(transferStatus - .getTotalFilesToTransfer()); - transferAttempt.setUpdatedAt(currentDate); - - if (getConfigurationService() - .getCachedConveyorConfigurationProperties() - .isLogSuccessfulTransfers()) { - - // create transfer item - TransferItem transferItem = new TransferItem(); - transferItem.setSequenceNumber(currentTime); - transferItem.setFile(true); - transferItem.setTransferType(transferAttempt.getTransfer() - .getTransferType()); - transferItem.setSourceFileAbsolutePath(transferStatus - .getSourceFileAbsolutePath()); - transferItem.setTargetFileAbsolutePath(transferStatus - .getTargetFileAbsolutePath()); - transferItem.setTransferredAt(currentDate); - transferItem.setLengthInBytes(transferStatus.getBytesTransfered()); - - // try { - transferItem.setTransferAttempt(transferAttempt); - transferAttempt.getTransferItems().add(transferItem); - - /* - * try { transferItemDAO.save(transferItem); } catch - * (TransferDAOException e) { throw new ConveyorExecutionException( - * "error saving transfer attempt", e); } - */ - - } - - try { - transferAttemptDAO.save(transferAttempt); - } catch (TransferDAOException e) { - throw new ConveyorExecutionException( - "error saving transfer attempt", e); - } - - // transferAttemptDAO.save(localTransferAttempt); - /* - * } catch (TransferDAOException ex) { throw new - * ConveyorExecutionException( "error saving transfer attempt", ex); } - */ - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.TransferAccountingManagementService# - * updateTransferAfterFailedFileTransfer - * (org.irods.jargon.core.transfer.TransferStatus, - * org.irods.jargon.transfer.dao.domain.TransferAttempt, int) - */ - @Override - public void updateTransferAfterFailedFileTransfer( - final org.irods.jargon.core.transfer.TransferStatus transferStatus, - TransferAttempt transferAttempt, final int totalFileErrorsSoFar) - throws ConveyorExecutionException { - - if (transferStatus == null) { - throw new IllegalArgumentException("null transfer status"); - } - - if (transferAttempt == null) { - throw new IllegalArgumentException("null transfer attempt"); - } - - try { - - transferAttempt = transferAttemptDAO.load(transferAttempt.getId()); - - long currentTime = System.currentTimeMillis(); - Date currentDate = new Date(currentTime); - transferAttempt.setAttemptStatus(TransferStatusEnum.ERROR); - transferAttempt.setUpdatedAt(currentDate); - transferAttempt.setTotalFilesErrorSoFar(totalFileErrorsSoFar); - - // create transfer item - TransferItem transferItem = new TransferItem(); - transferItem.setSequenceNumber(currentTime); - transferItem.setTransferType(transferAttempt.getTransfer() - .getTransferType()); - transferItem.setFile(true); - transferItem.setSourceFileAbsolutePath(transferStatus - .getSourceFileAbsolutePath()); - transferItem.setTargetFileAbsolutePath(transferStatus - .getTargetFileAbsolutePath()); - transferItem.setError(true); - transferItem.setTransferredAt(currentDate); - transferItem.setTransferAttempt(transferAttempt); - - if (transferStatus.getTransferException() != null) { - transferItem.setErrorMessage(transferStatus - .getTransferException().getMessage()); - transferItem.setErrorStackTrace(ExceptionUtils - .stackTraceToString(transferStatus - .getTransferException())); - } - - transferAttempt.getTransferItems().add(transferItem); - - transferAttemptDAO.save(transferAttempt); - } catch (TransferDAOException ex) { - throw new ConveyorExecutionException( - "error saving transfer attempt", ex); - } - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.TransferAccountingManagementService# - * updateTransferAttemptWithConveyorException - * (org.irods.jargon.transfer.dao.domain.TransferAttempt, - * java.lang.Exception) - */ - @Override - public void updateTransferAttemptWithConveyorException( - final TransferAttempt transferAttempt, final Exception exception) - throws ConveyorExecutionException { - - log.info("updateTransferAttemptWithConveyorException()"); - - if (transferAttempt == null) { - throw new IllegalArgumentException("null transferAttempt"); - } - - if (exception == null) { - throw new IllegalArgumentException("null exception"); - } - - log.info("transferAttempt:{}", transferAttempt); - - TransferAttempt localTransferAttempt; - try { - localTransferAttempt = transferAttemptDAO.findById(transferAttempt - .getId()); - if (localTransferAttempt == null) { - log.error("null tranfer attempt found, cannot update the database"); - throw new ConveyorExecutionException( - "error finding transfer attempt"); - - } - } catch (TransferDAOException e) { - throw new ConveyorExecutionException( - "error finding transfer attempt", e); - } - - // log.info("exception:{}", exception); - - Transfer transfer = localTransferAttempt.getTransfer(); - - transfer.setLastTransferStatus(TransferStatusEnum.ERROR); - transfer.setTransferState(TransferStateEnum.COMPLETE); - transfer.setUpdatedAt(new Timestamp(System.currentTimeMillis())); - - localTransferAttempt.setAttemptStatus(TransferStatusEnum.ERROR); - localTransferAttempt.setAttemptEnd(new Timestamp(System - .currentTimeMillis())); - localTransferAttempt.setErrorMessage(ERROR_ATTEMPTING_TO_RUN); - localTransferAttempt.setGlobalException(exception.getMessage()); - localTransferAttempt.setGlobalExceptionStackTrace(ExceptionUtils - .stackTraceToString(exception)); - localTransferAttempt.setUpdatedAt(localTransferAttempt.getAttemptEnd()); - - try { - log.info("saving transfer data via DAO"); - // transferAttemptDAO.save(transferAttempt); - transferDAO.save(transfer); - } catch (TransferDAOException ex) { - log.error("transferDAO exception saving data", ex); - throw new ConveyorExecutionException( - "error saving transfer attempt", ex); - } - - } - - /** - * @return the configurationService - */ - public ConfigurationService getConfigurationService() { - return configurationService; - } - - /** - * @param configurationService - * the configurationService to set - */ - public void setConfigurationService( - final ConfigurationService configurationService) { - this.configurationService = configurationService; - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.TransferAccountingManagementService# - * updateTransferAfterOverallWarningByFileErrorThreshold - * (org.irods.jargon.core.transfer.TransferStatus, - * org.irods.jargon.transfer.dao.domain.TransferAttempt) - */ - @Override - public void updateTransferAfterOverallWarningByFileErrorThreshold( - final TransferStatus transferStatus, - final TransferAttempt transferAttempt) - throws ConveyorExecutionException { - log.info("updateTransferStatusAfterOverallWarning()"); - transferUpdateOverall(transferStatus, transferAttempt, - TransferStatusEnum.WARNING, TransferStateEnum.COMPLETE, - WARNING_SOME_FAILED_MESSAGE); - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.TransferAccountingManagementService# - * updateTransferAfterOverallWarningNoFilesTransferred - * (org.irods.jargon.core.transfer.TransferStatus, - * org.irods.jargon.transfer.dao.domain.TransferAttempt) - */ - @Override - public void updateTransferAfterOverallWarningNoFilesTransferred( - final TransferStatus transferStatus, - final TransferAttempt transferAttempt) - throws ConveyorExecutionException { - log.info("updateTransferAfterOverallWarningNoFilesTransferred()"); - transferUpdateOverall(transferStatus, transferAttempt, - TransferStatusEnum.WARNING, TransferStateEnum.COMPLETE, - WARNING_NO_FILES_TRANSFERRED_MESSAGE); - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.TransferAccountingManagementService# - * updateTransferAfterOverallFailureByFileErrorThreshold - * (org.irods.jargon.core.transfer.TransferStatus, - * org.irods.jargon.transfer.dao.domain.TransferAttempt) - */ - @Override - public void updateTransferAfterOverallFailureByFileErrorThreshold( - final TransferStatus transferStatus, - final TransferAttempt transferAttempt) - throws ConveyorExecutionException { - log.info("updateTransferStatusAfterOverallWarning()"); - transferUpdateOverall(transferStatus, transferAttempt, - TransferStatusEnum.ERROR, TransferStateEnum.COMPLETE, - ERROR_SOME_FAILED_MESSAGE); - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.TransferAccountingManagementService# - * updateTransferAfterOverallSuccess - * (org.irods.jargon.core.transfer.TransferStatus, - * org.irods.jargon.transfer.dao.domain.TransferAttempt) - */ - @Override - public void updateTransferAfterOverallSuccess( - final org.irods.jargon.core.transfer.TransferStatus transferStatus, - final TransferAttempt transferAttempt) - throws ConveyorExecutionException { - - log.info("updateTransferAfterOverallSuccess()"); - - transferUpdateOverall(transferStatus, transferAttempt, - TransferStatusEnum.OK, TransferStateEnum.COMPLETE, null); - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.TransferAccountingManagementService# - * updateTransferAfterCancellation ( - * org.irods.jargon.transfer.dao.domain.TransferAttempt) - */ - @Override - public void updateTransferAfterCancellation( - final TransferAttempt transferAttempt) - throws ConveyorExecutionException { - log.info("updateTransferAfterCancellation()"); - - if (transferAttempt == null) { - throw new IllegalArgumentException("null transferAttempt"); - } - - log.info("transferAttempt:{}", transferAttempt); - - TransferAttempt localTransferAttempt; - try { - localTransferAttempt = transferAttemptDAO.load(transferAttempt - .getId()); - if (localTransferAttempt == null) { - log.error("null transfer attempt found, cannot update the database"); - throw new ConveyorExecutionException( - "error finding transfer attempt"); - - } - } catch (TransferDAOException e) { - throw new ConveyorExecutionException( - "error finding transfer attempt", e); - } - - Transfer transfer = localTransferAttempt.getTransfer(); - - transfer.setLastTransferStatus(TransferStatusEnum.OK); - transfer.setTransferState(TransferStateEnum.CANCELLED); - transfer.setUpdatedAt(new Timestamp(System.currentTimeMillis())); - localTransferAttempt.setAttemptEnd(new Timestamp(System - .currentTimeMillis())); - localTransferAttempt.setAttemptStatus(TransferStatusEnum.OK); - localTransferAttempt.setUpdatedAt(localTransferAttempt.getAttemptEnd()); - localTransferAttempt.setErrorMessage(WARNING_CANCELLED_MESSAGE); - - try { - transferAttemptDAO.save(localTransferAttempt); - transferDAO.save(transfer); - - } catch (TransferDAOException ex) { - throw new ConveyorExecutionException( - "error saving transfer attempt", ex); - } - } - - /** - * Handle details of updating the transfer status with an OK, Success, or - * Failure status as described by the parameters - * - * @param transferStatus - * {@link TransferStatus} for overall completion - * @param transferAttempt - * {@link TransferAttempt} - * @param transferStatusEnum - * @param transferStateEnum - * @param errorMessage - * @throws ConveyorExecutionException - */ - private void transferUpdateOverall(final TransferStatus transferStatus, - TransferAttempt transferAttempt, - final TransferStatusEnum transferStatusEnum, - final TransferStateEnum transferState, final String errorMessage) - throws ConveyorExecutionException { - - log.info("transferUpdateOverall()"); - - if (transferStatus == null) { - throw new IllegalArgumentException("null transferStatus"); - } - - if (transferAttempt == null) { - throw new IllegalArgumentException("null transferAttempt"); - } - - log.info("transferAttempt:{}", transferAttempt); - log.info("transferStatus:{}", transferStatus); - - Transfer transfer = null; - - try { - transferAttempt = transferAttemptDAO.load(transferAttempt.getId()); - if (transferAttempt == null) { - log.error("null transfer attempt found, cannot update the database"); - throw new ConveyorExecutionException( - "error finding transfer attempt"); - - } - transfer = transferAttempt.getTransfer(); - - } catch (TransferDAOException e) { - throw new ConveyorExecutionException( - "error finding transfer attempt", e); - } - - /* - * TransferAttempt localTransferAttempt; try { localTransferAttempt = - * transferAttemptDAO.findById(transferAttempt .getId()); if - * (localTransferAttempt == null) { - * log.error("null transfer attempt found, cannot update the database"); - * throw new ConveyorExecutionException( - * "error finding transfer attempt"); - * - * } } catch (TransferDAOException e) { throw new - * ConveyorExecutionException( "error finding transfer attempt", e); } - */ - - log.info("transfer for update:{}", transfer); - - transfer.setLastTransferStatus(transferStatusEnum); - transfer.setTransferState(transferState); - transfer.setUpdatedAt(new Timestamp(System.currentTimeMillis())); - transferAttempt - .setAttemptEnd(new Timestamp(System.currentTimeMillis())); - transferAttempt.setAttemptStatus(transferStatusEnum); - transferAttempt.setUpdatedAt(transferAttempt.getAttemptEnd()); - transferAttempt.setErrorMessage(errorMessage); - - log.info("updated transfer attempt:{}", transferAttempt); - - try { - transferAttemptDAO.save(transferAttempt); - transferDAO.save(transfer); - } catch (TransferDAOException ex) { - throw new ConveyorExecutionException( - "error saving transfer attempt", ex); - } - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.TransferAccountingManagementService# - * updateTransferAfterOverallFailure - * (org.irods.jargon.core.transfer.TransferStatus, - * org.irods.jargon.transfer.dao.domain.TransferAttempt) - */ - @Override - public void updateTransferAfterOverallFailure( - final TransferStatus transferStatus, - final TransferAttempt transferAttempt) - throws ConveyorExecutionException { - log.info("updateTransferAfterOverallFailure()"); - - if (transferStatus == null) { - throw new IllegalArgumentException("null transferStatus"); - } - - if (transferAttempt == null) { - throw new IllegalArgumentException("null transferAttempt"); - } - - log.info("transferAttempt:{}", transferAttempt); - log.info("transferStatus:{}", transferStatus); - - TransferAttempt localTransferAttempt; - try { - localTransferAttempt = transferAttemptDAO.load(transferAttempt - .getId()); - if (localTransferAttempt == null) { - log.error("null transfer attempt found, cannot update the database"); - throw new ConveyorExecutionException( - "error finding transfer attempt"); - - } - } catch (TransferDAOException e) { - throw new ConveyorExecutionException( - "error finding transfer attempt", e); - } - - Transfer transfer = localTransferAttempt.getTransfer(); - transfer.setLastTransferStatus(TransferStatusEnum.ERROR); - transfer.setTransferState(TransferStateEnum.COMPLETE); - transfer.setUpdatedAt(new Timestamp(System.currentTimeMillis())); - localTransferAttempt.setAttemptEnd(new Timestamp(System - .currentTimeMillis())); - localTransferAttempt.setAttemptStatus(TransferStatusEnum.ERROR); - localTransferAttempt.setErrorMessage(ERROR_IN_TRANSFER_AT_IRODS_LEVEL); - localTransferAttempt.setGlobalException(ExceptionUtils - .messageOrNullFromException(transferStatus - .getTransferException())); - localTransferAttempt.setGlobalExceptionStackTrace(ExceptionUtils - .stackTraceToString(transferStatus.getTransferException())); - - /* - * - * try { transferAttemptDAO.save(localTransferAttempt); - * transferDAO.save(transfer); } catch (TransferDAOException ex) { throw - * new ConveyorExecutionException( - * - * "error saving transfer attempt", ex); } - */ - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.TransferAccountingManagementService# - * updateTransferAfterRestartFileSkipped - * (org.irods.jargon.core.transfer.TransferStatus, - * org.irods.jargon.transfer.dao.domain.TransferAttempt) - */ - @Override - public void updateTransferAfterRestartFileSkipped( - final org.irods.jargon.core.transfer.TransferStatus transferStatus, - final TransferAttempt transferAttempt) - throws ConveyorExecutionException { - - log.info("updateTransferAfterRestartFileSkipped()"); - - TransferAttempt localTransferAttempt; - try { - localTransferAttempt = transferAttemptDAO.findById(transferAttempt - .getId()); - if (localTransferAttempt == null) { - log.error("null tranfer attempt found, cannot update the database"); - throw new ConveyorExecutionException( - "error finding transfer attempt"); - - } - } catch (TransferDAOException e) { - throw new ConveyorExecutionException( - "error finding transfer attempt", e); - } - - long currentTime = System.currentTimeMillis(); - Date currentDate = new Date(currentTime); - localTransferAttempt.setTotalFilesCount(transferStatus - .getTotalFilesToTransfer()); - localTransferAttempt.setUpdatedAt(currentDate); - localTransferAttempt.setTotalFilesSkippedSoFar(transferStatus - .getTotalFilesSkippedSoFar()); - localTransferAttempt.setTotalFilesTransferredSoFar(transferStatus - .getTotalFilesTransferredSoFar()); - log.info("total skipped so far:{}", - localTransferAttempt.getTotalFilesSkippedSoFar()); - - try { - transferAttemptDAO.save(localTransferAttempt); - log.info("transfer attempt was saved"); - } catch (TransferDAOException e) { - throw new ConveyorExecutionException( - "error saving transfer attempt", e); - } - - if (!getConfigurationService() - .getCachedConveyorConfigurationProperties() - .isLogSuccessfulTransfers()) { - log.info("not logging restart...update transfer attempt with counts"); - return; - } - - log.info("logging restart, log transfer item"); - - // create transfer item - TransferItem transferItem = new TransferItem(); - transferItem.setSequenceNumber(currentTime); - transferItem.setFile(true); - transferItem.setSkipped(true); - transferItem.setTransferType(localTransferAttempt.getTransfer() - .getTransferType()); - transferItem.setSourceFileAbsolutePath(transferStatus - .getSourceFileAbsolutePath()); - transferItem.setTargetFileAbsolutePath(transferStatus - .getTargetFileAbsolutePath()); - transferItem.setTransferredAt(currentDate); - - try { - transferItem.setTransferAttempt(localTransferAttempt); - localTransferAttempt.getTransferItems().add(transferItem); - transferItemDAO.save(transferItem); - } catch (TransferDAOException ex) { - throw new ConveyorExecutionException( - "error saving transfer attempt", ex); - } - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.TransferAccountingManagementService# - * prepareTransferForRestart(long) - */ - @Override - public Transfer prepareTransferForRestart(final long transferId) - throws ConveyorExecutionException, RejectedTransferException { - return restart(transferId, false); - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.TransferAccountingManagementService# - * restartProcessingTransferAtStartup(long) - */ - @Override - public Transfer restartProcessingTransferAtStartup(final long transferId) - throws ConveyorExecutionException, RejectedTransferException { - return restart(transferId, true); - } - - /** - * @param transferId - * @return - * @throws ConveyorExecutionException - * @throws RejectedTransferException - */ - private Transfer restart(final long transferId, final boolean isAtStartup) - throws ConveyorExecutionException, RejectedTransferException { - log.info("transferId:{}", transferId); - log.info("looking up transfer to restart..."); - - Transfer transfer; - try { - transfer = transferDAO.findById(new Long(transferId)); - } catch (TransferDAOException e) { - log.error("error looking up transfer by id", e); - throw new ConveyorExecutionException( - "unable to lookup transfer by id", e); - } - - TransferAttempt lastTransferAttempt; - try { - lastTransferAttempt = transferAttemptDAO - .findLastTransferAttemptForTransferByTransferId(transferId); - } catch (TransferDAOException e) { - log.error("error looking up last transfer attempt", e); - throw new ConveyorExecutionException( - "unable to lookup last transfer attempt", e); - } - - if (lastTransferAttempt == null) { - throw new RejectedTransferException( - "no previous attempt found to base restart on"); - } - - long currentTime = System.currentTimeMillis(); - Date currentDate = new Date(currentTime); - - log.info("building transfer attempt based on previous attempt..."); - transfer.setTransferState(TransferStateEnum.ENQUEUED); - transfer.setUpdatedAt(currentDate); - transfer.setLastTransferStatus(TransferStatusEnum.OK); - - TransferAttempt newTransferAttempt = new TransferAttempt(); - newTransferAttempt.setSequenceNumber(currentTime); - newTransferAttempt.setAttemptStatus(TransferStatusEnum.OK); - newTransferAttempt.setLastSuccessfulPath(lastTransferAttempt - .getLastSuccessfulPath()); - - if (isAtStartup) { - newTransferAttempt - .setTransferAttemptTypeEnum(TransferAttemptTypeEnum.RESTARTED_PROCESSING_TRANSFER_AT_STARTUP); - } else { - newTransferAttempt - .setTransferAttemptTypeEnum(TransferAttemptTypeEnum.RESTART); - } - - newTransferAttempt.setCreatedAt(currentDate); - newTransferAttempt.setUpdatedAt(currentDate); - newTransferAttempt.setTransfer(transfer); - transfer.getTransferAttempts().add(newTransferAttempt); - log.info("added new transfer attempt:{}", newTransferAttempt); - - try { - transferAttemptDAO.save(newTransferAttempt); - } catch (TransferDAOException e) { - log.error("error updating transfer for restart", e); - throw new ConveyorExecutionException( - "cannot update transfer for restart", e); - } - - return transfer; - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.TransferAccountingManagementService# - * prepareTransferForRestart(long) - */ - @Override - public Transfer prepareTransferForResubmit(final long transferId) - throws ConveyorExecutionException, RejectedTransferException { - log.info("transferId:{}", transferId); - log.info("looking up transfer to resubmit..."); - - Transfer transfer; - try { - transfer = transferDAO.findById(new Long(transferId)); - } catch (TransferDAOException e) { - log.error("error looking up transfer by id", e); - throw new ConveyorExecutionException( - "unable to lookup transfer by id", e); - } - - TransferAttempt lastTransferAttempt; - try { - lastTransferAttempt = transferAttemptDAO - .findLastTransferAttemptForTransferByTransferId(transferId); - } catch (TransferDAOException e) { - log.error("error looking up last transfer attempt", e); - throw new ConveyorExecutionException( - "unable to lookup last transfer attempt", e); - } - - if (lastTransferAttempt == null) { - throw new RejectedTransferException( - "no previous attempt found to base resubmit on"); - } - - long currentTime = System.currentTimeMillis(); - Date currentDate = new Date(currentTime); - - log.info("building transfer attempt based on previous attempt..."); - transfer.setTransferState(TransferStateEnum.ENQUEUED); - transfer.setUpdatedAt(currentDate); - transfer.setLastTransferStatus(TransferStatusEnum.OK); - - TransferAttempt newTransferAttempt = new TransferAttempt(); - newTransferAttempt.setSequenceNumber(currentTime); - newTransferAttempt.setAttemptStatus(TransferStatusEnum.OK); - newTransferAttempt - .setTransferAttemptTypeEnum(TransferAttemptTypeEnum.RESUBMIT); - newTransferAttempt.setCreatedAt(currentDate); - newTransferAttempt.setUpdatedAt(currentDate); - newTransferAttempt.setTransfer(transfer); - transfer.getTransferAttempts().add(newTransferAttempt); - log.info("added new transfer attempt:{}", newTransferAttempt); - - try { - transferDAO.save(transfer); - } catch (TransferDAOException e) { - log.error("error updating transfer for restart", e); - throw new ConveyorExecutionException( - "cannot update transfer for restart", e); - } - - return transfer; - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.TransferAccountingManagementService# - * isLogSuccessfulTransfers() - */ - @Override - public boolean isLogSuccessfulTransfers() throws ConveyorExecutionException { - return getConfigurationService() - .getCachedConveyorConfigurationProperties() - .isLogSuccessfulTransfers(); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/package-info.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/package-info.java deleted file mode 100644 index 569e1f074..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/basic/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Basic implementation of the conveyor service - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -package org.irods.jargon.conveyor.basic; \ No newline at end of file diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/AbstractConveyorComponentService.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/AbstractConveyorComponentService.java deleted file mode 100644 index dac4f2b9c..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/AbstractConveyorComponentService.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core; - -/** - * Common abstract superclass for sub-services that are aggregated under the - * ConveyorService - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class AbstractConveyorComponentService { - - /** - * required dependency - */ - private ConveyorExecutorService conveyorExecutorService; - - public ConveyorExecutorService getConveyorExecutorService() { - return conveyorExecutorService; - } - - public void setConveyorExecutorService( - final ConveyorExecutorService conveyorExecutorService) { - this.conveyorExecutorService = conveyorExecutorService; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/BootstrapperException.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/BootstrapperException.java deleted file mode 100644 index 4d008b131..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/BootstrapperException.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core; - -/** - * Exception bootstrapping the conveyor framework - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class BootstrapperException extends Exception { - - /** - * - */ - private static final long serialVersionUID = -6504361021682319203L; - - /** - * - */ - public BootstrapperException() { - } - - /** - * @param message - */ - public BootstrapperException(final String message) { - super(message); - } - - /** - * @param cause - */ - public BootstrapperException(final Throwable cause) { - super(cause); - } - - /** - * @param message - * @param cause - */ - public BootstrapperException(final String message, final Throwable cause) { - super(message, cause); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/CachedConveyorConfigurationProperties.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/CachedConveyorConfigurationProperties.java deleted file mode 100644 index 2a8fdafd3..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/CachedConveyorConfigurationProperties.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core; - -/** - * Properties that can control the behavior of the conveyor engine, including - * TransferOptions that control the detailed configuration of the - * jargon transfers. - *

- * These properties reflect the underlying configuration, and translate them - * into a usable class that is cached and updated whenever the underlying - * conveyor configuration is changed. The management of this is the - * responsibility of the ConfigurationService - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class CachedConveyorConfigurationProperties { - - private boolean logSuccessfulTransfers = false; - private int maxErrorsBeforeCancel = 0; - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("TransferEngineConfigurationProperties"); - sb.append("\n isLogSuccessfulTransfers:"); - sb.append(logSuccessfulTransfers); - return sb.toString(); - } - - /** - * Are successful transfer details logged in the database? - * - * @return - */ - public boolean isLogSuccessfulTransfers() { - return logSuccessfulTransfers; - } - - /** - * - * @param logSuccessfulTransfers - */ - public void setLogSuccessfulTransfers(final boolean logSuccessfulTransfers) { - this.logSuccessfulTransfers = logSuccessfulTransfers; - } - - /** - * @return the maxErrorsBeforeCancel - */ - public int getMaxErrorsBeforeCancel() { - return maxErrorsBeforeCancel; - } - - /** - * @param maxErrorsBeforeCancel - * the maxErrorsBeforeCancel to set - */ - public void setMaxErrorsBeforeCancel(final int maxErrorsBeforeCancel) { - this.maxErrorsBeforeCancel = maxErrorsBeforeCancel; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConfigurationPropertyConstants.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConfigurationPropertyConstants.java deleted file mode 100644 index d9233da99..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConfigurationPropertyConstants.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core; - -/** - * Constants used for configuration property keys - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class ConfigurationPropertyConstants { - - public static final String LOG_SUCCESSFUL_FILES_KEY = "transferengine.record.successful.files"; - public static final String MAX_ERRORS_BEFORE_CANCEL_KEY = "transferengine.max.transfer.errors"; - public static final String LOG_RESTART_FILES = "transferengine.record.restart.files"; - - private ConfigurationPropertyConstants() { - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConfigurationService.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConfigurationService.java deleted file mode 100644 index eb46ae5b2..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConfigurationService.java +++ /dev/null @@ -1,147 +0,0 @@ -package org.irods.jargon.conveyor.core; - -import java.util.List; -import java.util.Properties; - -import org.irods.jargon.core.pub.IRODSAccessObjectFactory; -import org.irods.jargon.core.transfer.TransferControlBlock; -import org.irods.jargon.transfer.dao.domain.ConfigurationProperty; - -/** - * Interface that describes the service layer for managing configuration - * information for transfer engine, and any application built on top of transfer - * engine. The configuration information is stored as key/value pairs. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public interface ConfigurationService { - - public static final String VERSION_PROPERTY = "version"; - - /** - * Retrieve the stored configuration information. - * - * @return List of {@link ConfgurationProperty} which - * represents the stored configuration information. - * @throws ConveyorExecutionException - */ - List listConfigurationProperties() - throws ConveyorExecutionException; - - /** - * Add a new configuration property to the configuration store. - * - * @param configurationProperty - * {@link ConfigurationProperty} that will be added to the store - * @return {@link ConfigurationProperty} that has been stored - * @throws ConveyorExecutionException - */ - ConfigurationProperty addConfigurationProperty( - ConfigurationProperty configurationProperty) - throws ConveyorExecutionException; - - /** - * Update an existing configuration property - * - * @param configurationProperty - * {@link ConfigurationProperty} that will be updated in the - * store - * @throws ConveyorExecutionException - */ - void updateConfigurationProperty(ConfigurationProperty configurationProperty) - throws ConveyorExecutionException; - - /** - * Delete the given property from the config store. - * - * @param configurationProperty - * {@link ConfigurationProperty} that will be deleted from the - * store - * @throws ConveyorExecutionException - */ - void deleteConfigurationProperty(ConfigurationProperty configurationProperty) - throws ConveyorExecutionException; - - /** - * Given a set of properties, add or update the database properties. This - * method will retain any other existing properties in the database - * unaltered. - * - * @param propertiesToImport - * {@link Properties} that contains the configuration information - * in key/value format. This will replace the contents of the - * ConveyorExecutionException - * @throws TransferEngineException - */ - void importProperties(Properties propertiesToImport) - throws ConveyorExecutionException; - - /** - * Export the properties in the configuration properties database as a set - * of Properties. - * - * @return - * @throws ConveyorExecutionException - */ - Properties exportProperties() throws ConveyorExecutionException; - - /** - * Given a key, find the configuration information for that key, or - * null if no such configuration property exists - * - * @param configurationKey - * String with the key for the given configuration - * @return {@link ConfigurationProperty} for the key, or null - * if not exists - * @throws ConveyorExecutionException - */ - ConfigurationProperty findConfigurationPropertyByKey(String configurationKey) - throws ConveyorExecutionException; - - /** - * Build a jargon structure that controls transfers based on the available - * configuration. - *

- * This service method is set up so as to be able to access the elements - * that can effect the transfer option settings. - * - * @param restartPath - * String that can be blank (not null), indicating - * the last good path in case of a restart - * @param irodsAccessObjectFactory - * {@link IRODSAccessObjectFactory} representing the current - * Jargon connection settings and configuration - * - * @return {@link TransferControlBlock} structure based on conveyor service - * configuration - * @throws ConveyorExecutionException - */ - TransferControlBlock buildDefaultTransferControlBlockBasedOnConfiguration( - final String restartPath, - final IRODSAccessObjectFactory irodsAccessObjectFactory) - throws ConveyorExecutionException; - - /** - * Method retrieves a plain object that reflects the cached configuration - * state exposed as easy to use java methods. This service is responsible - * for maintaining the cache, which saves database access and is easy to use - * by other services. - * - * @return - * @throws ConveyorExecutionException - */ - CachedConveyorConfigurationProperties getCachedConveyorConfigurationProperties() - throws ConveyorExecutionException; - - /** - * Indicates whether the conveyor service is in 'tear off' mode, which means - * that it initializes fresh each time instead of caching data - * - * @return boolean of true if the configuration indicates tear - * off mode - * @throws ConveyorExecutionException - */ - boolean isInTearOffMode() throws ConveyorExecutionException; - -} \ No newline at end of file diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorBootstrapper.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorBootstrapper.java deleted file mode 100644 index 6dff1d7a2..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorBootstrapper.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.irods.jargon.conveyor.core; - -import org.irods.jargon.core.pub.IRODSAccessObjectFactory; - -public interface ConveyorBootstrapper { - - public abstract ConveyorService bootstrap( - IRODSAccessObjectFactory irodsAccessObjectFactory) - throws BootstrapperException; - -} \ No newline at end of file diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorBusyException.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorBusyException.java deleted file mode 100644 index 5ccba91cc..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorBusyException.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core; - -/** - * Represents a time-out or the conveyor is busy and cannot currently perform an - * operation - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class ConveyorBusyException extends ConveyorExecutionException { - - /** - * - */ - private static final long serialVersionUID = 1738765007550443864L; - - /** - * - */ - public ConveyorBusyException() { - } - - /** - * @param arg0 - */ - public ConveyorBusyException(final String arg0) { - super(arg0); - } - - /** - * @param arg0 - */ - public ConveyorBusyException(final Throwable arg0) { - super(arg0); - } - - /** - * @param arg0 - * @param arg1 - */ - public ConveyorBusyException(final String arg0, final Throwable arg1) { - super(arg0, arg1); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorCallbackListener.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorCallbackListener.java deleted file mode 100644 index 839cf3429..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorCallbackListener.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.irods.jargon.conveyor.core; - -import org.irods.jargon.core.transfer.TransferStatusCallbackListener; - -/** - * Interface to be implemented by a listener that will receive callbacks on the - * overall status of the ConveyorService, as well as callbacks - * issued by the underlying Jargon transfer process. An example use-case would - * be a GUI interface that wants to present icons that depict the real-time - * status of the transfer engine. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public interface ConveyorCallbackListener extends - TransferStatusCallbackListener { - - /** - * Callback when the running status of the ConveyorService has - * updated. - * - * @param runningStatus - * QueueStatus with the new status to set - */ - void setQueueStatus(final QueueStatus queueStatus); - - /** - * Signals an exception in the actual functioning of the conveyor framework - * itself - * - * @param conveyorException - * Exception occurring within the conveyor framework - * that cannot be handled - */ - void signalUnhandledConveyorException(final Exception conveyorException); - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorExecutionException.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorExecutionException.java deleted file mode 100644 index a2bef7150..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorExecutionException.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core; - -/** - * Exception caused in the processing of a conveyor task. Note that this is an - * error in the processing, not in the actual underlying task, which is normally - * passed to the TransferStatusCallbackListener - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class ConveyorExecutionException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 394410484893939617L; - - /** - * - */ - public ConveyorExecutionException() { - } - - /** - * @param arg0 - */ - public ConveyorExecutionException(final String arg0) { - super(arg0); - } - - /** - * @param arg0 - */ - public ConveyorExecutionException(final Throwable arg0) { - super(arg0); - } - - /** - * @param arg0 - * @param arg1 - */ - public ConveyorExecutionException(final String arg0, final Throwable arg1) { - super(arg0, arg1); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorExecutionFuture.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorExecutionFuture.java deleted file mode 100644 index cfe7eee2e..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorExecutionFuture.java +++ /dev/null @@ -1,14 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core; - -/** - * Future result of a ConveyorCallable - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class ConveyorExecutionFuture { - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorExecutorService.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorExecutorService.java deleted file mode 100644 index 93b55cfc6..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorExecutorService.java +++ /dev/null @@ -1,180 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core; - -import java.util.Properties; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import org.irods.jargon.transfer.dao.domain.TransferAttempt; - -/** - * Interface for the mechanism to process transfer operations. This object - * provides the common lock for controlling access to the queue, so that certain - * operations that may effect a transfer that is currently running will not - * occur until the queue is idle. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public interface ConveyorExecutorService { - - public static final int MAX_AVAILABLE = 1; - public static final String TRY_LOCK_TIMEOUT = "try.lock.timeout.seconds"; - - ExecutorService executor = Executors.newFixedThreadPool(1); - - /** - * @return the currentTransferAttempt - */ - TransferAttempt getCurrentTransferAttempt(); - - public enum ErrorStatus { - OK, WARNING, ERROR - } - - public enum RunningStatus { - IDLE, PAUSED, BUSY, PAUSED_BUSY - } - - /** - * Request to cancel the running of the given transfer attempt - * - * @param transferAttempt - * {@link TransferAttempt} to be cancelled - * @throws ConveyorExecutionException - */ - void requestCancel(final TransferAttempt transferAttempt) - throws ConveyorExecutionException; - - /*** - * Given a properly configured transfer attempt, execute the transfer and - * cause all of the various updates to occur - * - * @param conveyorCallable - * {@link ConveyorCallable} that will be run - * - * @throws ConvyorExecutionTimeoutException - * if an execute is called with withTimout as - * true, and the operation times out - * @throws ConveyorExecutionException - * for any exception in the actual execution - */ - void processTransfer(final TransferAttempt transferAttempt, - final ConveyorService conveyorService) - throws ConveyorBusyException, ConveyorExecutionException; - - /** - * Shut down the underlying pool (will attempt to do so in an orderly - * fashion). Note that this will block on a currently running execution, and - * is meant for cleanup. - */ - void shutdown(); - - /** - * Inject Properties that can control aspects of this service - * - * @param executorServiceProperties - */ - void setExecutorServiceProperties(Properties executorServiceProperties); - - /** - * See if the system is in a state where I can perform an operation that may - * affect a running operation. If I am in a state to do such an operation, - * the transfer queue status will be set to BUSY or will remain PAUSED. - *

- * Note that it is incumbent on an operation that grabs the queue and sets - * it to busy to return it to a paused or idle status by calling - * setOperationCompleted(). This sequence is meant for - * operations that should occur when the queue is not running (e.g. purging - * the queue, changing the pass phrase). - *

- * Note that this operation will return a ConveyorBusyException - * if the queue is busy when the operation is requested. This can be - * presented to the caller as an instruction to complete such operations - * when the queue is paused or idle. - * - * @throws ConveyorBusyException - * if the queue is busy - */ - void setBusyForAnOperation() throws ConveyorBusyException; - - /** - * This method releases the queue from a busy or 'busy and paused' status - * back to idle or paused, and is meant to finish an operation that should - * block the queue running, as set by the setBusyForOperation() - * method. - *

- * Clients that call the setBusyForOperation() are required to - * finish by calling this method. - */ - void setOperationCompleted(); - - /** - * Set the status of the conveyor, this is used by listeners that want to - * show the current state. - * - * @param runningStatus - */ - void setRunningStatus(final RunningStatus runningStatus); - - /** - * Set the status that signals the state of the conveyor (idle, busy, etc) - * - * @return - */ - RunningStatus getRunningStatus(); - - /** - * Set the error status - * - * @param errorStatus - */ - void setErrorStatus(final ErrorStatus errorStatus); - - /** - * Get any error status for the overall conveyor - * - * @return - */ - ErrorStatus getErrorStatus(); - - /** - * Return an object that reflects the status of the queue (running and error - * status in a value object) - * - * @return {@link QueueStatus} - */ - QueueStatus getQueueStatus(); - - ConveyorService getConveyorService(); - - void setConveyorService(final ConveyorService conveyorService); - - /** - * Convenience method to peek at the number of files tranferred so far in - * the current transfer - * - * @return int with number of files transferred so far. Note - * that this will return 0 if a current transfer is not available - */ - int getNumberFilesTransferredSoFarInCurrentTransfer(); - - /** - * Request that the conveyor service pauses. This will cause a cancellation - * of any currently running process too. The queue will halt until unpause - * is called. - * - * @throws ConveyorExecutionException - */ - void requestPause() throws ConveyorExecutionException; - - /** - * Un-pause the queue and release the next item. - * - * @throws ConveyorExecutionException - */ - void requestResumeFromPause() throws ConveyorExecutionException; - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorExecutorServiceImpl.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorExecutorServiceImpl.java deleted file mode 100644 index 02fa4a3fa..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorExecutorServiceImpl.java +++ /dev/null @@ -1,457 +0,0 @@ -package org.irods.jargon.conveyor.core; - -import java.util.Properties; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - -import org.irods.jargon.conveyor.core.callables.AbstractConveyorCallable; -import org.irods.jargon.conveyor.core.callables.ConveyorCallableFactory; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Implementation of an executor of conveyor processes. The current - * implementation runs one conveyor process at a time. Future implementations - * may run multiple processes, but this may require other refactoring. - *

- * The queue uses a Semaphore to manage access to the queue. - * Callers must call the appropriate lockQueue and - * unlockQueue methods. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class ConveyorExecutorServiceImpl implements ConveyorExecutorService { - - private final Logger log = LoggerFactory - .getLogger(ConveyorExecutorServiceImpl.class); - - private ErrorStatus errorStatus = ErrorStatus.OK; - private RunningStatus runningStatus = RunningStatus.IDLE; - // private final Object statusSynchronizingObject = new Object(); - private final ConveyorCallableFactory conveyorCallableFactory = new ConveyorCallableFactory(); - private Future currentTransferFuture = null; - private TransferAttempt currentTransferAttempt = null; - private AbstractConveyorCallable currentCallable = null; - - /** - * Thread pool (just 1 for now) that runs service - */ - private final ExecutorService pool = Executors.newSingleThreadExecutor(); - - /** - * Injected properties that control functionality of the conveyor - */ - private Properties executorServiceProperties = null; - - private ConveyorService conveyorService; - - public Properties getExecutorServiceProperties() { - synchronized (this) { - return executorServiceProperties; - } - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.ConveyorExecutorService#requestPause() - */ - @Override - public void requestPause() throws ConveyorExecutionException { - log.info("requestPause"); - - log.info("attempting to pause if there is a running transfer"); - synchronized (this) { - setRunningStatus(RunningStatus.PAUSED); - if (currentTransferAttempt != null) { - log.info("there is a transfer to cancel"); - requestCancel(currentTransferAttempt); - } - } - - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.ConveyorExecutorService#requestResumeFromPause - * () - */ - @Override - public void requestResumeFromPause() throws ConveyorExecutionException { - log.info("requestResumeFromPause()"); - - synchronized (this) { - setRunningStatus(RunningStatus.IDLE); - - log.info("release next item to process if available"); - - synchronized (this) { - conveyorService.getQueueManagerService().dequeueNextOperation(); - } - } - } - - @Override - public void requestCancel(final TransferAttempt transferAttempt) - throws ConveyorExecutionException { - if (transferAttempt == null) { - throw new IllegalArgumentException("null transferAttempt"); - } - - log.info("requestCancel() will attempt to cancel transferAttempt:{}", - transferAttempt); - - if (transferAttempt.getId() == null) { - throw new IllegalArgumentException("transfer attempt has null id"); - } - - synchronized (this) { - - if (currentTransferAttempt == null) { - log.info("no current transfer, ignore"); - return; - } - - if (currentCallable == null) { - log.info("no current callable, ignore"); - return; - } - - log.info("blowing away the future"); - - // this shouldn't happen - if (currentTransferFuture == null) { - log.warn("no current future found, ignore and pretend it's cancelled"); - return; - } - - log.info(">>>setting tcb to cancel and then cancelling future..."); - - /* - * This is a temporary trap, but getting occ'l npe's on the - * following statement, need to resolve and remove this check? MC - */ - - if (currentCallable.getTransferControlBlock() == null) { - - log.warn("*****************************************************\ntransfer control block ref is null!\n*****************************************************\n"); - } else { - currentCallable.getTransferControlBlock().setCancelled(true); - } - - currentTransferFuture.cancel(true); - - // let the cancel percolate - try { - - Thread.sleep(5000); - /* - * no final callback will be sent, as the tcb has cancelled set. - */ - } catch (InterruptedException ex) { - // ignore - } - - conveyorService.getTransferAccountingManagementService() - .updateTransferAfterCancellation(transferAttempt); - - log.info(" go ahead and make call to complete"); - setOperationCompleted(); - log.info(">>>>>> operation completed in queue"); - - } - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.ConveyorExecutorService# - * setExecutorServiceProperties(java.util.Properties) - */ - @Override - public void setExecutorServiceProperties( - final Properties executorServiceProperties) { - if (executorServiceProperties == null) { - throw new IllegalArgumentException("null executorServiceProperties"); - } - - synchronized (this) { - this.executorServiceProperties = executorServiceProperties; - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.ConveyorExecutorService#unlockQueue() - */ - /* - * public void unlockQueue() { executorLock.release(); } - */ - - @Override - public void processTransfer(final TransferAttempt transferAttempt, - final ConveyorService conveyorService) - throws ConveyorBusyException, ConveyorExecutionException { - - log.info("processTransferAndHandleReturn"); - - if (transferAttempt == null) { - throw new IllegalArgumentException("null transferAttempt"); - } - - if (conveyorService == null) { - throw new IllegalArgumentException("null conveyorService"); - } - - /* - * Note that the dequeue operation in the queue manager has already set - * the queue status to busy. The callable below will handle any further - * updates to the queue status based on callbacks from the running - * transfer process. - */ - - log.info("submitting transferAttempt:{}", transferAttempt); - synchronized (this) { - - currentTransferAttempt = transferAttempt; - currentCallable = conveyorCallableFactory - .instanceCallableForOperation(transferAttempt, - conveyorService); - - currentTransferFuture = pool.submit(currentCallable); - - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.ConveyorExecutorService#shutdown() - */ - @Override - public void shutdown() { - synchronized (this) { - pool.shutdownNow(); - } - } - - /** - * @return the errorStatus - */ - @Override - public ErrorStatus getErrorStatus() { - synchronized (this) { - return errorStatus; - } - } - - /** - * @param errorStatus - * the errorStatus to set - */ - @Override - public void setErrorStatus(final ErrorStatus errorStatus) { - - if (errorStatus == null) { - throw new IllegalArgumentException("null errorStatus"); - } - - synchronized (this) { - this.errorStatus = errorStatus; - notifyCallbackListenerOfChangeInStatus(); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.ConveyorExecutorService#getRunningStatus() - */ - @Override - public RunningStatus getRunningStatus() { - synchronized (this) { - return runningStatus; - } - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.ConveyorExecutorService#setRunningStatus - * (org.irods.jargon.conveyor.core.ConveyorExecutorService.RunningStatus) - */ - @Override - public void setRunningStatus(final RunningStatus runningStatus) { - - if (runningStatus == null) { - throw new IllegalArgumentException("null runningStatus"); - } - - synchronized (this) { - this.runningStatus = runningStatus; - notifyCallbackListenerOfChangeInStatus(); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.ConveyorExecutorService#setOperationCompleted - * () - */ - @Override - public void setOperationCompleted() { - log.info("setOperationCompleted()"); - synchronized (this) { - if (runningStatus == RunningStatus.PAUSED_BUSY - || runningStatus == RunningStatus.PAUSED) { - log.info("setting paused"); - setRunningStatus(RunningStatus.PAUSED); - } else { - log.info("setting idle"); - setRunningStatus(RunningStatus.IDLE); - } - - log.info("clearing transfer attempt and future if they are there"); - currentTransferAttempt = null; - currentTransferFuture = null; - currentCallable = null; - log.info("cleared...operation complete"); - } - } - - /** - * See if the system is in a state where I can perform an operation that may - * affect a running operation. If I am in a state to do such an operation, - * the transfer queue status will be set to BUSY or will remain PAUSED. - *

- * Note that it is incumbent on an operation that grabs the queue and sets - * it to busy to return it to a paused or idle status by calling - * setOperationCompleted(). This sequence is meant for - * operations that should occur when the queue is not running (e.g. purging - * the queue, changing the pass phrase). - *

- * Note that this operation will return a ConveyorBusyException - * if the queue is busy when the operation is requested. This can be - * presented to the caller as an instruction to complete such operations - * when the queue is paused or idle. - * - * @throws ConveyorBusyException - * if the queue is busy - */ - @Override - public void setBusyForAnOperation() throws ConveyorBusyException { - - synchronized (this) { - if (runningStatus == RunningStatus.BUSY) { - // log.debug("will return busy exception"); - throw new ConveyorBusyException( - "cannot perform operation, busy"); - } - - /* - * I don't want to overwrite a system set to paused, so set to busy - * if I'm idle, otherwise, it will be in a paused state and remain - * there - */ - - if (runningStatus == RunningStatus.PAUSED) { - log.info("setting to paused busy"); - setRunningStatus(RunningStatus.PAUSED_BUSY); - } else { - log.info("set busy"); - setRunningStatus(RunningStatus.BUSY); - } - } - } - - /** - * @return the currentTransfer - */ - public synchronized Future getCurrentTransferFuture() { - return currentTransferFuture; - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.ConveyorExecutorService#getQueueStatus() - */ - @Override - public QueueStatus getQueueStatus() { - return new QueueStatus(runningStatus, errorStatus); - } - - @Override - public ConveyorService getConveyorService() { - return conveyorService; - } - - @Override - public void setConveyorService(final ConveyorService conveyorService) { - this.conveyorService = conveyorService; - } - - /** - * Be sure to always call the set and get error and running status methods, - * so that those setters will properly notify the callback listener of a - * change in that status! This method will send a notification of a new - * QueueStatus up to the listener (e.g. the iDrop gui). - */ - private void notifyCallbackListenerOfChangeInStatus() { - - // in initial spring wiring the conveyor service may be null while - // bootstrapping runs. - - if (conveyorService == null) { - log.info("in bootstrap sequence, ignore callback"); - return; - } - - ConveyorCallbackListener listener = conveyorService - .getConveyorCallbackListener(); - if (listener != null) { - synchronized (this) { - listener.setQueueStatus(getQueueStatus()); - } - } - } - - /** - * @return the currentTransferAttempt - */ - @Override - public synchronized TransferAttempt getCurrentTransferAttempt() { - return currentTransferAttempt; - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.ConveyorExecutorService# - * getNumberFilesTransferredSoFarInCurrentTransfer() - */ - @Override - public synchronized int getNumberFilesTransferredSoFarInCurrentTransfer() { - if (currentCallable == null) { - return 0; - } - - return currentCallable.getTransferControlBlock() - .getTotalFilesTransferredSoFar(); - - } - -} \ No newline at end of file diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorQueueTimerTask.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorQueueTimerTask.java deleted file mode 100644 index 7971166e2..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorQueueTimerTask.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.irods.jargon.conveyor.core; - -import java.util.TimerTask; - -import org.slf4j.LoggerFactory; - -/** - * Task to periodically check the queue - * - * @author Mike Conway - DICE (www.irods.org) - */ -public class ConveyorQueueTimerTask extends TimerTask { - - /** - * Required dependency - */ - private ConveyorService conveyorService; - private volatile boolean initDone = false; - - /** - * allows the timer task to be paused (just bypasses any operations when the - * timer fires) - */ - private volatile boolean paused = false; - - private final org.slf4j.Logger log = LoggerFactory - .getLogger(ConveyorQueueTimerTask.class); - - public ConveyorQueueTimerTask() { - - } - - /** - * Init method is called before starting queue timer task - *

- * Right now this is just doing dependency checks but might be expanded - * later - */ - public void init() { - log.info("init"); - if (conveyorService == null) { - throw new ConveyorRuntimeException("conveyorService not set"); - } - initDone = true; - - } - - /** - * Ping the conveyor periodically to look for any actions - */ - @Override - public void run() { - log.info("timer task running"); - if (!initDone) { - throw new ConveyorRuntimeException("init is not done"); - } - - if (paused) { - log.info("timer task is paused..."); - return; - } - - try { - log.info("timer task firing...dequeue if available"); - conveyorService.getQueueManagerService().dequeueNextOperation(); - } catch (ConveyorExecutionException e) { - log.error("exception running timer task", e); - throw new ConveyorRuntimeException( - "exception encountered running timer task", e); - } - - } - - /** - * @return the conveyorService - */ - public ConveyorService getConveyorService() { - return conveyorService; - } - - /** - * @param conveyorService - * the conveyorService to set - */ - public void setConveyorService(final ConveyorService conveyorService) { - this.conveyorService = conveyorService; - } - - /** - * @return the paused - */ - public synchronized boolean isPaused() { - return paused; - } - - /** - * @param paused - * the paused to set - */ - public synchronized void setPaused(final boolean paused) { - log.info("set paused to:{}", paused); - this.paused = paused; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorRuntimeException.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorRuntimeException.java deleted file mode 100644 index 4a5ca1c08..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorRuntimeException.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core; - -/** - * Unprocessable runtime exception in conveyor framework - * - * @author Mike Conway - DICE (www.irods.org) see - * https://code.renci.org/gf/project/jargon/ - * - */ -public class ConveyorRuntimeException extends RuntimeException { - - /** - * - */ - private static final long serialVersionUID = -6566360568054196399L; - - /** - * - */ - public ConveyorRuntimeException() { - } - - /** - * @param arg0 - */ - public ConveyorRuntimeException(final String arg0) { - super(arg0); - } - - /** - * @param arg0 - */ - public ConveyorRuntimeException(final Throwable arg0) { - super(arg0); - } - - /** - * @param arg0 - * @param arg1 - */ - public ConveyorRuntimeException(final String arg0, final Throwable arg1) { - super(arg0, arg1); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorService.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorService.java deleted file mode 100644 index 86fa22a30..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorService.java +++ /dev/null @@ -1,205 +0,0 @@ -package org.irods.jargon.conveyor.core; - -import org.irods.jargon.conveyor.synch.SynchComponentFactory; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.AuthenticationException; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.IRODSAccessObjectFactory; -import org.irods.jargon.transfer.exception.PassPhraseInvalidException; - -/** - * Core of conveyor framework, manages client interactions and access to - * conveyor services. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public interface ConveyorService { - - /** - * Retrieve the current error and running status of the conveyor service - * - * @return {@link QueueStatus} reflecting the current state of the conveyor - * service - */ - QueueStatus getQueueStatus(); - - /** - * Register a listener who will receive callback messages from running - * transfers - * - * @param listener - * {@link ConveyorCallbackListener} - */ - void registerCallbackListener(ConveyorCallbackListener listener); - - /** - * Get the registered callback listener (may be null) - * - * @return {@link ConveyorCallbackListener} - */ - ConveyorCallbackListener getConveyorCallbackListener(); - - /** - * Required initialization method that must be called before the - * ConveyorService can be used. This method validates (or - * initially sets) a pass phrase that unlocks the underlying cache of - * accounts. - * - * @param passPhrase - * String with the pass phrase used to initialize - * the underlying data store - * @throws PassPhraseInvalidException - * thrown if the pass phrase is not valid - * @throws ConveyorExecutionException - */ - void validatePassPhrase(String passPhrase) - throws PassPhraseInvalidException, ConveyorExecutionException; - - /** - * Initialize the conveyor service in shared mode. This means that all grid - * accounts are cleared and initialized at start up, all previous transfers - * are cleared, and the app starts in a 'fresh' state, with the account - * information provided, and the - * - * @param irodsAccount - * @throws AuthenticationException - * @throws JargonException - * @throws ConveyorExecutionException - */ - void validatePassPhraseInTearOffMode(final IRODSAccount irodsAccount) - throws AuthenticationException, JargonException, - ConveyorExecutionException, JargonException; - - /** - * Check to see if this is the first run of the conveyor service by looking - * for the presence of the pass phrase - * - * @return boolean of - * true if the pass phrase is already remembered - * @throws ConveyorExecutionException - */ - boolean isPreviousPassPhraseStored() throws ConveyorExecutionException; - - /** - * Method to blow away the conveyor store, can be used if the pass phrase is - * forgotten. This clears all information from the memory, equivalent to - * clearing all underlying data tables. - * - * @throws ConveyorExecutionException - */ - void resetConveyorService() throws ConveyorExecutionException; - - void setConveyorExecutorService( - ConveyorExecutorService conveyorExecutorService); - - ConveyorExecutorService getConveyorExecutorService(); - - void setGridAccountService(GridAccountService gridAccountService); - - GridAccountService getGridAccountService(); - - void setSynchronizationManagerService( - SynchronizationManagerService synchronizationManagerService); - - SynchronizationManagerService getSynchronizationManagerService(); - - void setFlowManagerService(FlowManagerService flowManagerService); - - FlowManagerService getFlowManagerService(); - - void setQueueManagerService(QueueManagerService queueManagerService); - - QueueManagerService getQueueManagerService(); - - /** - * Get the service that maintains records of status of transfers and - * transfer items - * - * @return - */ - TransferAccountingManagementService getTransferAccountingManagementService(); - - /** - * Set the service that maintains records of status of transfers and - * transfer items - * - * @param transferAccountingManagementService - */ - void setTransferAccountingManagementService( - TransferAccountingManagementService transferAccountingManagementService); - - /** - * Clean up and shut down the service - */ - void shutdown(); - - /** - * Get the {@link ConfigurationService} that is a required dependency, and - * manages the storage of arbitrary properties for configuration. - * - * @return {@link ConfigurationService} - */ - ConfigurationService getConfigurationService(); - - /** - * Setter for required dependency to manage configuration properties - * - * @param configurationService - */ - void setConfigurationService(ConfigurationService configurationService); - - IRODSAccessObjectFactory getIrodsAccessObjectFactory(); - - void setIrodsAccessObjectFactory( - IRODSAccessObjectFactory irodsAccessObjectFactory); - - void setConveyorCallbackListener( - ConveyorCallbackListener conveyorCallbackListener); - - /** - * Initialize the timer task that asynchronously triggers the queue, and any - * other setup tasks - *

- * This method must be called when bootstrapping the conveyor service, - * through spring configuration or otherwise - */ - void init(); - - /** - * Cancel the timer task that periodically checks the queue. It can be - * started again using the startQueueTimerTask method. - */ - void cancelQueueTimerTask(); - - /** - * Start the timer task that periodically checks the queue. It can be - * cancelled through the cancelQueueTimerTask method. - *

- * Calling this method also begins execution of the periodic timer task that - * will run any pending processes and do any periodic activity within the - * conveyor service. This method must be called by the client when ready to - * start processing. - * - * @throws ConveyorExecutionException - */ - void beginFirstProcessAndRunPeriodicServiceInvocation() - throws ConveyorExecutionException; - - /** - * Set the factory used to build components used in the synch process - * - * @param synchComponentFactory - * {@link SynchComponentFactory} - */ - void setSynchComponentFactory( - final SynchComponentFactory synchComponentFactory); - - /** - * Get the factory used to build synch components - * - * @return {@link SynchComponentFactory} - */ - SynchComponentFactory getSynchComponentFactory(); - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorServiceImpl.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorServiceImpl.java deleted file mode 100644 index 388c22241..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/ConveyorServiceImpl.java +++ /dev/null @@ -1,408 +0,0 @@ -package org.irods.jargon.conveyor.core; - -import java.util.Timer; - -import org.irods.jargon.conveyor.basic.BasicQueueManagerServiceImpl; -import org.irods.jargon.conveyor.synch.SynchComponentFactory; -import org.irods.jargon.conveyor.synch.SynchPeriodicScheduler; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.connection.auth.AuthResponse; -import org.irods.jargon.core.exception.AuthenticationException; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.IRODSAccessObjectFactory; -import org.irods.jargon.transfer.exception.PassPhraseInvalidException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Abstract implementation of the ConveyorService interface. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ - -public class ConveyorServiceImpl implements ConveyorService { - - private ConveyorCallbackListener conveyorCallbackListener; - - /** - * required dependency - */ - private QueueManagerService queueManagerService; - - /** - * required dependency - */ - private FlowManagerService flowManagerService; - - /** - * required dependency - */ - private SynchronizationManagerService synchronizationManagerService; - - /** - * required dependency - */ - private GridAccountService gridAccountService; - - /** - * required dependency - */ - private ConveyorExecutorService conveyorExecutorService; - - /** - * required dependency on the {@link ConfigurationService} that manages - * name/value pairs that reflect service configuration - */ - private ConfigurationService configurationService; - - /** - * required dependency on the {@link TransferAccountingManagementService} - * that manages the transfer actions as they are executed - */ - private TransferAccountingManagementService transferAccountingManagementService; - - /** - * required dependency on the {@link IRODSAccessObjectFactory} that will - * allow connections to iRODS - */ - private IRODSAccessObjectFactory irodsAccessObjectFactory; - - private Timer queueTimer = new Timer(); - - /** - * Required dependency on a factory to create synch components - * {@link SynchComponentFactory} - */ - private SynchComponentFactory synchComponentFactory; - - private static final Logger log = LoggerFactory - .getLogger(BasicQueueManagerServiceImpl.class); - - @Override - public ConfigurationService getConfigurationService() { - return configurationService; - } - - @Override - public void setConfigurationService( - final ConfigurationService configurationService) { - this.configurationService = configurationService; - } - - @Override - public QueueManagerService getQueueManagerService() { - log.info("returning queueManagerService: {}", queueManagerService); - return queueManagerService; - } - - @Override - public void setQueueManagerService( - final QueueManagerService queueMangerService) { - queueManagerService = queueMangerService; - } - - @Override - public FlowManagerService getFlowManagerService() { - return flowManagerService; - } - - @Override - public void setFlowManagerService( - final FlowManagerService flowManagerService) { - this.flowManagerService = flowManagerService; - } - - @Override - public SynchronizationManagerService getSynchronizationManagerService() { - return synchronizationManagerService; - } - - @Override - public void setSynchronizationManagerService( - final SynchronizationManagerService synchronizationManagerService) { - this.synchronizationManagerService = synchronizationManagerService; - } - - @Override - public GridAccountService getGridAccountService() { - return gridAccountService; - } - - @Override - public void setGridAccountService( - final GridAccountService gridAccountService) { - this.gridAccountService = gridAccountService; - } - - @Override - public ConveyorExecutorService getConveyorExecutorService() { - return conveyorExecutorService; - } - - @Override - public void setConveyorExecutorService( - final ConveyorExecutorService conveyorExecutorService) { - this.conveyorExecutorService = conveyorExecutorService; - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.ConveyorService#shutdown() - */ - @Override - public void shutdown() { - if (conveyorExecutorService != null) { - conveyorExecutorService.shutdown(); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.ConveyorService#validatePassPhrase(java - * .lang.String) - */ - @Override - public void validatePassPhrase(final String passPhrase) - throws PassPhraseInvalidException, ConveyorExecutionException { - - synchronized (this) { - log.info("validating pass phrase..."); - gridAccountService.validatePassPhrase(passPhrase); - log.info("validated..."); - init(); - } - - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.ConveyorService#resetConveyorService() - */ - @Override - public void resetConveyorService() throws ConveyorExecutionException { - gridAccountService.resetPassPhraseAndAccounts(); - - } - - @Override - public boolean isPreviousPassPhraseStored() - throws ConveyorExecutionException { - return gridAccountService.isPassPhraseStoredAlready(); - } - - /** - * @return the irodsAccessObjectFactory - */ - @Override - public IRODSAccessObjectFactory getIrodsAccessObjectFactory() { - return irodsAccessObjectFactory; - } - - /** - * @param irodsAccessObjectFactory - * the irodsAccessObjectFactory to set - */ - @Override - public void setIrodsAccessObjectFactory( - final IRODSAccessObjectFactory irodsAccessObjectFactory) { - this.irodsAccessObjectFactory = irodsAccessObjectFactory; - } - - /** - * Get a reference to a callback listener. In order to simply code sending - * callbacks, this method will ensure that the callback listener is not - * null, and in that case will create a dummy listener - * - * @return the transferStatusCallbackListener - */ - @Override - public synchronized ConveyorCallbackListener getConveyorCallbackListener() { - - if (conveyorCallbackListener == null) { - conveyorCallbackListener = new DevNullCallbackListener(); - } - - return conveyorCallbackListener; - } - - /** - * @param transferStatusCallbackListener - * the transferStatusCallbackListener to set - */ - @Override - public synchronized void setConveyorCallbackListener( - final ConveyorCallbackListener conveyorCallbackListener) { - this.conveyorCallbackListener = conveyorCallbackListener; - } - - @Override - public TransferAccountingManagementService getTransferAccountingManagementService() { - return transferAccountingManagementService; - } - - @Override - public void setTransferAccountingManagementService( - final TransferAccountingManagementService transferAccountingManagementService) { - this.transferAccountingManagementService = transferAccountingManagementService; - - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.ConveyorService#registerCallbackListener - * (org.irods.jargon.core.transfer.TransferStatusCallbackListener) - */ - @Override - public void registerCallbackListener(final ConveyorCallbackListener listener) { - conveyorCallbackListener = listener; - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.ConveyorService#getQueueStatus() - */ - @Override - public synchronized QueueStatus getQueueStatus() { - return getConveyorExecutorService().getQueueStatus(); - - } - - @Override - public synchronized void cancelQueueTimerTask() { - log.info("cancelQueueTimerTask()"); - if (queueTimer != null) { - queueTimer.cancel(); - queueTimer = null; - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.ConveyorService#startQueueTimerTask() - */ - @Override - public synchronized void beginFirstProcessAndRunPeriodicServiceInvocation() - throws ConveyorExecutionException { - /* - * Since I'm starting, look for any currently processing transactions - * and reset them to 'enqueued' - */ - - log.info("creating timer task to trigger queue actions"); - - ConveyorQueueTimerTask queueSchedulerTimerTask = new ConveyorQueueTimerTask(); - queueSchedulerTimerTask.setConveyorService(this); - queueSchedulerTimerTask.init(); - - SynchPeriodicScheduler synchPeriodicScheduler = new SynchPeriodicScheduler( - this); - queueTimer = new Timer(); - queueTimer.scheduleAtFixedRate(queueSchedulerTimerTask, 10000, 120000); - queueTimer.scheduleAtFixedRate(synchPeriodicScheduler, 20000, 360000); - log.info("timer scheduled"); - queueManagerService.dequeueNextOperation(); - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.ConveyorService#init() - */ - @Override - public void init() { - - log.info("init()"); - - if (getConfigurationService() == null) { - throw new ConveyorRuntimeException( - "null configurationService, dependency was not set"); - } - - try { - log.info("setting busy"); - getConveyorExecutorService().setBusyForAnOperation(); - log.info("checking for any transactions that were set to processing, and reset them to enqueued..."); - getQueueManagerService().preprocessQueueAtStartup(); - log.info("preprocessing done, unlock the queue"); - getConveyorExecutorService().setOperationCompleted(); - } catch (ConveyorBusyException e) { - log.error("cannot lock queue for initialization!", e); - throw new ConveyorRuntimeException("cannot lock queue for init", e); - } catch (ConveyorExecutionException e) { - log.error("cannot process queue for initialization!", e); - throw new ConveyorRuntimeException("cannot process queue for init", - e); - } - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.ConveyorService# - * validatePassPhraseInTearOffMode - * (org.irods.jargon.core.connection.IRODSAccount) - */ - @Override - public void validatePassPhraseInTearOffMode(final IRODSAccount irodsAccount) - throws AuthenticationException, ConveyorExecutionException, - JargonException { - log.info("validatePassPhraseInTearOffMode"); - synchronized (this) { - log.info("validating given iRODS Account..."); - if (irodsAccount == null) { - throw new IllegalArgumentException("null irodsAccount"); - } - - log.info("attempting to authenticate the given account:{}", - irodsAccount); - AuthResponse authResponse = getIrodsAccessObjectFactory() - .authenticateIRODSAccount(irodsAccount); - - log.info("auth accepted, set the pass phrase to the given password and store the grid Account"); - resetConveyorService(); - - gridAccountService.validatePassPhrase(irodsAccount.getPassword()); - gridAccountService.addOrUpdateGridAccountBasedOnIRODSAccount( - irodsAccount, authResponse); - init(); - } - - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.ConveyorService#setSynchComponentFactory - * (org.irods.jargon.conveyor.synch.SynchComponentFactory) - */ - @Override - public void setSynchComponentFactory( - final SynchComponentFactory synchComponentFactory) { - this.synchComponentFactory = synchComponentFactory; - - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.ConveyorService#getSynchComponentFactory() - */ - @Override - public SynchComponentFactory getSynchComponentFactory() { - return synchComponentFactory; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/DevNullCallbackListener.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/DevNullCallbackListener.java deleted file mode 100644 index 69f084a73..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/DevNullCallbackListener.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core; - -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.transfer.TransferStatus; - -/** - * Dummy callback listener - * - * @author Mike Conway - DICE (www.irods.org) see - * https://code.renci.org/gf/project/jargon/ - * - */ -public class DevNullCallbackListener implements ConveyorCallbackListener { - - /** - * - */ - public DevNullCallbackListener() { - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.core.transfer.TransferStatusCallbackListener#statusCallback - * (org.irods.jargon.core.transfer.TransferStatus) - */ - @Override - public FileStatusCallbackResponse statusCallback( - final TransferStatus transferStatus) throws JargonException { - - return FileStatusCallbackResponse.CONTINUE; - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.core.transfer.TransferStatusCallbackListener# - * overallStatusCallback(org.irods.jargon.core.transfer.TransferStatus) - */ - @Override - public void overallStatusCallback(final TransferStatus transferStatus) - throws JargonException { - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.core.transfer.TransferStatusCallbackListener# - * transferAsksWhetherToForceOperation(java.lang.String, boolean) - */ - @Override - public CallbackResponse transferAsksWhetherToForceOperation( - final String irodsAbsolutePath, final boolean isCollection) { - return CallbackResponse.CANCEL; - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.core.ConveyorCallbackListener#setQueueStatus - * (org.irods.jargon.conveyor.core.QueueStatus) - */ - @Override - public void setQueueStatus(final QueueStatus queueStatus) { - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.ConveyorCallbackListener# - * signalUnhandledConveyorException(java.lang.Exception) - */ - @Override - public void signalUnhandledConveyorException( - final Exception conveyorException) { - - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/FlowManagerService.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/FlowManagerService.java deleted file mode 100644 index 13d56663c..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/FlowManagerService.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core; - -import java.util.List; - -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpec; -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpecCacheService; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; - -/** - * Manages attached rules and workflows. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public interface FlowManagerService { - - /** - * Required dependency on a service that can process source scripts into - * FlowSpecs - * - * @param flowSpecCacheService - * {@link FlowSpecCacheService} that will scan directories to - * produce flow specifications - * @throws ConveyorExecutionException - */ - void setFlowSpecCacheService(final FlowSpecCacheService flowSpecCacheService) - throws ConveyorExecutionException; - - /** - * Given a TransferAttempt find the candidate - * FlowSpec objects that represent flows that are matched based - * on selectors - * - * @param transferAttempt - * {@link TransferAttempt} to match with the given flowSpecs - * @return List of {@link FlowSpec}, which are thread safe - * clones, of the available matches for the given transfer, based on - * the configured selectors - * @throws ConveyorExecutionException - */ - List retrieveCandidateFlowSpecs( - final TransferAttempt transferAttempt) - throws ConveyorExecutionException; -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/GridAccountService.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/GridAccountService.java deleted file mode 100644 index 3f044518c..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/GridAccountService.java +++ /dev/null @@ -1,230 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core; - -import java.util.List; - -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.connection.auth.AuthResponse; -import org.irods.jargon.transfer.dao.domain.GridAccount; -import org.irods.jargon.transfer.dao.domain.KeyStore; -import org.irods.jargon.transfer.exception.PassPhraseInvalidException; - -/** - * Manager of GridAccount which represents the cache of identities - * used in the system. - *

- * The underlying implementation should properly synchronize access to the data, - * and furthermore, should properly maintain locks on the underlying transfer - * queue so as not to process updates that could effect a running transfer. - *

- * In order to protect currently running transfers, this locking is done by - * checking the running status of the queue, and throwing a - * ConveyorBusy exception if the queue is currently not in an idle - * or paused state. Clients should check for these exceptions and forward advice - * to users to retry the operation when the queue is not busy. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public interface GridAccountService { - - /** - * Return the pass phrase used to encrypt/decrypt the password information - * cached in the transfer database. This is the clear text password rather - * than the hashed value stored in the database key store. - * - * @return String with the clear text pass phrase for the grid - * account cache information - */ - String getCachedPassPhrase(); - - /** - * Given a pass phrase (presented as clear next, not a hash), update all - * stored grid accounts to reflect the new pass phrase. - *

- * This method only works if the original pass phrase is first validated, - * calling the validatePassPhrase() method of this class - * - * @param passPhrase - * @return - * @throws ConveyorBusyException - * if the operation cannot currently be done, with the queue - * data currently processing. The operation may be retried after - * the queue is paused or idle - * @throws PassPhraseinvalidException - * if the existing pass phrase was not properly validated before - * setting a new one. - * @throws ConveyorExecutionException - */ - KeyStore changePassPhraseWhenAlreadyValidated(String passPhrase) - throws ConveyorBusyException, PassPhraseInvalidException, - ConveyorExecutionException; - - /** - * Given an IRODSAccount, add a new GridAccount, - * or update the underlying GridAccount with the information - * from the IRODSAccount. (default storage resource, default - * path, password). - *

- * Note that the grid account is unique by host, zone, and user name. - * - * @param irodsAccount - * {@link IRODSAccount} that will be used to create or update the - * GridAccount - * @return {@link GridAccount} that is equivalent to the - * IRODSAccount. Note that the password in the returned - * GridAccount is encrypted by the pass phrase set in - * the TransferManager - * @throws PassPhraseInvalidException - * @throws ConveyorExecutionException - */ - GridAccount addOrUpdateGridAccountBasedOnIRODSAccount( - IRODSAccount irodsAccount) throws PassPhraseInvalidException, - ConveyorExecutionException; - - /** - * Compare a given pass phrase's hash value with the previously stored - * value. If they match, then the pass phrase is validated and cached. This - * allows GridAccount information containing stored passwords - * to be decrypted. - * - * @param passPhrase - * String with the pass phrase to be validated, in - * clear text - * @throws ConveyorBusyException - * if the operation cannot currently be done, with the queue - * data currently processing. The operation may be retried after - * the queue is paused or idle - * @throws PassPhraseInvalidException - * if the pass phrase is not validated - * @throws ConveyorExecutionException - */ - void validatePassPhrase(String passPhrase) throws ConveyorBusyException, - PassPhraseInvalidException, ConveyorExecutionException; - - /** - * Delete the given GridAccount, including all child transfers - * and synchronizations - * - * @param gridAccount - * {@link GridAccount} to delete - * @throws ConveyorBusyException - * if the operation cannot currently be done, with the queue - * data currently processing. The operation may be retried after - * the queue is paused or idle - * @throws ConveyorExecutionException - */ - void deleteGridAccount(GridAccount gridAccount) - throws ConveyorBusyException, ConveyorExecutionException; - - /** - * Find the GridAccount corresponding to the given iRODS - * account - * - * @param irodsAccount - * {@link IRODSAccount} - * @return {@link GridAccount} that corresponds to the iRODS account, or - * null if no result is available - * @throws ConveyorExecutionException - */ - GridAccount findGridAccountByIRODSAccount(IRODSAccount irodsAccount) - throws ConveyorExecutionException; - - /** - * Return a list of grid accounts in host/zone/userName order - * - * @return List of {@link GridAccount} - * @throws ConveyorExecutionException - */ - List findAll() throws ConveyorExecutionException; - - /** - * Given a GridAccount return the corresponding iRODS account - * with the password decrypted - * - * @param gridAccount - * {@link GridAccount} containing cached account info - * @return {@link IRODSAccount} based on the GridAccount - * @throws ConveyorExecutionException - */ - IRODSAccount irodsAccountForGridAccount(final GridAccount gridAccount) - throws ConveyorExecutionException; - - /** - * Purge all grid accounts and related information from the store - * - * @throws ConveyorBusyException - * if the operation cannot currently be done, with the queue - * data currently processing. The operation may be retried after - * the queue is paused or idle - * @throws ConveyorExecutionException - */ - void deleteAllGridAccounts() throws ConveyorBusyException, - ConveyorExecutionException; - - /** - * Get a reference to the conveyor executor service that actually runs the - * underlying transfer operations - * - * @return - */ - ConveyorExecutorService getConveyorExecutorService(); - - /** - * Get rid of all accounts, and clear the pass phrase. This allows a client - * using this library to 'forget' the key and reset the entire application - * - * @throws ConveyorBusyException - * if the operation cannot currently be done, with the queue - * data currently processing. The operation may be retried after - * the queue is paused or idle - * @throws ConveyorExecutionException - */ - void resetPassPhraseAndAccounts() throws ConveyorBusyException, - ConveyorExecutionException; - - /** - * Checks if a pass phrase has been stored. - * - * @return boolean of true if the pass phrase has - * been stored - * @throws ConveyorExecutionException - */ - boolean isPassPhraseStoredAlready() throws ConveyorExecutionException; - - /** - * Associate the choice for default storage resource with the grid account - * - * @param resourceName - * String with a valid resource name, or blank - * @param irodsAccount - * {@link IRODSAccount} to save - * @throws ConveyorExecutionException - */ - void rememberDefaultStorageResource(String resourceName, - IRODSAccount irodsAccount) throws ConveyorExecutionException; - - /** - * Update the stored grid account, including optional - * AuthResponse data from an authentication. This allows - * caching of a secondary runAs identity. This is useful in authentication - * scenarios where a temporary account may be generated upon login and used, - * such as during PAM authentication. - * - * @param irodsAccount - * {@link IRODSAccount} to save - * @param authResponse - * {@link AuthResponse} to save, this may be left - * null, and if supplied will be cached in the grid - * account information - * @return {@link GridAccount} that corresponds to the iRODS account - * @throws PassPhraseInvalidException - * @throws ConveyorExecutionException - */ - GridAccount addOrUpdateGridAccountBasedOnIRODSAccount( - final IRODSAccount irodsAccount, final AuthResponse authResponse) - throws PassPhraseInvalidException, ConveyorExecutionException; - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/QueueManagerService.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/QueueManagerService.java deleted file mode 100644 index c3a1dddbd..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/QueueManagerService.java +++ /dev/null @@ -1,303 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core; - -import java.util.List; - -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.transfer.dao.TransferDAOException; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.irods.jargon.transfer.dao.domain.TransferItem; -import org.irods.jargon.transfer.dao.domain.TransferType; - -/** - * Manages the persistent queue of transfer information - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public interface QueueManagerService { - - /** - * Add a transfer operation to the queue. This transfer will be based on the - * given iRODS account information. The transfer will be scheduled for later - * execution. - * - * @param transfer - * {@link Transfer} to be executed - * @param irodsAccount - * {@link IRODSAccount} - * @throws RejectedTransferException - * if the transfer was rejected (e.g. for being a duplicate) - * @throws ConveyorExecutionException - */ - void enqueueTransferOperation(final Transfer transfer, - final IRODSAccount irodsAccount) throws RejectedTransferException, - ConveyorExecutionException; - - /** - * Signal that,if the queue is not busy, that the next pending operation - * should be launched. This may be safely called even if the queue is busy - * (the call will be ignored) or if there are no transfers to process. This - * method is suitable for calling by a timer process, for example, that - * checks for any pending work. - * - * @throws ConveyerExecutionException - */ - void dequeueNextOperation() throws ConveyorExecutionException; - - /** - * Convenience function for iDrop to start a transfer based on the given - * iRODS account information. This transfer will be based on the given iRODS - * account information. The transfer will be scheduled for later execution. - *

- * This method creates a Transfer based on the provided path - * and operation details, and places it in the queue. - * - * @param irodsFile - * String full path of iRODS file/folder for get or put - * @param localFile - * String full path of local file/folder for get or put - * @param irodsAccount - * {@link IRODSAccount} describing the IRODSAccount - * @param TransferType - * {@link TransferType} type of transfer - GET, PUT, etc - * @throws ConveyorExecutionException - */ - void enqueueTransferOperation(final String irodsFile, - final String localFile, final IRODSAccount irodsAccount, - final TransferType type) throws ConveyorExecutionException; - - /** - * Purge all of contents of queue, no matter what the status - * - * @throws ConveyorBusyException - * if the conveyor framework is busy, this indicates that the - * queue should be idle before purging - * @throws ConveyorExecutionException - * for other errors - */ - void purgeAllFromQueue() throws ConveyorBusyException, - ConveyorExecutionException; - - /** - * Cancel specified transfer, no matter what the status - * - * @throws TransferNotFoundException - * if transfer cannot be located - * @throws ConveyorExecutionException - * for other errors - */ - void cancelTransfer(final long transferAttemptId) - throws TransferNotFoundException, ConveyorExecutionException; - - /** - * Purge specified transfer from the queue, no matter what the status - * - * @throws ConveyorBusyException - * if the transfer is busy, this indicates that the queue should - * be idle before purging - * @throws ConveyorExecutionException - * for other errors - */ - void deleteTransferFromQueue(Transfer transfer) - throws ConveyorBusyException, ConveyorExecutionException; - - /** - * Get a list of the entire contents of the transfer queue - * - * @return List of {@link Transfer} containing the entire - * contents of the queue (including completed, etc) - * @throws ConveyorExecutionException - */ - List listAllTransfersInQueue() throws ConveyorExecutionException; - - /** - * Get a filled out (children initialized) representation of a transfer. - * - * @param transfer - * {@link Transfer} that will be updated in place with - * initialized children - * @throws ConveyorExecutionException - */ - Transfer initializeGivenTransferByLoadingChildren(Transfer transfer) - throws ConveyorExecutionException; - - /** - * Given an id, look up the transfer information in the database. - * - * @param transferId - * long with the transfer id - * @return {@link Transfer}, with all children except transfer items, - * initialized. This is done for efficiency, as the transfer items - * can be quite large. Note that null will be returned - * if the transfer cannot be found. - * @throws ConveyorExecutionException - */ - Transfer findTransferByTransferId(final long transferId) - throws ConveyorExecutionException; - - /** - * Cause a transfer to be resubmitted as a restart. A restart will look at - * the last successful transfer, and skip files before that restart point. - * The actual transfers will resume once the restart point is encountered. - *

- * Note that various configuration settings control how restarts are logged. - * Optionally, the framework can log each skipped file in the restart - * process to provide complete accounting for that transfer attempt. - * - * @param transferId - * long with the unique id for the transfer - * @throws TransferNotFoundException - * @throws RejectedTransferException - * if the transfer is not suitable for restart - * @throws ConveyorExecutionException - */ - void enqueueRestartOfTransferOperation(final long transferId) - throws TransferNotFoundException, RejectedTransferException, - ConveyorExecutionException; - - /** - * Cause a transfer to be resubmitted. A resubmit will start the transfer - * from the beginning. - * - * @param transferId - * long with the unique id for the transfer - * @throws RejectedTransferException - * if the transfer is not suitable for resubmit - * @throws TransferNotFoundException - * @throws ConveyorExecutionException - */ - void enqueueResubmitOfTransferOperation(final long transferId) - throws TransferNotFoundException, RejectedTransferException, - ConveyorExecutionException; - - /** - * General method allows saving of arbitrary Transfer - * information. This will add or update based on the provided information. - * Note that this method bypasses all of the semantics of transfer - * management, so it should be used carefully. - *

- * Typically, transfers are added by calling the - * enqueueTransferOperation methods. - * - * @param transfer - * {@link Transfer} to be saved, as is, in the queue - * @throws ConveyorExecutionException - */ - void saveOrUpdateTransfer(final Transfer transfer) - throws ConveyorExecutionException; - - /** - * General method allows adding of an arbitrary new - * TransferAttempt to a given transfer object. The transfer - * object must exist or an exception will occur. This method adds the - * transfer attempt information as-is, and bypasses all the transfer - * management semantics, so it should be used with care. Generally, the - * TransferAttempt is created by this service when a transfer - * is enqueued for processing using the normal - * enqueueTransferOperation methods. - *

- * - * Note that this method will add the transfer attempt to the transfer, and - * also set the transfer parent in the transfer attempt object provided. - * This method will also set the create and update dates for that transfer - * attempt to the current time. - * - * @param transferId - * long with the id of the transfer - * @param transferAttempt - * {@link TransferAttempt} to be added to the {@link Transfer} - * @Throws TransferNotFoundException - * @throws ConveyorExecutionException - */ - void addTransferAttemptToTransfer(long transferId, - TransferAttempt transferAttempt) throws TransferNotFoundException, - ConveyorExecutionException; - - /** - * Given an id and a start and max number of results return a list of - * TransferItems for the specified transfer attempt id. - * - * @param transferAttemptId - * long with the transfer attempt - * @return {@link TransferItems} list. - * @throws ConveyorExecutionException - */ - List getNextTransferItems(final long transferAttemptId, - int start, int length) throws ConveyorExecutionException; - - /** - * At startup of the conveyor service, preprocess the queue looking for any - * transfers that were marked as processing. This should be called before - * normal queue processing begins. - * - * @throws ConveyorExecutionException - */ - void preprocessQueueAtStartup() throws ConveyorExecutionException; - - /** - * Purge successfully completed transfers from the queue, leaving error and - * processing transfers - * - * @throws ConveyorBusyException - * @throws ConveyorExecutionException - */ - void purgeSuccessfulFromQueue() throws ConveyorBusyException, - ConveyorExecutionException; - - /** - * At startup, any processing transfers are reenqueued. This method will - * take a transfer that may be marked as processing and reenqueue it. Note - * that that this method does not trigger a dequeue, rather, it will rely on - * the startup sequence to do this. - * - * @param transferId - * long with the transfer id - * @throws TransferNotFoundException - * @throws RejectedTransferException - * @throws ConveyorExecutionException - */ - void reenqueueTransferAtBootstrapTime(long transferId) - throws TransferNotFoundException, RejectedTransferException, - ConveyorExecutionException; - - /** - * Do a pageable listing of items, allowing selection of the items to show - * by classification.
- * If showSucces is true, then successes AND errors are - * displayed, this is a 'list all' setting. This may be further refined by - * setting showSkipped, which, when true, will show any files - * skipped in the attempt, because of restarting.
- * Note that if showSuccess is false, then skipped files are - * also not shown. This will result in a listing of just error transfer - * items. - * - * @param transferAttemptId - * @param transferAttemptId - * long with the id of the - * TransferAttempt that will be looked up - * @param start - * int with the start index of the list of - * TransferItems to return - * @param length - * int with the max number of - * TransferItems to return - * @param showSuccess - * boolean that, when true, will show all items, - * including errors. When set to false, only error items are - * returned. - * @param showSkipped - * boolean that, when true, will show items skipped - * during a restart. When showSuccess is false, this - * will have no effect - * @return {@link TransferItems} list - * @throws TransferDAOException - */ - List getNextTransferItems(Long transferAttemptId, int start, - int length, boolean showSuccess, boolean showSkipped) - throws ConveyorExecutionException; - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/QueueStatus.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/QueueStatus.java deleted file mode 100644 index 33d1a7c85..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/QueueStatus.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core; - -import org.irods.jargon.conveyor.core.ConveyorExecutorService.ErrorStatus; -import org.irods.jargon.conveyor.core.ConveyorExecutorService.RunningStatus; - -/** - * An immutable value object that represents the state of the transfer queue - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class QueueStatus { - - private final RunningStatus runningStatus; - - private final ErrorStatus errorStatus; - - /** - * - */ - public QueueStatus(final RunningStatus runningStatus, - final ErrorStatus errorStatus) { - - if (runningStatus == null) { - throw new IllegalArgumentException("null running status"); - } - - if (errorStatus == null) { - throw new IllegalArgumentException("null error status"); - } - - this.runningStatus = runningStatus; - this.errorStatus = errorStatus; - } - - public RunningStatus getRunningStatus() { - return runningStatus; - } - - public ErrorStatus getErrorStatus() { - return errorStatus; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/RejectedTransferException.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/RejectedTransferException.java deleted file mode 100644 index 13298ada1..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/RejectedTransferException.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core; - -/** - * Exception caused by a requested transfer operation being rejected (e.g. for - * being a duplicate) - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class RejectedTransferException extends ConveyorExecutionException { - - /** - * - */ - private static final long serialVersionUID = -8444222046737658883L; - - /** - * - */ - public RejectedTransferException() { - } - - /** - * @param arg0 - */ - public RejectedTransferException(final String arg0) { - super(arg0); - } - - /** - * @param arg0 - */ - public RejectedTransferException(final Throwable arg0) { - super(arg0); - } - - /** - * @param arg0 - * @param arg1 - */ - public RejectedTransferException(final String arg0, final Throwable arg1) { - super(arg0, arg1); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/SynchronizationManagerService.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/SynchronizationManagerService.java deleted file mode 100644 index 1ac221e7f..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/SynchronizationManagerService.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core; - -import java.util.List; - -import org.irods.jargon.core.exception.DataNotFoundException; -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.transfer.dao.domain.Synchronization; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; - -/** - * Manages synchronizations scheduling. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public interface SynchronizationManagerService { - - /** - * Get a list of all configured synchronizations - * - * @return List of {@link Synchronization} - * @throws ConveyorExecutionException - */ - List listAllSynchronizations() - throws ConveyorExecutionException; - - /** - * Find and return a synch based on its id key. Return null if - * not found - * - * @param id - * long with the id - * @return {@link Synchronization} with that id, or null if not - * found - * @throws ConveyorExecutionException - */ - Synchronization findById(final long id) throws ConveyorExecutionException; - - /** - * Cause the next pending (if any) synchronization process to be executed If - * no synchs are pending, then nothing is done. - * - * @return - * - * @throws ConveyorExecutionException - */ - void triggerExecutionOfAnyNextPendingSynchronization() - throws ConveyorExecutionException; - - /** - * Cause an add or update of a synchronization - * - * @param synchronization - * {@link Synchronization} to add or update. - * @throws ConveyorExecutionException - */ - void addOrUpdateSynchronization(final Synchronization synchronization) - throws ConveyorExecutionException; - - /** - * Delete a synchronization - * - * @param synchronization - * {@link Synchronization} to delete - * @throws ConveyorExecutionException - */ - void deleteSynchronization(final Synchronization synchronization) - throws ConveyorExecutionException; - - /** - * Clear the history of transfer and attemps for the given synchronization - * - * @param synchronization - * {@link Synchronization} to purge - * @throws DataNotFoundException - * if the synch does not exist - * @throws ConveyorExecutionException - */ - void purgeSynchronizationHistory(final Synchronization synchronization) - throws DataNotFoundException, ConveyorExecutionException; - - /** - * Trigger immediate processing of a synchronization - * - * @param synchronization - * {@link Synchronization} to trigger, it must exist - * @throws RejectedTransferException - * if the transfer cannot be scheduled - * @throws ConveyorExecutionException - */ - void triggerSynchronizationNow(final Synchronization synchronization) - throws RejectedTransferException, ConveyorExecutionException; - - /** - * Given a transfer status that signals the successful completion of a - * synchronization operation, do the necessary updates that account for this - * synch. - * - * @param transferStatus - * {@link TransferStatus} this is a successful synch completion - * @param transferAttempt - * {@link TransferAttempt} for this synch attempt - * @throws ConveyorExecutionException - */ - void updateSynchronizationWithSuccessfulCompletion( - TransferStatus transferStatus, TransferAttempt transferAttempt) - throws ConveyorExecutionException; - - /** - * Given a transfer status that signals the warning completion of a - * synchronization operation, with errors about the configured threshold, do - * the necessary updates that account for this synch. - * - * @param transferStatus - * {@link TransferStatus} this is a successful synch completion - * @param transferAttempt - * {@link TransferAttempt} for this synch attempt - * @throws ConveyorExecutionException - */ - void updateSynchronizationWithWarningCompletion( - TransferStatus transferStatus, TransferAttempt transferAttempt) - throws ConveyorExecutionException; - - /** - * Given a transfer status that signals the failure completion of a - * synchronization operation do the necessary updates that account for this - * synch. - * - * @param transferStatus - * {@link TransferStatus} this is a successful synch completion - * @param transferAttempt - * {@link TransferAttempt} for this synch attempt - * @throws ConveyorExecutionException - */ - void updateSynchronizationWithFailure(TransferStatus transferStatus, - TransferAttempt transferAttempt) throws ConveyorExecutionException; - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/TransferAccountingManagementService.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/TransferAccountingManagementService.java deleted file mode 100644 index 60a2d0671..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/TransferAccountingManagementService.java +++ /dev/null @@ -1,256 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core; - -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; - -/** - * Service to manage updates to a Transfer as a result of running - * that transfer. This would include updates to the current attempt, and - * file-by-file accounting procedures as signaled in the transfer callback - * process - * - * @author Mike Conway - DICE (www.irods.org) - * - */ - -public interface TransferAccountingManagementService { - - public static final String WARNING_SOME_FAILED_MESSAGE = "Success, but some file transfers may have failed, please check the transfer details"; - public static final String WARNING_NO_FILES_TRANSFERRED_MESSAGE = "Success, but no files were found to transfer"; - public static final String WARNING_CANCELLED_MESSAGE = "Transfer was cancelled"; - public static final String ERROR_SOME_FAILED_MESSAGE = "Failure, too many file transfers have failed, please check the transfer details"; - public static final String ERROR_ATTEMPTING_TO_RUN = "An error occurred while attempting to create and invoke the transfer process"; - public static final String ERROR_IN_TRANSFER_AT_IRODS_LEVEL = "An error during the transfer process at the client or in iRODS"; - - /** - * Set up Transfer Attempt for Transfer about the be processed - * - * @param transfer - * {@link Transfer} containing populated data - * @return {@link TransferAttempt} based on the Transfer - * - * @throws ConveyorExecutionException - */ - TransferAttempt prepareTransferForExecution(Transfer transfer) - throws ConveyorExecutionException; - - /** - * Update a transfer attempt (with last successful path) and transfer item - * after a successful transfer. - * - * @param transferStatus - * {@link TransferStatus} returned from status callback - * @param transferAttempt - * {@link TransferAttempt} that resulted in successful transfer - * @throws ConveyorExecutionException - */ - void updateTransferAfterSuccessfulFileTransfer( - TransferStatus transferStatus, TransferAttempt transferAttempt) - throws ConveyorExecutionException; - - /** - * Update a transfer due to an error returned in callback from Jargon. - * - * @param transferStatus - * {@link TransferStatus} returned from status callback - * @param transferAttempt - * {@link TransferAttempt} that resulted in the transfer error - * @param totalFileErrorsSoFar - * int with the total number of errors that have - * occurred so far - * @throws ConveyorExecutionException - */ - void updateTransferAfterFailedFileTransfer(TransferStatus transferStatus, - TransferAttempt transferAttempt, final int totalFileErrorsSoFar) - throws ConveyorExecutionException; - - /** - * Update a transfer due to an error trying to set up and run the transfer - * in the conveyor framework. This is distinct from errors that come back to - * conveyor based on callbacks from Jargon, and covers errors in managing - * the queue or internal databases, or other programming logic or - * initialization issues. - * - * @param transferAttempt - * {@link TransferAttempt} that resulted in the error - * @param exception - * Exception that occurred - * @throws ConveyorExecutionException - */ - void updateTransferAttemptWithConveyorException( - final TransferAttempt transferAttempt, final Exception exception) - throws ConveyorExecutionException; - - /** - * Make necessary updates to the given transfer upon overall success (all - * files or operations involved are complete). This sets the overall status - * and status of the attempt. - * - * @param transferStatus - * {@link TransferStatus} from the callback - * @param transferAttempt - * {@link TransferAttempt} - * @throws ConveyorExecutionException - */ - void updateTransferAfterOverallSuccess( - org.irods.jargon.core.transfer.TransferStatus transferStatus, - TransferAttempt transferAttempt) throws ConveyorExecutionException; - - /** - * Make necessary updates to the given transfer upon cancellation. This sets - * the overall status and status of the attempt. - * - * @param transferAttempt - * {@link TransferAttempt} - * @throws ConveyorExecutionException - */ - void updateTransferAfterCancellation(TransferAttempt transferAttempt) - throws ConveyorExecutionException; - - /** - * Make necessary updates to the given transfer upon overall completion with - * a warning status (all files or operations involved are complete, but some - * were in error at a level below the warning threshold). This sets the - * overall status and status of the attempt. - * - * - * @param transferStatus - * {@link TransferStatus} from the callback - * @param transferAttempt - * {@link TransferAttempt} - * @throws ConveyorExecutionException - */ - void updateTransferAfterOverallWarningByFileErrorThreshold( - TransferStatus transferStatus, TransferAttempt transferAttempt) - throws ConveyorExecutionException; - - /** - * Make necessary updates to the given transfer upon overall completion with - * a warning status due to the fact that no files were found to transfer - * - * @param transferStatus - * {@link TransferStatus} from the callback - * @param transferAttempt - * {@link TransferAttempt} - * @throws ConveyorExecutionException - */ - void updateTransferAfterOverallWarningNoFilesTransferred( - TransferStatus transferStatus, TransferAttempt transferAttempt) - throws ConveyorExecutionException; - - /** - * Make necessary updates to the given transfer upon overall completion with - * a failure status (all files or operations involved are complete, but some - * were in error at a level above the warning threshold). This sets the - * overall status and status of the attempt. - * - * - * - * @param transferStatus - * {@link TransferStatus} from the callback - * @param transferAttempt - * {@link TransferAttempt} - * @throws ConveyorExecutionException - */ - void updateTransferAfterOverallFailureByFileErrorThreshold( - TransferStatus transferStatus, TransferAttempt transferAttempt) - throws ConveyorExecutionException; - - /** - * Make necessary updates to the given transfer upon overall failure. This - * sets the overall status and status of the attempt. - * - * - * @param transferStatus - * {@link TransferStatus} from the callback - * @param transferAttempt - * {@link TransferAttempt} - * @throws ConveyorExecutionException - */ - void updateTransferAfterOverallFailure( - org.irods.jargon.core.transfer.TransferStatus transferStatus, - TransferAttempt transferAttempt) throws ConveyorExecutionException; - - /** - * Make the necessary updates to the given transfer and transfer item based - * on the notification that a file was skipped during a restart process. The - * item may or may not be logged mediated by the 'log successful files' and - * 'log restart files' settings, but at any rate the transfer attempt is - * updated - * - * @param transferStatus - * {@link TransferStatus} from the callback - * @param transferAttempt - * {@link TransferAttempt} - * @throws ConveyorExecutionException - */ - void updateTransferAfterRestartFileSkipped(TransferStatus transferStatus, - TransferAttempt transferAttempt) throws ConveyorExecutionException; - - /** - * Prepare the transfer to be placed into the enqueued state with a transfer - * attempt ready to process - * - * @param transfer - * @return - * @throws ConveyorExecutionException - */ - TransferAttempt prepareTransferForProcessing(Transfer transfer) - throws ConveyorExecutionException; - - /** - * Prepare the given transfer for a restart. This includes setting up a new - * TransferAttempt with the proper restart path. - * - * @param transferId - * long that is the valid id of a transfer in the - * database - * @return {@link Transfer} with proper setup enqueued for restart - * @throws ConveyorExecutionException - * @throws RejectedTransferException - */ - Transfer prepareTransferForRestart(final long transferId) - throws ConveyorExecutionException, RejectedTransferException; - - /** - * Prepare the given transfer for a resubmit. This includes setting up a new - * TransferAttempt. - * - * @param transferId - * long that is the valid id of a transfer in the - * database - * @return {@link Transfer} with proper setup enqueued for resubmit - * @throws ConveyorExecutionException - * @throws RejectedTransferException - */ - Transfer prepareTransferForResubmit(final long transferId) - throws ConveyorExecutionException, RejectedTransferException; - - /** - * Indicates that successful transfers are logged. This delegates to the - * configuration service settings. - * - * @return boolean that indicates that successful transfer are - * logged - * @throws ConveyorExecutionException - */ - boolean isLogSuccessfulTransfers() throws ConveyorExecutionException; - - /** - * Indicates the transfer was found as processing at startup time (perhaps - * conveyor was abruptly terminated). The transfer will be restarted and - * marked as restarted at startup time. - * - * @param transferId - * @return - * @throws ConveyorExecutionException - * @throws RejectedTransferException - */ - Transfer restartProcessingTransferAtStartup(long transferId) - throws ConveyorExecutionException, RejectedTransferException; - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/TransferNotFoundException.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/TransferNotFoundException.java deleted file mode 100644 index 90a520662..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/TransferNotFoundException.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core; - -/** - * A transfer cannot be found - * - * @author Mike Conway - DICE (www.irods.org) see - * https://code.renci.org/gf/project/jargon/ - * - */ -public class TransferNotFoundException extends ConveyorExecutionException { - - /** - * - */ - private static final long serialVersionUID = 1060500590074590041L; - - public TransferNotFoundException() { - } - - /** - * @param arg0 - */ - public TransferNotFoundException(final String arg0) { - super(arg0); - } - - /** - * @param arg0 - */ - public TransferNotFoundException(final Throwable arg0) { - super(arg0); - } - - /** - * @param arg0 - * @param arg1 - */ - public TransferNotFoundException(final String arg0, final Throwable arg1) { - super(arg0, arg1); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/AbstractConveyorCallable.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/AbstractConveyorCallable.java deleted file mode 100644 index 370a18fc9..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/AbstractConveyorCallable.java +++ /dev/null @@ -1,870 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core.callables; - -import java.util.List; -import java.util.concurrent.Callable; - -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.ConveyorExecutionFuture; -import org.irods.jargon.conveyor.core.ConveyorExecutorService.ErrorStatus; -import org.irods.jargon.conveyor.core.ConveyorRuntimeException; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.conveyor.core.FlowManagerService; -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpec; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice.ExecResult; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.exception.JargonRuntimeException; -import org.irods.jargon.core.pub.IRODSAccessObjectFactory; -import org.irods.jargon.core.transfer.TransferControlBlock; -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.core.transfer.TransferStatus.TransferState; -import org.irods.jargon.core.transfer.TransferStatusCallbackListener; -import org.irods.jargon.transfer.dao.domain.GridAccount; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.irods.jargon.transfer.dao.domain.TransferStatusEnum; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.transaction.annotation.Transactional; - -/** - * Abstract super class for a transfer running process. This class, and its - * collaborators, are responsible for: - *

    - *
  • Running the actual transfer process via Jargon
  • - *
  • Intercepting any call-backs from the Jargon process, and making the - * appropriate updates to the transfer accounting database
  • - *
  • Catching any not-trapped errors and making a best effort to log, account - * for them in the accounting database, and notifying the client if any - * unresolved errors occur
  • - *
  • Forwarding any call-backs to the client, such as file and intra-file - * updates of transfers
  • - *
  • Evaluating a transfer at completion for any errors
  • - *
  • Modifying the error and running status of the execution queue when the - * transfer completes or has errors
  • - *
- * - * @author Mike Conway - DICE (www.irods.org) - * - */ -@Transactional(noRollbackFor = { JargonException.class }, rollbackFor = { ConveyorExecutionException.class }) -public abstract class AbstractConveyorCallable implements - Callable, TransferStatusCallbackListener { - - private final TransferAttempt transferAttempt; - private final ConveyorService conveyorService; - private TransferControlBlock transferControlBlock; - private FlowCoProcessor flowCoProcessor; - - private static final Logger log = LoggerFactory - .getLogger(AbstractConveyorCallable.class); - - private List candidateFlowSpecs = null; - private FlowSpec selectedFlowSpec = null; - - /** - * Convenience method to get a IRODSAccount with a decrypted - * password - * - * @param gridAccount - * @return - * @throws ConveyorExecutionException - */ - IRODSAccount getIRODSAccountForGridAccount(final GridAccount gridAccount) - throws ConveyorExecutionException { - - log.info("getIRODSAccountForGridAccount()"); - if (gridAccount == null) { - throw new IllegalArgumentException("null gridAccount"); - } - - return getConveyorService().getGridAccountService() - .irodsAccountForGridAccount(gridAccount); - } - - /** - * Convenience method to get the IRODSAccessObjectFactory - * - * @return - */ - IRODSAccessObjectFactory getIrodsAccessObjectFactory() { - return conveyorService.getIrodsAccessObjectFactory(); - } - - /** - * - * Default constructor takes required hooks for bi-directional communication - * with caller of the transfer processor - * - * @param transfer - * @param conveyorService - */ - public AbstractConveyorCallable(final TransferAttempt transferAttempt, - final ConveyorService conveyorService) { - - if (transferAttempt == null) { - throw new IllegalArgumentException("null transferAttempt"); - } - - if (conveyorService == null) { - throw new IllegalArgumentException("null conveyorService"); - } - - this.transferAttempt = transferAttempt; - this.conveyorService = conveyorService; - - } - - /** - * This method is to be implemented by each specific transfer subclass. This - * is wrapped in the call() method of this abstract superclass, - * so that this superclass can wrap the call with appropriate - * setup/teardown, as well as error handling. - * - * @param tcb - * {@link TransferControlBlock} that contains transfer options - * and other information shared with the underlying transfer - * @param irodsAccount - * {@link IRODSAccount} that has been resolved for this operation - * - * @throws ConveyorExecutionException - * for errors in conveyor processing - * @throws JargonException - * for errors in actual jargon-irods processing - */ - abstract void processCallForThisTransfer(final TransferControlBlock tcb, - final IRODSAccount irodsAccount) throws ConveyorExecutionException, - JargonException; - - /** - * Call method will invoke the processCall method to be - * implemented in each subclass. This will contain the specific code for - * each type of operation, and wrap it in error checking and other common - * processing. - *

- * Note that any type of error is trapped in the catch, and conveyor will - * attempt to log these errors as part of the transfer attempt, so that the - * database reflects any issues at all with how the transfers are managed. - * It is possible that conveyor itself will have errors and be unable to - * flag these in the database, in which case it tries to log these and throw - * an exception, but in this case something is really wrong. - *

- * The actual transfers are done in the callable, and if any sort of - * 'normal' iRODS or Jargon errors occur, these are not thrown from Jargon, - * because there is a registered callback listener. If the callback listener - * is present, Jargon will not throw an error from iRODS work, instead it - * puts the error in the callback, and normally, conveyor sees these - * callbacks and logs the errors in the conveyor database. - * - * @throws ConveyorExecutionException if something really bad - * happens. Mostly, any errors should be trapped and stuck in the - * database for the transfer. Errors should only be thrown if - * something goes wrong with that processing, and in that case - * something is pretty much messed up anyhow. In other words if you - * get an exception to throw here, something is broken with the - * framework itself, and the framework is giving up. - * - */ - @Override - public final ConveyorExecutionFuture call() - throws ConveyorExecutionException { - - IRODSAccount irodsAccount = null; - try { - synchronized (this) { - irodsAccount = getConveyorService().getGridAccountService() - .irodsAccountForGridAccount( - transferAttempt.getTransfer().getGridAccount()); - setTransferControlBlock(buildDefaultTransferControlBlock()); - } - - /* - * Note that end of transfer success/failure processing will be - * triggered by the overall status callback from Jargon. That - * overall status callback will cause the queue to be released and - * final statuses to be updated. - * - * The exception handling below is meant to trap 'out of band' or - * unanticipated exceptions, and signals that the conveyor service - * itself is fubar. That should be an unlikely occasion, and in that - * case it just shoots a flare and it's up to the client of the - * framework to handle things. - * - * Exceptions that occur in the transfer process (irods errors, - * security errors, client errors, network errors) should be - * handled, not by thrown exceptions, but by error callbacks from - * the jargon transfer processes, and are not caught below. - */ - - retrieveCandidateFlowSpecs(); - /* - * initialize the flow co processor. This is done here to avoid - * leaking a this ref from the constructor - */ - flowCoProcessor = new FlowCoProcessor(this); - processCallForThisTransfer(transferControlBlock, irodsAccount); - return new ConveyorExecutionFuture(); - } catch (JargonException je) { - - if (getTransferControlBlock().isCancelled()) { - log.info("cancelled, return future and proceed"); - return new ConveyorExecutionFuture(); - } - - log.info( - "jargon exception processing transfer, mark the transfer as an error and release the queue", - je); - - /* - * The following will call doCompletionSequence() in the finally to - * release the queue - */ - markTransferAsAnExceptionWhenProcessingCall(je); - return new ConveyorExecutionFuture(); - - } catch (JargonRuntimeException je) { - - if (getTransferControlBlock().isCancelled()) { - log.info("cancelled, return future and proceed"); - return new ConveyorExecutionFuture(); - } - - log.info( - "jargon runtime exception processing transfer, mark the transfer as an error and release the queue", - je); - - /* - * The following will call doCompletionSequence() in the finally to - * release the queue - */ - markTransferAsAnExceptionWhenProcessingCall(je); - return new ConveyorExecutionFuture(); - - } catch (Exception ex) { - - if (getTransferControlBlock().isCancelled()) { - log.info("cancelled, return future and proceed"); - return new ConveyorExecutionFuture(); - } - - log.error( - "*********** unanticipated exception occurred *************", - ex); - reportConveyerExceptionDuringProcessing(ex); - throw new ConveyorExecutionException( - "unhandled exception during transfer process", ex); - } - } - - /** - * When an exception occurs setting up the transfer in the call, mark the - * transfer as an exception and set error statuses. If the transfer cannot - * be updated, bubble the exception back up to the callback listener. - * - * @param je - * {@link Exception} that should be handled in the transfer - */ - private void markTransferAsAnExceptionWhenProcessingCall(final Exception je) { - log.info("markTransferAsAnExceptionWhenProcessingCall"); - try { - getConveyorService().getTransferAccountingManagementService() - .updateTransferAttemptWithConveyorException( - transferAttempt, je); - } catch (ConveyorExecutionException e) { - log.error( - "*********** unanticipated exception occurred *************", - e); - getConveyorService().getConveyorCallbackListener() - .signalUnhandledConveyorException(e); - - } catch (Exception e) { - log.error( - "*********** unanticipated exception occurred *************", - e); - getConveyorService().getConveyorCallbackListener() - .signalUnhandledConveyorException(e); - - } finally { - doCompletionSequence(); - } - - } - - /** - * @return the transferAttempt - */ - public TransferAttempt getTransferAttempt() { - return transferAttempt; - } - - /** - * @return the conveyorService - */ - public ConveyorService getConveyorService() { - return conveyorService; - } - - /** - * Get the TransferControlBlock that will control this - * transfer, based on configuration - * - * @return {@link TransferControlBlock} - * @throws ConveyorExecutionException - */ - protected TransferControlBlock buildDefaultTransferControlBlock() - throws ConveyorExecutionException { - return conveyorService.getConfigurationService() - .buildDefaultTransferControlBlockBasedOnConfiguration( - transferAttempt.getLastSuccessfulPath(), - getIrodsAccessObjectFactory()); - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.core.transfer.TransferStatusCallbackListener#statusCallback - * (org.irods.jargon.core.transfer.TransferStatus) - */ - @Override - public FileStatusCallbackResponse statusCallback( - final TransferStatus transferStatus) throws JargonException { - log.info("status callback:{}", transferStatus); - - FileStatusCallbackResponse response = FileStatusCallbackResponse.CONTINUE; - - try { - if (transferStatus.getTransferState() == TransferState.SUCCESS - || transferStatus.getTransferState() == TransferStatus.TransferState.IN_PROGRESS_COMPLETE_FILE) { - - if (selectedFlowSpec != null) { - log.info("processing post-file flow"); - ExecResult execResult = flowCoProcessor - .executePostFileChain(selectedFlowSpec, - transferStatus); - - if (execResult == ExecResult.ABORT_AND_TRIGGER_ANY_ERROR_HANDLER) { - flowCoProcessor - .executeAnyFailureMicroservice(selectedFlowSpec); - } else if (execResult == ExecResult.CANCEL_OPERATION) { - // cancel is set in coprocessor code - log.info("cancelling..."); - - } else if (execResult != ExecResult.CONTINUE) { - log.error( - "unsupported response for a pre-file operation:{}", - execResult); - throw new ConveyorExecutionException( - "unsupported response for a pre-file operation"); - } - } - - // FIXME: how is status updated by a skip, etc? should hti sonly - // be for a continue or skip rest of flow? - updateTransferStateOnFileCompletion(transferStatus); - - } else if (transferStatus.getTransferState() == TransferState.IN_PROGRESS_START_FILE) { - log.info("file initiation, this is just passed on by conveyor"); - - if (selectedFlowSpec != null) { - log.info("processing pre-file flow"); - ExecResult execResult = flowCoProcessor - .executePreFileChain(selectedFlowSpec, - transferStatus); - - if (execResult == ExecResult.ABORT_AND_TRIGGER_ANY_ERROR_HANDLER) { - flowCoProcessor - .executeAnyFailureMicroservice(selectedFlowSpec); - } else if (execResult == ExecResult.CANCEL_OPERATION) { - // cancel is set in coprocessor code - log.info("cancelling..."); - - } else if (execResult == ExecResult.SKIP_THIS_FILE) { - // FIXME: skip file processing? - updateTransferStateOnRestartFile(transferStatus); - - // need to decide whether to just skip out and update - // here, or whether to let jargon core do it and call - // back again? - response = FileStatusCallbackResponse.SKIP; - } else if (execResult != ExecResult.CONTINUE) { - log.error( - "unsupported response for a pre-file operation:{}", - execResult); - throw new ConveyorExecutionException( - "unsupported response for a pre-file operation"); - } - } - - } else if (transferStatus.getTransferState() == TransferState.RESTARTING) { - updateTransferStateOnRestartFile(transferStatus); - - } else if (transferStatus.getTransferState() == TransferState.FAILURE) { - /* - * create failure item get exception from callback and add to - * item - */ - /* - * Treat as a warning for now, an error will be signaled when - * more than the threshold number of file errors occurs - */ - getConveyorService().getConveyorExecutorService() - .setErrorStatus(ErrorStatus.WARNING); - getConveyorService().getTransferAccountingManagementService() - .updateTransferAfterFailedFileTransfer(transferStatus, - getTransferAttempt(), - transferControlBlock.getErrorCount()); - } - - } catch (ConveyorExecutionException ex) { - getConveyorService().getConveyorExecutorService().setErrorStatus( - ErrorStatus.ERROR); - getConveyorService().getConveyorCallbackListener() - .signalUnhandledConveyorException(ex); - throw new JargonException(ex.getMessage(), ex.getCause()); - } - - if (conveyorService.getConveyorCallbackListener() != null) { - conveyorService.getConveyorCallbackListener().statusCallback( - transferStatus); - } - - return response; - - } - - /** - * A restart file has been encountered. Do the proper updates to the - * transfer attempt and optionally log the restart of this file - * - * @param transferStatus - * @throws ConveyorExecutionException - */ - private void updateTransferStateOnRestartFile( - final TransferStatus transferStatus) - throws ConveyorExecutionException { - getConveyorService().getTransferAccountingManagementService() - .updateTransferAfterRestartFileSkipped(transferStatus, - getTransferAttempt()); - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.core.transfer.TransferStatusCallbackListener# - * overallStatusCallback(org.irods.jargon.core.transfer.TransferStatus) - */ - @Override - public void overallStatusCallback(final TransferStatus transferStatus) - throws JargonException { - log.info("overall status callback signalling completion:{}", - transferStatus); - boolean doComplete = false; - try { - if (transferStatus.getTransferState() == TransferStatus.TransferState.OVERALL_INITIATION) { - // potentially handle any pre proc for operation flow specs - log.info("handle overall initiation"); - handleOverallInitiation(transferStatus); - } else if (transferStatus.getTransferState() == TransferStatus.TransferState.OVERALL_COMPLETION) { - log.info("overall completion...updating status of transfer..."); - doComplete = true; - processOverallCompletionOfTransfer(transferStatus); - } else if (transferStatus.getTransferState() == TransferStatus.TransferState.SYNCH_COMPLETION) { - log.info("overall completion of synch...updating status of transfer..."); - doComplete = true; - processOverallCompletionOfTransfer(transferStatus); - } else if (transferStatus.getTransferState() == TransferStatus.TransferState.FAILURE) { - log.error("failure to transfer in status"); - doComplete = true; - processOverallCompletionOfTransferWithFailure(transferStatus); - } else if (transferStatus.getTransferState() == TransferState.CANCELLED) { - doComplete = true; - log.error("transfer cancelled, this will be handled by the conveyor execution service, and the callback here will be ignored"); - processOverallCompletionOfTransferWithCancel(transferStatus); - } else { - log.info("unhandled transfer status of:{}", transferStatus); - } - } catch (ConveyorExecutionException ex) { - log.error( - "conveyorExecutionException during handling of overall status callback:{}", - transferStatus, ex); - doComplete = true; - throw new JargonException(ex.getMessage(), ex.getCause()); - } finally { - if (conveyorService.getConveyorCallbackListener() != null) { - log.info("sending overall status callback to client"); - conveyorService.getConveyorCallbackListener() - .overallStatusCallback(transferStatus); - } - - /* - * signal a completion if it's not a callback that is informational - * or indicates startup - */ - if (doComplete) { - doCompletionSequence(); - } - - } - - } - - /** - * Handle an overall initiation of a transfer operation, signaling any - * flows, etc - * - * @param transferStatus - * @throws ConveyorExecutionException - */ - private void handleOverallInitiation(final TransferStatus transferStatus) - throws ConveyorExecutionException { - log.info("handleOverallInitiation()"); - if (getCandidateFlowSpecs().isEmpty()) { - log.info("No flows to inspect"); - return; - } - - // need to loop thru and run a condition on candidate flows - - for (FlowSpec flowSpec : candidateFlowSpecs) { - boolean runFlow = flowCoProcessor.evaluateCondition(flowSpec, - transferStatus); - if (runFlow) { - log.info("found a flow:{}", runFlow); - selectedFlowSpec = flowSpec; - } - } - - /* - * If I have a flow spec, run the pre op chain, which will be normal, - * will cause a cancellation, or may abort with an error - */ - if (selectedFlowSpec != null) { - log.info("have a flow spec, run any pre flow chain"); - ExecResult overallResult = flowCoProcessor - .executePreOperationChain(selectedFlowSpec, transferStatus); - log.info("overall result of pre-flow chain is:{}", overallResult); - } - - } - - @Override - public CallbackResponse transferAsksWhetherToForceOperation( - final String irodsAbsolutePath, final boolean isCollection) { - log.info("transferAsksWhetherToForceOperation"); - return CallbackResponse.YES_FOR_ALL; - } - - /** - * Called by callable methods when an unexpected exception occurs in - * conveyor processing of the transfer, rather than an error occurring while - * the transfer operation is in progress. In other words, when the callable - * is setting up the transfer, updating the queue manager, trying to launch - * the transfer process, any error that is not signaled by a callback from - * Jargon is treated as a conveyor processing error, and the transfer is - * marked as an error with a global message. - *

- * Note that calling this method will unlock the conveyor execution queue - * - * @param ex - * Exception that was caught while trying to process - * the transfer - * @throws ConveyorExecutionException - */ - void reportConveyerExceptionDuringProcessing(final Exception ex) - throws ConveyorExecutionException { - log.warn("reportConveyerExceptionDuringProcessing() is called"); - Exception myException = null; - - /* - * Overkill check just to narrow the kind of errors that I'm processing - */ - - if (ex == null) { - myException = new ConveyorExecutionException( - "warning! An exception was reported but null was provided to the reportConveyerExceptionDuringProcessing() method"); - } else { - log.info("reported exception:", ex); - myException = ex; - } - - log.info("updating transfer attempt with an exception"); - try { - getConveyorService().getTransferAccountingManagementService() - .updateTransferAttemptWithConveyorException( - transferAttempt, myException); - - } catch (Exception e) { - /* - * I've got an exception but cannot update the database with it. As - * a last step, log it, then try to signal the callback listener - * that some error has occurred - */ - log.error("************* exception occurred in conveyor framework,unable to update conveyor database***** will signal the callback listener"); - getConveyorService().getConveyorCallbackListener() - .signalUnhandledConveyorException(e); - getConveyorService().getConveyorExecutorService().setErrorStatus( - ErrorStatus.ERROR); - throw new ConveyorRuntimeException( - "unprocessable exception in conveyor, not updated in database", - e); - } finally { - log.info("aftar all possible error handling and notification, I am releasing the queue"); - doCompletionSequence(); - } - } - - /** - * Whether in an error state, or in a successfully completed state, release - * the execution queue and attempt to trigger any subsequent operations. - *

- * Note that any error in dequeuing the next transfer is logged, and the - * callback listener will be notified. - */ - private void doCompletionSequence() { - log.info("doCompletionSequence()"); - getConveyorService().getConveyorExecutorService() - .setOperationCompleted(); - log.info("signaling completion so queue manager can dequeue next"); - - try { - log.info("calling dequeue of next"); - getConveyorService().getQueueManagerService() - .dequeueNextOperation(); - } catch (ConveyorExecutionException e) { - log.error( - "unable to dequeue, will send an exception back to listener", - e); - conveyorService.getConveyorCallbackListener() - .signalUnhandledConveyorException(e); - conveyorService.getConveyorExecutorService().setErrorStatus( - ErrorStatus.ERROR); - } - } - - /** - * Given a transfer status, update the transfer state on completion of - * processing a file - * - * @param transferStatus - * @throws ConveyorExecutionException - */ - private void updateTransferStateOnFileCompletion( - final TransferStatus transferStatus) - throws ConveyorExecutionException { - getConveyorService().getTransferAccountingManagementService() - .updateTransferAfterSuccessfulFileTransfer(transferStatus, - getTransferAttempt()); - } - - /** - * A complete with success callback for an entire transfer operation, make - * the necessary updates - * - * @param transferStatus - * @throws ConveyorExecutionException - */ - protected void processOverallCompletionOfTransfer( - final TransferStatus transferStatus) - throws ConveyorExecutionException { - log.info("processOverallCompletionOfTransfer default version in AbstractConveyorCallable"); - - log.info("evaluating transfer status by inspecting items for any file level errors"); - TransferStatusEnum evaluatedStatus = evaluateTransferErrorsInItemsToSetOverallStatus(transferAttempt); - - log.info("status was:{}", evaluatedStatus); - - if (evaluatedStatus == TransferStatusEnum.OK) { - log.info("evaluated status is OK"); - if (getTransferControlBlock().getTotalFilesTransferredSoFar() == 0) { - conveyorService.getConveyorExecutorService().setErrorStatus( - ErrorStatus.WARNING); - getConveyorService().getTransferAccountingManagementService() - .updateTransferAfterOverallWarningNoFilesTransferred( - transferStatus, transferAttempt); - } else { - conveyorService.getConveyorExecutorService().setErrorStatus( - ErrorStatus.OK); - getConveyorService().getTransferAccountingManagementService() - .updateTransferAfterOverallSuccess(transferStatus, - getTransferAttempt()); - } - } else if (evaluatedStatus == TransferStatusEnum.WARNING) { - conveyorService.getConveyorExecutorService().setErrorStatus( - ErrorStatus.WARNING); - getConveyorService().getTransferAccountingManagementService() - .updateTransferAfterOverallWarningByFileErrorThreshold( - transferStatus, getTransferAttempt()); - } else if (evaluatedStatus == TransferStatusEnum.ERROR) { - conveyorService.getConveyorExecutorService().setErrorStatus( - ErrorStatus.ERROR); - getConveyorService().getTransferAccountingManagementService() - .updateTransferAfterOverallFailureByFileErrorThreshold( - transferStatus, getTransferAttempt()); - - } - } - - /** - * Handle a cancel from the overall status - * - * @param transferStatus - * @throws ConveyorExecutionException - */ - private void processOverallCompletionOfTransferWithCancel( - final TransferStatus transferStatus) - throws ConveyorExecutionException { - log.info("processOverallCompletionOfTransferWithFailure"); - conveyorService.getConveyorExecutorService().setErrorStatus( - ErrorStatus.OK); - getConveyorService().getTransferAccountingManagementService() - .updateTransferAfterCancellation(transferAttempt); - } - - /** - * Look at all of the items in the given transfer, and decide whether it's - * OK, or an ERROR or WARNING based on any file by file errors, and whether - * those errors are above or below the error threshold - * - * @param transferAttempt - * @return - */ - protected TransferStatusEnum evaluateTransferErrorsInItemsToSetOverallStatus( - final TransferAttempt transferAttempt) { - - assert transferAttempt != null; - - TransferStatusEnum status; - if (transferControlBlock.getErrorCount() > 0 - && transferControlBlock.getTotalFilesTransferredSoFar() == 0) { - log.info("transfer had errors and no files were successful, so mark as an error"); - status = TransferStatusEnum.ERROR; - } else if (transferControlBlock.getErrorCount() > 0 - && transferControlBlock.getErrorCount() < transferControlBlock - .getMaximumErrorsBeforeCanceling()) { - log.info("transfer had errors but below max"); - status = TransferStatusEnum.WARNING; - } else if (transferControlBlock.getErrorCount() > 0) { - log.info("transfer had errors but below max"); - status = TransferStatusEnum.ERROR; - } else { - log.info("transfer had no errors"); - status = TransferStatusEnum.OK; - } - - return status; - } - - /** - * When a transfer is done, and an overall status callback of failure has - * occurred, update the transfer attempt to reflect this error status - * - * @param transferStatus - * @throws ConveyorExecutionException - */ - protected void processOverallCompletionOfTransferWithFailure( - final TransferStatus transferStatus) - throws ConveyorExecutionException { - log.info("processOverallCompletionOfTransferWithFailure"); - conveyorService.getConveyorExecutorService().setErrorStatus( - ErrorStatus.ERROR); - getConveyorService().getTransferAccountingManagementService() - .updateTransferAfterOverallFailure(transferStatus, - transferAttempt); - - } - - /** - * @return the transferControlBlock, note that this may be null - * if it has not been initialized yet. The initialization is done in - * the call() method. - */ - public synchronized TransferControlBlock getTransferControlBlock() { - return transferControlBlock; - } - - /** - * @param transferControlBlock - * the transferControlBlock to set - */ - public synchronized void setTransferControlBlock( - final TransferControlBlock transferControlBlock) { - this.transferControlBlock = transferControlBlock; - } - - /** - * Convenience method to get the Transfer associated with this - * callable - * - * @return {@link Transfer} - */ - protected Transfer getTransfer() { - return getTransferAttempt().getTransfer(); - } - - /** - * On initiation of a transfer, get any candidate flow specs, selected based - * on properties of the transfer. These will later be evaluated based on - * conditions within the FlowSpec - * - * @return List of {@link FlowSpec} that are candidates for - * this transfer attempt. This reflects the flow specs that are - * cached for this instance - * - * @throws ConveyorExecutionException - */ - private List retrieveCandidateFlowSpecs() - throws ConveyorExecutionException { - log.info("retrieveCandidateFlowSpecs()"); - - FlowManagerService flowManagerService = conveyorService - .getFlowManagerService(); - - candidateFlowSpecs = flowManagerService - .retrieveCandidateFlowSpecs(getTransferAttempt()); - - return candidateFlowSpecs; - - } - - /** - * @return the candidateFlowSpecs that are cached, and this will cache them - * if they have not been obtained already - * @throws ConveyorExecutionException - */ - protected synchronized List getCandidateFlowSpecs() - throws ConveyorExecutionException { - if (candidateFlowSpecs == null) { - retrieveCandidateFlowSpecs(); - } - return candidateFlowSpecs; - } - - /** - * @param candidateFlowSpecs - * the candidateFlowSpecs to set - */ - protected synchronized void setCandidateFlowSpecs( - final List candidateFlowSpecs) { - this.candidateFlowSpecs = candidateFlowSpecs; - } - - /** - * @return the selectedFlowSpec - */ - protected FlowSpec getSelectedFlowSpec() { - return selectedFlowSpec; - } - - /** - * @return the flowCoProcessor - */ - FlowCoProcessor getFlowCoProcessor() { - return flowCoProcessor; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/ConveyorCallableFactory.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/ConveyorCallableFactory.java deleted file mode 100644 index acd144360..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/ConveyorCallableFactory.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core.callables; - -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class ConveyorCallableFactory { - - private final Logger log = LoggerFactory - .getLogger(ConveyorCallableFactory.class); - - public ConveyorCallableFactory() { - } - - /** - * Given a Transfer create the Callable that will - * process that transfer - * - * @param conveyorService - * {@link ConveyorService} that handles all operations - * @return {@link AbstractConveyorCallable} that will process the transfer - * @throws ConveyorExecutionException - * if a callable cannot be created or some other error occurs - */ - public AbstractConveyorCallable instanceCallableForOperation( - final TransferAttempt transferAttempt, - final ConveyorService conveyorService) - throws ConveyorExecutionException { - - log.info("instanceCallableForOperation()"); - - if (transferAttempt == null) { - throw new IllegalArgumentException("transferAttempt is null"); - } - - if (conveyorService == null) { - throw new IllegalArgumentException("conveyorService is null"); - } - - log.info("transferAttempt for callable:{}", transferAttempt); - - if (transferAttempt.getTransfer() == null) { - log.error("no transfer in transfer attempt"); - throw new ConveyorExecutionException( - "no transfer found for given transfer attempt"); - } - - switch (transferAttempt.getTransfer().getTransferType()) { - case PUT: - return new PutConveyorCallable(transferAttempt, conveyorService); - case GET: - return new GetConveyorCallable(transferAttempt, conveyorService); - case REPLICATE: - return new ReplicateConveyorCallable(transferAttempt, - conveyorService); - case COPY: - return new CopyConveyorCallable(transferAttempt, conveyorService); - case SYNCH: - return new SynchCallable(transferAttempt, conveyorService); - default: - throw new ConveyorExecutionException( - "Unable to create a processor for the given transfer"); - - } - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/CopyConveyorCallable.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/CopyConveyorCallable.java deleted file mode 100644 index 413f2c0c1..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/CopyConveyorCallable.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.irods.jargon.conveyor.core.callables; - -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.DataTransferOperations; -import org.irods.jargon.core.transfer.TransferControlBlock; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Callable for handling an iRODS copy operation - * - * @author Mike Conway - DICE (www.irods.org) - */ -public class CopyConveyorCallable extends AbstractConveyorCallable { - - private static final Logger log = LoggerFactory - .getLogger(PutConveyorCallable.class); - - public CopyConveyorCallable(final TransferAttempt transferAttempt, - final ConveyorService conveyorService) { - super(transferAttempt, conveyorService); - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.callables.AbstractConveyorCallable# - * processCallForThisTransfer - * (org.irods.jargon.core.transfer.TransferControlBlock, - * org.irods.jargon.core.connection.IRODSAccount) - */ - @Override - void processCallForThisTransfer(final TransferControlBlock tcb, - final IRODSAccount irodsAccount) throws ConveyorExecutionException, - JargonException { - log.info("processCallForThisTransfer()"); - - DataTransferOperations dataTransferOperationsAO = getIrodsAccessObjectFactory() - .getDataTransferOperations(irodsAccount); - dataTransferOperationsAO.copy(getTransferAttempt().getTransfer() - .getIrodsAbsolutePath(), getTransferAttempt().getTransfer() - .getGridAccount().getDefaultResource(), getTransferAttempt() - .getTransfer().getLocalAbsolutePath(), this, tcb); - - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/FlowCoProcessor.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/FlowCoProcessor.java deleted file mode 100644 index d25872631..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/FlowCoProcessor.java +++ /dev/null @@ -1,417 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core.callables; - -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpec; -import org.irods.jargon.conveyor.flowmanager.flow.dsl.FlowSpecificationException; -import org.irods.jargon.conveyor.flowmanager.microservice.ConditionMicroservice; -import org.irods.jargon.conveyor.flowmanager.microservice.ContainerEnvironment; -import org.irods.jargon.conveyor.flowmanager.microservice.InvocationContext; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice.ExecResult; -import org.irods.jargon.conveyor.flowmanager.microservice.MicroserviceException; -import org.irods.jargon.core.transfer.TransferStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Co-processor for flows, handles manipulations and running of flows associated - * with a callable operation - * - * @author Mike Conway - DICE - * - */ -class FlowCoProcessor { - - private final AbstractConveyorCallable callable; - private final ContainerEnvironment containerEnvironment = new ContainerEnvironment(); - private final InvocationContext invocationContext = new InvocationContext(); - - private static final Logger log = LoggerFactory - .getLogger(FlowCoProcessor.class); - - /** - * Constructor for co processor takes the sister - * AbstractConveyorCallable that will be doing operations on - * flows - * - * @param callable - * {@link AbstractConveyorCallable} that will be procssing the - * transfer and running flows - * @throws ConveyorExecutionException - */ - FlowCoProcessor(final AbstractConveyorCallable callable) - throws ConveyorExecutionException { - super(); - if (callable == null) { - throw new IllegalArgumentException("null callable"); - } - this.callable = callable; - containerEnvironment.setConveyorService(callable.getConveyorService()); - invocationContext.setIrodsAccount(callable - .getIRODSAccountForGridAccount(callable.getTransfer() - .getGridAccount())); - invocationContext.setTransferAttempt(callable.getTransferAttempt()); - invocationContext.setTransferControlBlock(callable - .getTransferControlBlock()); - - } - - /** - * Run the pre-op chain. This can result in (based on the responses from the - * microservices in ExecResult) a cancellation, or an abort of the transfer - * with an error - * - * @param flowSpec - * {@link FlowSpec} that was selected - * @param transferStatus - * {@link TransferStatus} that triggers this call - * @return {@link ExecResult} from the microservices - * @throws ConveyorExecutionException - */ - ExecResult executePreOperationChain(final FlowSpec flowSpec, - final TransferStatus transferStatus) - throws ConveyorExecutionException { - - log.info("executePreOperationChain()"); - - if (flowSpec == null) { - throw new IllegalArgumentException("null flowSpec"); - } - - if (transferStatus == null) { - throw new IllegalArgumentException("null transferStatus"); - } - - Microservice microservice; - ExecResult overallExecResult = ExecResult.CONTINUE; - for (String microserviceFqcn : flowSpec.getPreOperationChain()) { - - log.info("pre-op chain microservice:{}", microserviceFqcn); - microservice = createAndProvisionChainMicroservice(microserviceFqcn); - log.info("invoking next in chain..."); - try { - overallExecResult = microservice.execute(transferStatus); - } catch (MicroserviceException e) { - /* - * Errors that occur are treated as system or program erros, not - * as recoverable errors that should be reflected in the - * ExecResult - */ - log.error("error ocurred running a microservice", e); - throw new ConveyorExecutionException( - "error running microservice", e); - } - - if (overallExecResult == ExecResult.CANCEL_OPERATION) { - log.info("transfer is being cancelled"); - callable.getTransferControlBlock().setCancelled(true); - break; - } else if (overallExecResult == ExecResult.SKIP_THIS_CHAIN) { - log.info("skipping rest of chain"); - break; - } else if (overallExecResult == ExecResult.ABORT_AND_TRIGGER_ANY_ERROR_HANDLER) { - log.error("abort of operation by execResult of microservice"); - executeAnyFailureMicroservice(flowSpec); - throw new ConveyorExecutionException( - "Aborting operation through failure of microservice"); - } else if (overallExecResult != ExecResult.CONTINUE) { - log.error("unexpected exec result for a preop chain:{}", - overallExecResult); - throw new ConveyorExecutionException("unexpected exec result"); - } - } - - return overallExecResult; - - } - - /** - * Run the pre-file operation chain. This can result in (based on the - * responses from the microservices in ExecResult) a cancellation, or an - * abort of the transfer with an error, or ask that this file be excluded - * from the transfer - * - * @param flowSpec - * {@link FlowSpec} that was selected - * @param transferStatus - * {@link TransferStatus} that triggers this call - * @return {@link ExecResult} from the microservices - * @throws ConveyorExecutionException - */ - ExecResult executePreFileChain(final FlowSpec flowSpec, - final TransferStatus transferStatus) - throws ConveyorExecutionException { - - log.info("executePreFileChain()"); - - if (flowSpec == null) { - throw new IllegalArgumentException("null flowSpec"); - } - - if (transferStatus == null) { - throw new IllegalArgumentException("null transferStatus"); - } - - Microservice microservice; - ExecResult overallExecResult = ExecResult.CONTINUE; - for (String microserviceFqcn : flowSpec.getPreFileChain()) { - - log.info("pre-file chain microservice:{}", microserviceFqcn); - microservice = createAndProvisionChainMicroservice(microserviceFqcn); - log.info("invoking next in chain..."); - try { - overallExecResult = microservice.execute(transferStatus); - } catch (MicroserviceException e) { - /* - * Errors that occur are treated as system or program erros, not - * as recoverable errors that should be reflected in the - * ExecResult - */ - log.error("error ocurred running a microservice", e); - throw new ConveyorExecutionException( - "error running microservice", e); - } - - if (overallExecResult == ExecResult.CANCEL_OPERATION) { - log.info("transfer is being cancelled"); - callable.getTransferControlBlock().setCancelled(true); - break; - } else if (overallExecResult == ExecResult.SKIP_THIS_CHAIN) { - log.info("skipping rest of chain"); - break; - } else if (overallExecResult == ExecResult.SKIP_THIS_FILE) { - log.info("skipping file, and rest of chain"); - break; - } else if (overallExecResult == ExecResult.ABORT_AND_TRIGGER_ANY_ERROR_HANDLER) { - log.error("abort of operation by execResult of microservice"); - executeAnyFailureMicroservice(flowSpec); - throw new ConveyorExecutionException( - "Aborting operation through failure of microservice"); - } else if (overallExecResult != ExecResult.CONTINUE) { - log.error("unexpected exec result for a preop chain:{}", - overallExecResult); - throw new ConveyorExecutionException("unexpected exec result"); - } - } - - return overallExecResult; - - } - - /** - * Run the post-file operation chain. This can result in (based on the - * responses from the microservices in ExecResult) a cancellation, or an - * abort of the transfer with an error - * - * @param flowSpec - * {@link FlowSpec} that was selected - * @param transferStatus - * {@link TransferStatus} that triggers this call - * @return {@link ExecResult} from the microservices - * @throws ConveyorExecutionException - */ - ExecResult executePostFileChain(final FlowSpec flowSpec, - final TransferStatus transferStatus) - throws ConveyorExecutionException { - - log.info("executePostFileChain()"); - - if (flowSpec == null) { - throw new IllegalArgumentException("null flowSpec"); - } - - if (transferStatus == null) { - throw new IllegalArgumentException("null transferStatus"); - } - - Microservice microservice; - ExecResult overallExecResult = ExecResult.CONTINUE; - for (String microserviceFqcn : flowSpec.getPostFileChain()) { - - log.info("post-file chain microservice:{}", microserviceFqcn); - microservice = createAndProvisionChainMicroservice(microserviceFqcn); - log.info("invoking next in chain..."); - try { - overallExecResult = microservice.execute(transferStatus); - } catch (MicroserviceException e) { - /* - * Errors that occur are treated as system or program erros, not - * as recoverable errors that should be reflected in the - * ExecResult - */ - log.error("error ocurred running a microservice", e); - throw new ConveyorExecutionException( - "error running microservice", e); - } - - if (overallExecResult == ExecResult.CANCEL_OPERATION) { - log.info("transfer is being cancelled"); - callable.getTransferControlBlock().setCancelled(true); - break; - } else if (overallExecResult == ExecResult.SKIP_THIS_CHAIN) { - log.info("skipping rest of chain"); - break; - } else if (overallExecResult == ExecResult.ABORT_AND_TRIGGER_ANY_ERROR_HANDLER) { - log.error("abort of operation by execResult of microservice"); - executeAnyFailureMicroservice(flowSpec); - throw new ConveyorExecutionException( - "Aborting operation through failure of microservice"); - } else if (overallExecResult != ExecResult.CONTINUE) { - log.error("unexpected exec result for a post file chain:{}", - overallExecResult); - throw new ConveyorExecutionException("unexpected exec result"); - } - } - - return overallExecResult; - - } - - void executeAnyFailureMicroservice(final FlowSpec flowSpec) { - - log.error("failure stuff no implemented yet"); - throw new UnsupportedOperationException("implement me!!! please?"); - - } - - /** - * Create a microservice from a fully qualified class name and provision it - * with the various context objects - * - * @param microserviceFqcn - * @return - */ - private Microservice createAndProvisionChainMicroservice( - final String microserviceFqcn) { - Microservice microservice = createMicroserviceInstance(microserviceFqcn); - provisionMicroservice(microservice); - return microservice; - } - - /** - * Given a flow, execute any condition microservice and decide whether to - * run this flow - * - * @param flowSpec - * {@link FlowSpec} that will be evaluated - * @param transferStatus - * {@link TransferStatus} that triggers this call - * - * @return boolean that will indicate whether the given flow - * - * should run - * @throws ConveyorExecutionException - */ - boolean evaluateCondition(final FlowSpec flowSpec, - final TransferStatus transferStatus) - throws ConveyorExecutionException { - log.info("evaluateCondition()"); - - if (flowSpec == null) { - throw new IllegalArgumentException("null flowSpec"); - } - - if (flowSpec.getCondition() == null) { - return true; - } - - if (flowSpec.getCondition().isEmpty()) { - log.info("no condition specified, select this one"); - return true; - } - - if (transferStatus == null) { - throw new IllegalArgumentException("null transferStatus"); - } - - log.info("have a condition..evaluate it"); - - Microservice microservice = createMicroserviceInstance(flowSpec - .getCondition()); - - if (microservice instanceof ConditionMicroservice) { - log.info("have a condition microservice"); - } else { - throw new ConveyorExecutionException( - "condition is not a subclass of a ConditionMicroservice"); - } - - provisionMicroservice(microservice); - - log.info("executing condition...."); - ExecResult result; - try { - microservice.evaluateContext(); - result = microservice.execute(transferStatus); - } catch (MicroserviceException e) { - log.error("microservice exception executing condition", e); - throw new ConveyorExecutionException( - "unable to run condition microservice, this will be an error in the transfer", - e); - } - - log.info("evaluation of condition:{}", result); - if (result == ExecResult.CONTINUE) { - return true; - } else { - return false; - } - - } - - /** - * Augment the provided microservice with existing context information, - * making it ready to use - * - * @param microservice - */ - private void provisionMicroservice(final Microservice microservice) { - log.info("provision microservice"); - microservice.setContainerEnvironment(containerEnvironment); - microservice.setInvocationContext(invocationContext); - } - - /** - * Create an instance of the microservice. Note that this instance has not - * yet been injected with the necessary context information, this will be - * done later - * - * @param microserviceFullyQualifiedClassName - * @return - */ - private Microservice createMicroserviceInstance( - final String microserviceFullyQualifiedClassName) { - - if (microserviceFullyQualifiedClassName == null - || microserviceFullyQualifiedClassName.isEmpty()) { - throw new IllegalArgumentException( - "null or empty microserviceFullyQualifiedClassName"); - } - - try { - return (Microservice) Class.forName( - microserviceFullyQualifiedClassName).newInstance(); - } catch (InstantiationException e) { - throw new FlowSpecificationException( - "instantation exception creating microservice", e); - } catch (IllegalAccessException e) { - throw new FlowSpecificationException( - "illegalAccessException creating microservice", e); - } catch (ClassNotFoundException e) { - throw new FlowSpecificationException( - "class not found exception creating microservice", e); - } - - } - - /** - * @return the invocationContext - */ - InvocationContext getInvocationContext() { - return invocationContext; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/GetConveyorCallable.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/GetConveyorCallable.java deleted file mode 100644 index 0a53e8f19..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/GetConveyorCallable.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.irods.jargon.conveyor.core.callables; - -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.DataTransferOperations; -import org.irods.jargon.core.transfer.TransferControlBlock; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author lisa - */ -public class GetConveyorCallable extends AbstractConveyorCallable { - - private static final Logger log = LoggerFactory - .getLogger(PutConveyorCallable.class); - - public GetConveyorCallable(final TransferAttempt transferAttempt, - final ConveyorService conveyorService) { - super(transferAttempt, conveyorService); - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.callables.AbstractConveyorCallable# - * processCallForThisTransfer - * (org.irods.jargon.core.transfer.TransferControlBlock, - * org.irods.jargon.core.connection.IRODSAccount) - */ - @Override - void processCallForThisTransfer(final TransferControlBlock tcb, - final IRODSAccount irodsAccount) throws ConveyorExecutionException, - JargonException { - log.info("processCallForThisTransfer()"); - - DataTransferOperations dataTransferOperationsAO = getIrodsAccessObjectFactory() - .getDataTransferOperations(irodsAccount); - dataTransferOperationsAO - .getOperation(getTransferAttempt().getTransfer() - .getIrodsAbsolutePath(), getTransferAttempt() - .getTransfer().getLocalAbsolutePath(), - getTransferAttempt().getTransfer().getGridAccount() - .getDefaultResource(), this, tcb); - - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/PutConveyorCallable.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/PutConveyorCallable.java deleted file mode 100644 index c0040363a..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/PutConveyorCallable.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core.callables; - -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.DataTransferOperations; -import org.irods.jargon.core.transfer.TransferControlBlock; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Callable that will run a put operation and handle callbacks - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class PutConveyorCallable extends AbstractConveyorCallable { - - private static final Logger log = LoggerFactory - .getLogger(PutConveyorCallable.class); - - public PutConveyorCallable(final TransferAttempt transferAttempt, - final ConveyorService conveyorService) { - super(transferAttempt, conveyorService); - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.callables.AbstractConveyorCallable# - * processCallForThisTransfer - * (org.irods.jargon.core.transfer.TransferControlBlock, - * org.irods.jargon.core.connection.IRODSAccount) - */ - @Override - void processCallForThisTransfer(final TransferControlBlock tcb, - final IRODSAccount irodsAccount) throws ConveyorExecutionException, - JargonException { - log.info("processCallForThisTransfer()"); - DataTransferOperations dataTransferOperationsAO = getIrodsAccessObjectFactory() - .getDataTransferOperations(irodsAccount); - dataTransferOperationsAO - .putOperation(getTransferAttempt().getTransfer() - .getLocalAbsolutePath(), getTransferAttempt() - .getTransfer().getIrodsAbsolutePath(), - getTransferAttempt().getTransfer().getGridAccount() - .getDefaultResource(), this, tcb); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/ReplicateConveyorCallable.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/ReplicateConveyorCallable.java deleted file mode 100644 index b06c1f311..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/ReplicateConveyorCallable.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.irods.jargon.conveyor.core.callables; - -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.DataTransferOperations; -import org.irods.jargon.core.transfer.TransferControlBlock; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Callable to process a replication - * - * @author Mike Conway - DICE (www.irods.org) - */ -public class ReplicateConveyorCallable extends AbstractConveyorCallable { - - private static final Logger log = LoggerFactory - .getLogger(PutConveyorCallable.class); - - public ReplicateConveyorCallable(final TransferAttempt transferAttempt, - final ConveyorService conveyorService) { - super(transferAttempt, conveyorService); - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.callables.AbstractConveyorCallable# - * processCallForThisTransfer - * (org.irods.jargon.core.transfer.TransferControlBlock, - * org.irods.jargon.core.connection.IRODSAccount) - */ - @Override - void processCallForThisTransfer(final TransferControlBlock tcb, - final IRODSAccount irodsAccount) throws ConveyorExecutionException, - JargonException { - log.info("processCallForThisTransfer()"); - DataTransferOperations dataTransferOperationsAO = getIrodsAccessObjectFactory() - .getDataTransferOperations(irodsAccount); - dataTransferOperationsAO.replicate( - getTransfer().getIrodsAbsolutePath(), getTransfer() - .getResourceName(), this, tcb); - } -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/SynchCallable.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/SynchCallable.java deleted file mode 100644 index bd1b3885f..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/SynchCallable.java +++ /dev/null @@ -1,198 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core.callables; - -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.ConveyorExecutorService.ErrorStatus; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.conveyor.synch.AbstractSynchronizingDiffCreator; -import org.irods.jargon.conveyor.synch.AbstractSynchronizingDiffProcessor; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.transfer.TransferControlBlock; -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.core.transfer.TransferStatus.TransferState; -import org.irods.jargon.core.transfer.TransferStatus.TransferType; -import org.irods.jargon.datautils.tree.FileTreeModel; -import org.irods.jargon.transfer.dao.domain.Synchronization; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.irods.jargon.transfer.dao.domain.TransferStatusEnum; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Process a synchronization transfer - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class SynchCallable extends AbstractConveyorCallable { - - private static final Logger log = LoggerFactory - .getLogger(SynchCallable.class); - - /** - * @param transferAttempt - * @param conveyorService - */ - public SynchCallable(final TransferAttempt transferAttempt, - final ConveyorService conveyorService) { - super(transferAttempt, conveyorService); - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.callables.AbstractConveyorCallable# - * processCallForThisTransfer - * (org.irods.jargon.core.transfer.TransferControlBlock, - * org.irods.jargon.core.connection.IRODSAccount) - */ - @Override - void processCallForThisTransfer(final TransferControlBlock tcb, - final IRODSAccount irodsAccount) throws ConveyorExecutionException, - JargonException { - - log.info("processCallForThisTransfer for synch"); - - assert tcb != null; - assert irodsAccount != null; - - Synchronization synchronization = getTransfer().getSynchronization(); - - assert synchronization != null; - - sendSynchStatusMessage(getTransfer(), synchronization, - TransferState.SYNCH_INITIALIZATION); - - log.info("getting diff creation service..."); - - try { - AbstractSynchronizingDiffCreator diffCreator = getConveyorService() - .getSynchComponentFactory().instanceDiffCreator( - synchronization, tcb); - FileTreeModel diffModel = diffCreator.createDiff(getTransfer()); - - if (isCancelled()) { - log.info("cancellation received"); - sendSynchStatusMessage(getTransfer(), synchronization, - TransferState.CANCELLED); - } - - log.info("have file tree model, now process the diff to resolve it...get diff processor from factory"); - - AbstractSynchronizingDiffProcessor diffProcessor = getConveyorService() - .getSynchComponentFactory().instanceDiffProcessor( - synchronization, tcb); - - log.info("..have diff processor, now invoke..."); - - /* - * Note I register this callable as the callback listener, so that - * status updates flow back to this processor - */ - diffProcessor.execute(getTransferAttempt(), diffModel, this); - - if (isCancelled()) { - log.info("cancellation received"); - log.info("processing complete, send the final callback"); - - sendSynchStatusMessage(getTransfer(), synchronization, - TransferState.CANCELLED); - } else { - - log.info("processing complete, send the final callback"); - - sendSynchStatusMessage(getTransfer(), synchronization, - TransferState.SYNCH_COMPLETION); - - } - - } catch (Exception e) { - log.error("error encountered during synch processing", e); - - sendSynchStatusMessage(getTransfer(), synchronization, - TransferState.FAILURE); - - reportConveyerExceptionDuringProcessing(e); - } - - } - - private void sendSynchStatusMessage(final Transfer transfer, - final Synchronization synchronization, - final TransferState transferState) - throws ConveyorExecutionException { - // make an overall status callback that a synch is initiated - TransferStatus overallSynchStartStatus; - try { - overallSynchStartStatus = TransferStatus.instance( - TransferType.SYNCH, - synchronization.getLocalSynchDirectory(), - synchronization.getIrodsSynchDirectory(), - synchronization.getDefaultStorageResource(), 0L, 0L, 0, 0, - 0, transferState, transfer.getGridAccount().getHost(), - transfer.getGridAccount().getZone()); - - overallStatusCallback(overallSynchStartStatus); - - } catch (JargonException e) { - log.error("error creating synch", e); - throw new ConveyorExecutionException("error in synch processing", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.core.callables.AbstractConveyorCallable# - * processOverallCompletionOfTransfer - * (org.irods.jargon.core.transfer.TransferStatus) - */ - @Override - protected void processOverallCompletionOfTransfer( - final TransferStatus transferStatus) - throws ConveyorExecutionException { - log.info("processOverallCompletionOfTransfer() subclassed for synch"); - - log.info("evaluating transfer status by inspecting items for any file level errors"); - TransferStatusEnum evaluatedStatus = evaluateTransferErrorsInItemsToSetOverallStatus(getTransferAttempt()); - - log.info("status was:{}", evaluatedStatus); - - if (evaluatedStatus == TransferStatusEnum.OK) { - - getConveyorService().getConveyorExecutorService().setErrorStatus( - ErrorStatus.OK); - getConveyorService().getSynchronizationManagerService() - .updateSynchronizationWithSuccessfulCompletion( - transferStatus, getTransferAttempt()); - - } else if (evaluatedStatus == TransferStatusEnum.WARNING) { - getConveyorService().getConveyorExecutorService().setErrorStatus( - ErrorStatus.WARNING); - getConveyorService().getSynchronizationManagerService() - .updateSynchronizationWithWarningCompletion(transferStatus, - getTransferAttempt()); - } else if (evaluatedStatus == TransferStatusEnum.ERROR) { - getConveyorService().getConveyorExecutorService().setErrorStatus( - ErrorStatus.ERROR); - getConveyorService().getTransferAccountingManagementService() - .updateTransferAfterOverallFailureByFileErrorThreshold( - transferStatus, getTransferAttempt()); - - } - } - - /** - * Checks for a cancellation - * - * @return - */ - protected boolean isCancelled() { - return (getTransferControlBlock().isCancelled() || getTransferControlBlock() - .isPaused()); - } -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/package-info.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/package-info.java deleted file mode 100644 index 96c4a96c6..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/callables/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Implementations of callables for various transfer operations (put,get,etc.) - * @author Mike Conway - DICE (www.irods.org) - * - */ -package org.irods.jargon.conveyor.core.callables; \ No newline at end of file diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/package-info.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/package-info.java deleted file mode 100644 index 1bde1f1d6..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/core/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Core interfaces for conveyor framework - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -package org.irods.jargon.conveyor.core; \ No newline at end of file diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/FlowManagerException.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/FlowManagerException.java deleted file mode 100644 index 1ecfe1e4c..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/FlowManagerException.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.flow; - -/** - * General checked Exception in the processing of flows - * - * @author Mike Conway - DICE - * - */ -public class FlowManagerException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 409067804821147339L; - - /** - * - */ - public FlowManagerException() { - } - - /** - * @param arg0 - */ - public FlowManagerException(final String arg0) { - super(arg0); - } - - /** - * @param arg0 - */ - public FlowManagerException(final Throwable arg0) { - super(arg0); - } - - /** - * @param arg0 - * @param arg1 - */ - public FlowManagerException(final String arg0, final Throwable arg1) { - super(arg0, arg1); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/FlowSpec.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/FlowSpec.java deleted file mode 100644 index 5ce253f14..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/FlowSpec.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.flow; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represents a specification for a single flow. This is a workflow chain - * associated with a selector - *

- * Note that the various microservices are expressed as Strings that represent - * the fully qualified class name, and these will be validated as the FlowSpecs - * are created. The microservice instances are created when each new flow runs - * from this information - * - * @author Mike Conway - DICE - * - */ -public class FlowSpec implements Cloneable { - - private Selector selector = new Selector(); - private String condition; - private List preOperationChain = new ArrayList(); - private List preFileChain = new ArrayList(); - private List postFileChain = new ArrayList(); - private List postOperationChain = new ArrayList(); - private String errorHandler; - - /* - * (non-Javadoc) - * - * @see java.lang.Object#clone() - */ - @Override - public synchronized FlowSpec clone() { - FlowSpec clone = new FlowSpec(); - clone.setSelector(selector.clone()); - - if (condition != null) { - clone.setCondition(new String(condition)); - } - - ArrayList clonePreOperationChain = new ArrayList( - preOperationChain.size()); - for (String preop : preOperationChain) { - clonePreOperationChain.add(new String(preop)); - } - - ArrayList clonePreFileChain = new ArrayList( - preFileChain.size()); - for (String preop : preFileChain) { - clonePreFileChain.add(new String(preop)); - } - - ArrayList clonePostFileChain = new ArrayList( - postFileChain.size()); - for (String postop : postFileChain) { - clonePostFileChain.add(new String(postop)); - } - - ArrayList clonePostOpChain = new ArrayList( - postOperationChain.size()); - for (String postop : postOperationChain) { - clonePostOpChain.add(new String(postop)); - } - - clone.setPostFileChain(clonePostFileChain); - clone.setPostOperationChain(clonePostOpChain); - clone.setPreFileChain(clonePreFileChain); - clone.setPreOperationChain(clonePreOperationChain); - if (errorHandler != null) { - clone.setErrorHandler(new String(errorHandler)); - } - return clone; - - } - - public synchronized Selector getSelector() { - return selector; - } - - public synchronized void setSelector(final Selector selector) { - this.selector = selector; - } - - public synchronized String getCondition() { - return condition; - } - - public synchronized void setCondition(final String condition) { - this.condition = condition; - } - - public synchronized List getPreOperationChain() { - return preOperationChain; - } - - public synchronized void setPreOperationChain( - final List preOperationChain) { - this.preOperationChain = preOperationChain; - } - - public synchronized List getPreFileChain() { - return preFileChain; - } - - public synchronized void setPreFileChain(final List preFileChain) { - this.preFileChain = preFileChain; - } - - public synchronized List getPostFileChain() { - return postFileChain; - } - - public synchronized void setPostFileChain(final List postFileChain) { - this.postFileChain = postFileChain; - } - - public synchronized List getPostOperationChain() { - return postOperationChain; - } - - public synchronized void setPostOperationChain( - final List postOperationChain) { - this.postOperationChain = postOperationChain; - } - - public synchronized String getErrorHandler() { - return errorHandler; - } - - public synchronized void setErrorHandler(final String errorHandler) { - this.errorHandler = errorHandler; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/FlowSpecCacheService.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/FlowSpecCacheService.java deleted file mode 100644 index 57385a704..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/FlowSpecCacheService.java +++ /dev/null @@ -1,240 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.flow; - -import groovy.lang.Binding; -import groovy.util.GroovyScriptEngine; -import groovy.util.ResourceException; -import groovy.util.ScriptException; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.irods.jargon.core.utils.LocalFileUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Service to load flow specifications as DSL script files from a set of - * locations, and find appropriate flow specs given a specification - *

- * Since flow specs are groovy DSLs in a text file, this will run a groovy shell - * on each discovered specification - * - * @author Mike Conway - DICE - * - */ -public class FlowSpecCacheService { - - private List flowSourceLocalAbsolutePaths = new ArrayList(); - private List flowSpecs = new ArrayList(); - /** - * Dependency on delimiter, defaults to a , (comma) if not set explicitly - */ - private final String delimiter = ","; - - private static final Logger log = LoggerFactory - .getLogger(FlowSpecCacheService.class); - - /** - * - */ - public FlowSpecCacheService() { - } - - /** - * Scan the library of dsls and add a flowspec for each .groovy file - * - * @throws FlowSpecConfigurationException - * @throws FlowManagerException - */ - public synchronized void init() throws FlowSpecConfigurationException, - FlowManagerException { - - log.info("init()...scan for dsl files"); - - for (String flowPath : flowSourceLocalAbsolutePaths) { - findFlowsInPath(flowPath); - } - - log.info("flows processed"); - - if (flowSpecs.isEmpty()) { - log.warn("No flows configured"); - } - - flowSpecs = Collections.unmodifiableList(flowSpecs); - - } - - /** - * Scan the file and load up any flows you find. This does not recurse, so - * that one may control the load order by file sort order. - * - * @param flowPath - * @throws FlowSpecConfigurationException - * @throws FlowManagerException - */ - private void findFlowsInPath(final String flowPath) - throws FlowSpecConfigurationException, FlowManagerException { - - log.info("looking for flows in path:{}", flowPath); - - /* - * Ignore missing dirs and just plow ahead. Mabye later add a validate - * step? - */ - - File flowPathFile = new File(LocalFileUtils.normalizePath(flowPath)); - if (!flowPathFile.exists()) { - log.warn("flow path does not exist:{}", flowPath); - return; - } - - if (!flowPathFile.isDirectory()) { - log.warn("flow path not directory:{}", flowPath); - return; - } - - log.info("list chilren..."); - - for (File child : flowPathFile.listFiles()) { - log.info("child:{}", child); - - if (child.isFile()) { - if (LocalFileUtils.getFileExtension(child.getName()).equals( - ".groovy")) { - log.info("have groovy file"); - addGroovyDslToFlowSpecs(child); - } else { - continue; - } - } else { - // this is a dir, if I want to recurse to it here, for now it's - // flat to have more reasonable load orders - continue; - } - } - } - - private void addGroovyDslToFlowSpecs(final File child) - throws FlowManagerException { - - log.info("parsing groovy sript for flow:{}", child); - - /* - * Note here that the specified roots are scanned for any code changes, - * allowing recompile in place if they change - */ - String[] roots = flowSourceLocalAbsolutePaths - .toArray(new String[flowSourceLocalAbsolutePaths.size()]); - GroovyScriptEngine gse; - try { - gse = new GroovyScriptEngine(roots); - Binding binding = new Binding(); - log.info("running...{}", child.getName()); - Object result = gse.run(child.getName(), binding); - - if (result == null) { - log.warn("null result, script discarded for:{}", child); - } else if (result instanceof FlowSpec) { - log.info("adding flow spec for child"); - flowSpecs.add((FlowSpec) result); - } else { - log.warn("result not flow spec, discarding:{}", child); - } - } catch (IOException e) { - log.error( - "groovy error - io exception on startup of GroovyScriptEngine", - e); - throw new FlowManagerException("io exception starting groovy", e); - } catch (ResourceException e) { - log.error( - "groovy error - resource exception on startup of GroovyScriptEngine", - e); - throw new FlowManagerException( - "resource exception starting groovy", e); - } catch (ScriptException e) { - log.error( - "groovy error - script exception on startup of GroovyScriptEngine", - e); - throw new FlowManagerException("script exception starting groovy", - e); - } - - } - - /** - * Alternative setter for dependency on a list of paths, allowing a - * delimited string that represents the list of paths, separated by the - * given delimiter value; - * - * @param paths - * @param delimiter - */ - public synchronized void setFlowSourceLocalAbsolutePathsAsDelimitedString( - final String paths) { - log.info("setFLowSourceLocalAbsolutePathsAsDelimitedString()"); - - if (paths == null || paths.isEmpty()) { - throw new IllegalArgumentException("null or empty paths"); - } - - String[] splitPaths = paths.split(delimiter); - List pathsList = new ArrayList(); - for (String path : splitPaths) { - pathsList.add(path); - } - - setFlowSourceLocalAbsolutePaths(pathsList); - - } - - /** - * Setter for injecting the list of local absolute paths to scan for .groovy - * files that are flow specs. - *

- * This is saved internally as an immutable list - * - * @param flowSourceLocalAbsolutePaths - */ - public synchronized void setFlowSourceLocalAbsolutePaths( - final List flowSourceLocalAbsolutePaths) { - - if (flowSourceLocalAbsolutePaths == null) { - throw new IllegalArgumentException( - "null flowSourceLocalAbsolutePaths"); - } - - this.flowSourceLocalAbsolutePaths = Collections - .unmodifiableList(flowSourceLocalAbsolutePaths); - } - - /** - * Get the current set of flow specs. Note that this is an unmodifiable list - * of clones, so they are thread safe once obtained. - * - * @return - */ - public synchronized List getFlowSpecs() { - List clonedFlowSpecs = new ArrayList(); - - for (FlowSpec flowSpec : flowSpecs) { - clonedFlowSpecs.add(flowSpec.clone()); - } - - return Collections.unmodifiableList(clonedFlowSpecs); - } - - /** - * @return the delimiter - */ - public synchronized String getDelimiter() { - return delimiter; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/FlowSpecConfigurationException.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/FlowSpecConfigurationException.java deleted file mode 100644 index 2d2968829..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/FlowSpecConfigurationException.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.flow; - -/** - * @author Mike Conway - DICE - * - */ -public class FlowSpecConfigurationException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 178281169504283852L; - - /** - * - */ - public FlowSpecConfigurationException() { - } - - /** - * @param arg0 - */ - public FlowSpecConfigurationException(final String arg0) { - super(arg0); - } - - /** - * @param arg0 - */ - public FlowSpecConfigurationException(final Throwable arg0) { - super(arg0); - } - - /** - * @param arg0 - * @param arg1 - */ - public FlowSpecConfigurationException(final String arg0, - final Throwable arg1) { - super(arg0, arg1); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/Selector.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/Selector.java deleted file mode 100644 index 2641193cd..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/Selector.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.flow; - -/** - * Represents a selector for a flow - * - * @author Mike Conway - DICE - * - */ -public class Selector implements Cloneable { - - public enum FlowActionEnum { - ANY, PUT, GET - } - - public static final String ANY = "*"; - - private String hostSelector = ANY; - private String zoneSelector = ANY; - private FlowActionEnum flowActionEnum = FlowActionEnum.ANY; - - @Override - public synchronized Selector clone() { - Selector clone = new Selector(); - clone.setFlowActionEnum(flowActionEnum); - clone.setHostSelector(new String(hostSelector)); - clone.setZoneSelector(new String(zoneSelector)); - return clone; - } - - /** - * @return the hostSelector - */ - public synchronized String getHostSelector() { - return hostSelector; - } - - /** - * @param hostSelector - * the hostSelector to set - */ - public synchronized void setHostSelector(final String hostSelector) { - this.hostSelector = hostSelector; - } - - /** - * @return the zoneSelector - */ - public synchronized String getZoneSelector() { - return zoneSelector; - } - - /** - * @param zoneSelector - * the zoneSelector to set - */ - public synchronized void setZoneSelector(final String zoneSelector) { - this.zoneSelector = zoneSelector; - } - - /** - * @return the transferTypeSelector - */ - public synchronized FlowActionEnum getFlowActionEnum() { - return flowActionEnum; - } - - /** - * @param transferTypeSelector - * the transferTypeSelector to set - */ - public synchronized void setFlowActionEnum( - final FlowActionEnum flowActionEnum) { - this.flowActionEnum = flowActionEnum; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/SelectorProcessor.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/SelectorProcessor.java deleted file mode 100644 index dcdc11e4c..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/SelectorProcessor.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.flow; - -import org.irods.jargon.conveyor.basic.BasicFlowManagerService; -import org.irods.jargon.conveyor.flowmanager.flow.Selector.FlowActionEnum; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.irods.jargon.transfer.dao.domain.TransferType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Processor for comparing flows to transfers to decide whether the flow is - * selected to run. This can later be subclassed to handle regex and other - * things - * - * @author Mike Conway - DICE - * - */ -public class SelectorProcessor { - - private static final Logger log = LoggerFactory - .getLogger(BasicFlowManagerService.class); - - public SelectorProcessor() { - } - - /** - * We're starting out dumb and simple, it's a literal, a *, or literal+* for - * matching. Later we may switch to a regex or pluggable selectors - * - * @param flowSpec - * {@link FlowSpe} that is a candidate for matching - * @return - */ - public boolean evaluateSelectorForTransfer(final FlowSpec flowSpec, - final TransferAttempt transferAttempt) { - - log.info("match on action..."); - if (flowSpec.getSelector().getFlowActionEnum() == FlowActionEnum.ANY) { - // matches - } else if (flowSpec.getSelector().getFlowActionEnum() == FlowActionEnum.GET - && transferAttempt.getTransfer().getTransferType() == TransferType.GET) { - // matches - } else if (flowSpec.getSelector().getFlowActionEnum() == FlowActionEnum.PUT - && transferAttempt.getTransfer().getTransferType() == TransferType.PUT) { - // matches - } else { - - return false; - } - - log.info("passes action...check host..."); - - boolean passes = compareSelectorToTransferValueAsStringWithWildcard( - flowSpec.getSelector().getHostSelector(), transferAttempt - .getTransfer().getGridAccount().getHost()); - - if (!passes) { - log.info("fails host match"); - return false; - } - - log.info("passes action...check host..."); - - passes = compareSelectorToTransferValueAsStringWithWildcard(flowSpec - .getSelector().getZoneSelector(), transferAttempt.getTransfer() - .getGridAccount().getZone()); - - if (!passes) { - log.info("fails zone match"); - return false; - } - - log.info("matched!"); - return true; - - } - - boolean compareSelectorToTransferValueAsStringWithWildcard( - final String selectorValue, final String transferValue) { - - /* - * wildcard : blah* idx = 4 transfer : blahrk - * - * passes - * - * - * - * wildcard : blahhhh* idx = 7 transfer: blahhhh - * - * - * fails - */ - - if (selectorValue.isEmpty() || selectorValue.equals("*")) { - // matches selector - } else { - int idx = selectorValue.indexOf('*'); - - if (idx == -1) { - // no wild card *, so exact match - if (selectorValue.equals(transferValue.trim())) { - } else { - return false; - } - } else { - // flow spec has a wild card, so match up to the wild card - // blahh* becomes blahh, and idx is used to trim the comparison - // value - - String wildCardVal = selectorValue.substring(0, idx); - String transferWildCardVal = transferValue; - if (transferWildCardVal.length() < idx) { - // wild card longer than the host - return false; - } else { - // trim transfer to match wild card and compare - transferWildCardVal = transferWildCardVal.substring(0, idx); - if (transferWildCardVal.equals(wildCardVal)) { - // ok - } else { - return false; - } - - } - - } - - } - // if I get here its legit match - return true; - - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/ConditionSpecification.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/ConditionSpecification.java deleted file mode 100644 index b3988291c..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/ConditionSpecification.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.irods.jargon.conveyor.flowmanager.flow.dsl; - -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpec; -import org.irods.jargon.conveyor.flowmanager.microservice.ConditionMicroservice; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; - -/** - * Condition portion of flow specification - * - * @author Mike Conway - DICE - * - */ -public class ConditionSpecification extends FlowSpecDslMicroserviceElement { - - /** - * - * @param flowSpec - */ - public ConditionSpecification(final FlowSpec flowSpec) { - super(flowSpec); - } - - /** - * Add a condition to the flow that will do a pre-check to see whether the - * chains should run - * - * @param fullyQualifiedMicroserviceClassName - * String with a FQCN for a subclass of - * {@link ConditionMicroservice} that will be loaded. - * @return - */ - public PreOperationChainSpecification when( - final String fullyQualifiedMicroserviceClassName) { - - Microservice microservice = createMicroserviceInstance(fullyQualifiedMicroserviceClassName); - - if (microservice instanceof ConditionMicroservice) { - // ok - } else { - throw new FlowSpecificationException( - "condition microservice must be subclass of ConditionMicroservice"); - } - - getFlowSpec().setCondition(fullyQualifiedMicroserviceClassName); - return new PreOperationChainSpecification(getFlowSpec()); - - } - - /** - * Continue the flow with no particular pre-conditions - * - * @return - */ - public PreOperationChainSpecification onAllConditions() { - return new PreOperationChainSpecification(getFlowSpec()); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/ErrorHandlerSpecification.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/ErrorHandlerSpecification.java deleted file mode 100644 index d125a6dc6..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/ErrorHandlerSpecification.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.flow.dsl; - -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpec; -import org.irods.jargon.conveyor.flowmanager.microservice.ErrorHandlerMicroservice; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; - -/** - * Final link in a flow, this microservice can do any error handling if the flow - * is aborted abnormally - * - * @author Mike Conway - DICE - * - */ -public class ErrorHandlerSpecification extends FlowSpecDslMicroserviceElement { - - /** - * @param flowSpec - */ - public ErrorHandlerSpecification(final FlowSpec flowSpec) { - super(flowSpec); - } - - /** - * End the flow with no specified recovery error handler - * - * @return - */ - public FlowSpec endFlowWithoutErrorHandler() { - return getFlowSpec(); - } - - /** - * Set an error/recovery handler microservice and then end the flow chain. - * This returns a completed, executable flow. - * - * @param fullyQualifiedMicroserviceClassName - * String with a FQCN for a subclass - * @return - */ - public FlowSpec endFlowWithErrorHandler( - final String fullyQualifiedMicroserviceClassName) { - - Microservice microservice = createMicroserviceInstance(fullyQualifiedMicroserviceClassName); - - if (microservice instanceof ErrorHandlerMicroservice) { - // ok - } else { - throw new FlowSpecificationException( - "error microservice must be subclass of ErrorHandlerMicroservice"); - } - - getFlowSpec().setErrorHandler(fullyQualifiedMicroserviceClassName); - return getFlowSpec(); - - } -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/Flow.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/Flow.java deleted file mode 100644 index 91ae04236..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/Flow.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.flow.dsl; - -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpec; - -/** - * Base to initiate the start of a FlowSpec in the DSL - * - * @author Mike Conway - DICE - * - */ -public class Flow { - - /** - * - */ - private Flow() { - } - - /** - * Begin the definition of a flow chain here - * - * @return - */ - public static FlowActionSelectorSpecification define() { - FlowSpec flowSpec = new FlowSpec(); - FlowActionSelectorSpecification flowSelectorSpecification = new FlowActionSelectorSpecification( - flowSpec); - return flowSelectorSpecification; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowActionSelectorSpecification.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowActionSelectorSpecification.java deleted file mode 100644 index 89302b323..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowActionSelectorSpecification.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.flow.dsl; - -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpec; -import org.irods.jargon.conveyor.flowmanager.flow.Selector.FlowActionEnum; - -/** - * Sets up the ability to chose a required 'for' action - * - * @author Mike Conway - DICE - * - */ -public class FlowActionSelectorSpecification extends FlowSpecDslElement { - - /** - * - */ - public FlowActionSelectorSpecification(final FlowSpec flowSpec) { - super(flowSpec); - } - - /** - * Add an action to which this flow pertains. This defaults to 'any' action - * - * @param flowActionEnum - * {@link FlowActionEnum} - * @return - */ - public FlowHostSelectorSpecification forAction( - final FlowActionEnum flowActionEnum) { - if (flowActionEnum == null) { - throw new IllegalArgumentException("null flowActionEnum"); - } - - getFlowSpec().getSelector().setFlowActionEnum(flowActionEnum); - - return new FlowHostSelectorSpecification(getFlowSpec()); - - } - - /** - * Apply this specification to any action at all - * - * @return - */ - public FlowHostSelectorSpecification forAnyAction() { - - getFlowSpec().getSelector().setFlowActionEnum(FlowActionEnum.ANY); - return new FlowHostSelectorSpecification(getFlowSpec()); - - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowHostSelectorSpecification.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowHostSelectorSpecification.java deleted file mode 100644 index a8fb85250..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowHostSelectorSpecification.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.flow.dsl; - -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpec; -import org.irods.jargon.conveyor.flowmanager.flow.Selector; - -/** - * Allows specification of a host selector - * - * @author Mike Conway - DICE - * - */ -public class FlowHostSelectorSpecification extends FlowSpecDslElement { - - public FlowHostSelectorSpecification(final FlowSpec flowSpec) { - super(flowSpec); - } - - /** - * Add a selector (a string with wildcard or regex) for the host to - * consider. Blank or * will select any hose. - * - * @param hostSelector - * String with the host selector to which this will - * apply - * @return - */ - public FlowZoneSelectorSpecification forHost(final String hostSelector) { - if (hostSelector == null) { - throw new IllegalArgumentException("null hostSpecification"); - } - - String mySelector; - if (hostSelector.isEmpty()) { - mySelector = Selector.ANY; - } else { - mySelector = hostSelector; - } - getFlowSpec().getSelector().setHostSelector(mySelector); - - return new FlowZoneSelectorSpecification(getFlowSpec()); - - } - - /** - * Select any host for this flow - * - * @return - */ - public FlowZoneSelectorSpecification forAnyHost() { - getFlowSpec().getSelector().setHostSelector(Selector.ANY); - return new FlowZoneSelectorSpecification(getFlowSpec()); - - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowSpecDslElement.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowSpecDslElement.java deleted file mode 100644 index 5c3c7a2d9..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowSpecDslElement.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.irods.jargon.conveyor.flowmanager.flow.dsl; - -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpec; - -/** - * Parent class for an element of the FlowSpec dsl flow chain builder - * - * @author mikeconway - * - */ -public class FlowSpecDslElement { - - private final FlowSpec flowSpec; - - public FlowSpecDslElement(final FlowSpec flowSpec) { - super(); - if (flowSpec == null) { - throw new IllegalArgumentException("null flowSpec"); - } - this.flowSpec = flowSpec; - } - - protected FlowSpec getFlowSpec() { - return flowSpec; - } - -} \ No newline at end of file diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowSpecDslMicroserviceElement.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowSpecDslMicroserviceElement.java deleted file mode 100644 index 62792168d..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowSpecDslMicroserviceElement.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.flow.dsl; - -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpec; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; - -/** - * Superclass for a DSL element that deals with microservices. It can do things - * like validate the microservice - * - * @author Mike Conway - DICE - * - */ -public class FlowSpecDslMicroserviceElement extends FlowSpecDslElement { - - /** - * Create an instance of the microservice. Note that this instance has not - * yet been injected with the necessary context information, this will be - * done later - * - * @param microserviceFullyQualifiedClassName - * @return - */ - protected Microservice createMicroserviceInstance( - final String microserviceFullyQualifiedClassName) { - - if (microserviceFullyQualifiedClassName == null - || microserviceFullyQualifiedClassName.isEmpty()) { - throw new IllegalArgumentException( - "null or empty microserviceFullyQualifiedClassName"); - } - - try { - return (Microservice) Class.forName( - microserviceFullyQualifiedClassName).newInstance(); - } catch (InstantiationException e) { - throw new FlowSpecificationException( - "instantation exception creating microservice", e); - } catch (IllegalAccessException e) { - throw new FlowSpecificationException( - "illegalAccessException creating microservice", e); - } catch (ClassNotFoundException e) { - throw new FlowSpecificationException( - "class not found exception creating microservice", e); - } - - } - - /** - * Check to see if the microservice can be created - * - * @param microserviceFullyQualifiedClassName - * @return - */ - protected boolean checkMicroservice( - final String microserviceFullyQualifiedClassName) { - - if (microserviceFullyQualifiedClassName == null - || microserviceFullyQualifiedClassName.isEmpty()) { - throw new IllegalArgumentException( - "null or empty microserviceFullyQualifiedClassName"); - } - - try { - createMicroserviceInstance(microserviceFullyQualifiedClassName); - return true; - } catch (FlowSpecificationException e) { - return false; - } - - } - - /** - * @param flowSpec - */ - public FlowSpecDslMicroserviceElement(final FlowSpec flowSpec) { - super(flowSpec); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowSpecificationException.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowSpecificationException.java deleted file mode 100644 index d7da2353a..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowSpecificationException.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.flow.dsl; - -/** - * Exception (runtime) that occurs when defining a specification - * - * @author Mike Conway - DICE - * - */ -public class FlowSpecificationException extends RuntimeException { - - /** - * - */ - private static final long serialVersionUID = -5151193882349061547L; - - /** - * - */ - public FlowSpecificationException() { - } - - /** - * @param arg0 - */ - public FlowSpecificationException(final String arg0) { - super(arg0); - } - - /** - * @param arg0 - */ - public FlowSpecificationException(final Throwable arg0) { - super(arg0); - } - - /** - * @param arg0 - * @param arg1 - */ - public FlowSpecificationException(final String arg0, final Throwable arg1) { - super(arg0, arg1); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowZoneSelectorSpecification.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowZoneSelectorSpecification.java deleted file mode 100644 index 0ada80a62..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowZoneSelectorSpecification.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.flow.dsl; - -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpec; -import org.irods.jargon.conveyor.flowmanager.flow.Selector; - -/** - * @author Mike Conway - DICE - * - */ -public class FlowZoneSelectorSpecification extends FlowSpecDslElement { - - public FlowZoneSelectorSpecification(final FlowSpec flowSpec) { - super(flowSpec); - } - - /** - * Add a selector (a string with wildcard or regex) for the zone to - * consider. Blank or * will select any zone. - * - * @param hostSelector - * String with the zone selector to which this will - * apply - * @return - */ - public ConditionSpecification forZone(final String zoneSelector) { - if (zoneSelector == null) { - throw new IllegalArgumentException("null zoneSelector"); - } - - String mySelector; - if (zoneSelector.isEmpty()) { - mySelector = Selector.ANY; - } else { - mySelector = zoneSelector; - } - getFlowSpec().getSelector().setZoneSelector(mySelector); - - return new ConditionSpecification(getFlowSpec()); - - } - - /** - * Select any zone for this flow - * - * @return - */ - public ConditionSpecification forAnyZone() { - getFlowSpec().getSelector().setZoneSelector(Selector.ANY); - return new ConditionSpecification(getFlowSpec()); - - } -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/PostFileChainSpecification.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/PostFileChainSpecification.java deleted file mode 100644 index 76075f992..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/PostFileChainSpecification.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.flow.dsl; - -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpec; - -/** - * Handles post file chains in the DSL - * - * @author Mike Conway - DICE - * - */ -public class PostFileChainSpecification extends FlowSpecDslMicroserviceElement { - - /** - * @param flowSpec - */ - public PostFileChainSpecification(final FlowSpec flowSpec) { - super(flowSpec); - } - - /** - * Add the given microservice as the next link in the pre-operation chain - * - * @param microserviceFullyQualifiedClassName - * @return - */ - public PostFileChainSpecification addPostFileMicroservice( - final String microserviceFullyQualifiedClassName) { - - createMicroserviceInstance(microserviceFullyQualifiedClassName); - getFlowSpec().getPostFileChain().add( - microserviceFullyQualifiedClassName); - return this; - - } - - /** - * End the post file operation chain - * - * @return - */ - public PostOperationChainSpecification endPostFileChain() { - return new PostOperationChainSpecification(getFlowSpec()); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/PostOperationChainSpecification.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/PostOperationChainSpecification.java deleted file mode 100644 index f3f616ce7..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/PostOperationChainSpecification.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.flow.dsl; - -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpec; - -/** - * @author Mike Conway - DICE - * - */ -public class PostOperationChainSpecification extends - FlowSpecDslMicroserviceElement { - - public PostOperationChainSpecification(final FlowSpec flowSpec) { - super(flowSpec); - } - - /** - * Add the given microservice as the next link in the post-operation chain - * - * @param microserviceFullyQualifiedClassName - * @return - */ - public PostOperationChainSpecification addPostOperationMicroservice( - final String microserviceFullyQualifiedClassName) { - - createMicroserviceInstance(microserviceFullyQualifiedClassName); - getFlowSpec().getPostOperationChain().add( - microserviceFullyQualifiedClassName); - return this; - - } - - /** - * End the post file operation chain - * - * @return - */ - public ErrorHandlerSpecification endPostOperationChain() { - return new ErrorHandlerSpecification(getFlowSpec()); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/PreFileChainSpecification.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/PreFileChainSpecification.java deleted file mode 100644 index 5c50982a7..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/PreFileChainSpecification.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.flow.dsl; - -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpec; - -/** - * @author mikeconway - * - */ -public class PreFileChainSpecification extends FlowSpecDslMicroserviceElement { - - /** - * @param flowSpec - */ - public PreFileChainSpecification(final FlowSpec flowSpec) { - super(flowSpec); - } - - /** - * Add the given microservice as the next link in the pre-file chain - * - * @param microserviceFullyQualifiedClassName - * @return - */ - public PreFileChainSpecification addPreFileMicroservice( - final String microserviceFullyQualifiedClassName) { - - getFlowSpec().getPreFileChain() - .add(microserviceFullyQualifiedClassName); - return this; - - } - - /** - * End the pre file chain - * - * @return - */ - public PostFileChainSpecification endPreFileChain() { - return new PostFileChainSpecification(getFlowSpec()); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/PreOperationChainSpecification.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/PreOperationChainSpecification.java deleted file mode 100644 index fb955b582..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/PreOperationChainSpecification.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.flow.dsl; - -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpec; - -/** - * @author Mike Conway - DICE - * - */ -public class PreOperationChainSpecification extends - FlowSpecDslMicroserviceElement { - - /** - * @param flowSpec - */ - public PreOperationChainSpecification(final FlowSpec flowSpec) { - super(flowSpec); - } - - /** - * Add the given microervice as the next link in the pre-operation chain - * - * @param microserviceFullyQualifiedClassName - * @return - */ - public PreOperationChainSpecification addPreOperationMicroservice( - final String microserviceFullyQualifiedClassName) { - - createMicroserviceInstance(microserviceFullyQualifiedClassName); - getFlowSpec().getPreOperationChain().add( - microserviceFullyQualifiedClassName); - return this; - - } - - /** - * End the pre operation chain - * - * @return - */ - public PreFileChainSpecification endPreOperationChain() { - return new PreFileChainSpecification(getFlowSpec()); - } -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/package-info.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/package-info.java deleted file mode 100644 index a9b956f41..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * DSL support for developing flow specs - * @author Mike Conway - DICE - * - */ -package org.irods.jargon.conveyor.flowmanager.flow.dsl; \ No newline at end of file diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/package-info.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/package-info.java deleted file mode 100644 index 07d90321d..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/flow/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Represents a flow, or a series of microservices associated with an action - * - * @author Mike Conway - DICE - * - */ -package org.irods.jargon.conveyor.flowmanager.flow; - diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/ConditionMicroservice.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/ConditionMicroservice.java deleted file mode 100644 index 13f02dbdd..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/ConditionMicroservice.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice; - -import org.irods.jargon.core.transfer.TransferStatus; - -/** - * Microservice super class for a condition. By default this will return a - * continue - * - * @author Mike Conway - DICE - * - */ -public class ConditionMicroservice extends Microservice { - - /** - * - */ - public ConditionMicroservice() { - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.flowmanager.microservice.Microservice#execute - * (org.irods.jargon.core.transfer.TransferStatus) - */ - @Override - public ExecResult execute(final TransferStatus transferStatus) - throws MicroserviceException { - return ExecResult.CONTINUE; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/ContainerEnvironment.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/ContainerEnvironment.java deleted file mode 100644 index 2e3d0cef8..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/ContainerEnvironment.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice; - -import java.util.Properties; - -import org.irods.jargon.conveyor.core.ConveyorService; - -/** - * Represents the container that will be running microservices, providing - * something like a runtime environment, giving references to the flow manager - * that is running the rules, as well as hooks to talk with iRODS. This - * represents the stable, global state of the flow manager. - *

- * This is used on concert with the InvocationContext that - * represents the single-invocation environment, such as the current operating - * transfer, the curent account used, and a Map of properties that - * may be used to pass information between microservices. - * - * @author Mike Conway - DICE - * - */ -public class ContainerEnvironment { - - /** - * Required dependency on the conveyor service that represents the transfer - * manager and orchestration layer - */ - private ConveyorService conveyorService; - - /** - * Optional properties that may be configured globally - */ - private Properties globalConfigurationProperties = new Properties(); - - /** - * Get a reference to the main conveyor service, which represents the - * transfer queue and all recorded state - * - * @return {@link ConveyorService} - */ - public ConveyorService getConveyorService() { - return conveyorService; - } - - /** - * Set a reference to the main conveyor service - * - * @param conveyorService - * {@link ConveyorService} - */ - public void setConveyorService(final ConveyorService conveyorService) { - this.conveyorService = conveyorService; - } - - public Properties getGlobalConfigurationProperties() { - return globalConfigurationProperties; - } - - public void setGlobalConfigurationProperties( - final Properties globalConfigurationProperties) { - this.globalConfigurationProperties = globalConfigurationProperties; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/ErrorHandlerMicroservice.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/ErrorHandlerMicroservice.java deleted file mode 100644 index fc3ff25a6..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/ErrorHandlerMicroservice.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice; - -import org.irods.jargon.core.transfer.TransferStatus; - -/** - * Default error handler will propogate the abort - * - * @author Mike Conway - DICE - * - */ -public class ErrorHandlerMicroservice extends Microservice { - - /** - * - */ - public ErrorHandlerMicroservice() { - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.flowmanager.microservice.Microservice#execute() - */ - @Override - public ExecResult execute(final TransferStatus transferStatus) - throws MicroserviceException { - return ExecResult.ABORT_AND_TRIGGER_ANY_ERROR_HANDLER; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/InvocationContext.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/InvocationContext.java deleted file mode 100644 index 9e3fdd683..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/InvocationContext.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.transfer.TransferControlBlock; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; - -/** - * @author Mike Conway - DICE - * - */ -public class InvocationContext { - - /** - * Injected reference to the current, resolved iRODS account for this - * transfer - */ - private IRODSAccount irodsAccount; - - /** - * Injected reference to the current transfer attempt - */ - private TransferAttempt transferAttempt; - - /** - * Injected reference to the control block for the current transfer - */ - private TransferControlBlock transferControlBlock; - - /** - * Shared map of objects - */ - private final Map sharedProperties = new ConcurrentHashMap(); - - /** - * @return the {@link IRODSAccount} - */ - public IRODSAccount getIrodsAccount() { - return irodsAccount; - } - - /** - * @param irodsAccount - * the {@link IRODSAccount} to set - */ - public void setIrodsAccount(final IRODSAccount irodsAccount) { - this.irodsAccount = irodsAccount; - } - - /** - * @return the {@link TransferAttempt} - */ - public TransferAttempt getTransferAttempt() { - return transferAttempt; - } - - /** - * @param transferAttempt - * the {@link TransferAttempt} to set - */ - public void setTransferAttempt(final TransferAttempt transferAttempt) { - this.transferAttempt = transferAttempt; - } - - /** - * @return the {@link TransferControlBlock} - */ - public TransferControlBlock getTransferControlBlock() { - return transferControlBlock; - } - - /** - * @param transferControlBlock - * the {@link TransferControlBlock} to set - */ - public void setTransferControlBlock( - final TransferControlBlock transferControlBlock) { - this.transferControlBlock = transferControlBlock; - } - - /** - * @return the sharedProperties - */ - public Map getSharedProperties() { - return sharedProperties; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/Microservice.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/Microservice.java deleted file mode 100644 index 7d1b99a13..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/Microservice.java +++ /dev/null @@ -1,153 +0,0 @@ -package org.irods.jargon.conveyor.flowmanager.microservice; - -import org.irods.jargon.core.transfer.TransferStatus; - -/** - * - */ - -/** - * Abstract base class for client side microservice. Somewhat analogous to an - * iRODS microservice, this is an executable unit of code that performs a - * specific function, and is meant to be chained together into a larger - * workflow. - *

- * This class can be extended by clients to create new microservices. - * - * @author Mike Conway - DICE - * - */ -public class Microservice { - - /** - * Enumeration of the results of an exec step, as returned by the execute() - * method - * - */ - public enum ExecResult { - CONTINUE, SKIP_THIS_CHAIN, SKIP_THIS_FILE, CANCEL_OPERATION, ABORT_AND_TRIGGER_ANY_ERROR_HANDLER, TERMINATE_FLOW_FAIL_PRECONDITION - } - - /** - * Injected reference to the global environment for the flow manager - * container. This provides access to the conveyor service, which can be - * used to query and manipulate the transfer queue - */ - private ContainerEnvironment containerEnvironment; - - /** - * Injected reference to the current context (operation) that triggered this - * invocation, along with a simple store to pass values between - * microservices - */ - private InvocationContext invocationContext; - - public Microservice() { - } - - /** - * Gets a reference to the global environment in which this microservice is - * running - * - * @return {@link ContainerEnvironment} - */ - public ContainerEnvironment getContainerEnvironment() { - return containerEnvironment; - } - - /** - * Sets a reference to the global environment in which this microservice is - * running - * - * @param containerEnvironment - * {@link ContainerEnvironment} - */ - public void setContainerEnvironment( - final ContainerEnvironment containerEnvironment) { - this.containerEnvironment = containerEnvironment; - } - - /** - * Primary implementation hook. Implementor simply does what they need to in - * the execute() method and returns an ExecResult, or an exception if an - * error occurred. - *

- * - * @param transferStatus - * {@link TransferStatus} that initiates this microservice - * @return {@link ExecResult} enumeration value that signals handling of - * further microservices - * @throws MicroserviceException - */ - public ExecResult execute(final TransferStatus transferStatus) - throws MicroserviceException { - - if (transferStatus == null) { - throw new IllegalArgumentException("null transferStatus"); - } - - return ExecResult.CONTINUE; - } - - /** - * @return the {@link InvocationContext} - */ - public InvocationContext getInvocationContext() { - return invocationContext; - } - - /** - * @param invocationContext - * the {@link InvocationContext} to set - */ - public void setInvocationContext(final InvocationContext invocationContext) { - this.invocationContext = invocationContext; - } - - /** - * Handy method that will evaluate whether the microservice has been - * correctly provisioned. This is validated when the flow manager executes a - * microservice as a nice sanity check. - */ - public void evaluateContext() { - if (getContainerEnvironment() == null) { - throw new IllegalStateException("null container environment"); - } - - if (getContainerEnvironment().getConveyorService() == null) { - throw new IllegalStateException( - "null conveyor service in container environment"); - } - - if (getContainerEnvironment().getGlobalConfigurationProperties() == null) { - throw new IllegalStateException( - "null globalConfigurationProperties in container environment"); - } - - if (getInvocationContext() == null) { - throw new IllegalStateException("null invocation context"); - } - - if (getInvocationContext().getIrodsAccount() == null) { - throw new IllegalStateException( - "null irodsAccount in invocation context"); - } - - if (getInvocationContext().getSharedProperties() == null) { - throw new IllegalStateException( - "null shared properties in invocation context"); - } - - if (getInvocationContext().getTransferAttempt() == null) { - throw new IllegalStateException( - "null transferAttempt in invocation context"); - } - - if (getInvocationContext().getTransferControlBlock() == null) { - throw new IllegalStateException( - "null transferControlBlock in invocation context"); - } - - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/MicroserviceException.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/MicroserviceException.java deleted file mode 100644 index 5c0c629e4..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/MicroserviceException.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice; - -/** - * General exception in Microservice processing - * - * @author Mike - * - */ -public class MicroserviceException extends Exception { - - private static final long serialVersionUID = 7521674518232217903L; - - /** - * - */ - public MicroserviceException() { - } - - /** - * @param arg0 - */ - public MicroserviceException(final String arg0) { - super(arg0); - } - - /** - * @param arg0 - */ - public MicroserviceException(final Throwable arg0) { - super(arg0); - } - - /** - * @param arg0 - * @param arg1 - */ - public MicroserviceException(final String arg0, final Throwable arg1) { - super(arg0, arg1); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/CancelOperationMicroservice.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/CancelOperationMicroservice.java deleted file mode 100644 index 6a2dc53b2..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/CancelOperationMicroservice.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice.builtins; - -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.irods.jargon.conveyor.flowmanager.microservice.MicroserviceException; -import org.irods.jargon.core.transfer.TransferStatus; - -/** - * Simply cancels the chain - * - * @author Mike Conway - DICE - * - */ -public class CancelOperationMicroservice extends Microservice { - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.flowmanager.microservice.Microservice#execute - * (org.irods.jargon.core.transfer.TransferStatus) - */ - @Override - public ExecResult execute(final TransferStatus transferStatus) - throws MicroserviceException { - return ExecResult.CANCEL_OPERATION; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/EnqueueTransferMicroservice.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/EnqueueTransferMicroservice.java deleted file mode 100644 index a96310cf7..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/EnqueueTransferMicroservice.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice.builtins; - -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.RejectedTransferException; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.irods.jargon.conveyor.flowmanager.microservice.MicroserviceException; -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Microservice to enqueue a transfer. This will use the current transfer status - * and then check the shared whiteboard for any override parameters. - * - * @author Mike Conway - DICE - * - */ -public class EnqueueTransferMicroservice extends Microservice { - - private static final Logger log = LoggerFactory - .getLogger(EnqueueTransferMicroservice.class); - - /** - * Parameters that will override those in the transfer status for the new - * transfer - */ - public static final String LOCAL_FILE_NAME = EnqueueTransferMicroservice.class - .getName() + ":LOCAL_PATH"; - - public static final String IRODS_FILE_NAME = EnqueueTransferMicroservice.class - .getName() + ":IRODS_PATH"; - - public static final String RESOURCE = EnqueueTransferMicroservice.class - .getName() + ":RESOURCE"; - - public static final String ENQUEUED_TRANSFER = EnqueueTransferMicroservice.class - .getName() + ":ENQUEUED_TRANSFER"; - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.flowmanager.microservice.Microservice#execute - * (org.irods.jargon.core.transfer.TransferStatus) - */ - @Override - public ExecResult execute(final TransferStatus transferStatus) - throws MicroserviceException { - - log.info("execute"); - - Transfer oldTransfer = getInvocationContext().getTransferAttempt() - .getTransfer(); - - log.info("currentTransfer:{}", oldTransfer); - - Transfer transfer = new Transfer(); - transfer.setTransferType(oldTransfer.getTransferType()); - transfer.setGridAccount(oldTransfer.getGridAccount()); - - if (getInvocationContext().getSharedProperties().get(LOCAL_FILE_NAME) != null) { - log.info("overriding source file name"); - transfer.setLocalAbsolutePath((String) getInvocationContext() - .getSharedProperties().get(LOCAL_FILE_NAME)); - } else { - transfer.setLocalAbsolutePath(oldTransfer.getLocalAbsolutePath()); - } - - if (getInvocationContext().getSharedProperties().get(IRODS_FILE_NAME) != null) { - log.info("overriding irods file name"); - transfer.setIrodsAbsolutePath((String) getInvocationContext() - .getSharedProperties().get(IRODS_FILE_NAME)); - } else { - transfer.setIrodsAbsolutePath(oldTransfer.getIrodsAbsolutePath()); - } - - if (getInvocationContext().getSharedProperties().get(RESOURCE) != null) { - log.info("overriding resource name"); - transfer.setResourceName((String) getInvocationContext() - .getSharedProperties().get(RESOURCE)); - } else { - transfer.setResourceName(oldTransfer.getResourceName()); - } - - log.info("updated transfer is:{}", transfer); - try { - getContainerEnvironment() - .getConveyorService() - .getQueueManagerService() - .enqueueTransferOperation(transfer, - getInvocationContext().getIrodsAccount()); - - // add the enqueued transfer to the whiteboard - - getInvocationContext().getSharedProperties().put(ENQUEUED_TRANSFER, - transfer); - - } catch (RejectedTransferException e) { - log.error("rejected transfer:{}", transfer, e); - throw new MicroserviceException("updated transfer was rejected", e); - } catch (ConveyorExecutionException e) { - log.error("conveyor exception enqueueing new transfer", e); - throw new MicroserviceException( - "conveyor exception enqueueing new transfer", e); - } - - return ExecResult.CONTINUE; - - } -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/ExtractBundleMicroservice.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/ExtractBundleMicroservice.java deleted file mode 100644 index da909a6f7..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/ExtractBundleMicroservice.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice.builtins; - -import java.io.File; - -import org.irods.jargon.conveyor.flowmanager.microservice.InvocationContext; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.irods.jargon.conveyor.flowmanager.microservice.MicroserviceException; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.BulkFileOperationsAO; -import org.irods.jargon.core.pub.io.IRODSFile; -import org.irods.jargon.core.transfer.TransferStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Microservice to extract a bundle on iRODS. This expects a bundle to extract - * and a target directory as parameters using the keys displayed below in the - * invocation context shared white-board - * - * @author Mike Conway - DICE - * - */ -public class ExtractBundleMicroservice extends Microservice { - - /** - * The following parameters are inspected in the {@link InvocationContext} - * with an optional resource. - *

- * For the source file, if it is not specified, , then the microservice will - * first look for a tar file name deposited by the - * {@link TarCollectionMicroservice}. If that's not found an error will - * occur. - *

- * If the target collection is unspecified the parent of the required bundle - * file parameter is used as the target - */ - public static final String BUNDLE_TO_EXTRACT = ExtractBundleMicroservice.class - .getName() + ":BUNDLE_TO_EXTRACT"; - public static final String TARGET_COLLECTION = ExtractBundleMicroservice.class - .getName() + ":TARGET_COLLECTION"; - public static final String TARGET_RESOURCE = ExtractBundleMicroservice.class - .getName() + ":TARGET_RESOURCE"; - - private static final Logger log = LoggerFactory - .getLogger(ExtractBundleMicroservice.class); - - /** - * - */ - public ExtractBundleMicroservice() { - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.flowmanager.microservice.Microservice#execute - * (org.irods.jargon.core.transfer.TransferStatus) - */ - @Override - public ExecResult execute(final TransferStatus transferStatus) - throws MicroserviceException { - - log.info("execute"); - - String bundleToExtract = (String) getInvocationContext() - .getSharedProperties().get(BUNDLE_TO_EXTRACT); - if (bundleToExtract == null || bundleToExtract.isEmpty()) { - log.info("did not find BUNDLE_TO_EXTRACT, look at transfer status value"); - bundleToExtract = transferStatus.getTargetFileAbsolutePath(); - File sourceFile = new File( - transferStatus.getSourceFileAbsolutePath()); - StringBuilder sb = new StringBuilder(); - sb.append(bundleToExtract); - sb.append("/"); - sb.append(sourceFile.getName()); - bundleToExtract = sb.toString(); - - if (bundleToExtract == null || bundleToExtract.isEmpty()) { - log.error("no bundle to extract found"); - throw new MicroserviceException( - "missing BUNDLE_TO_EXTTRACT value"); - } - } - - log.info("bundle to extract:{}", bundleToExtract); - - IRODSFile targetFile = null; - try { - targetFile = getContainerEnvironment() - .getConveyorService() - .getIrodsAccessObjectFactory() - .getIRODSFileFactory( - getInvocationContext().getIrodsAccount()) - .instanceIRODSFile(bundleToExtract); - } catch (JargonException e1) { - log.error("jargon error getting target file"); - throw new MicroserviceException(); - } - - log.info("target file:{}", targetFile); - - if (targetFile.exists() && targetFile.isDirectory()) { - log.error("bundle file not in iRODS"); - throw new MicroserviceException(); - } - - log.info("look for target"); - - String targetCollection = (String) getInvocationContext() - .getSharedProperties().get(TARGET_COLLECTION); - - if (targetCollection == null || targetCollection.isEmpty()) { - log.info("no target collection passed in, use the parent of the tar file"); - targetCollection = targetFile.getParent(); - } - - log.info("target collection will be:{}", targetCollection); - - log.info("getting resource"); - String targetResource = (String) getInvocationContext() - .getSharedProperties().get(TARGET_RESOURCE); - - if (targetResource == null) { - targetResource = ""; - } - - log.info("setting target resource:{}", targetResource); - - log.info("ok have everything set let's uncompress the tar by calling iRODS"); - - try { - BulkFileOperationsAO bulkFileOperations = getContainerEnvironment() - .getConveyorService() - .getIrodsAccessObjectFactory() - .getBulkFileOperationsAO( - getInvocationContext().getIrodsAccount()); - - bulkFileOperations.extractABundleIntoAnIrodsCollection( - bundleToExtract, targetCollection, targetResource); - log.info("complete"); - return ExecResult.CONTINUE; - - } catch (JargonException e) { - log.error("unable to unbundle file", e); - throw new MicroserviceException( - "unable to unbundle file due to jargon errors", e); - } - - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/InspectForBundleOperationMicroservice.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/InspectForBundleOperationMicroservice.java deleted file mode 100644 index a583a8d3d..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/InspectForBundleOperationMicroservice.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice.builtins; - -import java.io.File; -import java.io.FileNotFoundException; - -import org.irods.jargon.conveyor.flowmanager.microservice.ConditionMicroservice; -import org.irods.jargon.conveyor.flowmanager.microservice.MicroserviceException; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.core.transfer.TransferStatus.TransferType; -import org.irods.jargon.core.utils.LocalFileUtils; -import org.irods.jargon.datautils.tree.TreeSummarizingService; -import org.irods.jargon.datautils.tree.TreeSummarizingServiceImpl; -import org.irods.jargon.datautils.tree.TreeSummary; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Inspect a source directory and decide whether it is useful to bundle up the - * contents instead of a file-by-file transfer - * - * @author Mike Conway - DICE - * - */ -public class InspectForBundleOperationMicroservice extends - ConditionMicroservice { - - private static final Logger log = LoggerFactory - .getLogger(InspectForBundleOperationMicroservice.class); - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.flowmanager.microservice.ConditionMicroservice - * #execute(org.irods.jargon.core.transfer.TransferStatus) - */ - @Override - public ExecResult execute(final TransferStatus transferStatus) - throws MicroserviceException { - - log.info("execute()...do a summary of the source dir"); - - if (transferStatus.getTransferType() != TransferType.PUT) { - throw new MicroserviceException( - "this microservice only makes sense in a PUT operation"); - } - - File localFile = new File(transferStatus.getSourceFileAbsolutePath()); - - if (!localFile.exists()) { - log.info("source file does not exist, consider a failed condition"); - return ExecResult.TERMINATE_FLOW_FAIL_PRECONDITION; - } - - if (!localFile.isDirectory()) { - log.info("source file is not a dir, consider a failed condition"); - return ExecResult.TERMINATE_FLOW_FAIL_PRECONDITION; - } - - TreeSummarizingService service = new TreeSummarizingServiceImpl( - getContainerEnvironment().getConveyorService() - .getIrodsAccessObjectFactory(), getInvocationContext() - .getIrodsAccount()); - - try { - log.info("generating tree summary"); - TreeSummary summary = service - .generateTreeSummaryForLocalFileTree(LocalFileUtils - .normalizePath(transferStatus - .getSourceFileAbsolutePath())); - - double averageSize = summary.calculateAverageLength(); - - /* - * Some dumb heuristics... - */ - - int score = 0; - - if (averageSize <= 20 * 1024) { - score += 10; - } else if (averageSize <= 200 * 1024) { - score += 5; - } else if (averageSize <= 1 * 1024 * 1024) { - score += 2; - } - - if (summary.getMaxLength() <= 20 * 1024) { - score += 10; - } else if (summary.getMaxLength() <= 200 * 1024) { - score += 5; - } else if (summary.getMaxLength() <= 20 * 1024 * 1024) { - score += 2; - } - - if (summary.getTotalFiles() >= 500) { - score += 10; - } else if (summary.getTotalFiles() >= 300) { - score += 5; - } else if (summary.getTotalFiles() >= 100) { - score += 2; - } - - log.info("total score:{}", score); - if (score > 20) { - return ExecResult.CONTINUE; - } else { - return ExecResult.TERMINATE_FLOW_FAIL_PRECONDITION; - } - - } catch (FileNotFoundException e) { - log.error("source file not found:{}", - transferStatus.getSourceFileAbsolutePath()); - throw new MicroserviceException("cannot find source file"); - } catch (JargonException e) { - log.error("jargon exception", e); - throw new MicroserviceException( - "jargon exception running microservice", e); - } - - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/InspectForUnbundleOperationMicroservice.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/InspectForUnbundleOperationMicroservice.java deleted file mode 100644 index 950223ba0..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/InspectForUnbundleOperationMicroservice.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice.builtins; - -import java.io.File; - -import org.irods.jargon.conveyor.flowmanager.microservice.ConditionMicroservice; -import org.irods.jargon.conveyor.flowmanager.microservice.MicroserviceException; -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.core.transfer.TransferStatus.TransferType; -import org.irods.jargon.core.utils.LocalFileUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Inspect a source and see if a tar file is being transferred that should be - * unbundled - * - * @author Mike Conway - DICE - * - */ -public class InspectForUnbundleOperationMicroservice extends - ConditionMicroservice { - - private static final Logger log = LoggerFactory - .getLogger(InspectForUnbundleOperationMicroservice.class); - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.flowmanager.microservice.ConditionMicroservice - * #execute(org.irods.jargon.core.transfer.TransferStatus) - */ - @Override - public ExecResult execute(final TransferStatus transferStatus) - throws MicroserviceException { - - log.info("execute()...do a summary of the source dir"); - - if (transferStatus.getTransferType() != TransferType.PUT) { - throw new MicroserviceException( - "this microservice only makes sense in a PUT operation"); - } - - File localFile = new File(transferStatus.getSourceFileAbsolutePath()); - - if (!localFile.exists()) { - log.info("source file does not exist, consider a failed condition"); - return ExecResult.TERMINATE_FLOW_FAIL_PRECONDITION; - } - - if (localFile.isDirectory()) { - log.info("source file is a dir, consider a failed condition"); - return ExecResult.TERMINATE_FLOW_FAIL_PRECONDITION; - } - - String ext = LocalFileUtils.getFileExtension(localFile.getName()); - log.info("extension is:{}", ext); - - if (ext.equals(".tar")) { - log.info("is a tar..."); - return ExecResult.CONTINUE; - } else { - log.info("not a tar"); - return ExecResult.TERMINATE_FLOW_FAIL_PRECONDITION; - } - - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/TarCollectionMicroservice.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/TarCollectionMicroservice.java deleted file mode 100644 index 6e0e4fcd5..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/TarCollectionMicroservice.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice.builtins; - -import java.io.File; -import java.io.FileNotFoundException; - -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.irods.jargon.conveyor.flowmanager.microservice.MicroserviceException; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.datautils.filearchive.LocalTarFileArchiver; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Microservice to tar up a given directory (based on the source collection of - * the transfer). - * - * @author Mike Conway - DICE - * - */ -public class TarCollectionMicroservice extends Microservice { - - /*** - * Name of the parameter that I will look for if there is a specific tar - * file name - */ - public static final String TAR_FILE_NAME = TarCollectionMicroservice.class - .getName() + ":TAR_FILE_NAME"; - - private static final Logger log = LoggerFactory - .getLogger(TarCollectionMicroservice.class); - - @Override - public ExecResult execute(final TransferStatus transferStatus) - throws MicroserviceException { - - log.info("execute"); - - String tarFileName = (String) getInvocationContext() - .getSharedProperties().get(TAR_FILE_NAME); - - /* - * TODO: where do I put this? for now use target dir and contents.tar - */ - if (tarFileName == null) { - File sourceFile = new File( - transferStatus.getSourceFileAbsolutePath()); - log.info("no tar file, create a temp dir for this tar file"); - StringBuilder targetDir = new StringBuilder(); - targetDir.append(sourceFile.getParent()); - targetDir.append("/contents"); - targetDir.append(System.currentTimeMillis()); - targetDir.append(".tar"); - tarFileName = targetDir.toString(); - } - - log.info("tar file name will be:{}", tarFileName); - - LocalTarFileArchiver localFileTarArchiver = new LocalTarFileArchiver( - transferStatus.getSourceFileAbsolutePath(), tarFileName); - - try { - File archiveFile = localFileTarArchiver.createArchive(); - getInvocationContext().getSharedProperties().put( - EnqueueTransferMicroservice.LOCAL_FILE_NAME, - archiveFile.getAbsolutePath()); - return ExecResult.CONTINUE; - - } catch (FileNotFoundException e) { - log.error("fileNotFoundException on create of tar file", e); - throw new MicroserviceException( - "microservice exception creating tar file", e); - } catch (JargonException e) { - log.error("JargonException on create of tar file", e); - throw new MicroserviceException( - "JargonException creating tar file", e); - } - - } -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/package-info.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/package-info.java deleted file mode 100644 index 9c6e33ff4..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/flowmanager/microservice/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Core definitions of basic components used to create microservices and flows in the client-side rule engine. This package provides the classes needed to construct - * new microservices - * - * @author Mike Conway - DICE - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice; \ No newline at end of file diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/gridaccount/GridAccountConfigurationException.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/gridaccount/GridAccountConfigurationException.java deleted file mode 100644 index 946eb06c2..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/gridaccount/GridAccountConfigurationException.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.gridaccount; - -import org.irods.jargon.conveyor.core.ConveyorExecutionException; - -/** - * Exception caused in grid account configuration process - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class GridAccountConfigurationException extends - ConveyorExecutionException { - - private static final long serialVersionUID = 5002386897952197209L; - - public GridAccountConfigurationException() { - super(); - } - - public GridAccountConfigurationException(final String arg0, - final Throwable arg1) { - super(arg0, arg1); - } - - public GridAccountConfigurationException(final String arg0) { - super(arg0); - } - - public GridAccountConfigurationException(final Throwable arg0) { - super(arg0); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/gridaccount/GridAccountConfigurationProcessor.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/gridaccount/GridAccountConfigurationProcessor.java deleted file mode 100644 index 01ed51f20..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/gridaccount/GridAccountConfigurationProcessor.java +++ /dev/null @@ -1,180 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.gridaccount; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.List; - -import org.irods.jargon.core.connection.AuthScheme; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.JargonException; - -/** - * Helper class can read a file of pre-seeded iRODS accounts in a , delimited - * format from a text file and can create a set of IRODSAccount - * objects that can be processed. - *

- * This class can also take a set of IRODSAccount objects and - * serialize them into a text file - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class GridAccountConfigurationProcessor { - - public static final String DELIM = ","; - public static final String COMMENT = "#"; - - /** - * Take a list of IRODSAccount and serialize into a text file - * - * @param gridAccountFile - * File to which the accounts will serialized (no - * password information is saved) - * @param irodsAccounts - * List of {@link IRODSAccount} - * @throws GridAccountConfigurationException - */ - public static void serializeIRODSAccountListToFile( - final File gridAccountFile, final List irodsAccounts) - throws GridAccountConfigurationException { - - if (gridAccountFile == null) { - throw new IllegalArgumentException("null gridAccountFile"); - } - - if (irodsAccounts == null) { - throw new IllegalArgumentException("null irodsAccounts"); - } - - try { - gridAccountFile.delete(); - PrintWriter out = new PrintWriter(gridAccountFile); - - for (IRODSAccount irodsAccount : irodsAccounts) { - out.println(buildLineForAccount(irodsAccount)); - } - out.flush(); - out.close(); - - } catch (IOException e) { - throw new GridAccountConfigurationException( - "unable to write out to grid account file", e); - } - } - - public static List deserializeIRODSAccountListFromFile( - final File gridAccountFile) - throws GridAccountConfigurationException { - - if (gridAccountFile == null) { - throw new IllegalArgumentException("null gridAccountFile"); - } - - if (!gridAccountFile.exists()) { - throw new GridAccountConfigurationException( - "gridAccountFile does not exist"); - } - - List irodsAccounts = new ArrayList(); - - try { - BufferedReader br = new BufferedReader(new FileReader( - gridAccountFile)); - String line; - IRODSAccount irodsAccount = null; - while ((line = br.readLine()) != null) { - irodsAccount = buildAccountForLine(line); - // tolerate null or blank lines - if (irodsAccount != null) { - irodsAccounts.add(buildAccountForLine(line)); - } - } - br.close(); - return irodsAccounts; - } catch (IOException e) { - throw new GridAccountConfigurationException( - "unable to write out to grid account file", e); - } - - } - - /** - * Given a String reflecting a line in a preset file, return - * the associated IRODSAccount if one can be found. This method - * will return null if the line is blank, or if it is a comment - * (prepended by a #). - *

- * The caller must check for nulls - * - * @param line - * String with a line from a serialized file - * @return {@link IRODSAccount} or null - * @throws GridAccountConfigurationException - */ - private static IRODSAccount buildAccountForLine(final String line) - throws GridAccountConfigurationException { - - if (line == null || line.isEmpty()) { - return null; - } - - // lines that start with # are treated as comments and ignored - if (line.startsWith(COMMENT)) { - return null; - } - - String[] elements = line.split("[" + DELIM + "]"); - - if (elements.length != 7) { - throw new GridAccountConfigurationException( - "unexpected number of parameters in line"); - } - - try { - return IRODSAccount.instance(elements[0], - Integer.parseInt(elements[1]), elements[3], - "", // no password here - elements[6], elements[2], elements[5], - AuthScheme.findTypeByString(elements[4])); - } catch (NumberFormatException e) { - throw new GridAccountConfigurationException( - "invalid port in position 1", e); - } catch (JargonException e) { - throw new GridAccountConfigurationException( - "error creating IRODSAccount", e); - } - - } - - /** - * Turn an IRODSAccount into a | delim String - * - * @param irodsAccount - * @return - */ - private static String buildLineForAccount(final IRODSAccount irodsAccount) { - StringBuilder sb = new StringBuilder(); - sb.append(irodsAccount.getHost()); - sb.append(DELIM); - sb.append(irodsAccount.getPort()); - sb.append(DELIM); - sb.append(irodsAccount.getZone()); - sb.append(DELIM); - sb.append(irodsAccount.getUserName()); - sb.append(DELIM); - sb.append(irodsAccount.getAuthenticationScheme()); - sb.append(DELIM); - sb.append(irodsAccount.getDefaultStorageResource()); - sb.append(DELIM); - sb.append(irodsAccount.getHomeDirectory()); - return sb.toString(); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/gridaccount/package-info.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/gridaccount/package-info.java deleted file mode 100644 index 05af15a9c..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/gridaccount/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Supporting packages for managing grid accounts - * @author Mike Conway - DICE (www.irods.org) - * - */ -package org.irods.jargon.conveyor.gridaccount; \ No newline at end of file diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/package-info.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/package-info.java deleted file mode 100644 index 40f8da763..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * @author mikeconway - * - */ -package org.irods.jargon.conveyor; \ No newline at end of file diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/AbstractSynchronizingComponent.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/AbstractSynchronizingComponent.java deleted file mode 100644 index 6a83ecdc8..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/AbstractSynchronizingComponent.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.irods.jargon.conveyor.synch; - -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.core.transfer.TransferControlBlock; - -public class AbstractSynchronizingComponent { - private ConveyorService conveyorService; - private TransferControlBlock transferControlBlock; - - public AbstractSynchronizingComponent( - final ConveyorService conveyorService, - final TransferControlBlock transferControlBlock) { - if (conveyorService == null) { - throw new IllegalArgumentException("null conveyorService"); - } - - if (transferControlBlock == null) { - throw new IllegalArgumentException("null transferControlBlock"); - } - - this.conveyorService = conveyorService; - this.transferControlBlock = transferControlBlock; - } - - /** - * @return the conveyorService - */ - public ConveyorService getConveyorService() { - return conveyorService; - } - - /** - * @param conveyorService - * the conveyorService to set - */ - public void setConveyorService(final ConveyorService conveyorService) { - this.conveyorService = conveyorService; - } - - /** - * @return the transferControlBlock - */ - public TransferControlBlock getTransferControlBlock() { - return transferControlBlock; - } - - /** - * @param transferControlBlock - * the transferControlBlock to set - */ - public void setTransferControlBlock( - final TransferControlBlock transferControlBlock) { - this.transferControlBlock = transferControlBlock; - } - - /** - * convenience method checks if this operation is cancelled - * - * @return boolean indicating that a cancellation was received - */ - public boolean isCancelled() { - return getTransferControlBlock().isCancelled(); - } -} \ No newline at end of file diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/AbstractSynchronizingDiffCreator.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/AbstractSynchronizingDiffCreator.java deleted file mode 100644 index 7188a3b3f..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/AbstractSynchronizingDiffCreator.java +++ /dev/null @@ -1,143 +0,0 @@ -package org.irods.jargon.conveyor.synch; - -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.transfer.TransferControlBlock; -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.core.transfer.TransferStatus.TransferState; -import org.irods.jargon.core.transfer.TransferStatus.TransferType; -import org.irods.jargon.core.transfer.TransferStatusCallbackListener; -import org.irods.jargon.datautils.tree.FileTreeModel; -import org.irods.jargon.transfer.dao.domain.Synchronization; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Given a synchronization, this component can create a proper file diff for - * later processing. A subclass of this method will compare the source and - * target directories, and develop a tree model that represents the observed - * differences. This will then be used in a later resolution phase to - * synchronize the directories. - * - * @author Mike Conway - DICE (www.irods.org) see - * https://code.renci.org/gf/project/jargon/ - */ -public abstract class AbstractSynchronizingDiffCreator extends - AbstractSynchronizingComponent { - - private static final char SLASH = '/'; - - private static final Logger log = LoggerFactory - .getLogger(AbstractSynchronizingDiffCreator.class); - - public AbstractSynchronizingDiffCreator( - final ConveyorService conveyorService, - final TransferControlBlock transferControlBlock) { - super(conveyorService, transferControlBlock); - } - - /** - * Process the given synchronization specification, creating a file diff - * model - * - * @param synchronization - * {@link Transfer} that describes the source and target for the - * diff operation - * @return {@link FileTreeModel} that represents the diff - * @throws ConveyorExecutionException - */ - public FileTreeModel createDiff(final Transfer transfer) - throws ConveyorExecutionException { - - log.info("createDiff()"); - if (transfer == null) { - throw new IllegalArgumentException("null transfer"); - } - - final Synchronization synchronization = transfer.getSynchronization(); - - if (synchronization == null) { - throw new IllegalArgumentException( - "transfer is not a synchronization"); - } - - // send the initial status callbacks - sendInitStatusMessages(transfer, synchronization); - - FileTreeModel fileTreeDiffModel = generateFileTreeDiffModel( - synchronization, transfer); - - log.info("file tree diff model complete"); - return fileTreeDiffModel; - } - - protected abstract FileTreeModel generateFileTreeDiffModel( - Synchronization synchronization, Transfer transfer) - throws ConveyorExecutionException; - - private void sendInitStatusMessages(final Transfer transfer, - final Synchronization synchronization) - throws ConveyorExecutionException { - // make an overall status callback that a synch is initiated - TransferStatus overallSynchStartStatus; - try { - - // make an overall status callback that a synch is initiated - - overallSynchStartStatus = TransferStatus.instance( - TransferType.SYNCH, synchronization - .getLocalSynchDirectory(), synchronization - .getIrodsSynchDirectory(), synchronization - .getDefaultStorageResource(), 0L, 0L, 0, 0, 0, - TransferState.SYNCH_DIFF_GENERATION, transfer - .getGridAccount().getHost(), transfer - .getGridAccount().getZone()); - getConfiguredCallbackListener().overallStatusCallback( - overallSynchStartStatus); - - } catch (JargonException e) { - log.error("error creating synch", e); - throw new ConveyorExecutionException("error in synch processing", e); - } - } - - /** - * Strip trailing slash and any other manipulations to ensure correct - * processing of paths - * - * @param filePath - * @return - */ - String normalizeFilePath(final String filePath) { - assert filePath != null; - - String calculatedLocalRoot = ""; - if (filePath.length() > 1) { - if (filePath.lastIndexOf(SLASH) == filePath.length() - 1) { - calculatedLocalRoot = filePath.substring(0, - filePath.length() - 1); - } else { - calculatedLocalRoot = filePath; - } - } - - return calculatedLocalRoot; - - } - - /** - * Handy method to get the required callback listener (guaranteed to not be - * null or an error will be thrown) - * - * @return {@link TransferStatusCallbackListener} - */ - protected TransferStatusCallbackListener getConfiguredCallbackListener() { - TransferStatusCallbackListener listener = getConveyorService() - .getConveyorCallbackListener(); - assert listener != null; - return listener; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/AbstractSynchronizingDiffProcessor.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/AbstractSynchronizingDiffProcessor.java deleted file mode 100644 index 8703e9f6e..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/AbstractSynchronizingDiffProcessor.java +++ /dev/null @@ -1,584 +0,0 @@ -package org.irods.jargon.conveyor.synch; - -import java.util.Enumeration; - -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.DataTransferOperations; -import org.irods.jargon.core.pub.IRODSAccessObjectFactory; -import org.irods.jargon.core.pub.io.IRODSFileFactory; -import org.irods.jargon.core.transfer.TransferControlBlock; -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.core.transfer.TransferStatus.TransferState; -import org.irods.jargon.core.transfer.TransferStatus.TransferType; -import org.irods.jargon.core.transfer.TransferStatusCallbackListener; -import org.irods.jargon.datautils.tree.FileTreeDiffEntry; -import org.irods.jargon.datautils.tree.FileTreeDiffEntry.DiffType; -import org.irods.jargon.datautils.tree.FileTreeModel; -import org.irods.jargon.datautils.tree.FileTreeNode; -import org.irods.jargon.transfer.dao.domain.Synchronization; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Abstract superclass for a mechanism to take a difference tree model and - * synchronize between iRODS and the local file system. This can be implemented - * for different synch strategies. - *

- * Note that this class keeps instance variables depending on the actual - * invocation after object creation, and is not meant to be shared or re-used - * for synch operations. A new class should be obtained from the factory for - * each synch operation. The caching is done for performance, as there is a - * minor expense to resolving the iRODS account and obtaining the hooks to do - * actual transfers to iRODS. - * - * - * @author Mike Conway - DICE (www.irods.org) - */ -public abstract class AbstractSynchronizingDiffProcessor implements - TransferStatusCallbackListener { - - private static final Logger log = LoggerFactory - .getLogger(AbstractSynchronizingDiffProcessor.class); - - private final ConveyorService conveyorService; - private final TransferControlBlock transferControlBlock; - private TransferAttempt transferAttempt; - - public static final String BACKUP_PREFIX = "synch-backup"; - - /** - * The fields below are initialized on demand with synchronized access - */ - - private IRODSAccount irodsAccount = null; - private DataTransferOperations dataTransferOperations = null; - private TransferStatusCallbackListener transferStatusCallbackListener = null; - - /** - * Create an instance with an initialized reference to the conveyor service - * - * @param conveyorService - * {@link ConveyorService} reference - * @param transferControlBlock - * {@link TransferControlBlock} instance that allows signalling - * of cancellation and communication with the calling process - */ - public AbstractSynchronizingDiffProcessor( - final ConveyorService conveyorService, - final TransferControlBlock transferControlBlock) { - super(); - - if (conveyorService == null) { - throw new IllegalArgumentException("null conveyorService"); - } - - if (transferControlBlock == null) { - throw new IllegalArgumentException("null transferControlBlock"); - } - - this.conveyorService = conveyorService; - this.transferControlBlock = transferControlBlock; - - } - - /** - * Given a diff embodied in a FileTreeModel, do necessary - * operations to synchronize between local and iRODS. - *

- * Given a properly calculated diff, do the stuff to bring the source and - * target directories in line. The actual way this synch is resolved depends - * on the implementation of the various 'schedule' methods stubbed out in - * this abstract class. A subclass can implement the stub schedule methods - * to respond to the reported 'diff' state. - * - * @param TransferAttempt - * {@link TransferAttempt} of type SYNCH, with a - * parent {@link Synchronization} that describes the synch - * relationship - * @param diffModel - * {@link FileTreeModel} that embodies the diff between local and - * iRODS - * @param transferStatusCallbackListener - * {@link TransferStatusCallbackListener} that will receive - * call-backs on the status of the diff processing - * @throws ConveyorExecutionException - */ - public void execute(final TransferAttempt transferAttempt, - final FileTreeModel diffModel, - final TransferStatusCallbackListener transferStatusCallbackListener) - throws ConveyorExecutionException { - - log.info("processDiff()"); - - assert transferAttempt != null; - assert diffModel != null; - assert transferStatusCallbackListener != null; - - try { - signalStartupCallback(transferAttempt.getTransfer() - .getSynchronization(), transferStatusCallbackListener); - - synchronized (this) { - irodsAccount = getConveyorService().getGridAccountService() - .irodsAccountForGridAccount( - transferAttempt.getTransfer() - .getSynchronization().getGridAccount()); - - dataTransferOperations = getConveyorService() - .getIrodsAccessObjectFactory() - .getDataTransferOperations(irodsAccount); - - this.transferStatusCallbackListener = transferStatusCallbackListener; - this.transferAttempt = transferAttempt; - - } - - processDiff((FileTreeNode) diffModel.getRoot(), transferAttempt - .getTransfer().getSynchronization() - .getLocalSynchDirectory(), transferAttempt.getTransfer() - .getSynchronization().getIrodsSynchDirectory()); - - log.info("diff processed, "); - - } catch (JargonException e) { - throw new ConveyorExecutionException(e); - } - - } - -/** - * Send a message that we are starting the diff resolve step - * - * @param synchronization {@link Synchronization - * @param transferStatusCallbackListener - * @throws JargonException - */ - protected void signalStartupCallback(final Synchronization synchronization, - final TransferStatusCallbackListener transferStatusCallbackListener) - throws JargonException { - // make an overall status callback that a synch is initiated - - TransferStatus overallSynchStartStatus = TransferStatus.instance( - TransferType.SYNCH, synchronization.getLocalSynchDirectory(), - synchronization.getIrodsSynchDirectory(), synchronization - .getDefaultStorageResource(), 0L, 0L, 0, 0, 0, - TransferState.SYNCH_DIFF_RESOLVE_STEP, synchronization - .getGridAccount().getHost(), synchronization - .getGridAccount().getZone()); - transferStatusCallbackListener - .overallStatusCallback(overallSynchStartStatus); - - } - -/** - * Send a message that we failed due to errors - * - * @param synchronization {@link Synchronization - * @param transferStatusCallbackListener - * @throws JargonException - */ - protected void signalFailureCallback(final Synchronization synchronization, - final TransferStatusCallbackListener transferStatusCallbackListener) - throws JargonException { - // make an overall status callback that a synch is initiated - - TransferStatus overallSynchStartStatus = TransferStatus.instance( - TransferType.SYNCH, synchronization.getLocalSynchDirectory(), - synchronization.getIrodsSynchDirectory(), synchronization - .getDefaultStorageResource(), 0L, 0L, 0, 0, 0, - TransferState.FAILURE, synchronization.getGridAccount() - .getHost(), synchronization.getGridAccount().getZone()); - transferStatusCallbackListener - .overallStatusCallback(overallSynchStartStatus); - - } - - /** - * Recursive method to process a difference node and its children. - * - * @param diffNode - * @param localRootAbsolutePath - * @param irodsRootAbsolutePath - * @param timestampforLastSynchLeftHandSide - * @param timestampForLastSynchRightHandSide - * @throws TransferEngineException - */ - private void processDiff(final FileTreeNode diffNode, - final String localRootAbsolutePath, - final String irodsRootAbsolutePath) - throws ConveyorExecutionException { - - if (transferControlBlock.isCancelled() - || transferControlBlock.isPaused()) { - log.info("cancelling..."); - return; - } - - final FileTreeDiffEntry fileTreeDiffEntry = (FileTreeDiffEntry) diffNode - .getUserObject(); - - log.debug("processing diff node:{}", fileTreeDiffEntry); - - processDiffNode(diffNode, localRootAbsolutePath, irodsRootAbsolutePath, - fileTreeDiffEntry); - - } - - /** - * @param diffNode - * @param localRootAbsolutePath - * @param irodsRootAbsolutePath - * @param fileTreeDiffEntry - * @throws TransferEngineException - */ - private void processDiffNode(final FileTreeNode diffNode, - final String localRootAbsolutePath, - final String irodsRootAbsolutePath, - final FileTreeDiffEntry fileTreeDiffEntry) - throws ConveyorExecutionException { - - if (isCancelled()) { - return; - } - - if (fileTreeDiffEntry.getDiffType() == DiffType.DIRECTORY_NO_DIFF) { - evaluateDirectoryNode(diffNode, localRootAbsolutePath, - irodsRootAbsolutePath, fileTreeDiffEntry); - } else if (fileTreeDiffEntry.getDiffType() == DiffType.LEFT_HAND_PLUS) { - log.debug("local file is new directory {}", fileTreeDiffEntry - .getCollectionAndDataObjectListingEntry() - .getFormattedAbsolutePath()); - scheduleLocalToIrods(diffNode, localRootAbsolutePath, - irodsRootAbsolutePath); - } else if (fileTreeDiffEntry.getDiffType() == DiffType.FILE_OUT_OF_SYNCH) { - log.debug("local file out of synch with irods {}", - fileTreeDiffEntry.getCollectionAndDataObjectListingEntry() - .getFormattedAbsolutePath()); - scheduleMatchedFileOutOfSynch(diffNode, localRootAbsolutePath, - irodsRootAbsolutePath); - } else if (fileTreeDiffEntry.getDiffType() == DiffType.RIGHT_HAND_PLUS) { - log.debug("irods file is new directory {}", fileTreeDiffEntry - .getCollectionAndDataObjectListingEntry() - .getFormattedAbsolutePath()); - scheduleIrodsToLocal(diffNode, localRootAbsolutePath, - irodsRootAbsolutePath); - } else if (fileTreeDiffEntry.getDiffType() == DiffType.LEFT_HAND_NEWER) { - log.debug("left hand file is newer than irods{}", fileTreeDiffEntry - .getCollectionAndDataObjectListingEntry() - .getFormattedAbsolutePath()); - scheduleLocalToIrods(diffNode, localRootAbsolutePath, - irodsRootAbsolutePath); - } else if (fileTreeDiffEntry.getDiffType() == DiffType.RIGHT_HAND_NEWER) { - log.debug("irods files is newer than left hand side {}", - fileTreeDiffEntry.getCollectionAndDataObjectListingEntry() - .getFormattedAbsolutePath()); - scheduleIrodsToLocal(diffNode, localRootAbsolutePath, - irodsRootAbsolutePath); - } else { - log.warn("unknown diff type:{}", fileTreeDiffEntry); - } - } - - /** - * Recurse through children if this is a directory - * - * @param diffNode - * @param localRootAbsolutePath - * @param irodsRootAbsolutePath - * @param timestampforLastSynchLeftHandSide - * @param timestampForLastSynchRightHandSide - * @param fileTreeDiffEntry - * @throws TransferEngineException - */ - private void evaluateDirectoryNode(final FileTreeNode diffNode, - final String localRootAbsolutePath, - final String irodsRootAbsolutePath, - final FileTreeDiffEntry fileTreeDiffEntry) - throws ConveyorExecutionException { - log.debug("evaluating directory: {}", fileTreeDiffEntry - .getCollectionAndDataObjectListingEntry() - .getFormattedAbsolutePath()); - FileTreeNode childNode; - @SuppressWarnings("rawtypes") - final Enumeration children = diffNode.children(); - while (children.hasMoreElements()) { - - if (isCancelled()) { - log.info("cancelling..."); - break; - } - - childNode = (FileTreeNode) children.nextElement(); - processDiff(childNode, localRootAbsolutePath, irodsRootAbsolutePath); - } - } - - /** - * Stub method that should be implemented by subclasses that need to move - * iRODS files to the local file system when out of synch. By default this - * method does nothing. - * - * @param diffNode - * {@link FileTreeNode} that represents the diff entry from the - * comparison phase - * @param localRootAbsolutePath - * String with the local root directory for the - * configured synch - * @param irodsRootAbsolutePath - * String with the irods root directory for the - * configured synch - * @throws ConveyorExecutionException - */ - protected void scheduleIrodsToLocal(final FileTreeNode diffNode, - final String localRootAbsolutePath, - final String irodsRootAbsolutePath) - throws ConveyorExecutionException { - - log.info("scheduleIrodsToLocal() not implemented by default"); - - } - - /** - * Stub method that should be implemented by subclasses that need to move - * local files to iRODS when out of synch. By default this method does - * nothing. - * - * @param diffNode - * {@link FileTreeNode} that represents the diff entry from the - * comparison phase - * @param localRootAbsolutePath - * String with the local root directory for the - * configured synch - * @param irodsRootAbsolutePath - * String with the irods root directory for the - * configured synch - * @throws ConveyorExecutionException - */ - protected void scheduleLocalToIrods(final FileTreeNode diffNode, - final String localRootAbsolutePath, - final String irodsRootAbsolutePath) - throws ConveyorExecutionException { - - log.info("scheduleLocalToIrods() not implemented by default"); - - } - - /* - * private void scheduleIrodsToLocal(final FileTreeNode diffNode, final - * String localRootAbsolutePath, final String irodsRootAbsolutePath) throws - * ConveyorExecutionException { - * - * log.info("\n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n"); - * - * log.info("scheduleIrodsToLocal for diffNode:{}", diffNode); - * - * - * FileTreeDiffEntry fileTreeDiffEntry = (FileTreeDiffEntry) diffNode - * .getUserObject(); CollectionAndDataObjectListingEntry entry = - * fileTreeDiffEntry .getCollectionAndDataObjectListingEntry(); - * - * String targetRelativePath; if (entry.getObjectType() == - * ObjectType.COLLECTION) { targetRelativePath = - * entry.getParentPath().substring( irodsRootAbsolutePath.length()); } else - * { targetRelativePath = entry.getFormattedAbsolutePath().substring( - * irodsRootAbsolutePath.length()); } - * - * StringBuilder sb = new StringBuilder(localRootAbsolutePath); - * sb.append(targetRelativePath); - * - * log.info("doing a get from irods under target at:{}", - * targetRelativePath); - * - * log.warn("get operations not yet implemented!"); - * - * } - */ - - /** - * Stub method when a file exists locally and in iRODS, to be processed by - * the subclass in an appropriate manner. By default this method does - * nothing - * - * @param diffNode - * {@link FileTreeNode} that represents the diff entry from the - * comparison phase - * @param localRootAbsolutePath - * String with the local root directory for the - * configured synch - * @param irodsRootAbsolutePath - * String with the irods root directory for the - * configured synch - * @throws ConveyorExecutionException - */ - protected void scheduleMatchedFileOutOfSynch(final FileTreeNode diffNode, - final String localRootAbsolutePath, - final String irodsRootAbsolutePath) - throws ConveyorExecutionException { - log.info("scheduleMatchedFileOutOfSynch() not implemented by default"); - } - - /** - * @return the transferControlBlock - */ - protected TransferControlBlock getTransferControlBlock() { - return transferControlBlock; - } - - /** - * @return the irodsAccount - */ - protected synchronized IRODSAccount getIrodsAccount() { - return irodsAccount; - } - - /** - * @param irodsAccount - * the irodsAccount to set - */ - protected synchronized void setIrodsAccount(final IRODSAccount irodsAccount) { - this.irodsAccount = irodsAccount; - } - - /** - * @return the dataTransferOperations - */ - protected synchronized DataTransferOperations getDataTransferOperations() { - return dataTransferOperations; - } - - /** - * @param dataTransferOperations - * the dataTransferOperations to set - */ - protected synchronized void setDataTransferOperations( - final DataTransferOperations dataTransferOperations) { - this.dataTransferOperations = dataTransferOperations; - } - - /** - * @return the conveyorService - */ - public ConveyorService getConveyorService() { - return conveyorService; - } - - /** - * @return the transferStatusCallbackListener - */ - protected synchronized TransferStatusCallbackListener getTransferStatusCallbackListener() { - return transferStatusCallbackListener; - } - - /** - * @param transferStatusCallbackListener - * the transferStatusCallbackListener to set - */ - protected synchronized void setTransferStatusCallbackListener( - final TransferStatusCallbackListener transferStatusCallbackListener) { - this.transferStatusCallbackListener = transferStatusCallbackListener; - } - - /** - * Convenience method to simplify obtaining a ref to the irods access object - * factory - * - * @return - */ - protected IRODSAccessObjectFactory getIrodsAccessObjectFactory() { - return getConveyorService().getIrodsAccessObjectFactory(); - } - - /** - * Convenience method to simplify obtaining a ref to an irods file factory, - * configured with the IRODSAccount used to initialize this - * synch processor - * - * @return - * @throws ConveyorExecutionException - */ - protected IRODSFileFactory getIrodsFileFactory() - throws ConveyorExecutionException { - try { - return getIrodsAccessObjectFactory().getIRODSFileFactory( - getIrodsAccount()); - } catch (JargonException e) { - log.error("cannot obtain irodsFileFactory", e); - throw new ConveyorExecutionException( - "unable to create an iRODS file factory", e); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.core.transfer.TransferStatusCallbackListener#statusCallback - * (org.irods.jargon.core.transfer.TransferStatus) - */ - @Override - public FileStatusCallbackResponse statusCallback( - final TransferStatus transferStatus) throws JargonException { - - if (transferStatus.isIntraFileStatusReport()) { - // quash - } else { - getTransferStatusCallbackListener().statusCallback(transferStatus); - } - - return FileStatusCallbackResponse.CONTINUE; - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.core.transfer.TransferStatusCallbackListener# - * overallStatusCallback(org.irods.jargon.core.transfer.TransferStatus) - */ - @Override - public void overallStatusCallback(final TransferStatus transferStatus) - throws JargonException { - - log.info( - "overall status callback will be quashed, but failures will be sure to have cancel set...{}", - transferStatus); - - if (transferStatus.getTransferState() == TransferState.FAILURE) { - log.error("failure in underlying transfer:{}", transferStatus); - log.info("set cancel in tcb, let synch process terminate"); - signalFailureCallback(transferAttempt.getTransfer() - .getSynchronization(), transferStatusCallbackListener); - } - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.core.transfer.TransferStatusCallbackListener# - * transferAsksWhetherToForceOperation(java.lang.String, boolean) - */ - @Override - public CallbackResponse transferAsksWhetherToForceOperation( - final String irodsAbsolutePath, final boolean isCollection) { - - log.info("overwrite situation, cancel as this shouldn't happen"); - - return CallbackResponse.CANCEL; - } - - /** - * Checks for a cancellation - * - * @return - */ - protected boolean isCancelled() { - return (transferControlBlock.isCancelled() || transferControlBlock - .isPaused()); - } - -} \ No newline at end of file diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/DefaultDiffCreator.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/DefaultDiffCreator.java deleted file mode 100644 index 430fa953d..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/DefaultDiffCreator.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.synch; - -import java.io.File; - -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.IRODSAccessObjectFactory; -import org.irods.jargon.core.transfer.TransferControlBlock; -import org.irods.jargon.datautils.tree.FileTreeDiffUtility; -import org.irods.jargon.datautils.tree.FileTreeDiffUtilityImpl; -import org.irods.jargon.datautils.tree.FileTreeModel; -import org.irods.jargon.transfer.dao.domain.Synchronization; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Default diff creating component based on comparing two trees, and computing - * file diffs by comparing length and then checksum - *

- * This is the simplest type of diff, and does not attempt to track history of - * local changes - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class DefaultDiffCreator extends AbstractSynchronizingDiffCreator { - - private static final Logger log = LoggerFactory - .getLogger(DefaultDiffCreator.class); - - public DefaultDiffCreator(final ConveyorService conveyorService, - final TransferControlBlock transferControlBlock) { - super(conveyorService, transferControlBlock); - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.conveyor.synch.AbstractSynchronizingDiffCreator# - * generateFileTreeDiffModel - * (org.irods.jargon.transfer.dao.domain.Synchronization, - * org.irods.jargon.transfer.dao.domain.Transfer) - */ - @Override - protected FileTreeModel generateFileTreeDiffModel( - final Synchronization synchronization, final Transfer transfer) - throws ConveyorExecutionException { - - log.info("generateFileTreeDiffModel()"); - - assert synchronization != null; - assert transfer != null; - - log.info("generating diff for: {}", synchronization); - - String localPath = normalizeFilePath(synchronization - .getLocalSynchDirectory()); - String irodsPath = normalizeFilePath(synchronization - .getIrodsSynchDirectory()); - - log.info("resolving account and obtaining access object factory..."); - IRODSAccount synchAccount = null; - synchAccount = getConveyorService().getGridAccountService() - .irodsAccountForGridAccount(synchronization.getGridAccount()); - - IRODSAccessObjectFactory irodsAccessObjectFactory = getConveyorService() - .getIrodsAccessObjectFactory(); - - // FIXME: add tcb and cancel to filetreediffutility - - FileTreeDiffUtility fileTreeDiffUtility = new FileTreeDiffUtilityImpl( - synchAccount, irodsAccessObjectFactory, - getTransferControlBlock()); - - FileTreeModel diffModel; - try { - diffModel = fileTreeDiffUtility.generateDiffLocalToIRODS(new File( - localPath), irodsPath, 0L, 0L); - } catch (JargonException e) { - log.error("unable to generate diff model", e); - throw new ConveyorExecutionException("error generating diff model", - e); - } - - log.info("diff model obtained:{}", diffModel); - return diffModel; - - } -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/DefaultSynchComponentFactory.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/DefaultSynchComponentFactory.java deleted file mode 100644 index 36962f557..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/DefaultSynchComponentFactory.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.synch; - -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.core.transfer.TransferControlBlock; -import org.irods.jargon.transfer.dao.domain.Synchronization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Implementation of a factory to create various components used to process - * synchronizations. This allows pluggable processors to create and resolve the - * diffs that drive synchronization. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class DefaultSynchComponentFactory implements SynchComponentFactory { - - private static final Logger log = LoggerFactory - .getLogger(DefaultSynchComponentFactory.class); - - /** - * Injected dependency - */ - private ConveyorService conveyorService; - - /** - * - */ - public DefaultSynchComponentFactory() { - } - - /** - * @return the conveyorService - */ - public ConveyorService getConveyorService() { - return conveyorService; - } - - /** - * Create an instance with an initialized reference to the conveyor service - * - * @param conveyorService - * {@link ConveyorService} reference - */ - public void setConveyorService(final ConveyorService conveyorService) { - this.conveyorService = conveyorService; - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.synch.SynchComponentFactory#instanceDiffCreator - * (org.irods.jargon.transfer.dao.domain.Synchronization) - */ - @Override - public AbstractSynchronizingDiffCreator instanceDiffCreator( - final Synchronization synchronization, - final TransferControlBlock transferControlBlock) { - - log.info("instanceDiffCreator()"); - - if (synchronization == null) { - throw new IllegalArgumentException("null synchronization"); - } - if (transferControlBlock == null) { - throw new IllegalArgumentException("null transferControlBlock"); - } - - switch (synchronization.getSynchronizationMode()) { - case ONE_WAY_LOCAL_TO_IRODS: - return new DefaultDiffCreator(getConveyorService(), - transferControlBlock); - case ONE_WAY_IRODS_TO_LOCAL: - throw new UnsupportedOperationException("unsupported synch type"); - case BI_DIRECTIONAL: - throw new UnsupportedOperationException("unsupported synch type"); - default: - throw new UnsupportedOperationException("unsupported synch type"); - } - - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.synch.SynchComponentFactory#instanceDiffProcessor - * (org.irods.jargon.transfer.dao.domain.Synchronization) - */ - @Override - public AbstractSynchronizingDiffProcessor instanceDiffProcessor( - final Synchronization synchronization, - final TransferControlBlock transferControlBlock) { - - log.info("instanceDiffProcessor()"); - - if (synchronization == null) { - throw new IllegalArgumentException("null synchronization"); - } - - if (transferControlBlock == null) { - throw new IllegalArgumentException("null transferControlBlock"); - } - - switch (synchronization.getSynchronizationMode()) { - case ONE_WAY_LOCAL_TO_IRODS: - return new LocalToIRODSDiffProcessor(getConveyorService(), - transferControlBlock); - case ONE_WAY_IRODS_TO_LOCAL: - throw new UnsupportedOperationException("unsupported synch type"); - case BI_DIRECTIONAL: - throw new UnsupportedOperationException("unsupported synch type"); - default: - throw new UnsupportedOperationException("unsupported synch type"); - } - - } -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/LocalToIRODSDiffProcessor.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/LocalToIRODSDiffProcessor.java deleted file mode 100644 index 5995eada9..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/LocalToIRODSDiffProcessor.java +++ /dev/null @@ -1,261 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.synch; - -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.exception.JargonRuntimeException; -import org.irods.jargon.core.pub.io.IRODSFile; -import org.irods.jargon.core.query.CollectionAndDataObjectListingEntry; -import org.irods.jargon.core.query.CollectionAndDataObjectListingEntry.ObjectType; -import org.irods.jargon.core.transfer.TransferControlBlock; -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.core.utils.LocalFileUtils; -import org.irods.jargon.datautils.tree.FileTreeDiffEntry; -import org.irods.jargon.datautils.tree.FileTreeNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Process a one-way local to iRODS diff - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class LocalToIRODSDiffProcessor extends - AbstractSynchronizingDiffProcessor { - - private static final Logger log = LoggerFactory - .getLogger(LocalToIRODSDiffProcessor.class); - - public LocalToIRODSDiffProcessor(final ConveyorService conveyorService, - final TransferControlBlock transferControlBlock) { - super(conveyorService, transferControlBlock); - } - - /** - * the node is a local file/collection that needs to be scheduled to move to - * iRODS - * - * @param diffNode - * @param localRootAbsolutePath - * @param irodsRootAbsolutePath - */ - @Override - protected void scheduleLocalToIrods(final FileTreeNode diffNode, - final String localRootAbsolutePath, - final String irodsRootAbsolutePath) - throws ConveyorExecutionException { - /* - * the diff node will have the absolute path of the local file, this is - * the source of the put. the irods path will be the local parent - * collection relative path, appended to the local root. - */ - - if (isCancelled()) { - return; - } - - log.info("\n\n>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n"); - log.info("scheduleLocalToIrods for diffNode:{}", diffNode); - - FileTreeDiffEntry fileTreeDiffEntry = (FileTreeDiffEntry) diffNode - .getUserObject(); - CollectionAndDataObjectListingEntry entry = fileTreeDiffEntry - .getCollectionAndDataObjectListingEntry(); - - String targetRelativePath; - StringBuilder sb = new StringBuilder(irodsRootAbsolutePath); - if (entry.getObjectType() == ObjectType.COLLECTION) { - targetRelativePath = entry.getParentPath().substring( - localRootAbsolutePath.length()); - log.info("entry is a collection, setting targetRelativePath to:{}", - targetRelativePath); - } else { - - if (entry.getPathOrName().charAt(0) == '.') { - log.debug("no backups of hidden files"); - return; - } - - targetRelativePath = entry.getFormattedAbsolutePath().substring( - localRootAbsolutePath.length()); - log.info("entry is a file, setting targetRelativePath to:{}", - targetRelativePath); - } - sb.append("/"); - - sb.append(targetRelativePath); - - String putPath = sb.toString(); - - log.info("processing a put to irods under target at computed path:{}", - putPath); - - try { - getTransferControlBlock().resetTransferData(); - getDataTransferOperations().putOperation( - entry.getFormattedAbsolutePath(), putPath, - getIrodsAccount().getDefaultStorageResource(), this, - getTransferControlBlock()); - } catch (Exception e) { - - log.error("error in put operation as part of synch", e); - getTransferControlBlock().reportErrorInTransfer(); - - if (getTransferStatusCallbackListener() == null) { - throw new ConveyorExecutionException( - "error occurred in synch, no status callback listener was specified", - e); - - } else { - try { - TransferStatus transferStatus = TransferStatus - .instanceForExceptionForSynch( - TransferStatus.TransferType.SYNCH, entry - .getFormattedAbsolutePath(), sb - .toString(), getIrodsAccount() - .getDefaultStorageResource(), 0L, - 0L, 0, 0, 0, e, - getIrodsAccount().getHost(), - getIrodsAccount().getZone()); - getTransferStatusCallbackListener().statusCallback( - transferStatus); - } catch (JargonException e1) { - log.error("error building transfer status", e1); - throw new JargonRuntimeException( - "exception building transfer status", e1); - } - } - - } - - log.info("put done"); - - } - - /** - * Move the local file to iRODS with iRODS backed up - * - * @param diffNode - * @param localRootAbsolutePath - * @param irodsRootAbsolutePath - * @throws TransferEngineException - */ - @Override - protected void scheduleMatchedFileOutOfSynch(final FileTreeNode diffNode, - final String localRootAbsolutePath, - final String irodsRootAbsolutePath) - throws ConveyorExecutionException { - log.info("\n\n>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n"); - log.info("scheduleLocalToIrodsWithIrodsBackup for diffNode:{}", - diffNode); - - FileTreeDiffEntry fileTreeDiffEntry = (FileTreeDiffEntry) diffNode - .getUserObject(); - CollectionAndDataObjectListingEntry entry = fileTreeDiffEntry - .getCollectionAndDataObjectListingEntry(); - - try { - - String targetRelativePath = entry.getFormattedAbsolutePath() - .substring(localRootAbsolutePath.length()); - - // became - // /testFileTreeDiffLocalLocalFileLengthSameLocalChecksumUpdated.txt - - IRODSFile targetFile = getIrodsFileFactory().instanceIRODSFile( - irodsRootAbsolutePath, targetRelativePath); - - if (targetFile.getName().charAt(0) == '.') { - log.debug("no backups of hidden files"); - return; - } - - // became - // irods://test1@localhost:1247/test1/home/test1/jargon-scratch/InPlaceSynchronizingDiffProcessorImplTest/testFileTreeDiffLocalLocalFileLengthSameLocalChecksumUpdated/testFileTreeDiffLocalLocalFileLengthSameLocalChecksumUpdated.txt - - log.debug("target file name in iRODS:{}", - targetFile.getAbsolutePath()); - - IRODSFile userHome = getIrodsFileFactory() - .instanceIRODSFileUserHomeDir( - getIrodsAccount().getUserName()); - - /* - * For backup, take the path under the users home directory, remove - * the zone/home/username part, and stick it under - * zone/home/username/backup dir name/... - */ - - String pathBelowUserHome = targetFile.getParent().substring( - userHome.getAbsolutePath().length()); - - StringBuilder irodsBackupAbsPath = new StringBuilder(); - irodsBackupAbsPath.append(userHome.getAbsolutePath()); - irodsBackupAbsPath.append('/'); - irodsBackupAbsPath.append(BACKUP_PREFIX); - irodsBackupAbsPath.append(pathBelowUserHome); - - // this became - // /test1/home/test1/synch-backup/testFileTreeDiffLocalLocalFileLengthSameLocalChecksumUpdated.txt - - String backupFileName = LocalFileUtils - .getFileNameWithTimeStampInterposed(targetFile.getName()); - IRODSFile backupFile = getConveyorService() - .getIrodsAccessObjectFactory() - .getIRODSFileFactory(getIrodsAccount()) - .instanceIRODSFile(irodsBackupAbsPath.toString(), - backupFileName); - backupFile.getParentFile().mkdirs(); - log.debug("backup file name:{}", backupFile.getAbsolutePath()); - - targetFile.renameTo(backupFile); - log.debug("rename done"); - - getTransferControlBlock().resetTransferData(); - getDataTransferOperations().putOperation( - entry.getFormattedAbsolutePath(), - targetFile.getAbsolutePath(), - getIrodsAccount().getDefaultStorageResource(), this, - getTransferControlBlock()); - - } catch (Exception e) { - - log.error("error in put operation as part of synch", e); - getTransferControlBlock().reportErrorInTransfer(); - - if (getTransferStatusCallbackListener() == null) { - throw new ConveyorExecutionException( - "error occurred in synch, no status callback listener was specified", - e); - - } else { - try { - TransferStatus transferStatus = TransferStatus - .instanceForExceptionForSynch( - TransferStatus.TransferType.SYNCH, entry - .getFormattedAbsolutePath(), - irodsRootAbsolutePath, getIrodsAccount() - .getDefaultStorageResource(), 0L, - 0L, 0, 0, 0, e, - getIrodsAccount().getHost(), - getIrodsAccount().getZone()); - getTransferStatusCallbackListener().statusCallback( - transferStatus); - } catch (JargonException e1) { - log.error("error building transfer status", e1); - throw new JargonRuntimeException( - "exception building transfer status", e1); - } - } - - } - - log.info("put done"); - - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/SynchComponentFactory.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/SynchComponentFactory.java deleted file mode 100644 index 95eae08ce..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/SynchComponentFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.irods.jargon.conveyor.synch; - -import org.irods.jargon.core.transfer.TransferControlBlock; -import org.irods.jargon.transfer.dao.domain.Synchronization; - -public interface SynchComponentFactory { - - /** - * Get an instance of the component that can create an appropriate diff - * model - * - * @param synchronization - * {@link Synchronization} that describes the type of diff - * @param transferControlBlock - * {@link TransferControlBlock} that can signal cancels, among - * other things - * @return - */ - public abstract AbstractSynchronizingDiffCreator instanceDiffCreator( - Synchronization synchronization, - final TransferControlBlock transferControlBlock); - - /** - * Get an instance of the component that can create an appropriate diff - * model - * - * @param synchronization - * {@link Synchronization} that describes the type of diff - * @param transferControlBlock - * {@link TransferControlBlock} that can signal cancels, among - * other things - * @return - */ - public abstract AbstractSynchronizingDiffProcessor instanceDiffProcessor( - Synchronization synchronization, - final TransferControlBlock transferControlBlock); - -} \ No newline at end of file diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/SynchPeriodicScheduler.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/SynchPeriodicScheduler.java deleted file mode 100644 index 9212e22f4..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/synch/SynchPeriodicScheduler.java +++ /dev/null @@ -1,181 +0,0 @@ -package org.irods.jargon.conveyor.synch; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.List; -import java.util.Set; -import java.util.TimerTask; - -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.conveyor.core.RejectedTransferException; -import org.irods.jargon.core.exception.JargonRuntimeException; -import org.irods.jargon.transfer.dao.domain.Synchronization; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferStateEnum; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Timer task that can periodically schedule synchronization tasks. This is - * meant to run periodically, and check the synchronizations in the transfer - * database to schedule appropriate synchronization jobs - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class SynchPeriodicScheduler extends TimerTask { - - private final ConveyorService conveyorService; - - public static final Logger log = LoggerFactory - .getLogger(SynchPeriodicScheduler.class); - - /** - * Default constructor with necessary dependencies. - * - * @param conveyorService - */ - public SynchPeriodicScheduler(final ConveyorService conveyorService) { - - if (conveyorService == null) { - throw new IllegalArgumentException("Null conveyorService"); - } - - this.conveyorService = conveyorService; - } - - @Override - public void run() { - log.info("running synch periodic scheduler, listing existing synchs..."); - - List synchronizations; - - try { - synchronizations = conveyorService - .getSynchronizationManagerService() - .listAllSynchronizations(); - } catch (ConveyorExecutionException e) { - log.error("synch exception listing synch data", e); - throw new JargonRuntimeException( - "synch exception listing synch data", e); - } - - log.info("synchs listed, inspecting for pending jobs..."); - Calendar nowDate = Calendar.getInstance(); - - for (Synchronization synchronization : synchronizations) { - log.info("evaluating synch:{}", synchronization); - if (computeShouldSynchBasedOnCurrentDateAndSynchProperties( - synchronization, nowDate)) { - scheduleASynchronization(synchronization); - } - } - - log.info("schedule process completed"); - - } - - /** - * Schedule a synchronization, after checking if a synch is already in the - * queue for this specification. - * - * @param synchronization - */ - private void scheduleASynchronization(final Synchronization synchronization) { - log.info("scheduling a synchronizaton:{}", synchronization); - boolean alreadyInQueue = false; - Set transfers = synchronization.getTransfers(); - for (Transfer transfer : transfers) { - if (transfer.getTransferState() == TransferStateEnum.ENQUEUED - || transfer.getTransferState() == TransferStateEnum.PROCESSING - || transfer.getTransferState() == TransferStateEnum.PAUSED) { - log.info( - "will not schedule this synch, as this synch transfer is already in the queue:{}", - transfer); - alreadyInQueue = true; - break; - } - } - - if (alreadyInQueue) { - return; - } - - log.info("no conflicting synch in queue, go ahead and schedule"); - try { - conveyorService.getSynchronizationManagerService() - .triggerSynchronizationNow(synchronization); - } catch (RejectedTransferException e) { - log.error("error enqueuing a synch process for synch:{}", - synchronization, e); - throw new JargonRuntimeException("synch enqueue error", e); - } catch (ConveyorExecutionException e) { - log.error("error enqueuing a synch process for synch:{}", - synchronization, e); - throw new JargonRuntimeException("synch enqueue error", e); - } - - log.info("synchronization enqueued"); - - } - - /** - * Given the specification in the Synchronization, - * - * @param synchronization - * @param nowDate - * @return - */ - protected boolean computeShouldSynchBasedOnCurrentDateAndSynchProperties( - final Synchronization synchronization, final Calendar nowDate) { - - Calendar targetDate = nowDate; - final DateFormat dateFormat = SimpleDateFormat.getDateTimeInstance(); - - if (synchronization.getLastSynchronized() == null) { - log.info("this is the first synchronization, go ahead and schedule"); - return true; - } - - // there has been a previous synch, so evaluate the date - boolean shouldSchedule = false; - log.info("last synch date was:{}", - dateFormat.format(synchronization.getLastSynchronized())); - - switch (synchronization.getFrequencyType()) { - case EVERY_HOUR: - targetDate.add(Calendar.HOUR, -1); - log.info("target date for hourly:{}", - dateFormat.format(targetDate.getTime())); - break; - case EVERY_DAY: - targetDate.add(Calendar.DAY_OF_WEEK, -1); - log.info("target date for daily:{}", - dateFormat.format(targetDate.getTime())); - break; - case EVERY_WEEK: - targetDate.add(Calendar.DAY_OF_WEEK, -7); - log.info("target date for weekly:{}", - dateFormat.format(targetDate.getTime())); - break; - case EVERY_TWO_MINUTES: - targetDate.add(Calendar.MINUTE, -2); - log.info("target date for every two minutes:{}", - dateFormat.format(targetDate.getTime())); - break; - default: - log.error("unknown frequency type:{}", - synchronization.getFrequencyType()); - throw new JargonRuntimeException("unknown frequency type"); - } - - if (synchronization.getLastSynchronized().getTime() < targetDate - .getTime().getTime()) { - shouldSchedule = true; - } - return shouldSchedule; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/utils/ExceptionUtils.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/utils/ExceptionUtils.java deleted file mode 100644 index 029523e02..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/utils/ExceptionUtils.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.utils; - -import java.io.PrintWriter; -import java.io.StringWriter; - -/** - * Utils for managing exceptions that might occur in conveyor processing - * - * @author Mike Conway - DICE (www.irods.org) see - * https://code.renci.org/gf/project/jargon/ - * - */ -public class ExceptionUtils { - - /** - * Given an exception, return the stack trace information in string format. - * If the given exception is null, just return null. Avoids NPEs in code - * when processing exceptions not always available - * - * @return String representation of a stack trace or - * null if there is no exception - */ - public static String stackTraceToString(final Exception e) { - - if (e == null) { - return null; - } - - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - e.printStackTrace(pw); - return sw.toString(); - } - - /** - * If an exception is present, return the message, otherwise, return null. - * Avoids NPEs in code when processing exceptions not always available - * - * @param e - * @return String with the exception message, or - * null if no exception is provided - */ - public static String messageOrNullFromException(final Exception e) { - if (e == null) { - return null; - } - - return e.getMessage(); - - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/utils/package-info.java b/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/utils/package-info.java deleted file mode 100644 index 5362d8ec4..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/conveyor/utils/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Basic utilities for conveyor service - * @author Mike Conway - DICE (www.irods.org) - * see https://code.renci.org/gf/project/jargon/ - * - */ -package org.irods.jargon.conveyor.utils; \ No newline at end of file diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/ConfigurationPropertyDAO.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/ConfigurationPropertyDAO.java deleted file mode 100644 index 774c1870c..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/ConfigurationPropertyDAO.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.irods.jargon.transfer.dao; - -import java.util.List; - -import org.irods.jargon.transfer.dao.domain.ConfigurationProperty; - -/** - * DAO-style interface for managing KVP configuration properties for the - * transfer engine. This is a generic property store that can also be used on - * apps built on top of transfer engine. Care should be taken to namespace - * define key names in case multiple apps desire to share this property store. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public interface ConfigurationPropertyDAO { - - /** - * Save the property to the store. Note that the key of the key/value pair - * is a unique database value, so that duplicate properties cannot be added - * - * @param configurationProperty - * {@link ConfigurationProperty} that represents an entry of a - * configuration value in the database. - * @throws TransferDAOException - */ - void saveOrUpdate(ConfigurationProperty configurationProperty) - throws TransferDAOException; - - /** - * Find a property based on the database id key - * - * @param id - * Long that contains the id of the desired record - * @return {@link ConfigurationProperty} that represents an entry of a - * configuration value in the database. - * @throws TransferDAOException - */ - ConfigurationProperty findById(Long id) throws TransferDAOException; - - /** - * Get all of the configuration properties stored in the database - * - * @return List of {@link ConfigurationProperty} representing - * the configuration properties store as key/value pairs - * @throws TransferDAOException - */ - List findAll() throws TransferDAOException; - - /** - * Delete the given property - * - * @param configurationProperty - * @throws TransferDAOException - */ - void delete(ConfigurationProperty configurationProperty) - throws TransferDAOException; - - /** - * Clear all of the properties in the config database - * - * @throws TransferDAOException - */ - void deleteAllProperties() throws TransferDAOException; - - /** - * Find the configuration information based on the given key - * - * @param propertyKey - * String (required) with the property key - * @return {@link ConfigurationProperty} matching the key, or - * null if no result - * @throws TransferDAOException - */ - ConfigurationProperty findByPropertyKey(String propertyKey) - throws TransferDAOException; - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/GridAccountDAO.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/GridAccountDAO.java deleted file mode 100644 index e61b46b8e..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/GridAccountDAO.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.irods.jargon.transfer.dao; - -import java.util.List; - -import org.irods.jargon.transfer.dao.domain.GridAccount; - -/** - * DAO interface for GridAccount managing a cache of iRODS accounts - * and related configuration. - *

- * The GridAccount preserves account information for transfers and - * synchs, and also allows preserving and automatically logging in to remembered - * grids. Note that this uses a scheme of encrypted passwords based on a global - * 'pass phrase' which must be provided for the various operations. In this way, - * passwords are always encrypted for all operations. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public interface GridAccountDAO { - - /** - * Save the given GridAccount to the database - * - * @param gridAccount - * {@link GridAccount} with login information - * @throws TransferDAOException - */ - void save(GridAccount gridAccount) throws TransferDAOException; - - /** - * List all grid accounts - * - * @return List of {@link GridAccount} in the database - * @throws TransferDAOException - */ - List findAll() throws TransferDAOException; - - /** - * Find a GridAccount based on its primary key (id) - * - * @param id - * Long with the primary key - * @return {@link GridAccount} or null if record not found - * @throws TransferDAOException - */ - GridAccount findById(Long id) throws TransferDAOException; - - /** - * Find the unique GridAccount based on the unique - * host/zone/user - * - * @param host - * String with the host name - * @param zone - * String with the zone name - * @param userName - * String with the user name - * @return {@link GridAccount} or null if not found - * @throws TransferDAOException - */ - GridAccount findByHostZoneAndUserName(String host, String zone, - String userName) throws TransferDAOException; - - /** - * Delete the given grid account - * - * @param gridAccount - * {@link GridAccount} that will be deleted - * @throws TransferDAOException - */ - void delete(GridAccount gridAccount) throws TransferDAOException; - - /** - * Delete all grid accounts in the database - * - * @throws TransferDAOException - */ - void deleteAll() throws TransferDAOException; - - /** - * Delete the given GridAccount and all related information - * from the grid account data. - * - * @param gridAccount - * {@link GridAccount} to be deleted - * @throws TransferDAOException - */ - void deleteGridAccount(GridAccount gridAccount) throws TransferDAOException; - -} \ No newline at end of file diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/KeyStoreDAO.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/KeyStoreDAO.java deleted file mode 100644 index ac00d4f06..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/KeyStoreDAO.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * - */ -package org.irods.jargon.transfer.dao; - -import org.irods.jargon.transfer.dao.domain.KeyStore; - -/** - * DAO for KeyStore managing the stored 'pass phrase' for the - * transfer database. - *

- * The GridAccount preserves account information for transfers and - * synchs, and also allows preserving and automatically logging in to remembered - * grids. Note that this uses a scheme of encrypted passwords based on a global - * 'pass phrase' which must be provided for the various operations. In this way, - * passwords are always encrypted for all operations. - *

- * This KeyStore holds a hash of the pass phrase used by the - * transfer manager user, and can verify the correct pass phrase. Note the - * actual pass phrase, and any unencrypted password information, is not found in - * the transfer database. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public interface KeyStoreDAO { - - /** - * Save the KeyStore entry in the transfer database - * - * @param keyStore - * {@link KeyStore} entry containing the hash of the pass phrase - * @throws TransferDAOException - */ - void save(KeyStore keyStore) throws TransferDAOException; - - /** - * Find the KeyStore associated with the given key. Note that - * null will be returned if it cannot be found. - * - * @param id - * String with the desired key - * @return {@link KeyStore} associated with the key - * @throws TransferDAOException - * if the record cannot be found - */ - KeyStore findById(String id) throws TransferDAOException; - - /** - * Delete the given KeyStore - * - * @param keyStore - * {@link KeyStore} to be deleted - * @throws TransferDAOException - */ - void delete(KeyStore keyStore) throws TransferDAOException; - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/SynchronizationDAO.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/SynchronizationDAO.java deleted file mode 100644 index dcf5a2f28..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/SynchronizationDAO.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.irods.jargon.transfer.dao; - -import java.util.List; - -import org.irods.jargon.transfer.dao.domain.Synchronization; - -/** - * - * @author jdr0887 - * - */ -public interface SynchronizationDAO { - - /** - * - * @param ea - * @return - * @throws DAOException - */ - public void save(Synchronization ea) throws TransferDAOException; - - /** - * - * @param id - * @return - * @throws DAOException - */ - public Synchronization findById(Long id) throws TransferDAOException; - - /** - * - * @param id - * @return - * @throws TransferDAOException - */ - public Synchronization findByName(String name) throws TransferDAOException; - - /** - * - * @return - * @throws TransferDAOException - */ - public List findAll() throws TransferDAOException; - - /** - * - * @param ea - * @throws TransferDAOException - */ - public void delete(Synchronization ea) throws TransferDAOException; - - /** - * Delete all synchronizations and associated transfers from the database - * - * @throws TransferDAOException - */ - public abstract void purgeSynchronizations() throws TransferDAOException; - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/TransferAttemptDAO.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/TransferAttemptDAO.java deleted file mode 100644 index 56c47884c..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/TransferAttemptDAO.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.irods.jargon.transfer.dao; - -import java.util.List; - -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.irods.jargon.transfer.dao.domain.TransferItem; -import org.irods.jargon.transfer.dao.domain.TransferStatusEnum; - -/** - * - * @author lisa - */ -public interface TransferAttemptDAO { - - /** - * - * @param ea - * @throws DAOException - */ - public void save(TransferAttempt ea) throws TransferDAOException; - - /** - * - * @param id - * @return - * @throws DAOException - */ - public TransferAttempt findById(Long id) throws TransferDAOException; - - /** - * - * @param ea - * @throws TransferDAOException - */ - public void delete(TransferAttempt ea) throws TransferDAOException; - - /** - * - * @param maxResults - * @param transferStatus - * @return - * @throws TransferDAOException - */ - public List findByTransferAttemptStatus(int maxResults, - TransferStatusEnum... transferStatus) throws TransferDAOException; - - /** - * Find the last TransferAttempt (most recent) if it exists for - * the given transfer. If the transfer or transfer attempt do not exist - * null will be returned - * - * @param transferId - * long with the id of the Transfer - * that will be looked up - * @return {@link TransferAttempt} that is the last attempt associated with - * the Transfer, or null - * @throws TransferDAOException - */ - public TransferAttempt findLastTransferAttemptForTransferByTransferId( - final long transferId) throws TransferDAOException; - - /** - * Get list of files associated with the TransferAttempt this - * list is paged with start record, and number of records to be retrieved - * - * @param transferAttemptId - * long with the id of the - * TransferAttempt that will be looked up - * @param start - * int with the start index of the list of - * TransferItems to return - * @param length - * int with the max number of - * TransferItems to return - * @return {@link TransferItems} list - * @throws TransferDAOException - */ - public List listTransferItemsInTransferAttempt( - final Long transferAttemptId, final int start, final int length) - throws TransferDAOException; - - /** - * Do a load of the TransferAttempt to ensure that the object - * is associated with a session - * - * @param id - * @return - * @throws TransferDAOException - */ - TransferAttempt load(Long id) throws TransferDAOException; - - /** - * Do a pageable listing of items, allowing selection of the items to show - * by classification.
- * If showSucces is true, then successes AND errors are - * displayed, this is a 'list all' setting. This may be further refined by - * setting showSkipped, which, when true, will show any files - * skipped in the attempt, because of restarting.
- * Note that if showSuccess is false, then skipped files are - * also not shown. This will result in a listing of just error transfer - * items. - * - * @param transferAttemptId - * @param transferAttemptId - * long with the id of the - * TransferAttempt that will be looked up - * @param start - * int with the start index of the list of - * TransferItems to return - * @param length - * int with the max number of - * TransferItems to return - * @param showSuccess - * boolean that, when true, will show all items, - * including errors. When set to false, only error items are - * returned. - * @param showSkipped - * boolean that, when true, will show items skipped - * during a restart. When showSuccess is false, this - * will have no effect - * @return {@link TransferItems} list - * @throws TransferDAOException - */ - List listTransferItemsInTransferAttempt( - Long transferAttemptId, int start, int length, boolean showSuccess, - boolean showSkipped) throws TransferDAOException; - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/TransferDAO.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/TransferDAO.java deleted file mode 100644 index 7e889de1e..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/TransferDAO.java +++ /dev/null @@ -1,145 +0,0 @@ -package org.irods.jargon.transfer.dao; - -import java.util.List; - -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferStateEnum; -import org.irods.jargon.transfer.dao.domain.TransferStatusEnum; - -/** - * - * @author jdr0887 - * - */ -public interface TransferDAO { - - /** - * - * @param ea - * @throws DAOException - */ - public void save(Transfer ea) throws TransferDAOException; - - /** - * - * @param id - * @return - * @throws DAOException - */ - public Transfer findById(Long id) throws TransferDAOException; - - /** - * - * @param id - * @return - * @throws TransferDAOException - */ - public Transfer findInitializedById(Long id) throws TransferDAOException; - - /** - * - * @param transferState - * @return - * @throws TransferDAOException - */ - public List findByTransferState( - TransferStateEnum... transferState) throws TransferDAOException; - - /** - * - * @param maxResults - * @return - * @throws TransferDAOException - */ - public List findAllSortedDesc(int maxResults) - throws TransferDAOException; - - /** - * - * @param maxResults - * @return - * @throws TransferDAOException - */ - public List findAll() throws TransferDAOException; - - /** - * - * @param maxResults - * @param transferState - * @return - * @throws TransferDAOException - */ - public List findByTransferState(int maxResults, - TransferStateEnum... transferState) throws TransferDAOException; - - /** - * - * @param maxResults - * @param transferStatus - * @return - * @throws TransferDAOException - */ - public List findByTransferStatus(int maxResults, - TransferStatusEnum... transferStatus) throws TransferDAOException; - - /** - * - * @param notIn - * @param transferState - * @throws TransferDAOException - */ - public void purgeQueue() throws TransferDAOException; - - /** - * - * @throws TransferDAOException - */ - public void purgeSuccessful() throws TransferDAOException; - - /** - * - * @param ea - * @throws TransferDAOException - */ - public void delete(Transfer ea) throws TransferDAOException; - - /** - * Delete the entire contents of the queue, no matter what the status is - * - * @throws TransferDAOException - */ - void purgeEntireQueue() throws TransferDAOException; - - /** - * Initialize lazy-loaded attempts and attempt items. This is a convenience - * method to initialize lazily-loaded child collections, note that some of - * these collections can be very large! - * - * @param transfer - * {@link Transfer} that will be re-attached to a session via - * merge, and then initialized via Hibernate - * @throws TransferDAOException - */ - Transfer initializeChildrenForTransfer(Transfer transfer) - throws TransferDAOException; - - /** - * Do a merge of the transfer - * - * @param transfer - * {@link Transfer} that will be re-attached to a session via - * merge, and then initialized via Hibernate - * @throws TransferDAOException - */ - void merge(Transfer transfer) throws TransferDAOException; - - /** - * Load the transfer to ensure it is attached - * - * @param id - * @return - * @throws TransferDAOException - */ - Transfer load(Long id) throws TransferDAOException; - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/TransferDAOException.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/TransferDAOException.java deleted file mode 100644 index 837be19ce..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/TransferDAOException.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.irods.jargon.transfer.dao; - -import org.irods.jargon.core.exception.JargonException; - -/** - * Denotes an exception occurring in the DAO layer of TransferEngine - * - * @author jdr0887 - * - */ -public class TransferDAOException extends JargonException { - - private static final long serialVersionUID = 2387712942850423010L; - - public TransferDAOException(final String message, - final int underlyingIRODSExceptionCode) { - super(message, underlyingIRODSExceptionCode); - } - - public TransferDAOException(final String message, final Throwable cause, - final int underlyingIRODSExceptionCode) { - super(message, cause, underlyingIRODSExceptionCode); - } - - public TransferDAOException(final String message, final Throwable cause) { - super(message, cause); - } - - public TransferDAOException(final String message) { - super(message); - } - - public TransferDAOException(final Throwable cause, - final int underlyingIRODSExceptionCode) { - super(cause, underlyingIRODSExceptionCode); - } - - public TransferDAOException(final Throwable cause) { - super(cause); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/TransferItemDAO.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/TransferItemDAO.java deleted file mode 100644 index 513305b2f..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/TransferItemDAO.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.irods.jargon.transfer.dao; - -import java.util.List; - -import org.irods.jargon.transfer.dao.domain.TransferItem; - -/** - * - * @author jdr0887 - * - */ -public interface TransferItemDAO { - - /** - * - * @param ea - * @throws DAOException - */ - public void save(TransferItem ea) throws TransferDAOException; - - /** - * - * @param id - * @return - * @throws DAOException - */ - public TransferItem findById(Long id) throws TransferDAOException; - - /** - * - * @param id - * @return - * @throws TransferDAOException - */ - public List findErrorItemsByTransferAttemptId(Long id) - throws TransferDAOException; - - /** - * - * @param ea - * @throws TransferDAOException - */ - public void delete(TransferItem ea) throws TransferDAOException; - - /** - * - * @param transferId - * @return - */ - public List findAllItemsForTransferByTransferAttemptId( - Long transferId) throws TransferDAOException; - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/ConfigurationProperty.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/ConfigurationProperty.java deleted file mode 100644 index 53faffd9e..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/ConfigurationProperty.java +++ /dev/null @@ -1,174 +0,0 @@ -package org.irods.jargon.transfer.dao.domain; - -import java.io.Serializable; -import java.util.Date; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; - -/** - * Represents a store of kvp configuration properties - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -@Entity -@Table(name = "configuration_property") -public class ConfigurationProperty implements Serializable { - - private static final long serialVersionUID = -8108807996395281600L; - - @Id() - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "id") - private Long id = null; - - /** - * iDrop configuration property, stored as a key - */ - @Column(name = "propertyKey", unique = true, nullable = false) - private String propertyKey = ""; - - @Column(name = "propertyValue", nullable = false) - private String propertyValue = ""; - - @Column(name = "created_at", nullable = false) - private Date createdAt; - - @Column(name = "updated_at") - private Date updatedAt; - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("ConfigurationProperty:"); - sb.append("\n id:"); - sb.append(id); - sb.append("\n propertyKey:"); - sb.append(propertyKey); - sb.append("\n propertyValue:"); - sb.append(propertyValue); - sb.append("\n createdAt:"); - sb.append(createdAt); - sb.append("\n updatedAt:"); - sb.append(updatedAt); - return sb.toString(); - } - - /** - * @return the id - */ - public Long getId() { - return id; - } - - /** - * @param id - * the id to set - */ - public void setId(final Long id) { - this.id = id; - } - - /** - * @return the propertyKey - */ - public String getPropertyKey() { - return propertyKey; - } - - /** - * @param propertyKey - * the propertyKey to set - */ - public void setPropertyKey(final String propertyKey) { - this.propertyKey = propertyKey; - } - - /** - * @return the propertyValue - */ - public String getPropertyValue() { - return propertyValue; - } - - /** - * access the property value as a boolean - * - * @return boolean that represents the cached property - */ - public boolean propertyValueAsBoolean() { - if (propertyValue == null) { - return false; - } - - return Boolean.parseBoolean(propertyValue); - } - - /** - * access the property value as an int - * - * @return int that represents the cached property. No property - * resolves to a zero - */ - public int propertyValueAsInt() { - if (propertyValue == null) { - return 0; - } - - return Integer.parseInt(propertyValue); - } - - /** - * @param propertyValue - * the propertyValue to set - */ - public void setPropertyValue(final String propertyValue) { - this.propertyValue = propertyValue; - } - - /** - * @return the createdAt - */ - public Date getCreatedAt() { - return createdAt; - } - - /** - * @param createdAt - * the createdAt to set - */ - public void setCreatedAt(final Date createdAt) { - this.createdAt = createdAt; - } - - /** - * @return the updatedAt - */ - public Date getUpdatedAt() { - return updatedAt; - } - - /** - * @param updatedAt - * the updatedAt to set - */ - public void setUpdatedAt(final Date updatedAt) { - this.updatedAt = updatedAt; - } - - /** - * Set the property value to an int - * - * @param i - */ - public void setPropertyValue(final int i) { - propertyValue = String.valueOf(i); - - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/FrequencyType.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/FrequencyType.java deleted file mode 100644 index d84c4b031..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/FrequencyType.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.irods.jargon.transfer.dao.domain; - -public enum FrequencyType { - - EVERY_TWO_MINUTES("Every 2 minutes"), - - EVERY_FIFTEEN_MINUTES("Every 15 minutes"), - - EVERY_HOUR("Every hour"), - - EVERY_DAY("Every day"), - - EVERY_WEEK("Every week"); - - private String readableName; - - private FrequencyType(final String readableName) { - this.readableName = readableName; - } - - /** - * @return the readableName - */ - public String getReadableName() { - return readableName; - } - - /** - * @param readableName - * the readableName to set - */ - public void setReadableName(final String readableName) { - this.readableName = readableName; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/GridAccount.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/GridAccount.java deleted file mode 100644 index 93c5d3cdf..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/GridAccount.java +++ /dev/null @@ -1,437 +0,0 @@ -package org.irods.jargon.transfer.dao.domain; - -import java.io.Serializable; -import java.util.Date; -import java.util.HashSet; -import java.util.Set; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.OneToMany; -import javax.persistence.OrderBy; -import javax.persistence.Table; - -import org.hibernate.annotations.Cascade; -import org.hibernate.annotations.CascadeType; -import org.hibernate.annotations.LazyCollection; -import org.hibernate.annotations.LazyCollectionOption; -import org.irods.jargon.core.connection.AuthScheme; -import org.irods.jargon.core.connection.IRODSAccount; - -/** - * Entity implementation class for Entity: GridAccount - *

- * This represents a stored grid account, which can be used for login processing - * (allowing saving of grid accounts for automatic re-authentication). This is - * also used to store account information for transfers that are in the transfer - * queue. - *

- * Note that the transfer engine encrypts grid account passwords using a general - * pass-phrase that must be supplied by the user. Clients of the transfer engine - * must obtain and verify the pass phrase and use it to derive the account - * passwords. - *

- * When dealing with GridAccount, the transfer manager will always - * expect grid accounts presented for storage or update to have clear text - * passwords, and the manager will encrypt the password on storage by the pass - * phrase. By the same token, any GridAccount returned by the - * transfer manager will have the password encoded. Internally, the transfer - * manager code will properly decypt the account information as needed. - * - */ -@Entity -@Table(name = "grid_account") -public class GridAccount implements Serializable { - - private static final long serialVersionUID = 589659419129682571L; - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "id") - private Long id; - - /** - * iRODS host name - */ - @Column(name = "host", nullable = false) - private String host = ""; - - /** - * iRODS port number - */ - @Column(name = "port", nullable = false) - private int port = 0; - - /** - * iRODS zone name - */ - @Column(name = "zone", nullable = false) - private String zone = ""; - - /** - * iRODS user name - */ - @Column(name = "user_name", nullable = false) - private String userName = ""; - - /** - * iRODS password (note that this is encrypted in the database by a - * user-provided pass-phrase - */ - @Column(name = "password", nullable = false) - private String password = ""; - - /** - * optional default storage resource - */ - @Column(name = "default_resource") - private String defaultResource = ""; - - /** - * Authentication scheme used for the grid account - */ - @Enumerated(EnumType.STRING) - @Column(name = "auth_scheme", nullable = false) - private AuthScheme authScheme; - - @Column(name = "preset") - private boolean preset; - - /** - * Optional default path on the iRODS grid to use for things like setting - * the root of a displayed tree - */ - @Column(name = "default_path", length = 32672) - private String defaultPath = ""; - - /** - * Optional free-form comment - */ - @Column(name = "comment") - private String comment = ""; - - @Column(name = "created_at", nullable = false) - private Date createdAt; - - @Column(name = "updated_at", nullable = false) - private Date updatedAt; - - /** - * Run as name - */ - @Column(name = "run_as_user_name", nullable = true) - private String runAsUserName = ""; - - /** - * Run as Authentication scheme used for the grid account - */ - @Enumerated(EnumType.STRING) - @Column(name = "run_as_auth_scheme", nullable = true) - private AuthScheme runAsAuthScheme; - - @Column(name = "auth_date", nullable = true) - private Date authDate; - - /** - * iRODS password (note that this is encrypted in the database by a - * user-provided pass-phrase - */ - @Column(name = "run_as_password", nullable = true) - private String runAsPassword = ""; - - @OneToMany(mappedBy = "gridAccount", targetEntity = Transfer.class, fetch = FetchType.LAZY) - @OrderBy("createdAt DESC") - @LazyCollection(LazyCollectionOption.TRUE) - @Cascade({ CascadeType.ALL }) - private final Set transfer = new HashSet(); - - @OneToMany(mappedBy = "gridAccount", targetEntity = Synchronization.class, fetch = FetchType.LAZY) - @OrderBy("name") - @LazyCollection(LazyCollectionOption.TRUE) - @Cascade({ CascadeType.ALL }) - private final Set synchronization = new HashSet(); - - /** - * @return - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("GridAccount:"); - sb.append("\n\t host:"); - sb.append(host); - sb.append("\n\tport:"); - sb.append(port); - sb.append("\n\tauthScheme:"); - sb.append(authScheme); - sb.append("\n\tpreset:"); - sb.append(preset); - sb.append("\n\tcomment:"); - sb.append(comment); - sb.append("\n\tzone:"); - sb.append(zone); - sb.append("\n\tuserName:"); - sb.append(userName); - sb.append("defaultResource:"); - sb.append(defaultResource); - sb.append("\n\tdefaultPath:"); - sb.append(defaultPath); - sb.append("\n\tcreatedAt:"); - sb.append(createdAt); - sb.append("\n\tupdatedAt:"); - sb.append(updatedAt); - sb.append("\n\tupdatedAt:"); - sb.append(updatedAt); - return sb.toString(); - } - - public GridAccount() { - super(); - } - - /** - * Create a GridAccount based on the values in a given - * IRODSAccount - * - * @param irodsAccount - * {@link IRODSAccount} - */ - public GridAccount(final IRODSAccount irodsAccount) { - - if (irodsAccount == null) { - throw new IllegalArgumentException("null irodsAccount"); - } - - authScheme = irodsAccount.getAuthenticationScheme(); - defaultResource = irodsAccount.getDefaultStorageResource(); - createdAt = new Date(); - host = irodsAccount.getHost(); - password = irodsAccount.getPassword(); - port = irodsAccount.getPort(); - updatedAt = createdAt; - userName = irodsAccount.getUserName(); - zone = irodsAccount.getZone(); - defaultPath = irodsAccount.getHomeDirectory(); - - } - - public Long getId() { - return id; - } - - public void setId(final Long id) { - this.id = id; - } - - public String getHost() { - return host; - } - - public void setHost(final String host) { - this.host = host; - } - - public int getPort() { - return port; - } - - public void setPort(final int port) { - this.port = port; - } - - public String getZone() { - return zone; - } - - public void setZone(final String zone) { - this.zone = zone; - } - - public String getUserName() { - return userName; - } - - public void setUserName(final String userName) { - this.userName = userName; - } - - public String getPassword() { - return password; - } - - public void setPassword(final String password) { - this.password = password; - } - - public String getDefaultResource() { - return defaultResource; - } - - public void setDefaultResource(final String defaultResource) { - this.defaultResource = defaultResource; - } - - public AuthScheme getAuthScheme() { - return authScheme; - } - - public void setAuthScheme(final AuthScheme authScheme) { - this.authScheme = authScheme; - } - - public String getDefaultPath() { - return defaultPath; - } - - public void setDefaultPath(final String defaultPath) { - this.defaultPath = defaultPath; - } - - public String getComment() { - return comment; - } - - public void setComment(final String comment) { - this.comment = comment; - } - - public Date getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(final Date createdAt) { - this.createdAt = createdAt; - } - - public Date getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(final Date updatedAt) { - this.updatedAt = updatedAt; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(final Object obj) { - if (obj == null) { - return false; - } - - if (!(obj instanceof GridAccount)) { - return false; - } - - GridAccount other = (GridAccount) obj; - - /* - * consider equal if same host/port/zone/user/password - */ - return (getHost().equals(other.getHost()) - && getPort() == other.getPort() - && getZone().equals(other.getZone()) - && getUserName().equals(other.getUserName()) - && getPassword().equals(other.getPassword()) && getAuthScheme() == other - .getAuthScheme()); - - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - /* has generated from host/port/zone/user/password/authscheme */ - return getHost().hashCode() + getPort() + getZone().hashCode() - + getUserName().hashCode() + getPassword().hashCode() - + getAuthScheme().hashCode(); - } - - /** - * @return the preset - */ - public boolean isPreset() { - return preset; - } - - /** - * @param preset - * the preset to set - */ - public void setPreset(final boolean preset) { - this.preset = preset; - } - - /** - * @return the runAsUserName - */ - public String getRunAsUserName() { - return runAsUserName; - } - - /** - * @param runAsUserName - * the runAsUserName to set - */ - public void setRunAsUserName(final String runAsUserName) { - this.runAsUserName = runAsUserName; - } - - /** - * @return the runAsAuthScheme - */ - public AuthScheme getRunAsAuthScheme() { - return runAsAuthScheme; - } - - /** - * @param runAsAuthScheme - * the runAsAuthScheme to set - */ - public void setRunAsAuthScheme(final AuthScheme runAsAuthScheme) { - this.runAsAuthScheme = runAsAuthScheme; - } - - /** - * @return the authDate - */ - public Date getAuthDate() { - return authDate; - } - - /** - * @param authDate - * the authDate to set - */ - public void setAuthDate(final Date authDate) { - this.authDate = authDate; - } - - /** - * @return the runAsPassword - */ - public String getRunAsPassword() { - return runAsPassword; - } - - /** - * @param runAsPassword - * the runAsPassword to set - */ - public void setRunAsPassword(final String runAsPassword) { - this.runAsPassword = runAsPassword; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/KeyStore.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/KeyStore.java deleted file mode 100644 index 718f9477d..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/KeyStore.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * - */ -package org.irods.jargon.transfer.dao.domain; - -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -/** - * Represents the stored key in the database. This is the 'pass phrase' by which - * passwords are encrypted. This is stored as a hash of the actual pass phrase, - * and can be used for logging in to iDrop, and for validating the pass phrase - * at login. - * - * @author Mike Conway - DICE (www.irods.org) - */ -@Entity -@Table(name = "key_store") -public class KeyStore implements Serializable { - - private static final long serialVersionUID = -5176136872075721634L; - public static final String KEY_STORE_PASS_PHRASE = "PASS_PHRASE"; - - @Id() - @Column(name = "id") - private String id = ""; - - @Column(name = "value", nullable = false) - private String value = ""; - - public KeyStore() { - } - - /** - * @return the value - */ - public String getValue() { - return value; - } - - /** - * @param value - * the value to set - */ - public void setValue(final String value) { - this.value = value; - } - - /** - * @return the id - */ - public String getId() { - return id; - } - - /** - * @param id - * the id to set - */ - public void setId(final String id) { - this.id = id; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/Synchronization.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/Synchronization.java deleted file mode 100644 index 3a8c16312..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/Synchronization.java +++ /dev/null @@ -1,350 +0,0 @@ -package org.irods.jargon.transfer.dao.domain; - -import java.util.Date; -import java.util.HashSet; -import java.util.Set; - -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.OrderBy; -import javax.persistence.Table; - -/** - * Represents the specification of a synchronization relationship between a - * local file system and an iRODS file system - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -@Entity -@Table(name = "synchronization") -public class Synchronization { - - @Id() - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "id") - private Long id; - - @Column(name = "name", nullable = false, unique = true) - private String name; - - @Column(name = "frequency_type") - @Enumerated(EnumType.STRING) - private FrequencyType frequencyType; - - /** - * Directory on local file system where synchronization will take place - */ - @Column(name = "local_synch_directory", length = 32672, nullable = false) - private String localSynchDirectory; - - /** - * Directory in iRODS where synchronization will take place - */ - @Column(name = "irods_synch_directory", length = 32672, nullable = false) - private String irodsSynchDirectory; - - /** - * Optional (blank if not used) resource that will be used to override the - * resource used for any synch operations - */ - @Column(name = "default_storage_resource", nullable = false) - private String defaultStorageResource = ""; - - /** - * Join to table that contain the grid login information - */ - @ManyToOne(targetEntity = GridAccount.class, fetch = FetchType.LAZY) - @JoinColumn(name = "grid_account_id", nullable = false) - private GridAccount gridAccount; - - @OneToMany(mappedBy = "synchronization", targetEntity = Transfer.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL) - @org.hibernate.annotations.Cascade({ - org.hibernate.annotations.CascadeType.SAVE_UPDATE, - org.hibernate.annotations.CascadeType.DELETE_ORPHAN }) - @org.hibernate.annotations.OnDelete(action = org.hibernate.annotations.OnDeleteAction.CASCADE) - @OrderBy("createdAt") - private Set transfers = new HashSet(); - - /** - * Time stamp of the last synchronization attempt - */ - @Column(name = "last_synchronized") - private Date lastSynchronized; - - /** - * Enumerated status of the last synchronization attempt - */ - @Column(name = "last_synchronization_status") - @Enumerated(EnumType.STRING) - private TransferStatusEnum lastSynchronizationStatus; - - /** - * Message associated with the last synchronization attempt - */ - @Column(name = "last_synchronization_message", length = 32672) - private String lastSynchronizationMessage; - - /** - * Enumerated mode of the synchronization (direction of - * org.irods.jargon.conveyor.synch) - */ - @Column(name = "synchronization_mode", nullable = false) - @Enumerated(EnumType.STRING) - private SynchronizationType synchronizationMode; - - /** - * Creation time - */ - @Column(name = "created_at", nullable = false) - private Date createdAt; - - /** - * Last updated time - */ - @Column(name = "updated_at") - private Date updatedAt; - - /** - * @return the id - */ - public Long getId() { - return id; - } - - /** - * @param id - * the id to set - */ - public void setId(final Long id) { - this.id = id; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name - * the name to set - */ - public void setName(final String name) { - this.name = name; - } - - /** - * @return the localSynchDirectory - */ - public String getLocalSynchDirectory() { - return localSynchDirectory; - } - - /** - * @param localSynchDirectory - * the localSynchDirectory to set - */ - public void setLocalSynchDirectory(final String localSynchDirectory) { - this.localSynchDirectory = localSynchDirectory; - } - - /** - * @return the irodsSynchDirectory - */ - public String getIrodsSynchDirectory() { - return irodsSynchDirectory; - } - - /** - * @param irodsSynchDirectory - * the irodsSynchDirectory to set - */ - public void setIrodsSynchDirectory(final String irodsSynchDirectory) { - this.irodsSynchDirectory = irodsSynchDirectory; - } - - /** - * @return the lastSynchronized - */ - public Date getLastSynchronized() { - return lastSynchronized; - } - - /** - * @param lastSynchronized - * the lastSynchronized to set - */ - public void setLastSynchronized(final Date lastSynchronized) { - this.lastSynchronized = lastSynchronized; - } - - /** - * @return the lastSynchronizationStatus - */ - public TransferStatusEnum getLastSynchronizationStatus() { - return lastSynchronizationStatus; - } - - /** - * @param lastSynchronizationStatus - * the lastSynchronizationStatus to set - */ - public void setLastSynchronizationStatus( - final TransferStatusEnum lastSynchronizationStatus) { - this.lastSynchronizationStatus = lastSynchronizationStatus; - } - - /** - * @return the lastSynchronizationMessage - */ - public String getLastSynchronizationMessage() { - return lastSynchronizationMessage; - } - - /** - * @param lastSynchronizationMessage - * the lastSynchronizationMessage to set - */ - public void setLastSynchronizationMessage( - final String lastSynchronizationMessage) { - this.lastSynchronizationMessage = lastSynchronizationMessage; - } - - /** - * @return the synchronizationMode - */ - public SynchronizationType getSynchronizationMode() { - return synchronizationMode; - } - - /** - * @param synchronizationMode - * the synchronizationMode to set - */ - public void setSynchronizationMode( - final SynchronizationType synchronizationMode) { - this.synchronizationMode = synchronizationMode; - } - - /** - * @return the createdAt - */ - public Date getCreatedAt() { - return createdAt; - } - - /** - * @param createdAt - * the createdAt to set - */ - public void setCreatedAt(final Date createdAt) { - this.createdAt = createdAt; - } - - /** - * @return the updatedAt - */ - public Date getUpdatedAt() { - return updatedAt; - } - - /** - * @param updatedAt - * the updatedAt to set - */ - public void setUpdatedAt(final Date updatedAt) { - this.updatedAt = updatedAt; - } - - /** - * @return the frequencyType - */ - public FrequencyType getFrequencyType() { - return frequencyType; - } - - /** - * @param frequencyType - * the frequencyType to set - */ - public void setFrequencyType(final FrequencyType frequencyType) { - this.frequencyType = frequencyType; - } - - /** - * @param transfers - * the transfers to set - */ - public void setTransfers(final Set transfers) { - this.transfers = transfers; - } - - /** - * @return the transfers - */ - public Set getTransfers() { - return transfers; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("synchronization"); - sb.append("\n id:"); - sb.append(id); - sb.append("\n name:"); - sb.append(name); - sb.append("\n localSynchDirectory:"); - sb.append(localSynchDirectory); - sb.append("\n irodsSynchDirectory:"); - sb.append(irodsSynchDirectory); - sb.append("\n frequencyType:"); - sb.append(frequencyType); - sb.append("\n synchronizationMode:"); - sb.append(synchronizationMode); - return sb.toString(); - } - - /** - * @return the gridAccount - */ - public GridAccount getGridAccount() { - return gridAccount; - } - - /** - * @param gridAccount - * the gridAccount to set - */ - public void setGridAccount(final GridAccount gridAccount) { - this.gridAccount = gridAccount; - } - - /** - * @return the defaultStorageResource - */ - public String getDefaultStorageResource() { - return defaultStorageResource; - } - - /** - * @param defaultStorageResource - * the defaultStorageResource to set - */ - public void setDefaultStorageResource(final String defaultStorageResource) { - this.defaultStorageResource = defaultStorageResource; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/SynchronizationType.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/SynchronizationType.java deleted file mode 100644 index f36bf5952..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/SynchronizationType.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.irods.jargon.transfer.dao.domain; - -/** - * Enumeration of synchronization modes. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public enum SynchronizationType { - - ONE_WAY_LOCAL_TO_IRODS, - - ONE_WAY_IRODS_TO_LOCAL, - - BI_DIRECTIONAL - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/Transfer.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/Transfer.java deleted file mode 100644 index 28dab01db..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/Transfer.java +++ /dev/null @@ -1,278 +0,0 @@ -package org.irods.jargon.transfer.dao.domain; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.OrderBy; -import javax.persistence.Table; -import javax.persistence.Temporal; - -import org.hibernate.annotations.Cascade; -import org.hibernate.annotations.CascadeType; -import org.hibernate.annotations.Fetch; -import org.hibernate.annotations.FetchMode; - -/** - * Domain object that represents a transfer activity between the local host and - * an iRODS server. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -@Entity -@Table(name = "transfer") -public class Transfer implements Serializable { - - private static final long serialVersionUID = -6714116121965036534L; - - @Id() - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "id") - private Long id; - - @Column(name = "sequence_number", nullable = false) - private long sequenceNumber; - - @Column(name = "transfer_state") - @Enumerated(EnumType.STRING) - private TransferStateEnum transferState; - - @Column(name = "last_transfer_status") - @Enumerated(EnumType.STRING) - private TransferStatusEnum lastTransferStatus; - - @Column(name = "transfer_type") - @Enumerated(EnumType.STRING) - private TransferType transferType; - - /** - * This resource is used to hold a specific (not default) resource for some - * operations, such as replication. - */ - @Column(name = "resource_name", nullable = true) - private String resourceName = ""; - - /** - * Overall synchronization configuration that is being processed by this - * transfer - */ - @ManyToOne(targetEntity = Synchronization.class, fetch = FetchType.LAZY) - @JoinColumn(name = "synchronization_id", nullable = true) - private Synchronization synchronization; - - @Column(name = "local_absolute_path", length = 32672) - private String localAbsolutePath = ""; - - @Column(name = "irods_absolute_path", length = 32672) - private String irodsAbsolutePath = ""; - - @OneToMany(mappedBy = "transfer", targetEntity = TransferAttempt.class, fetch = FetchType.EAGER) - @OrderBy("sequenceNumber") - @Cascade({ CascadeType.ALL }) - @Fetch(FetchMode.SELECT) - private List transferAttempts = new ArrayList(); - - @Column(name = "created_at") - @Temporal(javax.persistence.TemporalType.TIMESTAMP) - private Date createdAt; - - @Column(name = "updated_at") - @Temporal(javax.persistence.TemporalType.TIMESTAMP) - private Date updatedAt; - - /** - * Join to table that contain the grid login information - */ - @ManyToOne(targetEntity = GridAccount.class, fetch = FetchType.EAGER) - @JoinColumn(name = "grid_account_id", nullable = false) - private GridAccount gridAccount; - - public Transfer() { - super(); - } - - public TransferStateEnum getTransferState() { - return transferState; - } - - public void setTransferState(final TransferStateEnum transferState) { - this.transferState = transferState; - } - - public TransferType getTransferType() { - return transferType; - } - - public void setTransferType(final TransferType transferType) { - this.transferType = transferType; - } - - public String getLocalAbsolutePath() { - return localAbsolutePath; - } - - public void setLocalAbsolutePath(final String localAbsolutePath) { - this.localAbsolutePath = localAbsolutePath; - } - - public String getIrodsAbsolutePath() { - return irodsAbsolutePath; - } - - public void setIrodsAbsolutePath(final String irodsAbsolutePath) { - this.irodsAbsolutePath = irodsAbsolutePath; - } - - public Long getId() { - return id; - } - - public void setId(final Long id) { - this.id = id; - } - - public Date getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(final Date createdAt) { - this.createdAt = createdAt; - } - - public Date getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(final Date updatedAt) { - this.updatedAt = updatedAt; - } - - public TransferStatusEnum getLastTransferStatus() { - return lastTransferStatus; - } - - public void setLastTransferStatus( - final TransferStatusEnum lastTransferStatus) { - this.lastTransferStatus = lastTransferStatus; - } - - public List getTransferAttempts() { - return transferAttempts; - } - - public void setTransferAttempts(final List transferAttempts) { - this.transferAttempts = transferAttempts; - } - - public Synchronization getSynchronization() { - return synchronization; - } - - public void setSynchronization(final Synchronization synchronization) { - this.synchronization = synchronization; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("Transfer"); - sb.append("\n id:"); - sb.append(id); - sb.append("\n transferState:"); - sb.append(transferState); - if (resourceName != null) { - sb.append("\n\t resorceName:"); - sb.append(resourceName); - } - sb.append("\n transferStatus:"); - sb.append(lastTransferStatus); - sb.append("\n transferType:"); - sb.append(transferType); - sb.append("\n localAbsolutePath:"); - sb.append(localAbsolutePath); - sb.append("\n irodsAbsolutePath:"); - sb.append(irodsAbsolutePath); - sb.append("\n createdAt:"); - sb.append(createdAt); - sb.append("\n updatedAt:"); - sb.append(updatedAt); - return sb.toString(); - } - - /** - * @return the gridAccount - */ - public GridAccount getGridAccount() { - return gridAccount; - } - - /** - * @param gridAccount - * the gridAccount to set - */ - public void setGridAccount(final GridAccount gridAccount) { - this.gridAccount = gridAccount; - } - - /** - * @return the sequenceNumber - */ - public long getSequenceNumber() { - return sequenceNumber; - } - - /** - * @param sequenceNumber - * the sequenceNumber to set - */ - public void setSequenceNumber(final long sequenceNumber) { - this.sequenceNumber = sequenceNumber; - } - - /** - * @return the resourceName - */ - public String getResourceName() { - return resourceName; - } - - /** - * @param resourceName - * the resourceName to set - */ - public void setResourceName(final String resourceName) { - this.resourceName = resourceName; - } - - /** - * Handy method to compute the total time across all transfers. - *

- * Note that it is the responsibility of the caller to ensure that the - * transfer attempts for this transfer have been initialized. - */ - public long computeTotalTransferTime() { - - long totalTime = 0; - - for (TransferAttempt transferAttempt : getTransferAttempts()) { - totalTime += transferAttempt.computeTotalTimeInMillis(); - } - - return totalTime; - - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/TransferAttempt.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/TransferAttempt.java deleted file mode 100644 index 9daa80d21..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/TransferAttempt.java +++ /dev/null @@ -1,343 +0,0 @@ -package org.irods.jargon.transfer.dao.domain; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.OrderBy; -import javax.persistence.Table; -import javax.persistence.Temporal; - -import org.hibernate.annotations.Cascade; -import org.hibernate.annotations.CascadeType; -import org.hibernate.annotations.LazyCollection; -import org.hibernate.annotations.LazyCollectionOption; - -/** - * For a TransferAttempt, this is an individual transfer attempt - * within the transfer - * - * @author lisa - */ -@Entity -@Table(name = "transfer_attempt") -public class TransferAttempt implements Serializable { - - private static final long serialVersionUID = 1L; - - @Id() - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "id") - private Long id; - - @Column(name = "sequence_number", nullable = false) - private long sequenceNumber; - - @ManyToOne(targetEntity = Transfer.class, fetch = FetchType.LAZY) - @JoinColumn(name = "transfer_id", nullable = false) - private Transfer transfer; - - @Column(name = "transfer_attempt_start") - @Temporal(javax.persistence.TemporalType.TIMESTAMP) - private Date attemptStart; - - @Column(name = "transfer_attempt_end") - @Temporal(javax.persistence.TemporalType.TIMESTAMP) - private Date attemptEnd; - - @Column(name = "transfer_attempt_status") - @Enumerated(EnumType.STRING) - private TransferStatusEnum attemptStatus; - - @Column(name = "transfer_attempt_type") - private TransferAttemptTypeEnum transferAttemptTypeEnum = TransferAttemptTypeEnum.NORMAL; - - @Column(name = "error_message") - private String errorMessage; - - @Column(name = "global_exception", length = 32672) - private String globalException = ""; - - @Column(name = "global_exception_stack_trace", length = 32672) - private String globalExceptionStackTrace = ""; - - @Column(name = "last_successful_path", length = 32672) - private String lastSuccessfulPath = ""; - - @Column(name = "total_files_count") - private int totalFilesCount = 0; - - @Column(name = "total_files_transferred_so_far") - private int totalFilesTransferredSoFar = 0; - - @Column(name = "total_files_skipped_so_far") - private int totalFilesSkippedSoFar = 0; - - @Column(name = "total_files_error_so_far") - private int totalFilesErrorSoFar = 0; - - @OneToMany(mappedBy = "transferAttempt", targetEntity = TransferItem.class, fetch = FetchType.LAZY) - @OrderBy("sequenceNumber") - @Cascade({ CascadeType.ALL }) - @LazyCollection(LazyCollectionOption.EXTRA) - private List transferItems = new ArrayList(); - - @Column(name = "created_at") - @Temporal(javax.persistence.TemporalType.TIMESTAMP) - private Date createdAt; - - @Column(name = "updated_at") - @Temporal(javax.persistence.TemporalType.TIMESTAMP) - private Date updatedAt; - - public TransferAttempt() { - super(); - } - - public Long getId() { - return id; - } - - public void setId(final Long id) { - this.id = id; - } - - public Transfer getTransfer() { - return transfer; - } - - public void setTransfer(final Transfer transfer) { - this.transfer = transfer; - } - - public Date getAttemptStart() { - return attemptStart; - } - - public void setAttemptStart(final Date attemptStart) { - this.attemptStart = attemptStart; - } - - public Date getAttemptEnd() { - return attemptEnd; - } - - public void setAttemptEnd(final Date attemptEnd) { - this.attemptEnd = attemptEnd; - } - - public TransferStatusEnum getAttemptStatus() { - return attemptStatus; - } - - public void setAttemptStatus(final TransferStatusEnum attemptStatus) { - this.attemptStatus = attemptStatus; - } - - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(final String errorMessage) { - this.errorMessage = errorMessage; - } - - public List getTransferItems() { - return transferItems; - } - - public void setTransferItems(final List transferItems) { - this.transferItems = transferItems; - } - - public String getGlobalException() { - return globalException; - } - - public void setGlobalException(final String globalException) { - this.globalException = globalException; - } - - public String getLastSuccessfulPath() { - return lastSuccessfulPath; - } - - public void setLastSuccessfulPath(final String lastSuccessfulPath) { - this.lastSuccessfulPath = lastSuccessfulPath; - } - - public int getTotalFilesCount() { - return totalFilesCount; - } - - public void setTotalFilesCount(final int totalFilesCount) { - this.totalFilesCount = totalFilesCount; - } - - public int getTotalFilesTransferredSoFar() { - return totalFilesTransferredSoFar; - } - - public void setTotalFilesTransferredSoFar( - final int totalFilesTransferredSoFar) { - this.totalFilesTransferredSoFar = totalFilesTransferredSoFar; - } - - public String getGlobalExceptionStackTrace() { - return globalExceptionStackTrace; - } - - public void setGlobalExceptionStackTrace( - final String globalExceptionStackTrace) { - this.globalExceptionStackTrace = globalExceptionStackTrace; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("TransferAttempt:"); - sb.append("\n id:"); - sb.append(id); - sb.append("\n seq:"); - sb.append(sequenceNumber); - sb.append("\n attemptStart:"); - sb.append(attemptStart); - sb.append("\n attemptEnd:"); - sb.append(attemptEnd); - sb.append("\n attemptStatus:"); - sb.append(attemptStatus); - sb.append("\n errorMessage:"); - sb.append(errorMessage); - sb.append("\n globalException:"); - sb.append(globalException); - sb.append("\n lastSuccessfulPath:"); - sb.append(lastSuccessfulPath); - sb.append("\n totalFilesCount:"); - sb.append(totalFilesCount); - sb.append("\n totalFilesTransferredSoFar:"); - sb.append(totalFilesTransferredSoFar); - - return sb.toString(); - } - - /** - * @return the createdAt - */ - public Date getCreatedAt() { - return createdAt; - } - - /** - * @param createdAt - * the createdAt to set - */ - public void setCreatedAt(final Date createdAt) { - this.createdAt = createdAt; - } - - /** - * @return the updatedAt - */ - public Date getUpdatedAt() { - return updatedAt; - } - - /** - * @param updatedAt - * the updatedAt to set - */ - public void setUpdatedAt(final Date updatedAt) { - this.updatedAt = updatedAt; - } - - /** - * @return the sequenceNumber - */ - public long getSequenceNumber() { - return sequenceNumber; - } - - /** - * @param sequenceNumber - * the sequenceNumber to set - */ - public void setSequenceNumber(final long attemptSequenceNumber) { - sequenceNumber = attemptSequenceNumber; - } - - /** - * Handy method to compute the time of the transfer. This will return 0 if - * the transfer has not started, or is yet to complete. - * - * @return - */ - public long computeTotalTimeInMillis() { - - // if still running or not run, just return zero - if (getAttemptStart() == null || getAttemptEnd() == null) { - return 0; - } - - return getAttemptEnd().getTime() - getAttemptStart().getTime(); - - } - - /** - * @return the totalFilesSkippedSoFar - */ - public int getTotalFilesSkippedSoFar() { - return totalFilesSkippedSoFar; - } - - /** - * @param totalFilesSkippedSoFar - * the totalFilesSkippedSoFar to set - */ - public void setTotalFilesSkippedSoFar(final int totalFilesSkippedSoFar) { - this.totalFilesSkippedSoFar = totalFilesSkippedSoFar; - } - - /** - * @return the totalFilesErrorSoFar - */ - public int getTotalFilesErrorSoFar() { - return totalFilesErrorSoFar; - } - - /** - * @param totalFilesErrorSoFar - * the totalFilesErrorSoFar to set - */ - public void setTotalFilesErrorSoFar(final int totalFilesErrorSoFar) { - this.totalFilesErrorSoFar = totalFilesErrorSoFar; - } - - /** - * @return the transferAttemptTypeEnum - */ - public TransferAttemptTypeEnum getTransferAttemptTypeEnum() { - return transferAttemptTypeEnum; - } - - /** - * @param transferAttemptTypeEnum - * the transferAttemptTypeEnum to set - */ - public void setTransferAttemptTypeEnum( - final TransferAttemptTypeEnum transferAttemptTypeEnum) { - this.transferAttemptTypeEnum = transferAttemptTypeEnum; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/TransferAttemptTypeEnum.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/TransferAttemptTypeEnum.java deleted file mode 100644 index 6bd16688c..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/TransferAttemptTypeEnum.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * - */ -package org.irods.jargon.transfer.dao.domain; - -/** - * Enumeration for the purposes of a given tranfser attempt - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public enum TransferAttemptTypeEnum { - - NORMAL, RESTART, RESUBMIT, RESTARTED_PROCESSING_TRANSFER_AT_STARTUP - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/TransferItem.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/TransferItem.java deleted file mode 100644 index 5c0ed64a9..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/TransferItem.java +++ /dev/null @@ -1,233 +0,0 @@ -package org.irods.jargon.transfer.dao.domain; - -import java.io.Serializable; -import java.util.Date; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; - -/** - * For a Transfer, this is an individual operation within the - * transfer. This item would be a directory or file that was moved during the - * transfer. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -@Entity -@Table(name = "transfer_item") -public class TransferItem implements Serializable { - - private static final long serialVersionUID = 1L; - - @Id() - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "id") - private Long id; - - @Column(name = "sequence_number", nullable = false) - private long sequenceNumber; - - @ManyToOne(targetEntity = TransferAttempt.class, fetch = FetchType.LAZY) - @JoinColumn(name = "transfer_attempt_id", nullable = false) - private TransferAttempt transferAttempt; - - @Column(name = "source_file_absolute_path", length = 32672) - private String sourceFileAbsolutePath; - - @Column(name = "target_file_absolute_path", length = 32672) - private String targetFileAbsolutePath; - - @Column(name = "transfer_type") - @Enumerated(EnumType.STRING) - private TransferType transferType; - - @Column(name = "is_file") - private boolean file; - - @Column(name = "is_skipped") - private boolean skipped = false; - - @Column(name = "is_error") - private boolean error; - - @Column(name = "length_in_bytes") - private long lengthInBytes = 0L; - - @Column(name = "error_message") - private String errorMessage; - - @Column(name = "error_stack_trace", length = 32672) - private String errorStackTrace; - - @Column(name = "transferred_at") - @Temporal(javax.persistence.TemporalType.TIMESTAMP) - private Date transferredAt; - - public TransferItem() { - super(); - } - - public Long getId() { - return id; - } - - public void setId(final Long id) { - this.id = id; - } - - public String getSourceFileAbsolutePath() { - return sourceFileAbsolutePath; - } - - public void setSourceFileAbsolutePath(final String sourceFileAbsolutePath) { - this.sourceFileAbsolutePath = sourceFileAbsolutePath; - } - - public String getTargetFileAbsolutePath() { - return targetFileAbsolutePath; - } - - public void setTargetFileAbsolutePath(final String targetFileAbsolutePath) { - this.targetFileAbsolutePath = targetFileAbsolutePath; - } - - public boolean isFile() { - return file; - } - - public void setFile(final boolean file) { - this.file = file; - } - - public boolean isError() { - return error; - } - - public void setError(final boolean error) { - this.error = error; - } - - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(final String errorMessage) { - this.errorMessage = errorMessage; - } - - public Date getTransferredAt() { - return transferredAt; - } - - public void setTransferredAt(final Date transferredAt) { - this.transferredAt = transferredAt; - } - - public TransferAttempt getTransferAttempt() { - return transferAttempt; - } - - public void setTransferAttempt(final TransferAttempt transferAttempt) { - this.transferAttempt = transferAttempt; - } - - public long getLengthInBytes() { - return lengthInBytes; - } - - public void setLengthInBytes(final long lengthInBytes) { - this.lengthInBytes = lengthInBytes; - } - - public String getErrorStackTrace() { - return errorStackTrace; - } - - public void setErrorStackTrace(final String errorStackTrace) { - this.errorStackTrace = errorStackTrace; - } - - /** - * @param transferType - * the transferType to set - */ - public void setTransferType(final TransferType transferType) { - this.transferType = transferType; - } - - /** - * @return the transferType - */ - public TransferType getTransferType() { - return transferType; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("TransferItem:"); - sb.append("\n id:"); - sb.append(id); - sb.append("\n transferType:"); - sb.append(transferType); - sb.append("\n sourceFileAbsolutePath:"); - sb.append(sourceFileAbsolutePath); - sb.append("\n targetFileAbsolutePath:"); - sb.append(targetFileAbsolutePath); - sb.append("\n isFile:"); - sb.append(file); - sb.append("\n isSkippedFile:"); - sb.append(skipped); - sb.append("\n lengthInBytes:"); - sb.append(lengthInBytes); - sb.append("\n isError:"); - sb.append(error); - sb.append("\n errorMessage:"); - sb.append(errorMessage); - sb.append("\n transferredAt:"); - sb.append(transferredAt); - return sb.toString(); - } - - /** - * @return the skipped - */ - public boolean isSkipped() { - return skipped; - } - - /** - * @param skipped - * the skipped to set - */ - public void setSkipped(final boolean skipped) { - this.skipped = skipped; - } - - /** - * @return the sequenceNumber - */ - public long getSequenceNumber() { - return sequenceNumber; - } - - /** - * @param sequenceNumber - * the sequenceNumber to set - */ - public void setSequenceNumber(final long sequenceNumber) { - this.sequenceNumber = sequenceNumber; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/TransferStateEnum.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/TransferStateEnum.java deleted file mode 100644 index 11e77ccfd..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/TransferStateEnum.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.irods.jargon.transfer.dao.domain; - -public enum TransferStateEnum { - - IDLE, - - PROCESSING, - - PAUSED, - - CANCELLED, - - COMPLETE, - - ENQUEUED; - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/TransferStatusEnum.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/TransferStatusEnum.java deleted file mode 100644 index 4dc2940b5..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/TransferStatusEnum.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.irods.jargon.transfer.dao.domain; - -public enum TransferStatusEnum { - - ERROR, - - WARNING, - - OK; - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/TransferType.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/TransferType.java deleted file mode 100644 index 77df3f504..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/domain/TransferType.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.irods.jargon.transfer.dao.domain; - -public enum TransferType { - - PUT, - - GET, - - REPLICATE, - - COPY, - - SYNCH, - - UNKNOWN; - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/ConfigurationPropertyDAOImpl.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/ConfigurationPropertyDAOImpl.java deleted file mode 100644 index 4fa9da305..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/ConfigurationPropertyDAOImpl.java +++ /dev/null @@ -1,177 +0,0 @@ -package org.irods.jargon.transfer.dao.impl; - -import java.util.Date; -import java.util.List; - -import org.hibernate.Criteria; -import org.hibernate.HibernateException; -import org.hibernate.criterion.Restrictions; -import org.irods.jargon.transfer.dao.ConfigurationPropertyDAO; -import org.irods.jargon.transfer.dao.TransferDAOException; -import org.irods.jargon.transfer.dao.domain.ConfigurationProperty; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.orm.hibernate3.HibernateTemplate; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - -/** - * DAO for persistence of configuration properties. This is where preferences - * and other data are stored. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class ConfigurationPropertyDAOImpl extends HibernateDaoSupport implements - ConfigurationPropertyDAO { - - private static final Logger log = LoggerFactory - .getLogger(ConfigurationPropertyDAOImpl.class); - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.ConfigurationPropertyDAO#saveOrUpdate(org - * .irods.jargon.transfer.dao.domain.ConfigurationProperty) - */ - @Override - public void saveOrUpdate(final ConfigurationProperty configurationProperty) - throws TransferDAOException { - log.info("entering save(ConfigurationProperty)"); - if (configurationProperty == null) { - throw new IllegalArgumentException("null configurationProperty"); - } - - log.info("configurationProperty:{}", configurationProperty); - - if (configurationProperty.getPropertyKey() == null - || configurationProperty.getPropertyKey().isEmpty()) { - throw new IllegalArgumentException( - "null or empty configuration property key"); - } - - log.info("see if prop already exists..."); - // see if prop already exists - ConfigurationProperty prop = findByPropertyKey(configurationProperty - .getPropertyKey()); - - if (prop == null) { - log.info("prop is new, go ahead and save"); - prop = configurationProperty; - prop.setCreatedAt(new Date()); - } else { - log.info("prop already found, update the value"); - prop.setPropertyValue(configurationProperty.getPropertyValue()); - prop.setUpdatedAt(new Date()); - } - - getSessionFactory().getCurrentSession().saveOrUpdate(prop); - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.ConfigurationPropertyDAO#findById(java. - * lang.Long) - */ - @Override - public ConfigurationProperty findById(final Long id) - throws TransferDAOException { - log.info("entering findById with id:{}", id); - return (ConfigurationProperty) getSessionFactory().getCurrentSession() - .get(ConfigurationProperty.class, id); - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.ConfigurationPropertyDAO#findByPropertyKey - * (java.lang.String) - */ - @Override - public ConfigurationProperty findByPropertyKey(final String propertyKey) - throws TransferDAOException { - if (propertyKey == null || propertyKey.isEmpty()) { - throw new IllegalArgumentException("null or empty property key"); - } - log.info("findByPropertyKey key=", propertyKey); - try { - Criteria criteria = getSessionFactory().getCurrentSession() - .createCriteria(ConfigurationProperty.class); - criteria.add(Restrictions.eq("propertyKey", propertyKey)); - return (ConfigurationProperty) criteria.uniqueResult(); - - } catch (HibernateException e) { - log.error("HibernateException", e); - throw new TransferDAOException(e); - } catch (Exception e) { - log.error("error", e); - throw new TransferDAOException("exception in findById", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.transfer.dao.ConfigurationPropertyDAO#findAll() - */ - @SuppressWarnings("unchecked") - @Override - public List findAll() throws TransferDAOException { - Criteria criteria = getSessionFactory().getCurrentSession() - .createCriteria(ConfigurationProperty.class); - - return criteria.list(); - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.ConfigurationPropertyDAO#delete(org.irods - * .jargon.transfer.dao.domain.ConfigurationProperty) - */ - @Override - public void delete(final ConfigurationProperty configurationProperty) - throws TransferDAOException { - try { - - getSessionFactory().getCurrentSession().delete( - configurationProperty); - } catch (HibernateException e) { - log.error("HibernateException", e); - throw new TransferDAOException(e); - } catch (Exception e) { - - log.error("error in delete(ConfigurationProperty)", e); - throw new TransferDAOException( - "Failed delete(ConfigurationProperty)", e); - } - - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.ConfigurationPropertyDAO#deleteAllProperties - * () - */ - @Override - public void deleteAllProperties() throws TransferDAOException { - log.info("deleteAllProperties()"); - StringBuilder sb = new StringBuilder(); - sb.append("delete from ConfigurationProperty as prop"); - - log.debug("delete properties sql:{}", sb.toString()); - - HibernateTemplate hibernateTemplate = super.getHibernateTemplate(); - - int rows = hibernateTemplate.bulkUpdate(sb.toString()); - log.debug("deleted properties count of: {}", rows); - - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/GridAccountDAOImpl.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/GridAccountDAOImpl.java deleted file mode 100644 index 18452baad..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/GridAccountDAOImpl.java +++ /dev/null @@ -1,226 +0,0 @@ -package org.irods.jargon.transfer.dao.impl; - -import java.util.List; - -import org.hibernate.Criteria; -import org.hibernate.HibernateException; -import org.hibernate.Session; -import org.hibernate.criterion.CriteriaSpecification; -import org.hibernate.criterion.Restrictions; -import org.irods.jargon.transfer.dao.GridAccountDAO; -import org.irods.jargon.transfer.dao.TransferDAOException; -import org.irods.jargon.transfer.dao.domain.GridAccount; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - -/** - * DAO for GridAccount managing a cache of iRODS accounts and - * related configuration. - *

- * The GridAccount preserves account information for transfers and - * synchs, and also allows preserving and automatically logging in to remembered - * grids. Note that this uses a scheme of encrypted passwords based on a global - * 'pass phrase' which must be provided for the various operations. In this way, - * passwords are always encrypted for all operations. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class GridAccountDAOImpl extends HibernateDaoSupport implements - GridAccountDAO { - - private static final Logger log = LoggerFactory - .getLogger(GridAccountDAOImpl.class); - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.GridAccountDAO#save(org.irods.jargon.transfer - * .dao.domain.GridAccount) - */ - @Override - public void save(final GridAccount gridAccount) throws TransferDAOException { - logger.info("save()"); - - if (gridAccount == null) { - throw new IllegalArgumentException("null gridAccount"); - } - - getSessionFactory().getCurrentSession().saveOrUpdate(gridAccount); - logger.info("update successful"); - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.transfer.dao.GridAccountDAO#findAll() - */ - @SuppressWarnings("unchecked") - @Override - public List findAll() throws TransferDAOException { - logger.debug("entering findAll()"); - List ret = null; - Session session = getSessionFactory().getCurrentSession(); - try { - Criteria criteria = session.createCriteria(GridAccount.class); - criteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY); - ret = criteria.list(); - } catch (Exception e) { - logger.error("error in findAll()", e); - throw new TransferDAOException("Failed findAll()", e); - } - - return ret; - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.GridAccountDAO#findById(java.lang.Long) - */ - @Override - public GridAccount findById(final Long id) throws TransferDAOException { - logger.debug("entering findById(Long)"); - - if (id == null) { - throw new IllegalArgumentException("null id"); - } - - GridAccount ret = null; - Session session = getSessionFactory().getCurrentSession(); - try { - Criteria criteria = session.createCriteria(GridAccount.class); - criteria.add(Restrictions.eq("id", id)); - ret = (GridAccount) criteria.uniqueResult(); - } catch (Exception e) { - logger.error("error in findById(Long)", e); - throw new TransferDAOException("Failed findById(Long)", e); - } - - return ret; - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.GridAccountDAO#findByHostZoneAndUserName - * (java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public GridAccount findByHostZoneAndUserName(final String host, - final String zone, final String userName) - throws TransferDAOException { - logger.info("findByHostZoneAndUserName()"); - - if (host == null || host.isEmpty()) { - throw new IllegalArgumentException("host is null or empty"); - } - - if (zone == null || zone.isEmpty()) { - throw new IllegalArgumentException("zone is null or empty"); - } - - if (userName == null || userName.isEmpty()) { - throw new IllegalArgumentException("userName is null or empty"); - } - - GridAccount ret = null; - Session session = getSessionFactory().getCurrentSession(); - try { - Criteria criteria = session.createCriteria(GridAccount.class); - criteria.add(Restrictions.eq("host", host)) - .add(Restrictions.eq("zone", zone)) - .add(Restrictions.eq("userName", userName)); - ret = (GridAccount) criteria.uniqueResult(); - } catch (Exception e) { - logger.error("error in query", e); - throw new TransferDAOException("error in find query", e); - } - - return ret; - - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.GridAccountDAO#deleteGridAccount(org.irods - * .jargon.transfer.dao.domain.GridAccount) - */ - @Override - public void deleteGridAccount(final GridAccount gridAccount) - throws TransferDAOException { - log.debug("entering deleteGridAccount()"); - - if (gridAccount == null) { - throw new IllegalArgumentException("null gridAccount"); - } - - log.info("gridAccount:{}", gridAccount); - - try { - Session session = getSessionFactory().getCurrentSession(); - GridAccount toDelete = (GridAccount) session.merge(gridAccount); - session.delete(toDelete); - log.info("deleted"); - } catch (HibernateException e) { - log.error("HibernateException", e); - throw new TransferDAOException(e); - } catch (Exception e) { - log.error("error in purgeQueue()", e); - throw new TransferDAOException("Failed purgeQueue()", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.transfer.dao.GridAccountDAO#deleteAll() - */ - @Override - public void deleteAll() throws TransferDAOException { - try { - - List gridAccounts = findAll(); - - for (GridAccount gridAccount : gridAccounts) { - delete(gridAccount); - } - - } catch (HibernateException e) { - log.error("HibernateException", e); - throw new TransferDAOException(e); - } catch (Exception e) { - log.error("error in deleteAll()", e); - throw new TransferDAOException("Failed deleteAll()", e); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.GridAccountDAO#delete(org.irods.jargon. - * transfer.dao.domain.GridAccount) - */ - @Override - public void delete(final GridAccount gridAccount) - throws TransferDAOException { - - logger.debug("delete()"); - - try { - getSessionFactory().getCurrentSession().delete(gridAccount); - } catch (Exception e) { - logger.error("error in delete()", e); - throw new TransferDAOException("Failed delete()", e); - } - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/KeyStoreDAOImpl.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/KeyStoreDAOImpl.java deleted file mode 100644 index 7cbf217cd..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/KeyStoreDAOImpl.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.irods.jargon.transfer.dao.impl; - -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.criterion.Restrictions; -import org.irods.jargon.transfer.dao.KeyStoreDAO; -import org.irods.jargon.transfer.dao.TransferDAOException; -import org.irods.jargon.transfer.dao.domain.KeyStore; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - -/** - * DAO for KeyStore managing the stored 'pass phrase' for the - * transfer database. - *

- * The GridAccount preserves account information for transfers and - * synchs, and also allows preserving and automatically logging in to remembered - * grids. Note that this uses a scheme of encrypted passwords based on a global - * 'pass phrase' which must be provided for the various operations. In this way, - * passwords are always encrypted for all operations. - *

- * This KeyStore holds a hash of the pass phrase used by the - * transfer manager user, and can verify the correct pass phrase. Note the - * actual pass phrase, and any unencrypted password information, is not found in - * the transfer database. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class KeyStoreDAOImpl extends HibernateDaoSupport implements KeyStoreDAO { - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.KeyStoreDAO#save(org.irods.jargon.transfer - * .dao.domain.KeyStore) - */ - @Override - public void save(final KeyStore keyStore) throws TransferDAOException { - logger.info("save()"); - - if (keyStore == null) { - throw new IllegalArgumentException("null keyStore"); - } - - try { - getSessionFactory().getCurrentSession().saveOrUpdate(keyStore); - } catch (Exception e) { - logger.error("error in save()", e); - throw new TransferDAOException("Failed saveOrUpdate()", e); - } - - logger.info("update successful"); - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.transfer.dao.KeyStoreDAO#findById(java.lang.String) - */ - @Override - public KeyStore findById(final String id) throws TransferDAOException { - logger.debug("entering findById()"); - - if (id == null) { - throw new IllegalArgumentException("null id"); - } - - KeyStore ret = null; - Session session = getSessionFactory().getCurrentSession(); - try { - Criteria criteria = session.createCriteria(KeyStore.class); - criteria.add(Restrictions.eq("id", id)); - ret = (KeyStore) criteria.uniqueResult(); - } catch (Exception e) { - logger.error("error in findById()", e); - throw new TransferDAOException("Failed findById()", e); - } - - return ret; - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.KeyStoreDAO#delete(org.irods.jargon.transfer - * .dao.domain.KeyStore) - */ - @Override - public void delete(final KeyStore keyStore) throws TransferDAOException { - - logger.debug("delete()"); - - if (keyStore == null) { - throw new IllegalArgumentException("null keyStore"); - } - - try { - getSessionFactory().getCurrentSession().delete(keyStore); - } catch (Exception e) { - logger.error("error in delete()", e); - throw new TransferDAOException("Failed delete()", e); - } - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/SynchronizationDAOImpl.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/SynchronizationDAOImpl.java deleted file mode 100644 index f1e0b964b..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/SynchronizationDAOImpl.java +++ /dev/null @@ -1,182 +0,0 @@ -package org.irods.jargon.transfer.dao.impl; - -import java.util.List; - -import org.hibernate.Criteria; -import org.hibernate.HibernateException; -import org.hibernate.Session; -import org.hibernate.criterion.CriteriaSpecification; -import org.hibernate.criterion.Restrictions; -import org.irods.jargon.transfer.dao.SynchronizationDAO; -import org.irods.jargon.transfer.dao.TransferDAOException; -import org.irods.jargon.transfer.dao.domain.Synchronization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.orm.hibernate3.HibernateTemplate; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - -/** - * - * @author Mike Conway - * - */ -public class SynchronizationDAOImpl extends HibernateDaoSupport implements - SynchronizationDAO { - - private static final Logger log = LoggerFactory - .getLogger(SynchronizationDAOImpl.class); - - public SynchronizationDAOImpl() { - super(); - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.SynchronizationDAO#purgeSynchronizations() - */ - @Override - public void purgeSynchronizations() throws TransferDAOException { - try { - - StringBuilder sb = new StringBuilder(); - sb.append("delete from Synchronization"); - - log.debug("delete synchronization sql:{}", sb.toString()); - - HibernateTemplate hibernateTemplate = super.getHibernateTemplate(); - - int rows = hibernateTemplate.bulkUpdate(sb.toString()); - log.debug("deleted synchs count of: {}", rows); - - } catch (HibernateException e) { - log.error("HibernateException", e); - throw new TransferDAOException(e); - } catch (Exception e) { - log.error("error in purgeSynchronizations()", e); - throw new TransferDAOException("Failed purgeSynchronizations()", e); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.AccountDAO#save(org.irods.jargon.transfer - * .dao.domain.Account) - */ - @Override - public void save(final Synchronization synchronization) - throws TransferDAOException { - logger.debug("entering save(Synchronization)"); - try { - - getSessionFactory().getCurrentSession().saveOrUpdate( - synchronization); - - } catch (Exception e) { - - log.error("error in save(synchronization)", e); - throw new TransferDAOException("Failed save(synchronization)", e); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.AccountDAO#findByName(java.lang.String) - */ - @Override - public Synchronization findByName(final String name) - throws TransferDAOException { - logger.debug("entering findByName(String)"); - if (name == null || name.isEmpty()) { - throw new IllegalArgumentException("null or empty name"); - } - log.info("findByName name:{}", name); - try { - Criteria criteria = getSessionFactory().getCurrentSession() - .createCriteria(Synchronization.class); - criteria.add(Restrictions.eq("name", name)); - return (Synchronization) criteria.uniqueResult(); - - } catch (HibernateException e) { - log.error("HibernateException", e); - throw new TransferDAOException(e); - } catch (Exception e) { - log.error("error", e); - throw new TransferDAOException("exception in findByName", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.transfer.dao.AccountDAO#findAll() - */ - @SuppressWarnings("unchecked") - @Override - public List findAll() throws TransferDAOException { - logger.debug("entering findAll()"); - List ret = null; - Session session = getSessionFactory().getCurrentSession(); - try { - Criteria criteria = session.createCriteria(Synchronization.class); - criteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY); - ret = criteria.list(); - } catch (Exception e) { - logger.error("error in findAll()", e); - throw new TransferDAOException("Failed findAll()", e); - } - - return ret; - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.transfer.dao.AccountDAO#findById(java.lang.Long) - */ - @Override - public Synchronization findById(final Long id) throws TransferDAOException { - logger.debug("entering findById(Long)"); - Synchronization ret = null; - Session session = getSessionFactory().getCurrentSession(); - try { - Criteria criteria = session.createCriteria(Synchronization.class); - criteria.add(Restrictions.eq("id", id)); - ret = (Synchronization) criteria.uniqueResult(); - } catch (Exception e) { - logger.error("error in findById(Long)", e); - throw new TransferDAOException("Failed findById(Long)", e); - } - - return ret; - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.AccountDAO#delete(org.irods.jargon.transfer - * .dao.domain.Account) - */ - @Override - public void delete(final Synchronization synchronization) - throws TransferDAOException { - logger.debug("entering delete(Synchronization)"); - - try { - - getSessionFactory().getCurrentSession().delete(synchronization); - - } catch (Exception e) { - - log.error("error in delete(synchronization)", e); - throw new TransferDAOException("Failed delete(synchronization)", e); - } - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/TransferAttemptDAOImpl.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/TransferAttemptDAOImpl.java deleted file mode 100644 index 792779f2f..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/TransferAttemptDAOImpl.java +++ /dev/null @@ -1,207 +0,0 @@ -package org.irods.jargon.transfer.dao.impl; - -import java.util.List; - -import org.hibernate.Criteria; -import org.hibernate.HibernateException; -import org.hibernate.criterion.Restrictions; -import org.irods.jargon.transfer.dao.TransferAttemptDAO; -import org.irods.jargon.transfer.dao.TransferDAOException; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.irods.jargon.transfer.dao.domain.TransferItem; -import org.irods.jargon.transfer.dao.domain.TransferStatusEnum; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - -/** - * Database operations for the TransferAttempt - * - * @author lisa - */ -public class TransferAttemptDAOImpl extends HibernateDaoSupport implements - TransferAttemptDAO { - - private static final Logger log = LoggerFactory - .getLogger(TransferItemDAOImpl.class); - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.TransferAttemptDAO#save(org.irods.jargon - * .transfer.dao.domain.TransferAttempt) - */ - @Override - public void save(final TransferAttempt transferAttempt) - throws TransferDAOException { - logger.info("save()"); - getSessionFactory().getCurrentSession().saveOrUpdate(transferAttempt); - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.TransferAttemptDAO#findById(java.lang.Long) - */ - @Override - public TransferAttempt findById(final Long id) throws TransferDAOException { - logger.debug("entering findById(Long)"); - return (TransferAttempt) getSessionFactory().getCurrentSession().get( - TransferAttempt.class, id); - } - - @Override - public TransferAttempt load(final Long id) throws TransferDAOException { - logger.debug("entering findById(Long)"); - return (TransferAttempt) getSessionFactory().getCurrentSession().load( - TransferAttempt.class, id); - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.TransferAttemptDAO#delete(org.irods.jargon - * .transfer.dao.domain.TransferAttempt) - */ - @Override - public void delete(final TransferAttempt ea) throws TransferDAOException { - throw new UnsupportedOperationException("Not supported yet."); - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.TransferAttemptDAO#findByTransferAttemptStatus - * (int, org.irods.jargon.transfer.dao.domain.TransferStatus[]) - */ - @Override - public List findByTransferAttemptStatus( - final int maxResults, final TransferStatusEnum... transferStatus) - throws TransferDAOException { - throw new UnsupportedOperationException("Not supported yet."); - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.transfer.dao.TransferAttemptDAO# - * findLastTransferAttemptForTransferByTransferId(long) - */ - @Override - public TransferAttempt findLastTransferAttemptForTransferByTransferId( - final long transferId) throws TransferDAOException { - - Transfer transfer = (Transfer) getSessionFactory().getCurrentSession() - .get(Transfer.class, transferId); - - if (transfer == null) { - return null; - } - - TransferAttempt attempts[] = new TransferAttempt[transfer - .getTransferAttempts().size()]; - attempts = transfer.getTransferAttempts().toArray(attempts); - - if (attempts.length == 0) { - return null; - } - - return attempts[attempts.length - 1]; - - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.TransferAttemptDAO#findNextTransferItems - * (java.lang.Long, int, int) - */ - @Override - public List listTransferItemsInTransferAttempt( - final Long transferAttemptId, final int start, final int length) - throws TransferDAOException { - log.debug("entering findNextTransferItems(Long, int, int)"); - - if (transferAttemptId == null) { - throw new IllegalArgumentException( - "null or empty transfer attempt id"); - } - - try { - Criteria criteria = getSessionFactory().getCurrentSession() - .createCriteria(TransferItem.class) - .createCriteria("transferAttempt") - .add(Restrictions.eq("id", transferAttemptId)) - .setFirstResult(start).setMaxResults(length); - - @SuppressWarnings("unchecked") - List ls = criteria.list(); - - return ls; - } catch (HibernateException e) { - log.error("HibernateException", e); - throw new TransferDAOException(e); - } catch (Exception e) { - log.error("error in findNextTransferItems(Long, int, int)", e); - throw new TransferDAOException( - "Failed findNextTransferItems(Long, int, int)", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.transfer.dao.TransferAttemptDAO# - * listTransferItemsInTransferAttempt(java.lang.Long, int, int, boolean, - * boolean) - */ - @Override - public List listTransferItemsInTransferAttempt( - final Long transferAttemptId, final int start, final int length, - final boolean showSuccess, final boolean showSkipped) - throws TransferDAOException { - log.debug("entering findNextTransferItems(Long, int, int, boolean, boolean)"); - - if (transferAttemptId == null) { - throw new IllegalArgumentException( - "null or empty transfer attempt id"); - } - - try { - Criteria criteria = getSessionFactory().getCurrentSession() - .createCriteria(TransferItem.class); - - if (showSuccess) { - if (!showSkipped) { - criteria.add(Restrictions.eq("skipped", false)); - } - } else { - criteria.add(Restrictions.eq("error", true)); - } - - criteria.createCriteria("transferAttempt").add( - Restrictions.eq("id", transferAttemptId)); - - criteria.setFirstResult(start).setMaxResults(length); - - @SuppressWarnings("unchecked") - List ls = criteria.list(); - - return ls; - } catch (HibernateException e) { - log.error("HibernateException", e); - throw new TransferDAOException(e); - } catch (Exception e) { - log.error("error in findNextTransferItems(Long, int, int)", e); - throw new TransferDAOException( - "Failed findNextTransferItems(Long, int, int)", e); - } - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/TransferDAOImpl.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/TransferDAOImpl.java deleted file mode 100644 index 5e247a6e1..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/TransferDAOImpl.java +++ /dev/null @@ -1,392 +0,0 @@ -package org.irods.jargon.transfer.dao.impl; - -import java.util.List; - -import org.hibernate.Criteria; -import org.hibernate.FetchMode; -import org.hibernate.Hibernate; -import org.hibernate.HibernateException; -import org.hibernate.criterion.Order; -import org.hibernate.criterion.Restrictions; -import org.irods.jargon.transfer.dao.TransferDAO; -import org.irods.jargon.transfer.dao.TransferDAOException; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.irods.jargon.transfer.dao.domain.TransferStateEnum; -import org.irods.jargon.transfer.dao.domain.TransferStatusEnum; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.orm.hibernate3.HibernateTemplate; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - -/** - * - * @author jdr0887 - * - */ -public class TransferDAOImpl extends HibernateDaoSupport implements TransferDAO { - - private static final Logger log = LoggerFactory - .getLogger(TransferDAOImpl.class); - - public TransferDAOImpl() { - super(); - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.transfer.dao.TransferDAO#save(org.irods.jargon - * .transfer.dao.domain.Transfer) - */ - @Override - public void save(final Transfer transfer) throws TransferDAOException { - logger.info("entering save(Transfer)"); - getSessionFactory().getCurrentSession().saveOrUpdate(transfer); - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.transfer.dao.TransferDAO#merge(org.irods.jargon.transfer - * .dao.domain.Transfer) - */ - @Override - public void merge(final Transfer transfer) throws TransferDAOException { - logger.info("entering merge(Transfer)"); - getSessionFactory().getCurrentSession().merge(transfer); - } - - @Override - public Transfer initializeChildrenForTransfer(final Transfer transfer) - throws TransferDAOException { - log.info("initializeChildrenForTransfer"); - if (transfer == null) { - throw new IllegalArgumentException("null transfer"); - } - - log.info("merging transfer"); - Transfer merged = (Transfer) getSessionFactory().getCurrentSession() - .merge(transfer); - - for (TransferAttempt attempt : merged.getTransferAttempts()) { - attempt.getAttemptStatus(); - - /* - * for (TransferItem item : attempt.getTransferItems()) { - * item.getSourceFileAbsolutePath(); } - */ - - } - return merged; - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.transfer.dao.TransferDAO#findById(java.lang .Long) - */ - @Override - public Transfer findById(final Long id) throws TransferDAOException { - logger.debug("entering findById(Long)"); - return (Transfer) getSessionFactory().getCurrentSession().get( - Transfer.class, id); - } - - @Override - public Transfer load(final Long id) throws TransferDAOException { - logger.debug("entering load(Long)"); - return (Transfer) getSessionFactory().getCurrentSession().load( - Transfer.class, id); - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.transfer.dao.TransferDAO#findInitializedById - * (java.lang.Long) - */ - @Override - public Transfer findInitializedById(final Long id) - throws TransferDAOException { - logger.debug("entering findInitializedById(Long)"); - Transfer transfer = (Transfer) getSessionFactory().getCurrentSession() - .get(Transfer.class, id); - Hibernate.initialize(transfer); - return transfer; - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.transfer.dao.TransferDAO#findByTransferState - * (org.irods.jargon.transfer.dao.domain.TransferState[]) - */ - @SuppressWarnings("unchecked") - @Override - public List findByTransferState( - final TransferStateEnum... transferState) - throws TransferDAOException { - log.debug("entering findByTransferState(TransferState...)"); - - try { - Criteria criteria = getSessionFactory().getCurrentSession() - .createCriteria(Transfer.class); - criteria.add(Restrictions.in("transferState", transferState)); - criteria.addOrder(Order.desc("createdAt")); - // date instead? - criteria.setFetchMode("synchronization", FetchMode.JOIN); - return criteria.list(); - } catch (HibernateException e) { - log.error("HibernateException", e); - throw new TransferDAOException(e); - } catch (Exception e) { - log.error("error in findByTransferState(TransferState...)", e); - throw new TransferDAOException( - "Failed findByTransferState(TransferState...)", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.transfer.dao.TransferDAO#findByTransferState (int, - * org.irods.jargon.transfer.dao.domain.TransferState[]) - */ - @SuppressWarnings("unchecked") - @Override - public List findByTransferState(final int maxResults, - final TransferStateEnum... transferState) - throws TransferDAOException { - log.debug("entering findByTransferState(int, TransferState...)"); - try { - Criteria criteria = getSessionFactory().getCurrentSession() - .createCriteria(Transfer.class); - criteria.add(Restrictions.in("transferState", transferState)); - criteria.setMaxResults(maxResults); - criteria.addOrder(Order.desc("createdAt")); - criteria.setFetchMode("synchronization", FetchMode.JOIN); - return criteria.list(); - - } catch (HibernateException e) { - log.error("HibernateException", e); - throw new TransferDAOException(e); - } catch (Exception e) { - log.error("error in findByTransferState(int, TransferState...)", e); - throw new TransferDAOException( - "Failed findByTransferState(int, TransferState...)", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.transfer.dao.TransferDAO#findByTransferStatus (int, - * org.irods.jargon.transfer.dao.domain.TransferStatus[]) - */ - @SuppressWarnings("unchecked") - @Override - public List findByTransferStatus(final int maxResults, - final TransferStatusEnum... transferStatus) - throws TransferDAOException { - log.debug("entering findByTransferState(int, TransferStatus...)"); - - try { - Criteria criteria = getSessionFactory().getCurrentSession() - .createCriteria(Transfer.class); - criteria.add(Restrictions.in("transferStatus", transferStatus)); - criteria.setFetchMode("synchronization", FetchMode.JOIN); - criteria.setMaxResults(maxResults); - criteria.addOrder(Order.desc("createdAt")); - return criteria.list(); - } catch (HibernateException e) { - log.error("HibernateException", e); - throw new TransferDAOException(e); - } catch (Exception e) { - log.error("error in findByTransferState(int, TransferStatus...)", e); - throw new TransferDAOException( - "Failed findByTransferState(int, TransferStatus...)", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.transfer.dao.TransferDAO#findAllSortedDesc (int) - */ - @SuppressWarnings("unchecked") - @Override - public List findAllSortedDesc(final int maxResults) - throws TransferDAOException { - - try { - Criteria criteria = getSessionFactory().getCurrentSession() - .createCriteria(Transfer.class); - criteria.setMaxResults(maxResults); - criteria.addOrder(Order.desc("createdAt")); - criteria.setFetchMode("synchronization", FetchMode.JOIN); - return criteria.list(); - } catch (HibernateException e) { - log.error("HibernateException", e); - throw new TransferDAOException(e); - } catch (Exception e) { - log.error("error in findAllSortedDesc(int)", e); - throw new TransferDAOException("Failed findAllSortedDesc(int)", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.transfer.dao.TransferDAO#findAll() - */ - @SuppressWarnings("unchecked") - @Override - public List findAll() throws TransferDAOException { - log.debug("entering findAll()"); - try { - Criteria criteria = getSessionFactory().getCurrentSession() - .createCriteria(Transfer.class); - criteria.addOrder(Order.desc("createdAt")); - // criteria.setFetchMode("synchronization", FetchMode.JOIN); - // criteria.setFetchMode("transferAttempts", FetchMode.JOIN); - return criteria.list(); - } catch (HibernateException e) { - log.error("HibernateException", e); - throw new TransferDAOException(e); - } catch (Exception e) { - log.error("error in findAll()", e); - throw new TransferDAOException("Failed findAll()", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.transfer.dao.TransferDAO#purgeQueue() - */ - @Override - public void purgeQueue() throws TransferDAOException { - log.debug("entering purgeQueue()"); - - try { - - StringBuilder sb = new StringBuilder(); - sb.append("delete from TransferItem as item where "); - sb.append("item.transfer.id in ("); - sb.append("select id from Transfer as transfer where transfer.transferState <> ?)"); - - log.debug("delete items sql:{}", sb.toString()); - - HibernateTemplate hibernateTemplate = super.getHibernateTemplate(); - - int rows = hibernateTemplate.bulkUpdate(sb.toString(), - TransferStateEnum.PROCESSING); - log.debug("deleted items count of: {}", rows); - - sb = new StringBuilder(); - sb.append("delete from Transfer where transferState <> ?"); - - log.debug("delete items sql:{}", sb.toString()); - - rows = super.getHibernateTemplate().bulkUpdate(sb.toString(), - TransferStateEnum.PROCESSING); - log.debug("deleted transfers count of: {}", rows); - - } catch (HibernateException e) { - log.error("HibernateException", e); - throw new TransferDAOException(e); - } catch (Exception e) { - log.error("error in purgeQueue()", e); - throw new TransferDAOException("Failed purgeQueue()", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.transfer.dao.TransferDAO#purgeEntireQueue() - */ - @Override - public void purgeEntireQueue() throws TransferDAOException { - log.debug("entering purgeQueue()"); - - try { - - HibernateTemplate hibernateTemplate = super.getHibernateTemplate(); - StringBuilder sb = new StringBuilder(); - sb.append("delete from TransferItem"); - log.debug("delete items sql:{}", sb.toString()); - - int rows = hibernateTemplate.bulkUpdate(sb.toString()); - log.debug("deleted items count of: {}", rows); - - sb = new StringBuilder(); - sb.append("delete from TransferAttempt"); - rows = hibernateTemplate.bulkUpdate(sb.toString()); - log.debug("deleted attempts count of: {}", rows); - - sb = new StringBuilder(); - sb.append("delete from Transfer"); - - log.debug("delete transfers sql:{}", sb.toString()); - - rows = super.getHibernateTemplate().bulkUpdate(sb.toString()); - log.debug("deleted transfers count of: {}", rows); - - } catch (HibernateException e) { - log.error("HibernateException", e); - throw new TransferDAOException(e); - } catch (Exception e) { - log.error("error in purgeQueue()", e); - throw new TransferDAOException("Failed purgeQueue()", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.transfer.dao.TransferDAO#purgeSuccessful() - */ - @Override - public void purgeSuccessful() throws TransferDAOException { - log.debug("entering purgeSuccessful()"); - - List transfers = findAll(); - - for (Transfer transfer : transfers) { - if ((transfer.getTransferState() == TransferStateEnum.COMPLETE || transfer - .getTransferState() == TransferStateEnum.CANCELLED) - && (transfer.getLastTransferStatus() == TransferStatusEnum.OK)) { - log.info("deleting...{}", transfer); - - } - } - - } - - /* - * (non-Javadoc) - * - * @see org.irods.jargon.transfer.dao.TransferDAO#delete(org.irods. - * jargon.transfer.dao.domain.Transfer) - */ - @Override - public void delete(final Transfer transfer) throws TransferDAOException { - logger.debug("entering delete()"); - - try { - getSessionFactory().getCurrentSession().delete(transfer); - } catch (HibernateException e) { - log.error("HibernateException", e); - throw new TransferDAOException(e); - } catch (Exception e) { - - log.error("error in delete(Transfer entity)", e); - throw new TransferDAOException("Failed delete(Transfer entity)", e); - } - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/TransferItemDAOImpl.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/TransferItemDAOImpl.java deleted file mode 100644 index 398f70e7d..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/dao/impl/TransferItemDAOImpl.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.irods.jargon.transfer.dao.impl; - -import java.util.List; - -import org.hibernate.Criteria; -import org.hibernate.HibernateException; -import org.hibernate.criterion.Order; -import org.hibernate.criterion.Restrictions; -import org.irods.jargon.transfer.dao.TransferDAOException; -import org.irods.jargon.transfer.dao.TransferItemDAO; -import org.irods.jargon.transfer.dao.domain.TransferItem; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.dao.DataAccessResourceFailureException; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - -/** - * - * @author jdr0887 - * - */ -public class TransferItemDAOImpl extends HibernateDaoSupport implements - TransferItemDAO { - - private static final Logger log = LoggerFactory - .getLogger(TransferItemDAOImpl.class); - - public TransferItemDAOImpl() { - super(); - } - - @Override - public void save(final TransferItem transferItem) - throws TransferDAOException { - - try { - getSessionFactory().getCurrentSession().saveOrUpdate(transferItem); - } catch (Exception e) { - - log.error("error in save(TransferItem)", e); - throw new TransferDAOException("Failed save(TransferItem)", e); - } - } - - @SuppressWarnings("unchecked") - @Override - public List findErrorItemsByTransferAttemptId(final Long id) - throws TransferDAOException { - log.debug("entering findErrorItemsByTransferAttemptId(Long)"); - - try { - Criteria criteria = getSessionFactory().getCurrentSession() - .createCriteria(TransferItem.class); - criteria.add(Restrictions.eq("error", true)); - criteria.createCriteria("transferAttempt").add( - Restrictions.eq("id", id)); - criteria.addOrder(Order.asc("transferredAt")); - return criteria.list(); - } catch (HibernateException e) { - log.error("HibernateException", e); - throw new TransferDAOException(e); - } catch (Exception e) { - log.error("error in findErrorItemsByTransferAttemptId(Long)", e); - throw new TransferDAOException( - "Failed findErrorItemsByTransferAttemptId(Long)", e); - } - } - - @SuppressWarnings("unchecked") - @Override - public List findAllItemsForTransferByTransferAttemptId( - final Long id) throws TransferDAOException { - log.debug("entering findAllItemsForTransferByTransferAttemptId(Long)"); - - try { - Criteria criteria = getSessionFactory().getCurrentSession() - .createCriteria(TransferItem.class); - criteria.createCriteria("transferAttempt").add( - Restrictions.eq("id", id)); - criteria.addOrder(Order.asc("transferredAt")); - return criteria.list(); - } catch (HibernateException e) { - log.error("HibernateException", e); - throw new TransferDAOException(e); - } catch (Exception e) { - log.error("error in findAllItemsForTransferByTransferId(Long)", e); - throw new TransferDAOException( - "Failed findAllItemsForTransferByTransferAttemptId(Long)", - e); - } - } - - @Override - public TransferItem findById(final Long id) throws TransferDAOException { - logger.debug("entering findById(Long)"); - - try { - Criteria criteria = getSessionFactory().getCurrentSession() - .createCriteria(TransferItem.class); - return (TransferItem) criteria.uniqueResult(); - } catch (DataAccessResourceFailureException e) { - throw new TransferDAOException(e); - } catch (HibernateException e) { - throw new TransferDAOException(e); - } catch (IllegalStateException e) { - throw new TransferDAOException(e); - } - } - - @Override - public void delete(final TransferItem transferItem) - throws TransferDAOException { - logger.debug("entering delete(TransferItem)"); - - try { - - getSessionFactory().getCurrentSession().delete(transferItem); - - } catch (Exception e) { - - log.error("error in delete(TransferItem)", e); - throw new TransferDAOException("Failed delete(TransferItem)", e); - } - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/exception/CannotUpdateTransferInProgressException.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/exception/CannotUpdateTransferInProgressException.java deleted file mode 100644 index be7e49f9e..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/exception/CannotUpdateTransferInProgressException.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.irods.jargon.transfer.exception; - -import org.irods.jargon.core.exception.JargonException; - -/** - * Exception caused by an attempt to update transfer manager data for transfers - * that are in progress. - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class CannotUpdateTransferInProgressException extends JargonException { - - private static final long serialVersionUID = 7777520801522885436L; - - public CannotUpdateTransferInProgressException(final String message, - final int underlyingIRODSExceptionCode) { - super(message, underlyingIRODSExceptionCode); - } - - public CannotUpdateTransferInProgressException(final String message, - final Throwable cause, final int underlyingIRODSExceptionCode) { - super(message, cause, underlyingIRODSExceptionCode); - } - - public CannotUpdateTransferInProgressException(final String message, - final Throwable cause) { - super(message, cause); - } - - public CannotUpdateTransferInProgressException(final String message) { - super(message); - } - - public CannotUpdateTransferInProgressException(final Throwable cause, - final int underlyingIRODSExceptionCode) { - super(cause, underlyingIRODSExceptionCode); - } - - public CannotUpdateTransferInProgressException(final Throwable cause) { - super(cause); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/exception/PassPhraseInvalidException.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/exception/PassPhraseInvalidException.java deleted file mode 100644 index 4c474c72b..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/exception/PassPhraseInvalidException.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * - */ -package org.irods.jargon.transfer.exception; - -import org.irods.jargon.core.exception.JargonException; - -/** - * Exception when the pass phrase cannot be validated - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class PassPhraseInvalidException extends JargonException { - - private static final long serialVersionUID = -6039687071909450418L; - - /** - * @param message - */ - public PassPhraseInvalidException(final String message) { - super(message); - } - - /** - * @param message - * @param cause - */ - public PassPhraseInvalidException(final String message, - final Throwable cause) { - super(message, cause); - } - - /** - * @param cause - */ - public PassPhraseInvalidException(final Throwable cause) { - super(cause); - } - - /** - * @param message - * @param cause - * @param underlyingIRODSExceptionCode - */ - public PassPhraseInvalidException(final String message, - final Throwable cause, final int underlyingIRODSExceptionCode) { - super(message, cause, underlyingIRODSExceptionCode); - } - - /** - * @param cause - * @param underlyingIRODSExceptionCode - */ - public PassPhraseInvalidException(final Throwable cause, - final int underlyingIRODSExceptionCode) { - super(cause, underlyingIRODSExceptionCode); - } - - /** - * @param message - * @param underlyingIRODSExceptionCode - */ - public PassPhraseInvalidException(final String message, - final int underlyingIRODSExceptionCode) { - super(message, underlyingIRODSExceptionCode); - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/util/DomainUtils.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/util/DomainUtils.java deleted file mode 100644 index 93dc2c7de..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/util/DomainUtils.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * - */ -package org.irods.jargon.transfer.util; - -import java.util.Date; - -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.transfer.dao.domain.GridAccount; - -/** - * Utilities used by the various domain objects - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class DomainUtils { - - /** - * Create a skeleton GridAccount based on the contents of a - * given IRODSAccount - *

- * Note that the given password is not encrypted by pass phrase, so that - * might need to be addressed by the caller. - * - * @param irodsAccount - * {@link IRODSAccount} - * @return {@link GridAccount} - */ - public static GridAccount gridAccountFromIRODSAccount( - final IRODSAccount irodsAccount) { - - if (irodsAccount == null) { - throw new IllegalArgumentException("null irodsAccount"); - } - - GridAccount gridAccount = new GridAccount(); - gridAccount.setAuthScheme(irodsAccount.getAuthenticationScheme()); - gridAccount.setComment("hello"); - gridAccount.setCreatedAt(new Date()); - gridAccount.setDefaultPath("/a/path"); - gridAccount - .setDefaultResource(irodsAccount.getDefaultStorageResource()); - gridAccount.setHost(irodsAccount.getHost()); - gridAccount.setPassword(irodsAccount.getPassword()); - gridAccount.setPort(irodsAccount.getPort()); - gridAccount.setUpdatedAt(new Date()); - gridAccount.setUserName(irodsAccount.getUserName()); - gridAccount.setZone(irodsAccount.getZone()); - return gridAccount; - - } - - /** - * Create an IRODSAccount given a GridAccount - * instance. - * - * @param gridAccount - * {@link GridAccount} - * @return {@link IRODSAccount} - * @throws JargonException - */ - public static IRODSAccount irodsAccountFromGridAccount( - final GridAccount gridAccount) throws JargonException { - - if (gridAccount == null) { - throw new IllegalArgumentException("null gridAccount"); - } - - IRODSAccount irodsAccount = IRODSAccount.instance( - gridAccount.getHost(), gridAccount.getPort(), - gridAccount.getUserName(), gridAccount.getPassword(), - gridAccount.getDefaultPath(), gridAccount.getZone(), - gridAccount.getDefaultResource()); - irodsAccount.setAuthenticationScheme(gridAccount.getAuthScheme()); - return irodsAccount; - } - -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/util/EnumUserType.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/util/EnumUserType.java deleted file mode 100644 index 3fff0b2ff..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/util/EnumUserType.java +++ /dev/null @@ -1,164 +0,0 @@ -/** - * - */ -package org.irods.jargon.transfer.util; - -import java.io.Serializable; -import java.lang.reflect.Method; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Properties; - -import org.hibernate.HibernateException; -import org.hibernate.type.NullableType; -import org.hibernate.type.TypeFactory; -import org.hibernate.usertype.ParameterizedType; -import org.hibernate.usertype.UserType; - -public class EnumUserType implements UserType, ParameterizedType { - private static final String DEFAULT_IDENTIFIER_METHOD_NAME = "name"; - - private static final String DEFAULT_VALUE_OF_METHOD_NAME = "valueOf"; - - @SuppressWarnings("rawtypes") - private Class enumClass; - - private Class identifierType; - - private Method identifierMethod; - - private Method valueOfMethod; - - private NullableType type; - - private int[] sqlTypes; - - @Override - public void setParameterValues(final Properties parameters) { - String enumClassName = parameters.getProperty("enumClassName"); - try { - enumClass = Class.forName(enumClassName).asSubclass(Enum.class); - } catch (ClassNotFoundException cfne) { - throw new HibernateException("Enum class not found", cfne); - } - - String identifierMethodName = parameters.getProperty( - "identifierMethod", DEFAULT_IDENTIFIER_METHOD_NAME); - - try { - identifierMethod = enumClass.getMethod(identifierMethodName, - new Class[0]); - identifierType = identifierMethod.getReturnType(); - } catch (Exception e) { - throw new HibernateException("Failed to obtain identifier method", - e); - } - - type = (NullableType) TypeFactory.basic(identifierType.getName()); - - if (type == null) { - throw new HibernateException("Unsupported identifier type " - + identifierType.getName()); - } - - sqlTypes = new int[] { type.sqlType() }; - - String valueOfMethodName = parameters.getProperty("valueOfMethod", - DEFAULT_VALUE_OF_METHOD_NAME); - - try { - valueOfMethod = enumClass.getMethod(valueOfMethodName, - new Class[] { identifierType }); - } catch (Exception e) { - throw new HibernateException("Failed to obtain valueOf method", e); - } - } - - @SuppressWarnings("rawtypes") - @Override - public Class returnedClass() { - return enumClass; - } - - @Override - public Object nullSafeGet(final ResultSet rs, final String[] names, - final Object owner) throws HibernateException, SQLException { - Object identifier = type.get(rs, names[0]); - if (rs.wasNull()) { - return null; - } - - try { - return valueOfMethod.invoke(enumClass, new Object[] { identifier }); - } catch (Exception e) { - throw new HibernateException( - "Exception while invoking valueOf method '" - + valueOfMethod.getName() + "' of " - + "enumeration class '" + enumClass + "'", e); - } - } - - @Override - public void nullSafeSet(final PreparedStatement st, final Object value, - final int index) throws HibernateException, SQLException { - try { - if (value == null) { - st.setNull(index, type.sqlType()); - } else { - Object identifier = identifierMethod.invoke(value, - new Object[0]); - type.set(st, identifier, index); - } - } catch (Exception e) { - throw new HibernateException( - "Exception while invoking identifierMethod '" - + identifierMethod.getName() + "' of " - + "enumeration class '" + enumClass + "'", e); - } - } - - @Override - public int[] sqlTypes() { - return sqlTypes; - } - - @Override - public Object assemble(final Serializable cached, final Object owner) - throws HibernateException { - return cached; - } - - @Override - public Object deepCopy(final Object value) throws HibernateException { - return value; - } - - @Override - public Serializable disassemble(final Object value) - throws HibernateException { - return (Serializable) value; - } - - @Override - public boolean equals(final Object x, final Object y) - throws HibernateException { - return x == y; - } - - @Override - public int hashCode(final Object x) throws HibernateException { - return x.hashCode(); - } - - @Override - public boolean isMutable() { - return false; - } - - @Override - public Object replace(final Object original, final Object target, - final Object owner) throws HibernateException { - return original; - } -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/util/HibernateUtil.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/util/HibernateUtil.java deleted file mode 100644 index cd5dde9c2..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/util/HibernateUtil.java +++ /dev/null @@ -1,169 +0,0 @@ -/** - * - */ -package org.irods.jargon.transfer.util; - -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.cfg.Configuration; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferItem; -import org.irods.jargon.transfer.util.StringEncryptor.EncryptionException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Utility to manage hibernate session. Instances are created such that they can - * compute the desired location of the transfer database. In many cases, the - * transfer database will be - * - * @author Mike Conway - DICE (www.irods.org) - * - */ -public class HibernateUtil { - - private static final Logger log = LoggerFactory - .getLogger(HibernateUtil.class); - - private final SessionFactory factory; - - /** - * Create an instance that can open Hibernate sessions using the default - * hibernate xml configuration. - * - * @return - * @throws JargonException - */ - public static HibernateUtil instanceUsingDefaultConfig() - throws JargonException { - return new HibernateUtil(); - } - - /** - * Create an instance that uses a database at the given path. This is useful - * for creation of databases within user directories - * - * @param pathToDatabase - * String with the full path to the transfer - * database such that it can be incorporated in the jdbc url. - * @return HibernateUtil instance configured to create sessions - * to the appropriate database. - * @throws JargonException - */ - public static HibernateUtil instanceGivingPathToDatabase( - final String pathToDatabase) throws JargonException { - return new HibernateUtil(pathToDatabase); - } - - /** - * Create an instance that uses a database at the given path. This is useful - * for creation of databases within user directories - * - * @param pathToDatabase - * String with the full path to the transfer - * database such that it can be incorporated in the jdbc url. - * @return HibernateUtil instance configured to create sessions - * to the appropriate database. - * @throws JargonException - */ - private HibernateUtil(final String pathToDatabase) throws JargonException { - factory = setUpFactoryUsingGivenDatabasePath(pathToDatabase); - } - - /** - * Create an instance using the default Hibernate configuration. - * - * @throws JargonException - */ - private HibernateUtil() throws JargonException { - log.info("creating hibernate session factory using default configuration in the hibernate.cfg.xml file"); - factory = new Configuration().configure().buildSessionFactory(); - } - - /** - * Return a session using the pre-configured Hibernate session configuration - * information. - * - * @return - */ - public Session getSession() { - return factory.getCurrentSession(); - } - - private SessionFactory setUpFactoryUsingGivenDatabasePath( - final String transferDatabasePath) throws JargonException { - - String userHomeDirectory = System.getProperty("user.home"); - log.info("user home directory = {}", userHomeDirectory); - StringBuilder sb = new StringBuilder(); - sb.append(userHomeDirectory); - sb.append("/.idrop/"); - sb.append(transferDatabasePath); - - StringBuilder jdbcUrlBuilder = new StringBuilder(); - jdbcUrlBuilder.append("jdbc:derby:"); - jdbcUrlBuilder.append(sb); - jdbcUrlBuilder.append(";create=true"); - // jdbcUrlBuilder.append("target/transferDatabase"); - - // Properties p = System.getProperties(); - // p.put("derby.system.home", derbyPath); - - sb.append(transferDatabasePath); - log.info("computed url for database:{}", jdbcUrlBuilder.toString()); - - Configuration cfg = new Configuration(); - cfg.addClass(Transfer.class); - cfg.addClass(TransferItem.class); - cfg.setProperty("hibernate.connection.driver_class", - "org.apache.derby.jdbc.EmbeddedDriver"); - cfg.setProperty("hibernate.connection.password", "transfer"); - cfg.setProperty("hibernate.connection.url", jdbcUrlBuilder.toString()); - cfg.setProperty("hibernate.connection.username", "transfer"); - cfg.setProperty("hibernate.c3p0.min_size", "1"); - cfg.setProperty("hibernate.c3p0.max_size", "3"); - cfg.setProperty("hibernate.c3p0.timeout", "1800"); - cfg.setProperty("hibernate.c3p0.max_statements", "0"); - cfg.setProperty("hibernate.dialect", - "org.hibernate.dialect.DerbyDialect"); - cfg.setProperty("hibernate.current_session_context_class", "thread"); - cfg.setProperty("cache.provider_class", - "org.hibernate.cache.NoCacheProvider"); - cfg.setProperty("hibernate.hbm2ddl.auto", "update"); - log.info("hibernate config:{}", cfg); - - return cfg.buildSessionFactory(); - - } - - public static String obfuscate(final String stringToObfuscate) - throws JargonException { - String encryptionKey = "123456789012345678901234567890"; - - StringEncryptor encrypter; - try { - encrypter = new StringEncryptor( - StringEncryptor.DES_ENCRYPTION_SCHEME, encryptionKey); - String encryptedString = encrypter.encrypt(stringToObfuscate); - return encryptedString; - } catch (EncryptionException e) { - throw new JargonException("error encrypting password"); - } - } - - public static String retrieve(final String encryptedString) - throws JargonException { - String encryptionKey = "123456789012345678901234567890"; - - StringEncryptor encrypter; - try { - encrypter = new StringEncryptor( - StringEncryptor.DES_ENCRYPTION_SCHEME, encryptionKey); - String decryptedString = encrypter.decrypt(encryptedString); - return decryptedString; - } catch (EncryptionException e) { - throw new JargonException("error decrypting password", e); - } - } -} diff --git a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/util/StringEncryptor.java b/jargon-conveyor/src/main/java/org/irods/jargon/transfer/util/StringEncryptor.java deleted file mode 100644 index a5f70a8bd..000000000 --- a/jargon-conveyor/src/main/java/org/irods/jargon/transfer/util/StringEncryptor.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * - */ -package org.irods.jargon.transfer.util; - -import java.io.UnsupportedEncodingException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.spec.KeySpec; - -import javax.crypto.Cipher; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.SecretKey; -import javax.crypto.SecretKeyFactory; -import javax.crypto.spec.DESKeySpec; -import javax.crypto.spec.DESedeKeySpec; - -import org.irods.jargon.core.utils.Base64; - -import sun.misc.BASE64Decoder; - -/** - * @author Mike Conway - DICE (www.irods.org) - * - */ -@SuppressWarnings("restriction") -public class StringEncryptor { - - public static final String DESEDE_ENCRYPTION_SCHEME = "DESede"; - - public static final String DES_ENCRYPTION_SCHEME = "DES"; - - // public static final String DES_PADDED_ENCRYPTION_SCHEME = - // "DES/CFB/PKCS5Padding"; - public static final String DES_PADDED_ENCRYPTION_SCHEME = "DES/CBC/PKCS5Padding"; - - public static final String DEFAULT_ENCRYPTION_KEY = "jfiadsfijaisejflaisdfjjieiefjakdlfjasdlkfjasliejfasfjaiseajfas;irijgirgaisjfa;sidfja;seijfgas;ihgar;iafjas;df"; - - private KeySpec keySpec; - - private SecretKeyFactory keyFactory; - - private Cipher cipher; - - private static final String UNICODE_FORMAT = "UTF8"; - - public StringEncryptor(final String encryptionScheme) - throws EncryptionException { - this(encryptionScheme, DEFAULT_ENCRYPTION_KEY); - } - - public StringEncryptor(final String encryptionScheme, - final String encryptionKey) throws EncryptionException { - - if (encryptionKey == null) { - throw new IllegalArgumentException("encryption key was null"); - } - if (encryptionKey.trim().length() < 24) { - throw new IllegalArgumentException( - "encryption key was less than 24 characters"); - } - - try { - byte[] keyAsBytes = encryptionKey.getBytes(UNICODE_FORMAT); - - if (encryptionScheme.equals(DESEDE_ENCRYPTION_SCHEME)) { - keySpec = new DESedeKeySpec(keyAsBytes); - } else if (encryptionScheme.equals(DES_ENCRYPTION_SCHEME)) { - keySpec = new DESKeySpec(keyAsBytes); - } else { - throw new IllegalArgumentException( - "Encryption scheme not supported: " + encryptionScheme); - } - - keyFactory = SecretKeyFactory.getInstance(encryptionScheme); - cipher = Cipher.getInstance(encryptionScheme); - - } catch (InvalidKeyException e) { - throw new EncryptionException(e); - } catch (UnsupportedEncodingException e) { - throw new EncryptionException(e); - } catch (NoSuchAlgorithmException e) { - throw new EncryptionException(e); - } catch (NoSuchPaddingException e) { - throw new EncryptionException(e); - } - - } - - public String encrypt(final String unencryptedString) - throws EncryptionException { - if (unencryptedString == null) { - throw new IllegalArgumentException("unencrypted string was null "); - } - - // if blank return blank - if (unencryptedString.isEmpty()) { - return ""; - } - - try { - SecretKey key = keyFactory.generateSecret(keySpec); - cipher.init(Cipher.ENCRYPT_MODE, key); - byte[] cleartext = unencryptedString.getBytes(UNICODE_FORMAT); - byte[] ciphertext = cipher.doFinal(cleartext); - /* - * Go from an unencrypted byte array to an encrypted byte array - */ - return Base64.toString(ciphertext); - } catch (Exception e) { - throw new EncryptionException(e); - } - } - - public String decrypt(final String encryptedString) - throws EncryptionException { - if (encryptedString == null) { - throw new IllegalArgumentException("encrypted string was null "); - } - - // if blank just return blank - if (encryptedString.isEmpty()) { - return ""; - } - - try { - SecretKey key = keyFactory.generateSecret(keySpec); - cipher.init(Cipher.DECRYPT_MODE, key); - BASE64Decoder base64decoder = new BASE64Decoder(); - byte[] cleartext = base64decoder.decodeBuffer(encryptedString); - byte[] ciphertext = cipher.doFinal(cleartext); - - return bytes2String(ciphertext); - } catch (Exception e) { - throw new EncryptionException(e); - } - } - - private static String bytes2String(final byte[] bytes) { - StringBuffer stringBuffer = new StringBuffer(); - for (byte b : bytes) { - stringBuffer.append((char) b); - } - return stringBuffer.toString(); - } - - public static class EncryptionException extends Exception { - - private static final long serialVersionUID = 3877601749214910931L; - - public EncryptionException(final Throwable t) { - super(t); - } - } -} diff --git a/jargon-conveyor/src/main/resources/conveyor.properties b/jargon-conveyor/src/main/resources/conveyor.properties deleted file mode 100644 index 31d638a39..000000000 --- a/jargon-conveyor/src/main/resources/conveyor.properties +++ /dev/null @@ -1,2 +0,0 @@ -max.sessions=1 -try.lock.timeout.seconds=30 \ No newline at end of file diff --git a/jargon-conveyor/src/main/resources/hibernate-configuration-3.0.dtd b/jargon-conveyor/src/main/resources/hibernate-configuration-3.0.dtd deleted file mode 100644 index a22cd7b50..000000000 --- a/jargon-conveyor/src/main/resources/hibernate-configuration-3.0.dtd +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jargon-conveyor/src/main/resources/hibernate-mapping-3.0.dtd b/jargon-conveyor/src/main/resources/hibernate-mapping-3.0.dtd deleted file mode 100644 index de7bf3d1f..000000000 --- a/jargon-conveyor/src/main/resources/hibernate-mapping-3.0.dtd +++ /dev/null @@ -1,1036 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jargon-conveyor/src/main/resources/spring-aop-2.0.xsd b/jargon-conveyor/src/main/resources/spring-aop-2.0.xsd deleted file mode 100644 index 7a292f190..000000000 --- a/jargon-conveyor/src/main/resources/spring-aop-2.0.xsd +++ /dev/null @@ -1,533 +0,0 @@ - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<xsd:schema xmlns="http://www.springframework.org/schema/aop" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:tool="http://www.springframework.org/schema/tool" targetNamespace="http://www.springframework.org/schema/aop" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xsd:import namespace="http://www.springframework.org/schema/beans" schemaLocation="http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"/>
<xsd:import namespace="http://www.springframework.org/schema/tool" schemaLocation="http://www.springframework.org/schema/tool/spring-tool-2.0.xsd"/>
<xsd:annotation>
<xsd:documentation>
<![CDATA[
Defines the configuration elements for the Spring Framework's AOP support.
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:element name="config">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
A section (compartmentalization) of AOP-specific configuration (including - aspects, pointcuts, etc).
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="pointcut" type="pointcutType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
<![CDATA[ - A named pointcut definition. - ]]>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="advisor" type="advisorType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.aop.Advisor">
<![CDATA[ - A named advisor definition. - ]]>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="aspect" type="aspectType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
<![CDATA[ - A named aspect definition. - ]]>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="proxy-target-class" type="xsd:boolean" default="false">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
Are class-based (CGLIB) proxies to be created? By default, standard - Java interface-based proxies are created.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="aspectj-autoproxy">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator">
<![CDATA[
Enables the use of the @AspectJ style of Spring AOP.
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="include" type="includeType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
Indicates that only @AspectJ beans with names matched by the (regex) - pattern will be considered as defining aspects to use for Spring autoproxying.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="proxy-target-class" type="xsd:boolean" default="false">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
Are class-based (CGLIB) proxies to be created? By default, standard - Java interface-based proxies are created.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="scoped-proxy">
<xsd:complexType>
<xsd:annotation>
<xsd:documentation source="java:org.springframework.aop.scope.ScopedProxyFactoryBean">
<![CDATA[
Marks a bean definition as being a scoped proxy. - - A bean marked as such will be exposed via a proxy, with the 'real' - bean instance being retrieved from some other source (such as a - HttpSession) as and when required.
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:attribute name="proxy-target-class" type="xsd:boolean" default="true">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
Are class-based (CGLIB) proxies to be created? This is the default; in order to - switch to standard Java interface-based proxies, turn this flag to "false".
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="spring-configured">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect">
<![CDATA[
Signals the current application context to apply dependency injection - to non-managed objects that are instantiated outside of the Spring bean - factory (typically classes annotated with the @Configurable annotation).
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:element>
<xsd:complexType name="aspectType">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="pointcut" type="pointcutType">
<xsd:annotation>
<xsd:documentation>
<![CDATA[ - A named pointcut definition. - ]]>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="declare-parents" type="declareParentsType">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
Allows this aspect to introduce additional interfaces that the advised - object will transparently implement.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="before" type="basicAdviceType">
<xsd:annotation>
<xsd:documentation>
<![CDATA[ - A before advice definition. - ]]>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="after" type="basicAdviceType">
<xsd:annotation>
<xsd:documentation>
<![CDATA[ - An after advice definition. - ]]>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="after-returning" type="afterReturningAdviceType">
<xsd:annotation>
<xsd:documentation>
<![CDATA[ - An after-returning advice definition. - ]]>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="after-throwing" type="afterThrowingAdviceType">
<xsd:annotation>
<xsd:documentation>
<![CDATA[ - An after-throwing advice definition. - ]]>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="around" type="basicAdviceType">
<xsd:annotation>
<xsd:documentation>
<![CDATA[ - An around advice definition. - ]]>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:choice>
<xsd:attribute name="id" type="xsd:ID">
<xsd:annotation>
<xsd:documentation>
<![CDATA[ - The unique identifier for an aspect. - ]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="ref" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The name of the (backing) bean that encapsulates the aspect.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="order" type="xsd:int">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.core.Ordered">
<![CDATA[
Controls the ordering of the execution of this aspect when multiple - advice executes at a specific joinpoint.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<xsd:complexType name="includeType">
<xsd:attribute name="name" type="xsd:string">
<xsd:annotation>
<xsd:documentation source="java:java.util.regex.Pattern">
<![CDATA[
The regular expression defining which beans are to be included in the - list of @AspectJ beans; beans with names matched by the pattern will - be included.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<xsd:complexType name="pointcutType">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation>
<tool:exports type="org.springframework.aop.Pointcut"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:attribute name="id" type="xsd:ID">
<xsd:annotation>
<xsd:documentation>
<![CDATA[ - The unique identifier for a pointcut. - ]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="expression" use="required" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The pointcut expression. - - For example : 'execution(* com.xyz.myapp.service.*.*(..))'
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="type" default="aspectj">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The type of pointcut expression (see the associated enumeration). - DEPRECATED: Only AspectJ expression pointcuts are supported.
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="aspectj"/>
<xsd:enumeration value="regex"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
<xsd:complexType name="declareParentsType">
<xsd:attribute name="types-matching" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.aop.aspectj.TypePatternClassFilter">
<![CDATA[
The AspectJ type expression that defines what types (classes) the - introduction is restricted to. - - An example would be 'org.springframework.beans.ITestBean+'.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="implement-interface" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation source="java:java.lang.Class">
<![CDATA[
The fully qualified name of the interface that will be introduced.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="default-impl" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation source="java:java.lang.Class">
<![CDATA[
The fully qualified name of the class that will be instantiated to serve - as the default implementation of the introduced interface.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<xsd:complexType name="basicAdviceType">
<xsd:attribute name="pointcut" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
<![CDATA[ - The associated pointcut expression. - ]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="pointcut-ref" type="pointcutRefType">
<xsd:annotation>
<xsd:documentation>
<![CDATA[ - The name of an associated pointcut definition. - ]]>
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.aop.Pointcut"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="method" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The name of the method that defines the logic of the advice.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="arg-names" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The comma-delimited list of advice method argument (parameter) names - that will be matched from pointcut parameters.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<xsd:complexType name="afterReturningAdviceType">
<xsd:complexContent>
<xsd:extension base="basicAdviceType">
<xsd:attribute name="returning" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The name of the method parameter to which the return value must - be passed.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="afterThrowingAdviceType">
<xsd:complexContent>
<xsd:extension base="basicAdviceType">
<xsd:attribute name="throwing" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The name of the method parameter to which the thrown exception must - be passed.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="advisorType">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation>
<tool:exports type="org.springframework.aop.Advisor"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<!--
Rick : ID type written explicitly as opposed to being imported (c.f. [SPR-2290]
-->
<xsd:attribute name="id" type="xsd:ID"/>
<xsd:attribute name="advice-ref" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation>
<![CDATA[ - A reference to an advice bean. - ]]>
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.aopalliance.aop.Advice"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="pointcut" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
<![CDATA[ - A pointcut expression. - ]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="pointcut-ref" type="pointcutRefType">
<xsd:annotation>
<xsd:documentation>
<![CDATA[ - A reference to a pointcut definition. - ]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="order" type="xsd:int">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.core.Ordered">
<![CDATA[
Controls the ordering of the execution of this advice when multiple - advice executes at a specific joinpoint.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<xsd:simpleType name="pointcutRefType">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.aop.Pointcut"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:union memberTypes="xsd:string"/>
</xsd:simpleType>
</xsd:schema>
\ No newline at end of file diff --git a/jargon-conveyor/src/main/resources/spring-aop-3.0.xsd b/jargon-conveyor/src/main/resources/spring-aop-3.0.xsd deleted file mode 100644 index 879f57f7c..000000000 --- a/jargon-conveyor/src/main/resources/spring-aop-3.0.xsd +++ /dev/null @@ -1,408 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jargon-conveyor/src/main/resources/spring-beans-2.0.xsd b/jargon-conveyor/src/main/resources/spring-beans-2.0.xsd deleted file mode 100644 index 3bceb75aa..000000000 --- a/jargon-conveyor/src/main/resources/spring-beans-2.0.xsd +++ /dev/null @@ -1,1077 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ' element. - ]]> - - - - - - - - - - ' element. - ]]> - - - - - - - - - - - - - - ' element. - ]]> - - - - - - - - - - - - - ' element. - ]]> - - - - - ' element. - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - element (or "ref" - attribute). We recommend this in most cases as it makes documentation - more explicit. - - 2. "byName" - Autowiring by property name. If a bean of class Cat exposes a "dog" - property, Spring will try to set this to the value of the bean "dog" - in the current container. If there is no matching bean by name, nothing - special happens; use dependency-check="objects" to raise an error in - that case. - - 3. "byType" - Autowiring if there is exactly one bean of the property type in the - container. If there is more than one, a fatal error is raised, and - you cannot use byType autowiring for that bean. If there is none, - nothing special happens; use dependency-check="objects" to raise an - error in that case. - - 4. "constructor" - Analogous to "byType" for constructor arguments. If there is not exactly - one bean of the constructor argument type in the bean factory, a fatal - error is raised. - - 5. "autodetect" - Chooses "constructor" or "byType" through introspection of the bean - class. If a default constructor is found, "byType" gets applied. - - Note that explicit dependencies, i.e. "property" and "constructor-arg" - elements, always override autowiring. Autowire behavior can be combined - with dependency checking, which will be performed after all autowiring - has been completed. - - Note: This attribute will not be inherited by child bean definitions. - Hence, it needs to be specified per concrete bean definition. - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " element. - ]]> - - - - - ..." element. - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ". - ]]> - - - - - ..." - element. - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ". - ]]> - - - - - ..." - element. - ]]> - - - - - ". - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jargon-conveyor/src/main/resources/spring-beans-3.0.xsd b/jargon-conveyor/src/main/resources/spring-beans-3.0.xsd deleted file mode 100644 index dce67a3b7..000000000 --- a/jargon-conveyor/src/main/resources/spring-beans-3.0.xsd +++ /dev/null @@ -1,1152 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ' element. - ]]> - - - - - - - - - - ' element. - ]]> - - - - - - - - - - - - - ' element for the semantic details of autowire candidate beans. - ]]> - - - - - ' element. - ]]> - - - - - ' element. - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - element (or "ref" - attribute). We recommend this in most cases as it makes documentation - more explicit. - - Note that this default mode also allows for annotation-driven autowiring, - if activated. "no" refers to externally driven autowiring only, not - affecting any autowiring demands that the bean class itself expresses. - - 2. "byName" - Autowiring by property name. If a bean of class Cat exposes a "dog" - property, Spring will try to set this to the value of the bean "dog" - in the current container. If there is no matching bean by name, nothing - special happens. - - 3. "byType" - Autowiring if there is exactly one bean of the property type in the - container. If there is more than one, a fatal error is raised, and - you cannot use byType autowiring for that bean. If there is none, - nothing special happens. - - 4. "constructor" - Analogous to "byType" for constructor arguments. If there is not exactly - one bean of the constructor argument type in the bean factory, a fatal - error is raised. - - Note that explicit dependencies, i.e. "property" and "constructor-arg" - elements, always override autowiring. - - Note: This attribute will not be inherited by child bean definitions. - Hence, it needs to be specified per concrete bean definition. - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " element. - ]]> - - - - - ..." element. - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ". - ]]> - - - - - ..." element. - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ". - ]]> - - - - - ..." - element. - ]]> - - - - - ". - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jargon-conveyor/src/main/resources/spring-tx-2.0.xsd b/jargon-conveyor/src/main/resources/spring-tx-2.0.xsd deleted file mode 100644 index 2d3837e79..000000000 --- a/jargon-conveyor/src/main/resources/spring-tx-2.0.xsd +++ /dev/null @@ -1,198 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jargon-conveyor/src/main/resources/spring-tx-3.0.xsd b/jargon-conveyor/src/main/resources/spring-tx-3.0.xsd deleted file mode 100644 index 398e6f43d..000000000 --- a/jargon-conveyor/src/main/resources/spring-tx-3.0.xsd +++ /dev/null @@ -1,244 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jargon-conveyor/src/main/resources/transfer-dao-beans.xml b/jargon-conveyor/src/main/resources/transfer-dao-beans.xml deleted file mode 100644 index fbcb36997..000000000 --- a/jargon-conveyor/src/main/resources/transfer-dao-beans.xml +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - org.hibernate.dialect.DerbyDialect - false - true - update - false - 4 - 8 - 900 - 50 - false - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jargon-conveyor/src/main/resources/transfer-dao-hibernate-spring.cfg.xml b/jargon-conveyor/src/main/resources/transfer-dao-hibernate-spring.cfg.xml deleted file mode 100644 index 69ad472db..000000000 --- a/jargon-conveyor/src/main/resources/transfer-dao-hibernate-spring.cfg.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - diff --git a/jargon-conveyor/src/main/resources/transfer.properties b/jargon-conveyor/src/main/resources/transfer.properties deleted file mode 100644 index 56fb2ffe1..000000000 --- a/jargon-conveyor/src/main/resources/transfer.properties +++ /dev/null @@ -1,4 +0,0 @@ -jdbc.url=jdbc\:derby\:${user.home}/.idrop/idrop201/idrop-conveyor/database/transfer;create\=true -jdbc.user=transfer -jdbc.password=transfer -flow.dir=${user.home}/.idrop/idrop201/flow diff --git a/jargon-conveyor/src/main/resources/validation.xml b/jargon-conveyor/src/main/resources/validation.xml deleted file mode 100644 index 28d3aaeaf..000000000 --- a/jargon-conveyor/src/main/resources/validation.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - false - \ No newline at end of file diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/BasicConveyorBootstrapperImplTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/BasicConveyorBootstrapperImplTest.java deleted file mode 100644 index 5b143b44d..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/BasicConveyorBootstrapperImplTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.irods.jargon.conveyor.basic; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.core.ConveyorBootstrapper; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.core.pub.IRODSAccessObjectFactory; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.mockito.Mockito; - -public class BasicConveyorBootstrapperImplTest { - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Test - public void testBasicConveyorBootstrapperImpl() { - ConveyorBootstrapConfiguration conveyorBootstrapConfiguration = new ConveyorBootstrapConfiguration(); - ConveyorBootstrapper conveyorBootstrapper = new BasicConveyorBootstrapperImpl( - conveyorBootstrapConfiguration); - Assert.assertNotNull("should not happen", conveyorBootstrapper); - } - - @Test(expected = IllegalArgumentException.class) - public void testBasicConveyorBootstrapperImplNullConfigInConstructor() { - ConveyorBootstrapConfiguration conveyorBootstrapConfiguration = null; - ConveyorBootstrapper conveyorBootstrapper = new BasicConveyorBootstrapperImpl( - conveyorBootstrapConfiguration); - Assert.assertNotNull("should not happen", conveyorBootstrapper); - } - - @Test - public void testBootstrap() throws Exception { - ConveyorBootstrapConfiguration conveyorBootstrapConfiguration = new ConveyorBootstrapConfiguration(); - ConveyorBootstrapper conveyorBootstrapper = new BasicConveyorBootstrapperImpl( - conveyorBootstrapConfiguration); - IRODSAccessObjectFactory irodsAccessObjectFactory = Mockito - .mock(IRODSAccessObjectFactory.class); - ConveyorService service = conveyorBootstrapper - .bootstrap(irodsAccessObjectFactory); - service.shutdown(); - Assert.assertNotNull("no executor in service after bootstrap", - service.getConveyorExecutorService()); - Assert.assertNotNull("no gridAccountService after bootstrap", - service.getGridAccountService()); - Assert.assertNotNull( - "gridAccountService does not have reference to executor after bootstrap", - service.getGridAccountService().getConveyorExecutorService()); - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/BasicConveyorServiceTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/BasicConveyorServiceTest.java deleted file mode 100644 index 0f24d79d9..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/BasicConveyorServiceTest.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.irods.jargon.conveyor.basic; - -import java.util.Properties; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.transfer.exception.PassPhraseInvalidException; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; -import org.springframework.transaction.annotation.Transactional; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:transfer-dao-beans.xml", - "classpath:transfer-dao-hibernate-spring.cfg.xml" }) -@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true) -@Transactional -public class BasicConveyorServiceTest { - - public static final String testPassPhrase = "BasicConveyorServiceTest"; - @Autowired - private ConveyorService conveyorService; - private static TestingPropertiesHelper testingPropertiesLoader; - private static Properties testingProperties; - private static IRODSFileSystem irodsFileSystem; - - @SuppressWarnings("static-access") - @BeforeClass - public static void setUpBeforeClass() throws Exception { - testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - irodsFileSystem = irodsFileSystem.instance(); - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Test - public void testInitializeInTearOffMode() throws Exception { - conveyorService.setIrodsAccessObjectFactory(irodsFileSystem - .getIRODSAccessObjectFactory()); - conveyorService.resetConveyorService(); - IRODSAccount irodsAccount = testingPropertiesLoader - .buildIRODSAccountFromTestProperties(testingProperties); - conveyorService.validatePassPhraseInTearOffMode(irodsAccount); - Assert.assertEquals("did not cache pass phrase", irodsAccount - .getPassword(), conveyorService.getGridAccountService() - .getCachedPassPhrase()); - } - - @Test - public void testInitializeAndValidatePassPhrase() throws Exception { - conveyorService.resetConveyorService(); - conveyorService.validatePassPhrase(testPassPhrase); - Assert.assertTrue("did not validate pass phrase", - conveyorService.getGridAccountService().getCachedPassPhrase() - .equals(testPassPhrase)); - } - - @Test - public void testIsPassPhraseValidatedWhenNotValidated() throws Exception { - conveyorService.resetConveyorService(); - boolean actual = conveyorService.isPreviousPassPhraseStored(); - Assert.assertFalse("should not show pass phrase as validated", actual); - - } - - @Test - public void testIsPassPhraseValidatedWhenValidated() throws Exception { - conveyorService.resetConveyorService(); - conveyorService.validatePassPhrase(testPassPhrase); - boolean actual = conveyorService.isPreviousPassPhraseStored(); - Assert.assertTrue("should not show pass phrase as validated", actual); - - } - - @Test(expected = PassPhraseInvalidException.class) - public void testUseInvalidPassPhrase() throws Exception { - conveyorService.resetConveyorService(); - conveyorService.validatePassPhrase(testPassPhrase); - conveyorService.validatePassPhrase("iaminvalidhere"); - - } - - @Test - public void testResetAndThenCheckNotValid() throws Exception { - conveyorService.resetConveyorService(); - conveyorService.validatePassPhrase(testPassPhrase); - Assert.assertTrue("did not validate pass phrase", - conveyorService.getGridAccountService().getCachedPassPhrase() - .equals(testPassPhrase)); - conveyorService.resetConveyorService(); - Assert.assertTrue("should not be validated", conveyorService - .getGridAccountService().getCachedPassPhrase().isEmpty()); - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/BasicFlowManagerServiceTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/BasicFlowManagerServiceTest.java deleted file mode 100644 index f6fe299e7..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/BasicFlowManagerServiceTest.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.irods.jargon.conveyor.basic; - -import java.util.ArrayList; -import java.util.List; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpec; -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpecCacheService; -import org.irods.jargon.conveyor.flowmanager.flow.Selector.FlowActionEnum; -import org.irods.jargon.conveyor.flowmanager.flow.dsl.Flow; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.irods.jargon.transfer.dao.domain.GridAccount; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.irods.jargon.transfer.dao.domain.TransferType; -import org.junit.Test; -import org.mockito.Mockito; - -public class BasicFlowManagerServiceTest { - - @Test - public void testRetrieveCandidateFlowSpecs() - throws ConveyorExecutionException { - String host = "test"; - String zone = "zone"; - FlowActionEnum action = FlowActionEnum.GET; - - String fqcn = Microservice.class.getName(); - - FlowSpec flow = Flow.define().forAction(action).forHost(host) - .forZone(zone).onAllConditions().endPreOperationChain() - .endPreFileChain().addPostFileMicroservice(fqcn) - .endPostFileChain().endPostOperationChain() - .endFlowWithoutErrorHandler(); - - List candidates = new ArrayList(); - candidates.add(flow); - - FlowSpecCacheService flowSpecCacheService = Mockito - .mock(FlowSpecCacheService.class); - Mockito.when(flowSpecCacheService.getFlowSpecs()) - .thenReturn(candidates); - - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - BasicFlowManagerService flowManagerService = new BasicFlowManagerService(); - flowManagerService.setFlowSpecCacheService(flowSpecCacheService); - flowManagerService.setConveyorService(conveyorService); - - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost(host); - gridAccount.setZone(zone); - transfer.setTransferType(TransferType.GET); - transfer.setGridAccount(gridAccount); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - - List flowSpecs = flowManagerService - .retrieveCandidateFlowSpecs(transferAttempt); - Assert.assertFalse("did not get the flowSpec", flowSpecs.isEmpty()); - - } - - @Test - public void testRetrieveCandidateFlowSpecsWrongHost() - throws ConveyorExecutionException { - String host = "test"; - String zone = "zone"; - FlowActionEnum action = FlowActionEnum.GET; - - String fqcn = Microservice.class.getName(); - - FlowSpec flow = Flow.define().forAction(action).forHost(host) - .forZone(zone).onAllConditions().endPreOperationChain() - .endPreFileChain().addPostFileMicroservice(fqcn) - .endPostFileChain().endPostOperationChain() - .endFlowWithoutErrorHandler(); - - List candidates = new ArrayList(); - candidates.add(flow); - - FlowSpecCacheService flowSpecCacheService = Mockito - .mock(FlowSpecCacheService.class); - Mockito.when(flowSpecCacheService.getFlowSpecs()) - .thenReturn(candidates); - - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - BasicFlowManagerService flowManagerService = new BasicFlowManagerService(); - flowManagerService.setFlowSpecCacheService(flowSpecCacheService); - flowManagerService.setConveyorService(conveyorService); - - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost("xxxx"); - gridAccount.setZone(zone); - transfer.setTransferType(TransferType.GET); - transfer.setGridAccount(gridAccount); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - - List flowSpecs = flowManagerService - .retrieveCandidateFlowSpecs(transferAttempt); - Assert.assertTrue("should not be matching flow specs", - flowSpecs.isEmpty()); - - } -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/BasicQueueManagerServiceImplTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/BasicQueueManagerServiceImplTest.java deleted file mode 100644 index 25082fe07..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/BasicQueueManagerServiceImplTest.java +++ /dev/null @@ -1,549 +0,0 @@ -package org.irods.jargon.conveyor.basic; - -import java.io.File; -import java.util.List; -import java.util.Properties; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.core.ConfigurationPropertyConstants; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.conveyor.core.TransferAccountingManagementService; -import org.irods.jargon.conveyor.unittest.utils.TransferTestRunningUtilities; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.DataTransferOperations; -import org.irods.jargon.core.pub.IRODSAccessObjectFactory; -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.core.pub.io.IRODSFile; -import org.irods.jargon.core.pub.io.IRODSFileFactory; -import org.irods.jargon.core.transfer.TransferControlBlock; -import org.irods.jargon.core.transfer.TransferStatusCallbackListener; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.testutils.filemanip.FileGenerator; -import org.irods.jargon.transfer.dao.domain.ConfigurationProperty; -import org.irods.jargon.transfer.dao.domain.GridAccount; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.irods.jargon.transfer.dao.domain.TransferAttemptTypeEnum; -import org.irods.jargon.transfer.dao.domain.TransferItem; -import org.irods.jargon.transfer.dao.domain.TransferStateEnum; -import org.irods.jargon.transfer.dao.domain.TransferStatusEnum; -import org.irods.jargon.transfer.dao.domain.TransferType; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:transfer-dao-beans.xml", - "classpath:transfer-dao-hibernate-spring.cfg.xml" }) -@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false) -// @Transactional -public class BasicQueueManagerServiceImplTest { - private static Properties testingProperties = new Properties(); - private static org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - private static org.irods.jargon.testutils.filemanip.ScratchFileUtils scratchFileUtils = null; - public static final String IRODS_TEST_SUBDIR_PATH = "BasicQueueManagerServiceImplTest"; - private static org.irods.jargon.testutils.IRODSTestSetupUtilities irodsTestSetupUtilities = null; - @SuppressWarnings("unused") - private static org.irods.jargon.testutils.AssertionHelper assertionHelper = null; - private static IRODSFileSystem irodsFileSystem = null; - private static int TRANSFER_TIMEOUT = -1; - - @Autowired - private ConveyorService conveyorService; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - irodsFileSystem = IRODSFileSystem.instance(); - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - scratchFileUtils = new org.irods.jargon.testutils.filemanip.ScratchFileUtils( - testingProperties); - scratchFileUtils - .clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH); - irodsTestSetupUtilities = new org.irods.jargon.testutils.IRODSTestSetupUtilities(); - irodsTestSetupUtilities.clearIrodsScratchDirectory(); - irodsTestSetupUtilities.initializeIrodsScratchDirectory(); - irodsTestSetupUtilities - .initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH); - assertionHelper = new org.irods.jargon.testutils.AssertionHelper(); - } - - @Before - public void setUp() throws Exception { - conveyorService.setIrodsAccessObjectFactory(irodsFileSystem - .getIRODSAccessObjectFactory()); - conveyorService.getQueueManagerService().purgeAllFromQueue(); - conveyorService.getGridAccountService().resetPassPhraseAndAccounts(); - - } - - @After - public void tearDown() throws Exception { - conveyorService.getQueueManagerService().purgeAllFromQueue(); - } - - @Test - public void testEnqueuePutTransferOperationAndWaitUntilDone() - throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - - conveyorService.getConfigurationService().addConfigurationProperty( - logSuccessful); - - String rootCollection = "testEnqueuePutTransferOperationAndWaitUntilDone"; - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - - FileGenerator - .generateManyFilesAndCollectionsInParentCollectionByAbsolutePath( - localCollectionAbsolutePath, - "testEnqueuePutTransferOperationAndWaitUntilDone", 1, - 1, 1, "testFile", ".txt", 2, 2, 1, 2); - - IRODSFileFactory irodsFileFactory = irodsFileSystem - .getIRODSFileFactory(irodsAccount); - IRODSFile destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - File localFile = new File(localCollectionAbsolutePath); - - Transfer transfer = new Transfer(); - transfer.setIrodsAbsolutePath(destFile.getAbsolutePath()); - transfer.setLocalAbsolutePath(localFile.getAbsolutePath()); - transfer.setTransferType(TransferType.PUT); - - conveyorService.getQueueManagerService().enqueueTransferOperation( - transfer, irodsAccount); - - TransferTestRunningUtilities.waitForTransferToRunOrTimeout( - conveyorService, TRANSFER_TIMEOUT); - - List transfers = conveyorService.getQueueManagerService() - .listAllTransfersInQueue(); - Assert.assertFalse("no transfers in queue", transfers.isEmpty()); - Assert.assertEquals("should be 1 transfer..maybe test cleanup is bad", - 1, transfers.size()); - transfer = transfers.get(0); - - transfer = conveyorService.getQueueManagerService() - .initializeGivenTransferByLoadingChildren(transfer); - - Assert.assertFalse("did not create a transfer attempt", transfer - .getTransferAttempts().isEmpty()); - - Assert.assertEquals("did not get complete status", - TransferStateEnum.COMPLETE, transfer.getTransferState()); - - TransferAttempt attempts[] = new TransferAttempt[transfer - .getTransferAttempts().size()]; - attempts = transfer.getTransferAttempts().toArray(attempts); - Assert.assertEquals("should be 1 attempt", 1, attempts.length); - - TransferAttempt attempt = attempts[0]; - Assert.assertNotNull("transfer attempt not persisted", attempt.getId()); - - List items = conveyorService.getQueueManagerService() - .getNextTransferItems(attempt.getId(), 0, 1000); - - Assert.assertEquals("should be 2 items", 2, items.size()); - - } - - @Test - public void testRestartPutTransferOperationAndWaitUntilDone() - throws Exception { - int totFiles = 10; - int restartAt = 4; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - - conveyorService.getConfigurationService().addConfigurationProperty( - logSuccessful); - - ConfigurationProperty logRestart = new ConfigurationProperty(); - logRestart - .setPropertyKey(ConfigurationPropertyConstants.LOG_RESTART_FILES); - logRestart.setPropertyValue("true"); - - conveyorService.getConfigurationService().addConfigurationProperty( - logRestart); - - String rootCollection = "testRestartPutTransferOperationAndWaitUntilDone"; - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - - FileGenerator.generateManyFilesInGivenDirectory(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection, "test", ".txt", totFiles, 1, 1); - - IRODSFileFactory irodsFileFactory = irodsFileSystem - .getIRODSFileFactory(irodsAccount); - IRODSFile destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - File localFile = new File(localCollectionAbsolutePath); - File[] children = localFile.listFiles(); - - GridAccount gridAccount = conveyorService.getGridAccountService() - .findGridAccountByIRODSAccount(irodsAccount); - - Transfer transfer = new Transfer(); - transfer.setIrodsAbsolutePath(destFile.getAbsolutePath()); - transfer.setLocalAbsolutePath(localFile.getAbsolutePath()); - transfer.setTransferType(TransferType.PUT); - transfer.setTransferState(TransferStateEnum.COMPLETE); - transfer.setGridAccount(gridAccount); - transfer.setLastTransferStatus(TransferStatusEnum.ERROR); - - conveyorService.getQueueManagerService().saveOrUpdateTransfer(transfer); - - TransferAttempt attemptThatFailed = new TransferAttempt(); - attemptThatFailed.setAttemptStatus(TransferStatusEnum.ERROR); - attemptThatFailed.setLastSuccessfulPath(children[restartAt - 2] - .getAbsolutePath()); - conveyorService.getQueueManagerService().addTransferAttemptToTransfer( - transfer.getId(), attemptThatFailed); - - // now restart - conveyorService.getQueueManagerService() - .enqueueRestartOfTransferOperation(transfer.getId()); - - TransferTestRunningUtilities.waitForTransferToRunOrTimeout( - conveyorService, TRANSFER_TIMEOUT); - - List transfers = conveyorService.getQueueManagerService() - .listAllTransfersInQueue(); - Assert.assertFalse("no transfers in queue", transfers.isEmpty()); - Assert.assertEquals("should be 1 transfer..maybe test cleanup is bad", - 1, transfers.size()); - transfer = transfers.get(0); - - transfer = conveyorService.getQueueManagerService() - .initializeGivenTransferByLoadingChildren(transfer); - - Assert.assertFalse("did not create a transfer attempt", transfer - .getTransferAttempts().isEmpty()); - - Assert.assertEquals("did not get complete status", - TransferStateEnum.COMPLETE, transfer.getTransferState()); - - TransferAttempt attempts[] = new TransferAttempt[transfer - .getTransferAttempts().size()]; - attempts = transfer.getTransferAttempts().toArray(attempts); - Assert.assertEquals("should be 2 attempts", 2, attempts.length); - - TransferAttempt attempt = attempts[1]; - Assert.assertNotNull("transfer restart attempt not persisted", - attempt.getId()); - List items = conveyorService.getQueueManagerService() - .getNextTransferItems(attempt.getId(), 0, 1000); - - Assert.assertEquals("should be n items", totFiles, items.size()); - - int i = 1; - for (TransferItem item : items) { - Assert.assertNotNull("null source", - item.getSourceFileAbsolutePath()); - Assert.assertNotNull("null target", - item.getTargetFileAbsolutePath()); - Assert.assertNotNull("null transfer type", item.getTransferType()); - Assert.assertEquals(TransferType.PUT, item.getTransferType()); - Assert.assertTrue("should be file", item.isFile()); - if (i < restartAt) { - Assert.assertTrue("file should be marked as skipped", - item.isSkipped()); - } else { - Assert.assertFalse("file should not be marked as skipped", - item.isSkipped()); - } - i++; - - } - - } - - @Test - public void testEnqueuePutTransferOperationThrowExceptionOnDTO() - throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - - conveyorService.getConfigurationService().addConfigurationProperty( - logSuccessful); - - // shim in mock ao factory, this is cleaned up in the @Before method - - String rootCollection = "testEnqueuePutTransferOperationAndWaitUntilDone"; - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - Transfer transfer = new Transfer(); - transfer.setIrodsAbsolutePath(rootCollection); - transfer.setLocalAbsolutePath(localCollectionAbsolutePath); - transfer.setTransferType(TransferType.PUT); - - IRODSAccessObjectFactory irodsAccessObjectFactory = Mockito - .mock(IRODSAccessObjectFactory.class); - DataTransferOperations dto = Mockito.mock(DataTransferOperations.class); - - TransferControlBlock tcb = irodsFileSystem.getIrodsSession() - .buildDefaultTransferControlBlockBasedOnJargonProperties(); - - Mockito.when( - irodsAccessObjectFactory - .getDataTransferOperations(irodsAccount)).thenReturn( - dto); - Mockito.doThrow(new JargonException("blah")) - .when(dto) - .putOperation(Matchers.anyString(), Matchers.anyString(), - Matchers.anyString(), - Matchers.any(TransferStatusCallbackListener.class), - Matchers.any(TransferControlBlock.class)); - Mockito.when( - irodsAccessObjectFactory - .buildDefaultTransferControlBlockBasedOnJargonProperties()) - .thenReturn(tcb); - conveyorService.setIrodsAccessObjectFactory(irodsAccessObjectFactory); - - conveyorService.getQueueManagerService().enqueueTransferOperation( - transfer, irodsAccount); - - TransferTestRunningUtilities.waitForTransferToRunOrTimeout( - conveyorService, TRANSFER_TIMEOUT); - - List transfers = conveyorService.getQueueManagerService() - .listAllTransfersInQueue(); - Assert.assertFalse("no transfers in queue", transfers.isEmpty()); - Assert.assertEquals("should be 1 transfer..maybe test cleanup is bad", - 1, transfers.size()); - transfer = transfers.get(0); - - transfer = conveyorService.getQueueManagerService() - .initializeGivenTransferByLoadingChildren(transfer); - - Assert.assertFalse("did not create a transfer attempt", transfer - .getTransferAttempts().isEmpty()); - - Assert.assertEquals("did not get complete status", - TransferStateEnum.COMPLETE, transfer.getTransferState()); - - TransferAttempt attempts[] = new TransferAttempt[transfer - .getTransferAttempts().size()]; - attempts = transfer.getTransferAttempts().toArray(attempts); - Assert.assertEquals("should be 1 attempt", 1, attempts.length); - - TransferAttempt attempt = attempts[0]; - Assert.assertNotNull("transfer attempt not persisted", attempt.getId()); - Assert.assertEquals("should have a status of error", - TransferStatusEnum.ERROR, attempt.getAttemptStatus()); - Assert.assertNotNull("null error message", attempt.getErrorMessage()); - Assert.assertEquals( - "missing the attempt creating the transfer process message", - TransferAccountingManagementService.ERROR_ATTEMPTING_TO_RUN, - attempt.getErrorMessage()); - Assert.assertNotNull("missing global exception", - attempt.getGlobalException()); - Assert.assertEquals("global exception message incorrect", "blah", - attempt.getGlobalException()); - Assert.assertNotNull("should be a stack trace, was null", - attempt.getGlobalExceptionStackTrace()); - Assert.assertFalse("empty stack trace", attempt - .getGlobalExceptionStackTrace().isEmpty()); - - } - - @Test - public void testProcessQueueOnStartupWithProcessingTransaction() - throws Exception { - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - - conveyorService.getConfigurationService().addConfigurationProperty( - logSuccessful); - - ConfigurationProperty logRestart = new ConfigurationProperty(); - logRestart - .setPropertyKey(ConfigurationPropertyConstants.LOG_RESTART_FILES); - logRestart.setPropertyValue("true"); - - conveyorService.getConfigurationService().addConfigurationProperty( - logRestart); - - String rootCollection = "testProcessQueueOnStartupWithProcessingTransaction"; - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - - IRODSFileFactory irodsFileFactory = irodsFileSystem - .getIRODSFileFactory(irodsAccount); - IRODSFile destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - File localFile = new File(localCollectionAbsolutePath); - - GridAccount gridAccount = conveyorService.getGridAccountService() - .findGridAccountByIRODSAccount(irodsAccount); - - Transfer transfer = new Transfer(); - transfer.setIrodsAbsolutePath(destFile.getAbsolutePath()); - transfer.setLocalAbsolutePath(localFile.getAbsolutePath()); - transfer.setTransferType(TransferType.PUT); - transfer.setTransferState(TransferStateEnum.PROCESSING); - transfer.setGridAccount(gridAccount); - transfer.setLastTransferStatus(TransferStatusEnum.OK); - - conveyorService.getQueueManagerService().saveOrUpdateTransfer(transfer); - - TransferAttempt attemptThatWasProcessing = new TransferAttempt(); - attemptThatWasProcessing.setAttemptStatus(TransferStatusEnum.OK); - conveyorService.getQueueManagerService().addTransferAttemptToTransfer( - transfer.getId(), attemptThatWasProcessing); - - // now simulate startup - conveyorService.getQueueManagerService().preprocessQueueAtStartup(); - conveyorService.beginFirstProcessAndRunPeriodicServiceInvocation(); - - TransferTestRunningUtilities.waitForTransferToRunOrTimeout( - conveyorService, TRANSFER_TIMEOUT); - - List transfers = conveyorService.getQueueManagerService() - .listAllTransfersInQueue(); - Assert.assertFalse("no transfers in queue", transfers.isEmpty()); - Assert.assertEquals("should be 1 transfer..maybe test cleanup is bad", - 1, transfers.size()); - transfer = transfers.get(0); - - transfer = conveyorService.getQueueManagerService() - .initializeGivenTransferByLoadingChildren(transfer); - - Assert.assertFalse("did not create a transfer attempt", transfer - .getTransferAttempts().isEmpty()); - - // I'll get a warning because there are no files, but it shows it was - // enqueued and processed - Assert.assertEquals( - "did not get warning status, it shold have been marked enqueued and subsequently dequeued and processed", - TransferStateEnum.COMPLETE, transfer.getTransferState()); - - TransferAttempt attempts[] = new TransferAttempt[transfer - .getTransferAttempts().size()]; - attempts = transfer.getTransferAttempts().toArray(attempts); - Assert.assertEquals("should be 2 attempts", 2, attempts.length); - - TransferAttempt attempt = attempts[0]; - Assert.assertEquals("did not set status to OK", TransferStatusEnum.OK, - attempt.getAttemptStatus()); - - attempt = attempts[1]; - // this is warning because there were no files in the test - Assert.assertEquals( - "did not set status to warning (meaining it was enqueued and processed", - TransferStatusEnum.WARNING, attempt.getAttemptStatus()); - Assert.assertEquals( - "did not set as restarted at startup", - TransferAttemptTypeEnum.RESTARTED_PROCESSING_TRANSFER_AT_STARTUP, - attempt.getTransferAttemptTypeEnum()); - - } - - @Test - public void testPurgeSuccessfulTransfers() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - - conveyorService.getConfigurationService().addConfigurationProperty( - logSuccessful); - - GridAccount gridAccount = conveyorService.getGridAccountService() - .findGridAccountByIRODSAccount(irodsAccount); - - Transfer transfer = new Transfer(); - transfer.setGridAccount(gridAccount); - transfer.setIrodsAbsolutePath("irods"); - transfer.setLocalAbsolutePath("local"); - transfer.setTransferType(TransferType.PUT); - transfer.setLastTransferStatus(TransferStatusEnum.OK); - transfer.setTransferState(TransferStateEnum.COMPLETE); - - conveyorService.getQueueManagerService().saveOrUpdateTransfer(transfer); - transfer = new Transfer(); - transfer.setGridAccount(gridAccount); - - transfer.setIrodsAbsolutePath("irods"); - transfer.setLocalAbsolutePath("local"); - transfer.setTransferType(TransferType.PUT); - transfer.setLastTransferStatus(TransferStatusEnum.OK); - transfer.setTransferState(TransferStateEnum.PROCESSING); - conveyorService.getQueueManagerService().saveOrUpdateTransfer(transfer); - - conveyorService.getQueueManagerService().purgeSuccessfulFromQueue(); - - List actual = conveyorService.getQueueManagerService() - .listAllTransfersInQueue(); - Assert.assertFalse("no transfers left in queue", actual.isEmpty()); - - } -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/BasicSynchronizationServiceImplTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/BasicSynchronizationServiceImplTest.java deleted file mode 100644 index 157c30784..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/BasicSynchronizationServiceImplTest.java +++ /dev/null @@ -1,465 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.basic; - -import java.io.File; -import java.util.Date; -import java.util.List; -import java.util.Properties; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.ConveyorExecutorService.RunningStatus; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.conveyor.core.SynchronizationManagerService; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.core.pub.io.IRODSFile; -import org.irods.jargon.core.pub.io.IRODSFileFactory; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.transfer.dao.domain.FrequencyType; -import org.irods.jargon.transfer.dao.domain.Synchronization; -import org.irods.jargon.transfer.dao.domain.SynchronizationType; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; - -/** - * @author Mike Conway - DICE (www.irods.org) - * - */ - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:transfer-dao-beans.xml", - "classpath:transfer-dao-hibernate-spring.cfg.xml" }) -@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true) -// @Transactional(propagation = Propagation.REQUIRED) -public class BasicSynchronizationServiceImplTest { - - private static Properties testingProperties = new Properties(); - private static org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - private static org.irods.jargon.testutils.filemanip.ScratchFileUtils scratchFileUtils = null; - public static final String IRODS_TEST_SUBDIR_PATH = "BasicSynchronizationServiceImplTest"; - private static org.irods.jargon.testutils.IRODSTestSetupUtilities irodsTestSetupUtilities = null; - - private static IRODSFileSystem irodsFileSystem = null; - - @Autowired - private ConveyorService conveyorService; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - irodsFileSystem = IRODSFileSystem.instance(); - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - scratchFileUtils = new org.irods.jargon.testutils.filemanip.ScratchFileUtils( - testingProperties); - scratchFileUtils - .clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH); - irodsTestSetupUtilities = new org.irods.jargon.testutils.IRODSTestSetupUtilities(); - irodsTestSetupUtilities.clearIrodsScratchDirectory(); - irodsTestSetupUtilities.initializeIrodsScratchDirectory(); - irodsTestSetupUtilities - .initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH); - } - - @Before - public void setUp() throws Exception { - conveyorService.setIrodsAccessObjectFactory(irodsFileSystem - .getIRODSAccessObjectFactory()); - conveyorService.getQueueManagerService().purgeAllFromQueue(); - conveyorService.getGridAccountService().resetPassPhraseAndAccounts(); - - } - - @After - public void tearDown() throws Exception { - conveyorService.getQueueManagerService().purgeAllFromQueue(); - } - - @Test - public void testWiredIntoConveyorService() throws Exception { - - SynchronizationManagerService actual = conveyorService - .getSynchronizationManagerService(); - Assert.assertNotNull("synch service not wired in", actual); - } - - @Test(expected = IllegalArgumentException.class) - public void testAddSynchronizationMissingSynch() throws Exception { - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - conveyorService.getSynchronizationManagerService() - .addOrUpdateSynchronization(null); - - } - - @Test - public void testAddSynchronization() throws Exception { - String rootCollection = "testAddSynchronization"; - - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - - IRODSFileSystem irodsFileSystem = IRODSFileSystem.instance(); - IRODSFileFactory irodsFileFactory = irodsFileSystem - .getIRODSFileFactory(irodsAccount); - IRODSFile destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - destFile.mkdirs(); - - File localFile = new File(localCollectionAbsolutePath); - localFile.mkdirs(); - - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - Synchronization synchronization = new Synchronization(); - Date now = new Date(); - synchronization.setCreatedAt(now); - synchronization.setFrequencyType(FrequencyType.EVERY_DAY); - synchronization.setGridAccount(conveyorService.getGridAccountService() - .findGridAccountByIRODSAccount(irodsAccount)); - synchronization.setIrodsSynchDirectory(destFile.getAbsolutePath()); - synchronization.setLocalSynchDirectory(localFile.getAbsolutePath()); - synchronization.setName(rootCollection); - synchronization - .setSynchronizationMode(SynchronizationType.ONE_WAY_IRODS_TO_LOCAL); - synchronization.setUpdatedAt(now); - conveyorService.getSynchronizationManagerService() - .addOrUpdateSynchronization(synchronization); - - Assert.assertNotNull("did not persist", synchronization.getId()); - - } - - @Test(expected = ConveyorExecutionException.class) - public void testAddSynchronizationNullIRODS() throws Exception { - String rootCollection = "testAddSynchronization"; - - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - - File localFile = new File(localCollectionAbsolutePath); - localFile.mkdirs(); - - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - Synchronization synchronization = new Synchronization(); - Date now = new Date(); - synchronization.setCreatedAt(now); - synchronization.setFrequencyType(FrequencyType.EVERY_DAY); - synchronization.setGridAccount(conveyorService.getGridAccountService() - .findGridAccountByIRODSAccount(irodsAccount)); - synchronization.setIrodsSynchDirectory(null); - synchronization.setLocalSynchDirectory(localFile.getAbsolutePath()); - synchronization.setName(rootCollection); - synchronization - .setSynchronizationMode(SynchronizationType.ONE_WAY_IRODS_TO_LOCAL); - synchronization.setUpdatedAt(now); - conveyorService.getSynchronizationManagerService() - .addOrUpdateSynchronization(synchronization); - } - - @Test(expected = ConveyorExecutionException.class) - public void testAddSynchronizationNullLocal() throws Exception { - String rootCollection = "testAddSynchronization"; - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - - IRODSFileSystem irodsFileSystem = IRODSFileSystem.instance(); - IRODSFileFactory irodsFileFactory = irodsFileSystem - .getIRODSFileFactory(irodsAccount); - IRODSFile destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - destFile.mkdirs(); - - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - Synchronization synchronization = new Synchronization(); - Date now = new Date(); - synchronization.setCreatedAt(now); - synchronization.setFrequencyType(FrequencyType.EVERY_DAY); - synchronization.setGridAccount(conveyorService.getGridAccountService() - .findGridAccountByIRODSAccount(irodsAccount)); - synchronization.setIrodsSynchDirectory(destFile.getAbsolutePath()); - synchronization.setLocalSynchDirectory(null); - synchronization.setName(rootCollection); - synchronization - .setSynchronizationMode(SynchronizationType.ONE_WAY_IRODS_TO_LOCAL); - synchronization.setUpdatedAt(now); - conveyorService.getSynchronizationManagerService() - .addOrUpdateSynchronization(synchronization); - - } - - @Test - public void testUpdateSynchronization() throws Exception { - String rootCollection = "testUpdateSynchronization"; - - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - - IRODSFileSystem irodsFileSystem = IRODSFileSystem.instance(); - IRODSFileFactory irodsFileFactory = irodsFileSystem - .getIRODSFileFactory(irodsAccount); - IRODSFile destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - destFile.mkdirs(); - - File localFile = new File(localCollectionAbsolutePath); - localFile.mkdirs(); - - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - Synchronization synchronization = new Synchronization(); - Date now = new Date(); - synchronization.setCreatedAt(now); - synchronization.setFrequencyType(FrequencyType.EVERY_DAY); - synchronization.setGridAccount(conveyorService.getGridAccountService() - .findGridAccountByIRODSAccount(irodsAccount)); - synchronization.setIrodsSynchDirectory(destFile.getAbsolutePath()); - synchronization.setLocalSynchDirectory(localFile.getAbsolutePath()); - synchronization.setName(rootCollection); - synchronization - .setSynchronizationMode(SynchronizationType.ONE_WAY_IRODS_TO_LOCAL); - synchronization.setUpdatedAt(now); - conveyorService.getSynchronizationManagerService() - .addOrUpdateSynchronization(synchronization); - - synchronization.setFrequencyType(FrequencyType.EVERY_WEEK); - conveyorService.getSynchronizationManagerService() - .addOrUpdateSynchronization(synchronization); - - Synchronization actual = conveyorService - .getSynchronizationManagerService().findById( - synchronization.getId()); - - Assert.assertNotNull("did not find", actual); - - } - - @Test - public void testListAll() throws Exception { - String rootCollection = "testListAll"; - - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - - IRODSFileSystem irodsFileSystem = IRODSFileSystem.instance(); - IRODSFileFactory irodsFileFactory = irodsFileSystem - .getIRODSFileFactory(irodsAccount); - IRODSFile destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - destFile.mkdirs(); - - File localFile = new File(localCollectionAbsolutePath); - localFile.mkdirs(); - - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - Synchronization synchronization = new Synchronization(); - Date now = new Date(); - synchronization.setCreatedAt(now); - synchronization.setFrequencyType(FrequencyType.EVERY_DAY); - synchronization.setGridAccount(conveyorService.getGridAccountService() - .findGridAccountByIRODSAccount(irodsAccount)); - synchronization.setIrodsSynchDirectory(destFile.getAbsolutePath()); - synchronization.setLocalSynchDirectory(localFile.getAbsolutePath()); - synchronization.setName(rootCollection); - synchronization - .setSynchronizationMode(SynchronizationType.ONE_WAY_IRODS_TO_LOCAL); - synchronization.setUpdatedAt(now); - conveyorService.getSynchronizationManagerService() - .addOrUpdateSynchronization(synchronization); - - List actual = conveyorService - .getSynchronizationManagerService().listAllSynchronizations(); - - Assert.assertFalse("no synchs listed", actual.isEmpty()); - - } - - @Test - public void testDeleteSynchronization() throws Exception { - String rootCollection = "testDeleteSynchronization"; - - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - - IRODSFileSystem irodsFileSystem = IRODSFileSystem.instance(); - IRODSFileFactory irodsFileFactory = irodsFileSystem - .getIRODSFileFactory(irodsAccount); - IRODSFile destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - destFile.mkdirs(); - - File localFile = new File(localCollectionAbsolutePath); - localFile.mkdirs(); - - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - Synchronization synchronization = new Synchronization(); - Date now = new Date(); - synchronization.setCreatedAt(now); - synchronization.setFrequencyType(FrequencyType.EVERY_DAY); - synchronization.setGridAccount(conveyorService.getGridAccountService() - .findGridAccountByIRODSAccount(irodsAccount)); - synchronization.setIrodsSynchDirectory(destFile.getAbsolutePath()); - synchronization.setLocalSynchDirectory(localFile.getAbsolutePath()); - synchronization.setName(rootCollection); - synchronization - .setSynchronizationMode(SynchronizationType.ONE_WAY_IRODS_TO_LOCAL); - synchronization.setUpdatedAt(now); - conveyorService.getSynchronizationManagerService() - .addOrUpdateSynchronization(synchronization); - - conveyorService.getSynchronizationManagerService() - .deleteSynchronization(synchronization); - - Synchronization actual = conveyorService - .getSynchronizationManagerService().findById( - synchronization.getId()); - - Assert.assertNull("did not delete", actual); - - } - - @Test - public void testEnqueueSynchronization() throws Exception { - String rootCollection = "testEnqueueSynchronization"; - - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - - IRODSFileSystem irodsFileSystem = IRODSFileSystem.instance(); - IRODSFileFactory irodsFileFactory = irodsFileSystem - .getIRODSFileFactory(irodsAccount); - IRODSFile destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - destFile.mkdirs(); - - File localFile = new File(localCollectionAbsolutePath); - localFile.mkdirs(); - - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - Synchronization synchronization = new Synchronization(); - Date now = new Date(); - synchronization.setCreatedAt(now); - synchronization.setFrequencyType(FrequencyType.EVERY_DAY); - synchronization.setGridAccount(conveyorService.getGridAccountService() - .findGridAccountByIRODSAccount(irodsAccount)); - synchronization.setIrodsSynchDirectory(destFile.getAbsolutePath()); - synchronization.setLocalSynchDirectory(localFile.getAbsolutePath()); - synchronization.setName(rootCollection); - synchronization - .setSynchronizationMode(SynchronizationType.ONE_WAY_LOCAL_TO_IRODS); - synchronization.setUpdatedAt(now); - conveyorService.getSynchronizationManagerService() - .addOrUpdateSynchronization(synchronization); - - Assert.assertNotNull("did not persist", synchronization.getId()); - - System.out.println("triggering"); - conveyorService.getSynchronizationManagerService() - .triggerSynchronizationNow(synchronization); - - Thread.sleep(1000); - - while (conveyorService.getConveyorExecutorService().getRunningStatus() != RunningStatus.IDLE) { - Thread.sleep(1000); - } - - Synchronization postSynch = conveyorService - .getSynchronizationManagerService().findById( - synchronization.getId()); - Assert.assertNotNull("did not get post synch data", postSynch); - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/ConfigurationServiceImplTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/ConfigurationServiceImplTest.java deleted file mode 100644 index 0d0938e9f..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/ConfigurationServiceImplTest.java +++ /dev/null @@ -1,265 +0,0 @@ -package org.irods.jargon.conveyor.basic; - -import java.util.Date; -import java.util.List; -import java.util.Properties; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.core.ConfigurationService; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.core.transfer.TransferControlBlock; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.transfer.dao.domain.ConfigurationProperty; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; -import org.springframework.transaction.annotation.Transactional; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:transfer-dao-beans.xml", - "classpath:transfer-dao-hibernate-spring.cfg.xml" }) -@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true) -@Transactional -public class ConfigurationServiceImplTest { - - @Autowired - private ConfigurationService configurationService; - - @SuppressWarnings("unused") - private static Properties testingProperties = new Properties(); - @SuppressWarnings("unused") - private static org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - private static IRODSFileSystem irodsFileSystem = null; - - @Autowired - private ConveyorService conveyorService; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - irodsFileSystem = IRODSFileSystem.instance(); - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - } - - @AfterClass - public static void tearDown() throws Exception { - irodsFileSystem.closeAndEatExceptions(); - } - - @Before - public void setUp() throws Exception { - conveyorService.setIrodsAccessObjectFactory(irodsFileSystem - .getIRODSAccessObjectFactory()); - conveyorService.getQueueManagerService().purgeAllFromQueue(); - conveyorService.getGridAccountService().resetPassPhraseAndAccounts(); - - } - - @Test - public void testListConfigurationProperties() throws Exception { - String testKey1 = "testAddConfigurationProperty1"; - String testKey2 = "testAddConfigurationProperty2"; - String testValue = "testAddConfigurationPropertyValue"; - ConfigurationProperty configProperty = new ConfigurationProperty(); - configProperty.setPropertyKey(testKey1); - configProperty.setPropertyValue(testValue); - configProperty.setCreatedAt(new Date()); - configurationService.addConfigurationProperty(configProperty); - - configProperty = new ConfigurationProperty(); - configProperty.setPropertyKey(testKey2); - configProperty.setPropertyValue(testValue); - configProperty.setCreatedAt(new Date()); - configurationService.addConfigurationProperty(configProperty); - - List configurationProperties = configurationService - .listConfigurationProperties(); - Assert.assertNotNull("null configurationProperties", - configurationProperties); - Assert.assertFalse("no props found", configurationProperties.isEmpty()); - - } - - @Test - public void testAddConfigurationProperty() throws Exception { - String testKey = "testAddConfigurationProperty"; - String testValue = "testAddConfigurationPropertyValue"; - ConfigurationProperty configProperty = new ConfigurationProperty(); - configProperty.setPropertyKey(testKey); - configProperty.setPropertyValue(testValue); - configProperty.setCreatedAt(new Date()); - ConfigurationProperty actual = configurationService - .addConfigurationProperty(configProperty); - Assert.assertNotNull("null configuration property", actual); - } - - @Test(expected = IllegalArgumentException.class) - public void testAddConfigurationPropertyBlankKey() throws Exception { - String testKey = ""; - String testValue = "testAddConfigurationPropertyValue"; - ConfigurationProperty configProperty = new ConfigurationProperty(); - configProperty.setPropertyKey(testKey); - configProperty.setPropertyValue(testValue); - configProperty.setCreatedAt(new Date()); - configurationService.addConfigurationProperty(configProperty); - } - - @Test(expected = IllegalArgumentException.class) - public void testAddConfigurationPropertNull() throws Exception { - configurationService.addConfigurationProperty(null); - } - - @Test - public void testDeleteConfigurationProperty() throws Exception { - String testKey = "testDeleteConfigurationProperty"; - String testValue = "testDeleteConfigurationPropertyValue"; - ConfigurationProperty configProperty = new ConfigurationProperty(); - configProperty.setPropertyKey(testKey); - configProperty.setPropertyValue(testValue); - configProperty.setCreatedAt(new Date()); - ConfigurationProperty actual = configurationService - .addConfigurationProperty(configProperty); - Assert.assertNotNull("null configuration property", actual); - configurationService.deleteConfigurationProperty(actual); - Assert.assertTrue(true); - } - - @Test(expected = IllegalArgumentException.class) - public void testDeleteConfigurationPropertyNull() throws Exception { - configurationService.deleteConfigurationProperty(null); - } - - @Test - public void testUpdateConfigurationProperty() throws Exception { - String testKey = "testUpdateConfigurationProperty"; - String testValue = "testUpdateConfigurationPropertyVal"; - String testUpdatedValue = "testUpdateConfigurationPropertyValUpdated"; - - ConfigurationProperty configProperty = new ConfigurationProperty(); - configProperty.setPropertyKey(testKey); - configProperty.setPropertyValue(testValue); - configProperty.setCreatedAt(new Date()); - ConfigurationProperty actual = configurationService - .addConfigurationProperty(configProperty); - Assert.assertNotNull("null configuration property", actual); - - actual.setPropertyValue(testUpdatedValue); - configurationService.updateConfigurationProperty(actual); - - // no error means success - Assert.assertTrue(true); - - } - - @Test - public void testFindConfigurationPropertyByKey() throws Exception { - String testKey = "testFindConfigurationPropertyByKeyProperty"; - String testValue = "testFindConfigurationPropertyByKeyVal"; - - ConfigurationProperty configProperty = new ConfigurationProperty(); - configProperty.setPropertyKey(testKey); - configProperty.setPropertyValue(testValue); - configProperty.setCreatedAt(new Date()); - configurationService.addConfigurationProperty(configProperty); - - ConfigurationProperty actual = configurationService - .findConfigurationPropertyByKey(testKey); - Assert.assertNotNull("did not find key for props just added", actual); - - } - - @Test(expected = IllegalArgumentException.class) - public void testFindConfigurationPropertyByKeyNull() throws Exception { - configurationService.findConfigurationPropertyByKey(null); - } - - @Test - public void testExportConfigurationProperties() throws Exception { - String testKey = "testGetConfigurationProperties"; - String testValue = "testGetConfigurationPropertiesPropertyValue"; - ConfigurationProperty configProperty = new ConfigurationProperty(); - configProperty.setPropertyKey(testKey); - configProperty.setPropertyValue(testValue); - configProperty.setCreatedAt(new Date()); - configurationService.addConfigurationProperty(configProperty); - Properties properties = configurationService.exportProperties(); - Assert.assertNotNull("null configuration properties retrieved", - properties); - String actual = properties.getProperty(testKey); - Assert.assertNotNull("test property not returned in properties", actual); - Assert.assertEquals("property value not set", testValue, actual); - } - - @Test - public void testImportConfigurationProperties() throws Exception { - Properties testProperties = new Properties(); - String testKey1 = "testAddConfigurationProperty1"; - String testKey2 = "testAddConfigurationProperty2"; - String testValue = "testAddConfigurationPropertyValue"; - - testProperties.put(testKey1, testValue); - testProperties.put(testKey2, testValue); - configurationService.importProperties(testProperties); - Properties properties = configurationService.exportProperties(); - Assert.assertNotNull("null configuration properties retrieved", - properties); - String actual = properties.getProperty(testKey1); - Assert.assertNotNull("test property not returned in properties", actual); - Assert.assertEquals("property value not set", testValue, actual); - - } - - @Test - public void testBuildTransferControlBlockNullPath() throws Exception { - TransferControlBlock actual = configurationService - .buildDefaultTransferControlBlockBasedOnConfiguration(null, - irodsFileSystem.getIRODSAccessObjectFactory()); - Assert.assertEquals("did not set restart", "", - actual.getRestartAbsolutePath()); - } - - @Test(expected = IllegalArgumentException.class) - public void testBuildTransferControlBlockNullAccessObjectFactory() - throws Exception { - configurationService - .buildDefaultTransferControlBlockBasedOnConfiguration("/path", - null); - } - - @Test - public void testBuildTransferControlBlock() throws Exception { - TransferControlBlock actual = configurationService - .buildDefaultTransferControlBlockBasedOnConfiguration("", - irodsFileSystem.getIRODSAccessObjectFactory()); - Assert.assertEquals("did not set restart", "", - actual.getRestartAbsolutePath()); - } - - @Test - public void testBuildTransferControlBlockWithRestart() throws Exception { - TransferControlBlock actual = configurationService - .buildDefaultTransferControlBlockBasedOnConfiguration( - "restart", - irodsFileSystem.getIRODSAccessObjectFactory()); - Assert.assertEquals("did not set restart", "restart", - actual.getRestartAbsolutePath()); - } - - public void setConfigurationService( - final ConfigurationService configurationService) { - this.configurationService = configurationService; - } - - public ConfigurationService getConfigurationService() { - return configurationService; - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/GridAccountServiceImplTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/GridAccountServiceImplTest.java deleted file mode 100644 index a60331761..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/GridAccountServiceImplTest.java +++ /dev/null @@ -1,386 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.basic; - -import java.util.List; -import java.util.Properties; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.ConveyorExecutorService; -import org.irods.jargon.conveyor.core.GridAccountService; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.transfer.dao.GridAccountDAO; -import org.irods.jargon.transfer.dao.domain.GridAccount; -import org.irods.jargon.transfer.exception.PassPhraseInvalidException; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; -import org.springframework.transaction.annotation.Transactional; - -/** - * @author Mike Conway - DICE (www.irods.org) - * - */ - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:transfer-dao-beans.xml", - "classpath:transfer-dao-hibernate-spring.cfg.xml" }) -@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true) -@Transactional -public class GridAccountServiceImplTest { - - private static Properties testingProperties = new Properties(); - private static org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - } - - @Before - public void before() throws Exception { - gridAccountService.resetPassPhraseAndAccounts(); - } - - @Autowired - private GridAccountService gridAccountService; - - @Test - public void testAddOrUpdateGridAccountBasedOnIRODSAccountWillBeAdd() - throws Exception { - String testUserName = "user1"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - String passPhrase = irodsAccount.getUserName(); - gridAccountService.validatePassPhrase(passPhrase); - GridAccount gridAccount = gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - Assert.assertEquals("wrong host", irodsAccount.getHost(), - gridAccount.getHost()); - Assert.assertEquals("wrong port", irodsAccount.getPort(), - gridAccount.getPort()); - Assert.assertEquals("wrong zone", irodsAccount.getZone(), - gridAccount.getZone()); - Assert.assertEquals("wrong user name", irodsAccount.getUserName(), - gridAccount.getUserName()); - } - - @Test(expected = IllegalArgumentException.class) - public void testAddOrUpdateGridAccountBasedOnIRODSAccountNullAccount() - throws Exception { - IRODSAccount irodsAccount = null; - String passPhrase = "ooogabooga"; - gridAccountService.validatePassPhrase(passPhrase); - gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - } - - @Test(expected = ConveyorExecutionException.class) - public void testAddOrUpdateGridAccountBasedOnIRODSAccountNotValidated() - throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, "test", "test"); - GridAccountServiceImpl gridAccountServiceTest = new GridAccountServiceImpl(); - GridAccountDAO gridAccountDAO = Mockito.mock(GridAccountDAO.class); - gridAccountServiceTest.setGridAccountDAO(gridAccountDAO); - ConveyorExecutorService conveyorExecutorService = Mockito - .mock(ConveyorExecutorService.class); - gridAccountServiceTest - .setConveyorExecutorService(conveyorExecutorService); - gridAccountServiceTest - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - } - - @Test - public void testAddOrUpdateGridAccountBasedOnIRODSAccountWillBeUpdate() - throws Exception { - String testUserName = "user1"; - String newResc = "newResc"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - String passPhrase = "ooogabooga"; - gridAccountService.validatePassPhrase(passPhrase); - GridAccount gridAccount = gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - irodsAccount = IRODSAccount.instance(irodsAccount.getHost(), - irodsAccount.getPort(), irodsAccount.getUserName(), - testUserName, "", irodsAccount.getZone(), newResc); - gridAccount = gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - Assert.assertEquals("did not update default resource", newResc, - gridAccount.getDefaultResource()); - } - - @Test - public void testRememberResource() throws Exception { - String testUserName = "user1"; - String newResc = "newResc"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - String passPhrase = "ooogabooga"; - gridAccountService.validatePassPhrase(passPhrase); - gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - gridAccountService - .rememberDefaultStorageResource(newResc, irodsAccount); - - GridAccount actual = gridAccountService - .findGridAccountByIRODSAccount(irodsAccount); - - Assert.assertEquals("did not update default resource", newResc, - actual.getDefaultResource()); - } - - @Test - public void testValidatePassPhraseWhenNoneThenRevalidateShouldBeGood() - throws Exception { - String passPhrase = "ooogabooga"; - gridAccountService.validatePassPhrase(passPhrase); - // revalidate - gridAccountService.validatePassPhrase(passPhrase); - } - - @Test(expected = PassPhraseInvalidException.class) - public void testValidatePassPhraseWhenInvalid() throws Exception { - String passPhrase = "ooogabooga"; - gridAccountService.validatePassPhrase(passPhrase); - gridAccountService.validatePassPhrase(passPhrase + "oogaooga"); - } - - @Test - public void testDeleteGridAccount() throws Exception { - String testUserName = "user1"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - String passPhrase = "ooogabooga"; - gridAccountService.validatePassPhrase(passPhrase); - GridAccount gridAccount = gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - gridAccountService.deleteGridAccount(gridAccount); - GridAccount lookedUp = gridAccountService - .findGridAccountByIRODSAccount(irodsAccount); - Assert.assertNull("should have deleted", lookedUp); - - } - - @Test - public void testDeleteGridAccountNotExists() throws Exception { - String testUserName = "user1"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - String passPhrase = "ooogabooga"; - gridAccountService.validatePassPhrase(passPhrase); - GridAccount gridAccount = new GridAccount(irodsAccount); - gridAccountService.deleteGridAccount(gridAccount); - - } - - @Test(expected = IllegalArgumentException.class) - public void testStorePassPhraseNull() throws Exception { - gridAccountService.changePassPhraseWhenAlreadyValidated(null); - } - - @Test(expected = IllegalArgumentException.class) - public void testStorePassPhraseBlank() throws Exception { - gridAccountService.changePassPhraseWhenAlreadyValidated(""); - } - - @Test(expected = IllegalArgumentException.class) - public void testDeleteGridAccountNullAccount() throws Exception { - String passPhrase = "ooogabooga"; - gridAccountService.validatePassPhrase(passPhrase); - GridAccount gridAccount = null; - gridAccountService.deleteGridAccount(gridAccount); - - } - - @Test(expected = IllegalArgumentException.class) - public void testFindGridAccountByIRODSAccountNull() throws Exception { - IRODSAccount irodsAccount = null; - String passPhrase = "ooogabooga"; - gridAccountService.validatePassPhrase(passPhrase); - gridAccountService.findGridAccountByIRODSAccount(irodsAccount); - - } - - @Test - public void testFindAll() throws Exception { - String testUserName = "user1"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - String testUserName2 = "user2"; - IRODSAccount irodsAccount2 = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName2, testUserName2); - String passPhrase = "ooogabooga"; - gridAccountService.validatePassPhrase(passPhrase); - gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount2); - - List actual = gridAccountService.findAll(); - Assert.assertEquals("did not get two accounts", 2, actual.size()); - - } - - @Test - public void testStorePassPhraseWithAlreadyCachedGridAccounts() - throws Exception { - String testUserName = "user1"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - String passPhrase = "ooogabooga"; - gridAccountService.validatePassPhrase(passPhrase); - gridAccountService.deleteAllGridAccounts(); - - gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - /* - * account added and encrypted, now store a new pass phrase and make - * sure I still can properly decrypt it - */ - passPhrase = "boogaoooga"; - gridAccountService.changePassPhraseWhenAlreadyValidated(passPhrase); - - List gridAccounts = gridAccountService.findAll(); - Assert.assertEquals("should be one account", 1, gridAccounts.size()); - IRODSAccount actual = gridAccountService - .irodsAccountForGridAccount(gridAccounts.get(0)); - Assert.assertEquals( - "did not properly decrypt password using new pass phrase", - actual.getPassword(), irodsAccount.getPassword()); - - } - - @Test(expected = PassPhraseInvalidException.class) - public void testChangePassPhraseWhenNotAlreadyValidated() throws Exception { - String passPhrase = "ooogabooga"; - GridAccountServiceImpl gridAccountServiceTest = new GridAccountServiceImpl(); - GridAccountDAO gridAccountDAO = Mockito.mock(GridAccountDAO.class); - gridAccountServiceTest.setGridAccountDAO(gridAccountDAO); - ConveyorExecutorService conveyorExecutorService = Mockito - .mock(ConveyorExecutorService.class); - gridAccountServiceTest - .setConveyorExecutorService(conveyorExecutorService); - gridAccountServiceTest.deleteAllGridAccounts(); - - gridAccountServiceTest.changePassPhraseWhenAlreadyValidated(passPhrase); - - } - - @Test(expected = IllegalArgumentException.class) - public void testValidateNullPassPhrase() throws Exception { - GridAccountService gridAccountServiceTest = new GridAccountServiceImpl(); - gridAccountServiceTest.validatePassPhrase(null); - - } - - @Test(expected = IllegalArgumentException.class) - public void testValidateBlankPassPhrase() throws Exception { - - gridAccountService.validatePassPhrase(""); - - } - - @Test(expected = IllegalArgumentException.class) - public void testReplacePassPhraseNull() throws Exception { - GridAccountService gridAccountServiceTest = new GridAccountServiceImpl(); - gridAccountServiceTest.changePassPhraseWhenAlreadyValidated(null); - } - - @Test(expected = ConveyorExecutionException.class) - public void testFindGridAccountForIRODSAccountNotValidated() - throws Exception { - GridAccountServiceImpl gridAccountServiceTest = new GridAccountServiceImpl(); - GridAccountDAO gridAccountDAO = Mockito.mock(GridAccountDAO.class); - gridAccountServiceTest.setGridAccountDAO(gridAccountDAO); - ConveyorExecutorService conveyorExecutorService = Mockito - .mock(ConveyorExecutorService.class); - gridAccountServiceTest - .setConveyorExecutorService(conveyorExecutorService); - String testUserName = "user1"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - gridAccountService.findGridAccountByIRODSAccount(irodsAccount); - - } - - @Test(expected = IllegalArgumentException.class) - public void testFindGridAccountForIRODSAccountNullAccount() - throws Exception { - GridAccountServiceImpl gridAccountServiceTest = new GridAccountServiceImpl(); - GridAccountDAO gridAccountDAO = Mockito.mock(GridAccountDAO.class); - gridAccountServiceTest.setGridAccountDAO(gridAccountDAO); - ConveyorExecutorService conveyorExecutorService = Mockito - .mock(ConveyorExecutorService.class); - gridAccountServiceTest - .setConveyorExecutorService(conveyorExecutorService); - gridAccountService.findGridAccountByIRODSAccount(null); - - } - - @Test - public void testReset() throws Exception { - String testUserName = "user1"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - String passPhrase = "ooogabooga"; - gridAccountService.validatePassPhrase(passPhrase); - gridAccountService.deleteAllGridAccounts(); - - gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - gridAccountService.resetPassPhraseAndAccounts(); - gridAccountService.findAll(); - - } - - @Test - public void testIsPassPhraseAlreadyStoredWhenAlreadyStored() - throws Exception { - - String passPhrase = "ooogabooga"; - gridAccountService.validatePassPhrase(passPhrase); - boolean actual = gridAccountService.isPassPhraseStoredAlready(); - Assert.assertTrue("should show pass phrase as already stored", actual); - - } - - @Test - public void testIsPassPhraseAlreadyStoredWhenNotAlreadyStored() - throws Exception { - - boolean actual = gridAccountService.isPassPhraseStoredAlready(); - Assert.assertFalse("should not show pass phrase as already stored", - actual); - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/TransferAccountingManagementServiceImplTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/TransferAccountingManagementServiceImplTest.java deleted file mode 100644 index f36079c9f..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/basic/TransferAccountingManagementServiceImplTest.java +++ /dev/null @@ -1,995 +0,0 @@ -package org.irods.jargon.conveyor.basic; - -import java.sql.Timestamp; -import java.util.List; -import java.util.Properties; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.core.ConfigurationPropertyConstants; -import org.irods.jargon.conveyor.core.ConfigurationService; -import org.irods.jargon.conveyor.core.ConveyorExecutionException; -import org.irods.jargon.conveyor.core.GridAccountService; -import org.irods.jargon.conveyor.core.QueueManagerService; -import org.irods.jargon.conveyor.core.RejectedTransferException; -import org.irods.jargon.conveyor.core.TransferAccountingManagementService; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.core.transfer.TransferStatus.TransferState; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.transfer.dao.TransferDAO; -import org.irods.jargon.transfer.dao.domain.ConfigurationProperty; -import org.irods.jargon.transfer.dao.domain.GridAccount; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.irods.jargon.transfer.dao.domain.TransferItem; -import org.irods.jargon.transfer.dao.domain.TransferStateEnum; -import org.irods.jargon.transfer.dao.domain.TransferStatusEnum; -import org.irods.jargon.transfer.dao.domain.TransferType; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; -import org.springframework.transaction.annotation.Transactional; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:transfer-dao-beans.xml", - "classpath:transfer-dao-hibernate-spring.cfg.xml" }) -@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true) -@Transactional -public class TransferAccountingManagementServiceImplTest { - private static Properties testingProperties = new Properties(); - private static org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - - @Autowired - private TransferAccountingManagementService transferAccountingManagementService; - - @Autowired - private QueueManagerService queueManagerService; - - @Autowired - private GridAccountService gridAccountService; - - @Autowired - private ConfigurationService configurationService; - - @Autowired - private TransferDAO transferDAO; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() throws Exception { - gridAccountService.resetPassPhraseAndAccounts(); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testPrepareNewTransferForProcessing() throws Exception { - String testUserName = "user1"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - String passPhrase = irodsAccount.getUserName(); - gridAccountService.validatePassPhrase(passPhrase); - GridAccount gridAccount = gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - Transfer transfer = new Transfer(); - transfer.setCreatedAt(new Timestamp(System.currentTimeMillis())); - transfer.setIrodsAbsolutePath("/path"); - transfer.setLocalAbsolutePath("local"); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - - TransferAttempt transferAttempt = transferAccountingManagementService - .prepareTransferForProcessing(transfer); - - Assert.assertNotNull("null transfer attempt", transferAttempt); - Assert.assertEquals(TransferStatusEnum.OK, - transfer.getLastTransferStatus()); - Assert.assertEquals("should have an enqueued state", - TransferStateEnum.ENQUEUED, transfer.getTransferState()); - Assert.assertFalse("no id set", transferAttempt.getId() == 0); - Assert.assertNotNull("no transfer parent in attempt", - transferAttempt.getTransfer()); - - Assert.assertNull("should be no start set for attempt", - transferAttempt.getAttemptStart()); - Assert.assertNull("should not be an end date for attempt", - transferAttempt.getAttemptEnd()); - Assert.assertNotNull("no transfer attempt status set", - transferAttempt.getAttemptStatus()); - Assert.assertEquals("should have ok for status in attempt", - TransferStatusEnum.OK, transferAttempt.getAttemptStatus()); - Assert.assertEquals("should have blank error message", "", - transferAttempt.getGlobalException()); - - } - - @Test - public void testUpdateTransferAttemptWithConveyorException() - throws Exception { - String testUserName = "user1"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - String passPhrase = irodsAccount.getUserName(); - gridAccountService.validatePassPhrase(passPhrase); - GridAccount gridAccount = gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - Transfer transfer = new Transfer(); - transfer.setCreatedAt(new Timestamp(System.currentTimeMillis())); - transfer.setIrodsAbsolutePath("/path"); - transfer.setLocalAbsolutePath("local"); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - - TransferAttempt transferAttempt = transferAccountingManagementService - .prepareTransferForProcessing(transfer); - - TransferAttempt transferAttemptExecution = transferAccountingManagementService - .prepareTransferForExecution(transferAttempt.getTransfer()); - transfer = transferAttempt.getTransfer(); - - Exception myException; - - try { - throw new JargonException("blah"); - } catch (JargonException je) { - myException = je; - } - - transferAccountingManagementService - .updateTransferAttemptWithConveyorException( - transferAttemptExecution, myException); - - Assert.assertNotNull("null transfer attempt", transferAttemptExecution); - Assert.assertEquals(TransferStatusEnum.ERROR, - transfer.getLastTransferStatus()); - - Assert.assertNotNull("should be an end date for attempt", - transferAttemptExecution.getAttemptEnd()); - Assert.assertNotNull("no transfer attempt status set", - transferAttemptExecution.getAttemptStatus()); - Assert.assertEquals("should have an error attempt status", - TransferStatusEnum.ERROR, - transferAttemptExecution.getAttemptStatus()); - Assert.assertEquals("should have error message", - TransferAccountingManagementService.ERROR_ATTEMPTING_TO_RUN, - transferAttemptExecution.getErrorMessage()); - Assert.assertEquals("should have global exception message", - myException.getMessage(), - transferAttemptExecution.getGlobalException()); - Assert.assertNotNull("should have stack trace info", - transferAttemptExecution.getGlobalExceptionStackTrace()); - Assert.assertFalse("empty stack trace", transferAttemptExecution - .getGlobalExceptionStackTrace().isEmpty()); - - } - - @Test - public void testUpdateTransferAttemptWithFailure() throws Exception { - String testUserName = "user1"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - String passPhrase = irodsAccount.getUserName(); - gridAccountService.validatePassPhrase(passPhrase); - GridAccount gridAccount = gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - Transfer transfer = new Transfer(); - transfer.setCreatedAt(new Timestamp(System.currentTimeMillis())); - transfer.setIrodsAbsolutePath("/path"); - transfer.setLocalAbsolutePath("local"); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - - TransferAttempt transferAttempt = transferAccountingManagementService - .prepareTransferForProcessing(transfer); - - TransferAttempt transferAttemptExecution = transferAccountingManagementService - .prepareTransferForExecution(transferAttempt.getTransfer()); - transfer = transferAttempt.getTransfer(); - - try { - throw new JargonException("blah"); - } catch (JargonException je) { - } - - org.irods.jargon.core.transfer.TransferStatus overallStatus = org.irods.jargon.core.transfer.TransferStatus - .instance( - org.irods.jargon.core.transfer.TransferStatus.TransferType.GET, - transfer.getIrodsAbsolutePath(), transfer - .getLocalAbsolutePath(), transfer - .getGridAccount().getDefaultResource(), 0L, 0L, - 0, 0, 0, TransferState.FAILURE, transfer - .getGridAccount().getHost(), transfer - .getGridAccount().getZone()); - - transferAccountingManagementService.updateTransferAfterOverallFailure( - overallStatus, transferAttemptExecution); - - Assert.assertNotNull("null transfer attempt", transferAttemptExecution); - Assert.assertEquals(TransferStatusEnum.ERROR, - transfer.getLastTransferStatus()); - - Assert.assertNotNull("should be an end date for attempt", - transferAttemptExecution.getAttemptEnd()); - Assert.assertNotNull("no transfer attempt status set", - transferAttemptExecution.getAttemptStatus()); - Assert.assertEquals("should have an error attempt status", - TransferStatusEnum.ERROR, - transferAttemptExecution.getAttemptStatus()); - - } - - @Test - public void testPrepareTransferForRestart() throws Exception { - String testUserName = "user1"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - String passPhrase = irodsAccount.getUserName(); - gridAccountService.validatePassPhrase(passPhrase); - GridAccount gridAccount = gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - configurationService.addConfigurationProperty(logSuccessful); - - ConfigurationProperty logRestart = new ConfigurationProperty(); - logRestart - .setPropertyKey(ConfigurationPropertyConstants.LOG_RESTART_FILES); - logRestart.setPropertyValue("true"); - configurationService.addConfigurationProperty(logRestart); - - Transfer transfer = new Transfer(); - transfer.setCreatedAt(new Timestamp(System.currentTimeMillis())); - transfer.setIrodsAbsolutePath("/path"); - transfer.setLocalAbsolutePath("/local"); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - - TransferAttempt transferAttempt = transferAccountingManagementService - .prepareTransferForProcessing(transfer); - transferAttempt = transferAccountingManagementService - .prepareTransferForExecution(transferAttempt.getTransfer()); - TransferStatus status = TransferStatus.instance( - TransferStatus.TransferType.PUT, "/local/1.txt", "/path", "", - 100L, 100L, 1, 0, 2, TransferState.IN_PROGRESS_COMPLETE_FILE, - irodsAccount.getHost(), irodsAccount.getZone()); - - transferAccountingManagementService - .updateTransferAfterSuccessfulFileTransfer(status, - transferAttempt); - - TransferAttempt attempts[] = new TransferAttempt[transfer - .getTransferAttempts().size()]; - attempts = transfer.getTransferAttempts().toArray(attempts); - - Assert.assertEquals(1, attempts.length); - TransferAttempt attemptWith1Successful = attempts[attempts.length - 1]; - - Assert.assertNull("should not be an end date for attempt", - attemptWith1Successful.getAttemptEnd()); - Assert.assertNotNull("no transfer attempt status set", - attemptWith1Successful.getAttemptStatus()); - Assert.assertEquals("should have an error attempt status", - TransferStatusEnum.OK, - attemptWith1Successful.getAttemptStatus()); - Assert.assertEquals("/local/1.txt", - attemptWith1Successful.getLastSuccessfulPath()); - Assert.assertEquals(1, - attemptWith1Successful.getTotalFilesTransferredSoFar()); - Assert.assertEquals(2, attemptWith1Successful.getTotalFilesCount()); - - // cause an error now after 1 file - JargonException myException; - try { - throw new JargonException("blah"); - } catch (JargonException je) { - myException = je; - } - - TransferStatus overallStatus = TransferStatus.instanceForException( - TransferStatus.TransferType.GET, transfer - .getIrodsAbsolutePath(), transfer - .getLocalAbsolutePath(), transfer.getGridAccount() - .getDefaultResource(), 0L, 0L, 0, 0, 0, myException, - irodsAccount.getHost(), irodsAccount.getZone()); - - transferAccountingManagementService.updateTransferAfterOverallFailure( - overallStatus, attemptWith1Successful); - - // now schedule a restart... - - transferAccountingManagementService - .prepareTransferForRestart(attemptWith1Successful.getTransfer() - .getId()); - - Assert.assertEquals("with restart, should have status enqueued", - TransferStateEnum.ENQUEUED, transfer.getTransferState()); - Assert.assertEquals("should have reset to transfer status of OK", - TransferStatusEnum.OK, transfer.getLastTransferStatus()); - - TransferAttempt[] attemptsAfterRestart = new TransferAttempt[transfer - .getTransferAttempts().size()]; - transfer.getTransferAttempts().toArray(attemptsAfterRestart); - - Assert.assertEquals(2, attemptsAfterRestart.length); - TransferAttempt restartAttempt = attemptsAfterRestart[attemptsAfterRestart.length - 1]; - - Assert.assertNull("should not be an end date for attempt", - restartAttempt.getAttemptEnd()); - Assert.assertNull("should not be a start date for attempt", - restartAttempt.getAttemptStart()); - Assert.assertNotNull("no transfer attempt status set", - restartAttempt.getAttemptStatus()); - Assert.assertEquals("should have an error attempt status", - TransferStatusEnum.OK, restartAttempt.getAttemptStatus()); - Assert.assertEquals("/local/1.txt", - restartAttempt.getLastSuccessfulPath()); - - } - - @Test(expected = RejectedTransferException.class) - public void testPrepareTransferForRestartBadId() throws Exception { - transferAccountingManagementService.prepareTransferForRestart(new Long( - -1000)); - } - - @Test(expected = IllegalArgumentException.class) - public void testPrepareTransferForExecutionNullTransfer() throws Exception { - transferAccountingManagementService.prepareTransferForExecution(null); - } - - @Test(expected = ConveyorExecutionException.class) - public void testPrepareTransferForExecutionNullIdInTransfer() - throws Exception { - Transfer transfer = new Transfer(); - transferAccountingManagementService - .prepareTransferForExecution(transfer); - } - - @Test(expected = ConveyorExecutionException.class) - public void testPrepareTransferForExecutionNoAttemptInTransfer() - throws Exception { - String testUserName = "test1"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - String passPhrase = irodsAccount.getUserName(); - gridAccountService.validatePassPhrase(passPhrase); - GridAccount gridAccount = gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - Transfer transfer = new Transfer(); - transfer.setGridAccount(gridAccount); - transfer.setIrodsAbsolutePath("x"); - transfer.setLocalAbsolutePath("blah"); - transfer.setTransferState(TransferStateEnum.ENQUEUED); - transfer.setTransferType(TransferType.PUT); - transferDAO.save(transfer); - transferAccountingManagementService - .prepareTransferForExecution(transfer); - } - - @Test(expected = IllegalArgumentException.class) - public void testUpdateTransferAfterSuccessfulFileTransferNullStatus() - throws Exception { - TransferAttempt transferAttempt = new TransferAttempt(); - transferAccountingManagementService - .updateTransferAfterSuccessfulFileTransfer(null, - transferAttempt); - } - - @Test(expected = IllegalArgumentException.class) - public void testUpdateTransferAfterSuccessfulFileTransferNullTransfer() - throws Exception { - TransferStatus transferStatus = Mockito.mock(TransferStatus.class); - transferAccountingManagementService - .updateTransferAfterSuccessfulFileTransfer(transferStatus, null); - } - - @Test - public void testUpdateTransferAfterOverallSuccess() throws Exception { - String testUserName = "user1"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - String passPhrase = irodsAccount.getUserName(); - gridAccountService.validatePassPhrase(passPhrase); - GridAccount gridAccount = gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - configurationService.addConfigurationProperty(logSuccessful); - - ConfigurationProperty logRestart = new ConfigurationProperty(); - logRestart - .setPropertyKey(ConfigurationPropertyConstants.LOG_RESTART_FILES); - logRestart.setPropertyValue("true"); - configurationService.addConfigurationProperty(logRestart); - - Transfer transfer = new Transfer(); - transfer.setCreatedAt(new Timestamp(System.currentTimeMillis())); - transfer.setIrodsAbsolutePath("/path"); - transfer.setLocalAbsolutePath("/local"); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - - TransferAttempt transferAttempt = transferAccountingManagementService - .prepareTransferForProcessing(transfer); - transferAttempt = transferAccountingManagementService - .prepareTransferForExecution(transferAttempt.getTransfer()); - TransferStatus status = TransferStatus.instance( - TransferStatus.TransferType.PUT, "/local/1.txt", "/path", "", - 100L, 100L, 1, 0, 2, TransferState.IN_PROGRESS_COMPLETE_FILE, - irodsAccount.getHost(), irodsAccount.getZone()); - - transferAccountingManagementService - .updateTransferAfterSuccessfulFileTransfer(status, - transferAttempt); - - TransferStatus overallSuccess = TransferStatus - .instance(TransferStatus.TransferType.PUT, "/", "/", "", 1L, - 1L, 1, 0, 1, - TransferStatus.TransferState.OVERALL_COMPLETION, - "host", "zone"); - - transferAccountingManagementService.updateTransferAfterOverallSuccess( - overallSuccess, transferAttempt); - Assert.assertEquals(TransferStatusEnum.OK, - transfer.getLastTransferStatus()); - - TransferAttempt[] attemptsAfterSuccess = new TransferAttempt[transfer - .getTransferAttempts().size()]; - transfer.getTransferAttempts().toArray(attemptsAfterSuccess); - - Assert.assertEquals(1, attemptsAfterSuccess.length); - TransferAttempt successfulAttempt = attemptsAfterSuccess[attemptsAfterSuccess.length - 1]; - - Assert.assertNotNull("should be an end date for attempt", - successfulAttempt.getAttemptEnd()); - Assert.assertNotNull("no transfer attempt status set", - successfulAttempt.getAttemptStatus()); - Assert.assertEquals("should have an error attempt status", - TransferStatusEnum.OK, successfulAttempt.getAttemptStatus()); - - } - - @Test - public void testUpdateTransferAfterOverallWarning() throws Exception { - String testUserName = "user1"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - String passPhrase = irodsAccount.getUserName(); - gridAccountService.validatePassPhrase(passPhrase); - GridAccount gridAccount = gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - configurationService.addConfigurationProperty(logSuccessful); - - ConfigurationProperty logRestart = new ConfigurationProperty(); - logRestart - .setPropertyKey(ConfigurationPropertyConstants.LOG_RESTART_FILES); - logRestart.setPropertyValue("true"); - configurationService.addConfigurationProperty(logRestart); - - Transfer transfer = new Transfer(); - transfer.setCreatedAt(new Timestamp(System.currentTimeMillis())); - transfer.setIrodsAbsolutePath("/path"); - transfer.setLocalAbsolutePath("/local"); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - - TransferAttempt transferAttempt = transferAccountingManagementService - .prepareTransferForProcessing(transfer); - transferAttempt = transferAccountingManagementService - .prepareTransferForExecution(transferAttempt.getTransfer()); - TransferStatus status = TransferStatus.instance( - TransferStatus.TransferType.PUT, "/local/1.txt", "/path", "", - 100L, 100L, 1, 0, 2, TransferState.IN_PROGRESS_COMPLETE_FILE, - irodsAccount.getHost(), irodsAccount.getZone()); - - transferAccountingManagementService - .updateTransferAfterSuccessfulFileTransfer(status, - transferAttempt); - - TransferStatus overallSuccess = TransferStatus - .instance(TransferStatus.TransferType.PUT, "/", "/", "", 1L, - 1L, 1, 0, 1, - TransferStatus.TransferState.OVERALL_COMPLETION, - "host", "zone"); - - transferAccountingManagementService - .updateTransferAfterOverallWarningByFileErrorThreshold( - overallSuccess, transferAttempt); - Assert.assertEquals(TransferStatusEnum.WARNING, - transfer.getLastTransferStatus()); - - TransferAttempt[] attemptsAfterSuccess = new TransferAttempt[transfer - .getTransferAttempts().size()]; - transfer.getTransferAttempts().toArray(attemptsAfterSuccess); - - Assert.assertEquals(1, attemptsAfterSuccess.length); - TransferAttempt successfulAttempt = attemptsAfterSuccess[attemptsAfterSuccess.length - 1]; - - Assert.assertNotNull("should be an end date for attempt", - successfulAttempt.getAttemptEnd()); - Assert.assertNotNull("no transfer attempt status set", - successfulAttempt.getAttemptStatus()); - Assert.assertEquals( - "shold have error message", - TransferAccountingManagementService.WARNING_SOME_FAILED_MESSAGE, - successfulAttempt.getErrorMessage()); - Assert.assertEquals("should have a warning attempt status", - TransferStatusEnum.WARNING, - successfulAttempt.getAttemptStatus()); - - } - - @Test - public void testUpdateTransferAfterOverallWarningNoFilesTransferred() - throws Exception { - String testUserName = "user1"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - String passPhrase = irodsAccount.getUserName(); - gridAccountService.validatePassPhrase(passPhrase); - GridAccount gridAccount = gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - configurationService.addConfigurationProperty(logSuccessful); - - ConfigurationProperty logRestart = new ConfigurationProperty(); - logRestart - .setPropertyKey(ConfigurationPropertyConstants.LOG_RESTART_FILES); - logRestart.setPropertyValue("true"); - configurationService.addConfigurationProperty(logRestart); - - Transfer transfer = new Transfer(); - transfer.setCreatedAt(new Timestamp(System.currentTimeMillis())); - transfer.setIrodsAbsolutePath("/path"); - transfer.setLocalAbsolutePath("/local"); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - - TransferAttempt transferAttempt = transferAccountingManagementService - .prepareTransferForProcessing(transfer); - transferAttempt = transferAccountingManagementService - .prepareTransferForExecution(transferAttempt.getTransfer()); - - TransferStatus overallSuccess = TransferStatus - .instance(TransferStatus.TransferType.PUT, "/", "/", "", 1L, - 1L, 1, 0, 1, - TransferStatus.TransferState.OVERALL_COMPLETION, - "host", "zone"); - - transferAccountingManagementService - .updateTransferAfterOverallWarningNoFilesTransferred( - overallSuccess, transferAttempt); - - Assert.assertEquals(TransferStatusEnum.WARNING, - transfer.getLastTransferStatus()); - - TransferAttempt[] attemptsAfterSuccess = new TransferAttempt[transfer - .getTransferAttempts().size()]; - transfer.getTransferAttempts().toArray(attemptsAfterSuccess); - - Assert.assertEquals(1, attemptsAfterSuccess.length); - TransferAttempt successfulAttempt = attemptsAfterSuccess[attemptsAfterSuccess.length - 1]; - - Assert.assertNotNull("should be an end date for attempt", - successfulAttempt.getAttemptEnd()); - Assert.assertNotNull("no transfer attempt status set", - successfulAttempt.getAttemptStatus()); - Assert.assertEquals( - "shold have error message", - TransferAccountingManagementService.WARNING_NO_FILES_TRANSFERRED_MESSAGE, - successfulAttempt.getErrorMessage()); - Assert.assertEquals("should have a warning attempt status", - TransferStatusEnum.WARNING, - successfulAttempt.getAttemptStatus()); - - } - - @Test - public void testUpdateTransferAfterOverallFailure() throws Exception { - String testUserName = "user1"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - String passPhrase = irodsAccount.getUserName(); - gridAccountService.validatePassPhrase(passPhrase); - GridAccount gridAccount = gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - configurationService.addConfigurationProperty(logSuccessful); - - ConfigurationProperty logRestart = new ConfigurationProperty(); - logRestart - .setPropertyKey(ConfigurationPropertyConstants.LOG_RESTART_FILES); - logRestart.setPropertyValue("true"); - configurationService.addConfigurationProperty(logRestart); - - Transfer transfer = new Transfer(); - transfer.setCreatedAt(new Timestamp(System.currentTimeMillis())); - transfer.setIrodsAbsolutePath("/path"); - transfer.setLocalAbsolutePath("/local"); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - - TransferAttempt transferAttempt = transferAccountingManagementService - .prepareTransferForProcessing(transfer); - transferAttempt = transferAccountingManagementService - .prepareTransferForExecution(transferAttempt.getTransfer()); - TransferStatus status = TransferStatus.instance( - TransferStatus.TransferType.PUT, "/local/1.txt", "/path", "", - 100L, 100L, 1, 0, 2, TransferState.IN_PROGRESS_COMPLETE_FILE, - irodsAccount.getHost(), irodsAccount.getZone()); - - transferAccountingManagementService - .updateTransferAfterSuccessfulFileTransfer(status, - transferAttempt); - - TransferStatus overallSuccess = TransferStatus - .instance(TransferStatus.TransferType.PUT, "/", "/", "", 1L, - 1L, 1, 0, 1, - TransferStatus.TransferState.OVERALL_COMPLETION, - "host", "zone"); - - transferAccountingManagementService - .updateTransferAfterOverallFailureByFileErrorThreshold( - overallSuccess, transferAttempt); - Assert.assertEquals(TransferStatusEnum.ERROR, - transfer.getLastTransferStatus()); - - TransferAttempt[] attemptsAfterSuccess = new TransferAttempt[transfer - .getTransferAttempts().size()]; - transfer.getTransferAttempts().toArray(attemptsAfterSuccess); - - Assert.assertEquals(1, attemptsAfterSuccess.length); - TransferAttempt successfulAttempt = attemptsAfterSuccess[attemptsAfterSuccess.length - 1]; - - Assert.assertNotNull("should be an end date for attempt", - successfulAttempt.getAttemptEnd()); - Assert.assertNotNull("no transfer attempt status set", - successfulAttempt.getAttemptStatus()); - Assert.assertEquals("shold have error message", - TransferAccountingManagementService.ERROR_SOME_FAILED_MESSAGE, - successfulAttempt.getErrorMessage()); - Assert.assertEquals("should have a warning attempt status", - TransferStatusEnum.ERROR, successfulAttempt.getAttemptStatus()); - - } - - @Test - public void testUpdateTransferAfterOverallCancel() throws Exception { - String testUserName = "user1"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - String passPhrase = irodsAccount.getUserName(); - gridAccountService.validatePassPhrase(passPhrase); - GridAccount gridAccount = gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - configurationService.addConfigurationProperty(logSuccessful); - - ConfigurationProperty logRestart = new ConfigurationProperty(); - logRestart - .setPropertyKey(ConfigurationPropertyConstants.LOG_RESTART_FILES); - logRestart.setPropertyValue("true"); - configurationService.addConfigurationProperty(logRestart); - - Transfer transfer = new Transfer(); - transfer.setCreatedAt(new Timestamp(System.currentTimeMillis())); - transfer.setIrodsAbsolutePath("/path"); - transfer.setLocalAbsolutePath("/local"); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - - TransferAttempt transferAttempt = transferAccountingManagementService - .prepareTransferForProcessing(transfer); - transferAttempt = transferAccountingManagementService - .prepareTransferForExecution(transferAttempt.getTransfer()); - TransferStatus status = TransferStatus.instance( - TransferStatus.TransferType.PUT, "/local/1.txt", "/path", "", - 100L, 100L, 1, 0, 2, TransferState.IN_PROGRESS_COMPLETE_FILE, - irodsAccount.getHost(), irodsAccount.getZone()); - - transferAccountingManagementService - .updateTransferAfterSuccessfulFileTransfer(status, - transferAttempt); - - transferAccountingManagementService - .updateTransferAfterCancellation(transferAttempt); - - Assert.assertEquals(TransferStatusEnum.OK, - transfer.getLastTransferStatus()); - - TransferAttempt[] attemptsAfterSuccess = new TransferAttempt[transfer - .getTransferAttempts().size()]; - transfer.getTransferAttempts().toArray(attemptsAfterSuccess); - - Assert.assertEquals(1, attemptsAfterSuccess.length); - TransferAttempt successfulAttempt = attemptsAfterSuccess[attemptsAfterSuccess.length - 1]; - - Assert.assertNotNull("should be an end date for attempt", - successfulAttempt.getAttemptEnd()); - Assert.assertNotNull("no transfer attempt status set", - successfulAttempt.getAttemptStatus()); - Assert.assertEquals("shold have error message", - TransferAccountingManagementService.WARNING_CANCELLED_MESSAGE, - successfulAttempt.getErrorMessage()); - Assert.assertEquals("should have a warning attempt status", - TransferStatusEnum.OK, successfulAttempt.getAttemptStatus()); - - } - - @Test - public void testUpdateTransferAfterRestartFileSkipped() throws Exception { - String testUserName = "user1"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - String passPhrase = irodsAccount.getUserName(); - gridAccountService.validatePassPhrase(passPhrase); - GridAccount gridAccount = gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - configurationService.addConfigurationProperty(logSuccessful); - - ConfigurationProperty logRestart = new ConfigurationProperty(); - logRestart - .setPropertyKey(ConfigurationPropertyConstants.LOG_RESTART_FILES); - logRestart.setPropertyValue("true"); - configurationService.addConfigurationProperty(logRestart); - - Transfer transfer = new Transfer(); - transfer.setCreatedAt(new Timestamp(System.currentTimeMillis())); - transfer.setIrodsAbsolutePath("/path"); - transfer.setLocalAbsolutePath("/local"); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - - TransferAttempt transferAttempt = transferAccountingManagementService - .prepareTransferForProcessing(transfer); - transferAttempt = transferAccountingManagementService - .prepareTransferForExecution(transferAttempt.getTransfer()); - TransferStatus status = TransferStatus.instance( - TransferStatus.TransferType.PUT, "/local/1.txt", "/path", "", - 100L, 100L, 1, 0, 2, TransferState.IN_PROGRESS_COMPLETE_FILE, - irodsAccount.getHost(), irodsAccount.getZone()); - - transferAccountingManagementService - .updateTransferAfterSuccessfulFileTransfer(status, - transferAttempt); - - TransferAttempt attempts[] = new TransferAttempt[transfer - .getTransferAttempts().size()]; - attempts = transfer.getTransferAttempts().toArray(attempts); - - Assert.assertEquals(1, attempts.length); - TransferAttempt attemptWith1Successful = attempts[attempts.length - 1]; - - Assert.assertNull("should not be an end date for attempt", - attemptWith1Successful.getAttemptEnd()); - Assert.assertNotNull("no transfer attempt status set", - attemptWith1Successful.getAttemptStatus()); - Assert.assertEquals("should have an error attempt status", - TransferStatusEnum.OK, - attemptWith1Successful.getAttemptStatus()); - Assert.assertEquals("/local/1.txt", - attemptWith1Successful.getLastSuccessfulPath()); - Assert.assertEquals(1, - attemptWith1Successful.getTotalFilesTransferredSoFar()); - Assert.assertEquals(2, attemptWith1Successful.getTotalFilesCount()); - - // cause an error now after 1 file - JargonException myException; - try { - throw new JargonException("blah"); - } catch (JargonException je) { - myException = je; - } - - TransferStatus overallStatus = TransferStatus.instanceForException( - TransferStatus.TransferType.GET, transfer - .getIrodsAbsolutePath(), transfer - .getLocalAbsolutePath(), transfer.getGridAccount() - .getDefaultResource(), 0L, 0L, 0, 0, 0, myException, - irodsAccount.getHost(), irodsAccount.getZone()); - - transferAccountingManagementService.updateTransferAfterOverallFailure( - overallStatus, attemptWith1Successful); - - // now schedule a restart... - - transferAccountingManagementService - .prepareTransferForRestart(attemptWith1Successful.getTransfer() - .getId()); - - Assert.assertEquals("with restart, should have status enqueued", - TransferStateEnum.ENQUEUED, transfer.getTransferState()); - Assert.assertEquals("should have reset to transfer status of OK", - TransferStatusEnum.OK, transfer.getLastTransferStatus()); - - TransferAttempt[] attemptsAfterRestart = new TransferAttempt[transfer - .getTransferAttempts().size()]; - transfer.getTransferAttempts().toArray(attemptsAfterRestart); - - Assert.assertEquals(2, attemptsAfterRestart.length); - TransferAttempt restartAttempt = attemptsAfterRestart[attemptsAfterRestart.length - 1]; - - Assert.assertNull("should not be an end date for attempt", - restartAttempt.getAttemptEnd()); - Assert.assertNull("should not be a start date for attempt", - restartAttempt.getAttemptStart()); - Assert.assertNotNull("no transfer attempt status set", - restartAttempt.getAttemptStatus()); - Assert.assertEquals("should have an OK attempt status", - TransferStatusEnum.OK, restartAttempt.getAttemptStatus()); - Assert.assertEquals("/local/1.txt", - restartAttempt.getLastSuccessfulPath()); - - // now show the transfer as executing - transferAccountingManagementService - .prepareTransferForExecution(restartAttempt.getTransfer()); - - // now show skipping the first file - status = TransferStatus.instance(TransferStatus.TransferType.PUT, - "/local/1.txt", "/path", "", 100L, 100L, 1, 0, 2, - TransferState.RESTARTING, irodsAccount.getHost(), - irodsAccount.getZone()); - - // HERE!!!!!! - transferAccountingManagementService - .updateTransferAfterRestartFileSkipped(status, restartAttempt); - - // this should show up under the transfer attempt as a successful, - // skipped file - - TransferItem[] itemsAfterRestart = new TransferItem[restartAttempt - .getTransferItems().size()]; - restartAttempt.getTransferItems().toArray(itemsAfterRestart); - - Assert.assertEquals(1, itemsAfterRestart.length); - TransferItem restartedItem = itemsAfterRestart[itemsAfterRestart.length - 1]; - Assert.assertNotNull("null transfer item", restartedItem); - Assert.assertEquals("did not set source path", - status.getSourceFileAbsolutePath(), - restartedItem.getSourceFileAbsolutePath()); - Assert.assertEquals(status.getTargetFileAbsolutePath(), - restartedItem.getTargetFileAbsolutePath()); - Assert.assertEquals("should not be flagged as an error", false, - restartedItem.isError()); - Assert.assertEquals("should be flagged as a restart", true, - restartedItem.isSkipped()); - - } - - @Test - public void testUpdateTransferAfterFailedFileTransfer() throws Exception { - String testUserName = "user1"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, testUserName, testUserName); - String passPhrase = irodsAccount.getUserName(); - gridAccountService.validatePassPhrase(passPhrase); - GridAccount gridAccount = gridAccountService - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - configurationService.addConfigurationProperty(logSuccessful); - - ConfigurationProperty logRestart = new ConfigurationProperty(); - logRestart - .setPropertyKey(ConfigurationPropertyConstants.LOG_RESTART_FILES); - logRestart.setPropertyValue("true"); - configurationService.addConfigurationProperty(logRestart); - - Transfer transfer = new Transfer(); - transfer.setCreatedAt(new Timestamp(System.currentTimeMillis())); - transfer.setIrodsAbsolutePath("/path"); - transfer.setLocalAbsolutePath("/local"); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - - TransferAttempt transferAttempt = transferAccountingManagementService - .prepareTransferForProcessing(transfer); - transferAttempt = transferAccountingManagementService - .prepareTransferForExecution(transferAttempt.getTransfer()); - - // cause an error now after 1 file - JargonException myException; - try { - throw new JargonException("blah"); - } catch (JargonException je) { - myException = je; - } - - TransferStatus status = TransferStatus.instanceForException( - TransferStatus.TransferType.GET, transfer - .getIrodsAbsolutePath(), transfer - .getLocalAbsolutePath(), transfer.getGridAccount() - .getDefaultResource(), 0L, 0L, 0, 0, 0, myException, - irodsAccount.getHost(), irodsAccount.getZone()); - - transferAccountingManagementService - .updateTransferAfterFailedFileTransfer(status, transferAttempt, - 1); - - List transferItems = transferAttempt.getTransferItems(); - TransferItem failureItem = transferItems.get(0); - Assert.assertFalse("no transfer items", transferItems.isEmpty()); - Assert.assertEquals("should have transfer type of PUT", - TransferType.PUT, failureItem.getTransferType()); - Assert.assertEquals("wrong source path", - status.getSourceFileAbsolutePath(), - failureItem.getSourceFileAbsolutePath()); - Assert.assertEquals("wrong target path", - status.getTargetFileAbsolutePath(), - failureItem.getTargetFileAbsolutePath()); - Assert.assertEquals("did not set exception message", - myException.getMessage(), failureItem.getErrorMessage()); - Assert.assertFalse("did not fill in stack trace", failureItem - .getErrorStackTrace().isEmpty()); - Assert.assertTrue("should be marked as an error", failureItem.isError()); - - } -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/core/ConveyorExecutorServiceImplFunctionalTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/core/ConveyorExecutorServiceImplFunctionalTest.java deleted file mode 100644 index a4c3113d7..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/core/ConveyorExecutorServiceImplFunctionalTest.java +++ /dev/null @@ -1,607 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.core; - -import java.io.File; -import java.util.List; -import java.util.Properties; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.unittest.utils.TransferTestRunningUtilities; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.pub.DataTransferOperations; -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.core.pub.io.IRODSFile; -import org.irods.jargon.core.pub.io.IRODSFileFactory; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.testutils.filemanip.FileGenerator; -import org.irods.jargon.transfer.dao.domain.ConfigurationProperty; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.irods.jargon.transfer.dao.domain.TransferStateEnum; -import org.irods.jargon.transfer.dao.domain.TransferStatusEnum; -import org.irods.jargon.transfer.dao.domain.TransferType; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; - -/** - * Functional tests for conveyor service - * - * @author Mike Conway - DICE (www.irods.org) see - * https://code.renci.org/gf/project/jargon/ - * - */ - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:transfer-dao-beans.xml", - "classpath:transfer-dao-hibernate-spring.cfg.xml" }) -@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false) -public class ConveyorExecutorServiceImplFunctionalTest { - private static Properties testingProperties = new Properties(); - private static org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - private static org.irods.jargon.testutils.filemanip.ScratchFileUtils scratchFileUtils = null; - public static final String IRODS_TEST_SUBDIR_PATH = "ConveyorExecutorServiceImplFunctionalTest"; - private static org.irods.jargon.testutils.IRODSTestSetupUtilities irodsTestSetupUtilities = null; - private static IRODSFileSystem irodsFileSystem = null; - private static int TRANSFER_TIMEOUT = -1; - - @Autowired - private ConveyorService conveyorService; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - irodsFileSystem = IRODSFileSystem.instance(); - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - scratchFileUtils = new org.irods.jargon.testutils.filemanip.ScratchFileUtils( - testingProperties); - scratchFileUtils - .clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH); - irodsTestSetupUtilities = new org.irods.jargon.testutils.IRODSTestSetupUtilities(); - irodsTestSetupUtilities.clearIrodsScratchDirectory(); - irodsTestSetupUtilities.initializeIrodsScratchDirectory(); - irodsTestSetupUtilities - .initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH); - } - - @Before - public void setUp() throws Exception { - conveyorService.setIrodsAccessObjectFactory(irodsFileSystem - .getIRODSAccessObjectFactory()); - conveyorService.getQueueManagerService().purgeAllFromQueue(); - conveyorService.getConveyorExecutorService().setOperationCompleted(); - conveyorService.getGridAccountService().resetPassPhraseAndAccounts(); - - } - - @After - public void tearDown() throws Exception { - conveyorService.getQueueManagerService().purgeAllFromQueue(); - } - - /** - * Do a put, cancel partway through - * - * @throws Exception - */ - @Ignore - // FIXME: check this one out later, hibernate lock error? Might be timing... - public void testPutWithCancellation() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - - conveyorService.getConfigurationService().addConfigurationProperty( - logSuccessful); - - String rootCollection = "testEnqueuePutTransferOperationAndWaitUntilDone"; - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - - FileGenerator - .generateManyFilesAndCollectionsInParentCollectionByAbsolutePath( - localCollectionAbsolutePath, - "testEnqueuePutTransferOperationAndWaitUntilDone", 2, - 5, 2, "testFile", ".txt", 10, 5, 100, 2000); - - IRODSFileFactory irodsFileFactory = irodsFileSystem - .getIRODSFileFactory(irodsAccount); - IRODSFile destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - File localFile = new File(localCollectionAbsolutePath); - - Transfer transfer = new Transfer(); - transfer.setIrodsAbsolutePath(destFile.getAbsolutePath()); - transfer.setLocalAbsolutePath(localFile.getAbsolutePath()); - transfer.setTransferType(TransferType.PUT); - - conveyorService.getQueueManagerService().enqueueTransferOperation( - transfer, irodsAccount); - - TransferTestRunningUtilities.waitForTransferToTransferNFiles( - conveyorService, TRANSFER_TIMEOUT, 15); - conveyorService.getConveyorExecutorService().requestCancel( - conveyorService.getConveyorExecutorService() - .getCurrentTransferAttempt()); - - List transfers = conveyorService.getQueueManagerService() - .listAllTransfersInQueue(); - Assert.assertFalse("no transfers in queue", transfers.isEmpty()); - Assert.assertEquals("should be 1 transfer..maybe test cleanup is bad", - 1, transfers.size()); - transfer = transfers.get(0); - - transfer = conveyorService.getQueueManagerService() - .initializeGivenTransferByLoadingChildren(transfer); - - Assert.assertFalse("did not create a transfer attempt", transfer - .getTransferAttempts().isEmpty()); - - Assert.assertEquals("did not get complete status", - TransferStateEnum.CANCELLED, transfer.getTransferState()); - - TransferAttempt attempts[] = new TransferAttempt[transfer - .getTransferAttempts().size()]; - attempts = transfer.getTransferAttempts().toArray(attempts); - Assert.assertEquals("should be 1 attempt", 1, attempts.length); - - TransferAttempt attempt = attempts[0]; - Assert.assertNotNull("transfer attempt not persisted", attempt.getId()); - Assert.assertEquals("did not set cancelled message", - TransferAccountingManagementService.WARNING_CANCELLED_MESSAGE, - attempt.getErrorMessage()); - } - - /** - * do a get of a nested collection that should be 'normal' - * - * @throws Exception - */ - @Test - public void testGetNestedCollection() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - - conveyorService.getConfigurationService().addConfigurationProperty( - logSuccessful); - - String rootCollection = "testGetWithCancellation"; - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - String localCollectionReturnAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection + "return"); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - - FileGenerator - .generateManyFilesAndCollectionsInParentCollectionByAbsolutePath( - localCollectionAbsolutePath, - "testEnqueuePutTransferOperationAndWaitUntilDone", 2, - 5, 2, "testFile", ".txt", 10, 5, 100, 2000); - - IRODSFileFactory irodsFileFactory = irodsFileSystem - .getIRODSFileFactory(irodsAccount); - IRODSFile destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - File localFile = new File(localCollectionAbsolutePath); - File localReturnFile = new File(localCollectionReturnAbsolutePath); - - DataTransferOperations dto = irodsFileSystem - .getIRODSAccessObjectFactory().getDataTransferOperations( - irodsAccount); - - dto.putOperation(localFile, destFile, null, null); - - Transfer transfer = new Transfer(); - transfer.setIrodsAbsolutePath(destFile.getAbsolutePath()); - transfer.setLocalAbsolutePath(localReturnFile.getAbsolutePath()); - transfer.setTransferType(TransferType.GET); - - conveyorService.getQueueManagerService().enqueueTransferOperation( - transfer, irodsAccount); - - TransferTestRunningUtilities.waitForTransferToRunOrTimeout( - conveyorService, TRANSFER_TIMEOUT); - - List transfers = conveyorService.getQueueManagerService() - .listAllTransfersInQueue(); - Assert.assertFalse("no transfers in queue", transfers.isEmpty()); - Assert.assertEquals("should be 1 transfer..maybe test cleanup is bad", - 1, transfers.size()); - transfer = transfers.get(0); - - transfer = conveyorService.getQueueManagerService() - .initializeGivenTransferByLoadingChildren(transfer); - - Assert.assertFalse("did not create a transfer attempt", transfer - .getTransferAttempts().isEmpty()); - - Assert.assertEquals("did not get complete status", - TransferStateEnum.COMPLETE, transfer.getTransferState()); - - TransferAttempt attempts[] = new TransferAttempt[transfer - .getTransferAttempts().size()]; - attempts = transfer.getTransferAttempts().toArray(attempts); - Assert.assertEquals("should be 1 attempt", 1, attempts.length); - - TransferAttempt attempt = attempts[0]; - Assert.assertNotNull("transfer attempt not persisted", attempt.getId()); - - } - - @Test - public void testGetSingleFile() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - - conveyorService.getConfigurationService().addConfigurationProperty( - logSuccessful); - - String testFileName = "test.file"; - String rootCollection = "testGetSingleFile"; - String localCollectionReturnAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection + "return"); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - - String absPath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH); - - FileGenerator.generateFileOfFixedLengthGivenName(absPath, testFileName, - 3); - - File localFile = new File(absPath, testFileName); - - IRODSFileFactory irodsFileFactory = irodsFileSystem - .getIRODSFileFactory(irodsAccount); - IRODSFile destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - File localReturnFile = new File(localCollectionReturnAbsolutePath); - - DataTransferOperations dto = irodsFileSystem - .getIRODSAccessObjectFactory().getDataTransferOperations( - irodsAccount); - - dto.putOperation(localFile, destFile, null, null); - - destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath + "/" - + testFileName); - - Transfer transfer = new Transfer(); - transfer.setIrodsAbsolutePath(destFile.getAbsolutePath()); - transfer.setLocalAbsolutePath(localReturnFile.getAbsolutePath()); - transfer.setTransferType(TransferType.GET); - - conveyorService.getQueueManagerService().enqueueTransferOperation( - transfer, irodsAccount); - - TransferTestRunningUtilities.waitForTransferToRunOrTimeout( - conveyorService, TRANSFER_TIMEOUT); - - List transfers = conveyorService.getQueueManagerService() - .listAllTransfersInQueue(); - Assert.assertFalse("no transfers in queue", transfers.isEmpty()); - Assert.assertEquals("should be 1 transfer..maybe test cleanup is bad", - 1, transfers.size()); - transfer = transfers.get(0); - - transfer = conveyorService.getQueueManagerService() - .initializeGivenTransferByLoadingChildren(transfer); - - Assert.assertFalse("did not create a transfer attempt", transfer - .getTransferAttempts().isEmpty()); - - Assert.assertEquals("did not get complete status", - TransferStateEnum.COMPLETE, transfer.getTransferState()); - - TransferAttempt attempts[] = new TransferAttempt[transfer - .getTransferAttempts().size()]; - attempts = transfer.getTransferAttempts().toArray(attempts); - Assert.assertEquals("should be 1 attempt", 1, attempts.length); - - TransferAttempt attempt = attempts[0]; - Assert.assertNotNull("transfer attempt not persisted", attempt.getId()); - - } - - /** - * do a get of a nested collection that should be 'normal' - * - * @throws Exception - */ - @Test - public void testCopyNestedCollection() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - - conveyorService.getConfigurationService().addConfigurationProperty( - logSuccessful); - - String rootCollection = "testCopyNestedCollection"; - String targetCollection = "testCopyNestedCollectionTarget"; - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - - String irodsCopySourceAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH + "/" - + rootCollection); - - String irodsCopyTargetAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH + "/" - + targetCollection); - - FileGenerator - .generateManyFilesAndCollectionsInParentCollectionByAbsolutePath( - localCollectionAbsolutePath, - "testEnqueuePutTransferOperationAndWaitUntilDone", 2, - 5, 2, "testFile", ".txt", 10, 5, 100, 2000); - - IRODSFileFactory irodsFileFactory = irodsFileSystem - .getIRODSFileFactory(irodsAccount); - IRODSFile destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - File localFile = new File(localCollectionAbsolutePath); - - DataTransferOperations dto = irodsFileSystem - .getIRODSAccessObjectFactory().getDataTransferOperations( - irodsAccount); - - dto.putOperation(localFile, destFile, null, null); - - Transfer transfer = new Transfer(); - transfer.setIrodsAbsolutePath(irodsCopySourceAbsolutePath); - transfer.setLocalAbsolutePath(irodsCopyTargetAbsolutePath); - transfer.setTransferType(TransferType.COPY); - - conveyorService.getQueueManagerService().enqueueTransferOperation( - transfer, irodsAccount); - - TransferTestRunningUtilities.waitForTransferToRunOrTimeout( - conveyorService, TRANSFER_TIMEOUT); - - List transfers = conveyorService.getQueueManagerService() - .listAllTransfersInQueue(); - Assert.assertFalse("no transfers in queue", transfers.isEmpty()); - Assert.assertEquals("should be 1 transfer..maybe test cleanup is bad", - 1, transfers.size()); - transfer = transfers.get(0); - - transfer = conveyorService.getQueueManagerService() - .initializeGivenTransferByLoadingChildren(transfer); - - Assert.assertFalse("did not create a transfer attempt", transfer - .getTransferAttempts().isEmpty()); - - Assert.assertEquals("did not get complete status", - TransferStateEnum.COMPLETE, transfer.getTransferState()); - - Assert.assertEquals("did not get OK status", TransferStatusEnum.OK, - transfer.getLastTransferStatus()); - - TransferAttempt attempts[] = new TransferAttempt[transfer - .getTransferAttempts().size()]; - attempts = transfer.getTransferAttempts().toArray(attempts); - Assert.assertEquals("should be 1 attempt", 1, attempts.length); - - TransferAttempt attempt = attempts[0]; - Assert.assertNotNull("transfer attempt not persisted", attempt.getId()); - - } - - /** - * do a get of a nested collection that should be 'normal' - * - * @throws Exception - */ - @Test - public void testReplicateNestedCollection() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - - conveyorService.getConfigurationService().addConfigurationProperty( - logSuccessful); - - String rootCollection = "testReplicateNestedCollection"; - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - - String irodsSourceAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH + "/" - + rootCollection); - - FileGenerator - .generateManyFilesAndCollectionsInParentCollectionByAbsolutePath( - localCollectionAbsolutePath, - "testEnqueuePutTransferOperationAndWaitUntilDone", 2, - 5, 2, "testFile", ".txt", 10, 5, 100, 2000); - - IRODSFileFactory irodsFileFactory = irodsFileSystem - .getIRODSFileFactory(irodsAccount); - IRODSFile destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - File localFile = new File(localCollectionAbsolutePath); - - DataTransferOperations dto = irodsFileSystem - .getIRODSAccessObjectFactory().getDataTransferOperations( - irodsAccount); - - dto.putOperation(localFile, destFile, null, null); - - Transfer transfer = new Transfer(); - transfer.setIrodsAbsolutePath(irodsSourceAbsolutePath); - transfer.setResourceName(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_SECONDARY_RESOURCE_KEY)); - transfer.setTransferType(TransferType.REPLICATE); - - conveyorService.getQueueManagerService().enqueueTransferOperation( - transfer, irodsAccount); - - TransferTestRunningUtilities.waitForTransferToRunOrTimeout( - conveyorService, TRANSFER_TIMEOUT); - - List transfers = conveyorService.getQueueManagerService() - .listAllTransfersInQueue(); - Assert.assertFalse("no transfers in queue", transfers.isEmpty()); - Assert.assertEquals("should be 1 transfer..maybe test cleanup is bad", - 1, transfers.size()); - transfer = transfers.get(0); - - transfer = conveyorService.getQueueManagerService() - .initializeGivenTransferByLoadingChildren(transfer); - - Assert.assertFalse("did not create a transfer attempt", transfer - .getTransferAttempts().isEmpty()); - - Assert.assertEquals("did not get complete status", - TransferStateEnum.COMPLETE, transfer.getTransferState()); - - Assert.assertEquals("did not get OK status", TransferStatusEnum.OK, - transfer.getLastTransferStatus()); - - TransferAttempt attempts[] = new TransferAttempt[transfer - .getTransferAttempts().size()]; - attempts = transfer.getTransferAttempts().toArray(attempts); - Assert.assertEquals("should be 1 attempt", 1, attempts.length); - - TransferAttempt attempt = attempts[0]; - Assert.assertNotNull("transfer attempt not persisted", attempt.getId()); - - } - - /** - * do a get of a nested collection that should be 'normal' - * - * @throws Exception - */ - @Test - public void testTransferWithUnknownType() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - - conveyorService.getConfigurationService().addConfigurationProperty( - logSuccessful); - - Transfer transfer = new Transfer(); - transfer.setIrodsAbsolutePath("blah"); - transfer.setTransferType(TransferType.UNKNOWN); - - conveyorService.getQueueManagerService().enqueueTransferOperation( - transfer, irodsAccount); - - TransferTestRunningUtilities.waitForTransferToRunOrTimeout( - conveyorService, TRANSFER_TIMEOUT); - - List transfers = conveyorService.getQueueManagerService() - .listAllTransfersInQueue(); - Assert.assertFalse("no transfers in queue", transfers.isEmpty()); - Assert.assertEquals("should be 1 transfer..maybe test cleanup is bad", - 1, transfers.size()); - transfer = transfers.get(0); - - transfer = conveyorService.getQueueManagerService() - .initializeGivenTransferByLoadingChildren(transfer); - - Assert.assertFalse("did not create a transfer attempt", transfer - .getTransferAttempts().isEmpty()); - - Assert.assertEquals("did not get complete status", - TransferStateEnum.COMPLETE, transfer.getTransferState()); - - Assert.assertEquals("did not get errir status", - TransferStatusEnum.ERROR, transfer.getLastTransferStatus()); - - TransferAttempt attempts[] = new TransferAttempt[transfer - .getTransferAttempts().size()]; - attempts = transfer.getTransferAttempts().toArray(attempts); - Assert.assertEquals("should be 1 attempt", 1, attempts.length); - - TransferAttempt attempt = attempts[0]; - Assert.assertNotNull("transfer attempt not persisted", attempt.getId()); - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/core/ConveyorExecutorServiceImplTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/core/ConveyorExecutorServiceImplTest.java deleted file mode 100644 index 6ccb8200f..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/core/ConveyorExecutorServiceImplTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.irods.jargon.conveyor.core; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -public class ConveyorExecutorServiceImplTest { - - private static ConveyorExecutorService conveyorExecutorService = new ConveyorExecutorServiceImpl(); - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - conveyorExecutorService.shutdown(); - } - - @Test(expected = IllegalArgumentException.class) - public void testExecWhenNull() throws Exception { - conveyorExecutorService.processTransfer(null, null); - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/core/ConveyorQueueTimerTaskTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/core/ConveyorQueueTimerTaskTest.java deleted file mode 100644 index 32d57d6cf..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/core/ConveyorQueueTimerTaskTest.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.irods.jargon.conveyor.core; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.mockito.Mockito; - -public class ConveyorQueueTimerTaskTest { - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testInit() throws Exception { - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - QueueManagerService queueManager = Mockito - .mock(QueueManagerService.class); - conveyorService.setQueueManagerService(queueManager); - Mockito.when(conveyorService.getQueueManagerService()).thenReturn( - queueManager); - - ConveyorQueueTimerTask timer = new ConveyorQueueTimerTask(); - timer.setConveyorService(conveyorService); - timer.init(); - timer.run(); - Mockito.verify(queueManager).dequeueNextOperation(); - - } - - @Test - public void testRunWhenPaused() throws Exception { - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - QueueManagerService queueManager = Mockito - .mock(QueueManagerService.class); - conveyorService.setQueueManagerService(queueManager); - Mockito.when(conveyorService.getQueueManagerService()).thenReturn( - queueManager); - - ConveyorQueueTimerTask timer = new ConveyorQueueTimerTask(); - timer.setConveyorService(conveyorService); - timer.init(); - timer.setPaused(true); - timer.run(); - Mockito.verify(queueManager, Mockito.never()).dequeueNextOperation(); - - } - - @Test(expected = ConveyorRuntimeException.class) - public void testInitNoConveyor() throws Exception { - ConveyorQueueTimerTask timer = new ConveyorQueueTimerTask(); - timer.init(); - - } - - @Test(expected = ConveyorRuntimeException.class) - public void testRunWithoutInit() throws Exception { - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - QueueManagerService queueManager = Mockito - .mock(QueueManagerService.class); - conveyorService.setQueueManagerService(queueManager); - Mockito.when(conveyorService.getQueueManagerService()).thenReturn( - queueManager); - - ConveyorQueueTimerTask timer = new ConveyorQueueTimerTask(); - timer.setConveyorService(conveyorService); - timer.run(); - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/core/callables/FlowCoProcessorTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/core/callables/FlowCoProcessorTest.java deleted file mode 100644 index e8b67af7c..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/core/callables/FlowCoProcessorTest.java +++ /dev/null @@ -1,437 +0,0 @@ -package org.irods.jargon.conveyor.core.callables; - -import java.util.ArrayList; -import java.util.List; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpec; -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpecCacheService; -import org.irods.jargon.conveyor.flowmanager.flow.Selector.FlowActionEnum; -import org.irods.jargon.conveyor.flowmanager.flow.dsl.Flow; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice.ExecResult; -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.AlwaysDontRunConditionMicroservice; -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.AlwaysRunConditionMicroservice; -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.LogAndCancelMicroservice; -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.LogAndContinueMicroservice; -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.LogAndSkipChainMicroservice; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.pub.IRODSAccessObjectFactory; -import org.irods.jargon.core.transfer.DefaultTransferControlBlock; -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.transfer.dao.domain.GridAccount; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.irods.jargon.transfer.dao.domain.TransferType; -import org.junit.Test; -import org.mockito.Mockito; - -public class FlowCoProcessorTest { - - @Test - public void testEvaluateConditionNoRun() throws Exception { - - String host = "test"; - String zone = "zone"; - FlowActionEnum action = FlowActionEnum.PUT; - - String fqcn = Microservice.class.getName(); - String condFqcn = AlwaysDontRunConditionMicroservice.class.getName(); - - IRODSAccessObjectFactory irodsAccessObjectFactory = Mockito - .mock(IRODSAccessObjectFactory.class); - - IRODSAccount irodsAccount = IRODSAccount.instance("host", 1247, "user", - "pwd", "", "zone", ""); - - FlowSpec flow = Flow.define().forAction(action).forHost(host) - .forZone(zone).when(condFqcn).endPreOperationChain() - .endPreFileChain().addPostFileMicroservice(fqcn) - .endPostFileChain().endPostOperationChain() - .endFlowWithoutErrorHandler(); - - List candidates = new ArrayList(); - candidates.add(flow); - - FlowSpecCacheService flowSpecCacheService = Mockito - .mock(FlowSpecCacheService.class); - Mockito.when(flowSpecCacheService.getFlowSpecs()) - .thenReturn(candidates); - - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost(host); - gridAccount.setZone(zone); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - DefaultTransferControlBlock.instance(); - PutConveyorCallable callable = Mockito.mock(PutConveyorCallable.class); - Mockito.when(callable.getCandidateFlowSpecs()).thenReturn(candidates); - Mockito.when(callable.getConveyorService()).thenReturn(conveyorService); - Mockito.when(callable.getIrodsAccessObjectFactory()).thenReturn( - irodsAccessObjectFactory); - Mockito.when(callable.getTransferAttempt()).thenReturn(transferAttempt); - Mockito.when(callable.getTransfer()).thenReturn(transfer); - Mockito.when(callable.getIRODSAccountForGridAccount(gridAccount)) - .thenReturn(irodsAccount); - Mockito.when(callable.getTransferControlBlock()).thenReturn( - DefaultTransferControlBlock.instance()); - - FlowCoProcessor flowCoProcessor = new FlowCoProcessor(callable); - TransferStatus status = Mockito.mock(TransferStatus.class); - boolean actual = flowCoProcessor.evaluateCondition(flow, status); - Assert.assertFalse("should have evaluated condition to false", actual); - - } - - @Test - public void testEvaluateCondition() throws Exception { - - String host = "test"; - String zone = "zone"; - FlowActionEnum action = FlowActionEnum.PUT; - - String fqcn = Microservice.class.getName(); - String condFqcn = AlwaysRunConditionMicroservice.class.getName(); - - IRODSAccessObjectFactory irodsAccessObjectFactory = Mockito - .mock(IRODSAccessObjectFactory.class); - - IRODSAccount irodsAccount = IRODSAccount.instance("host", 1247, "user", - "pwd", "", "zone", ""); - - FlowSpec flow = Flow.define().forAction(action).forHost(host) - .forZone(zone).when(condFqcn).endPreOperationChain() - .endPreFileChain().addPostFileMicroservice(fqcn) - .endPostFileChain().endPostOperationChain() - .endFlowWithoutErrorHandler(); - - List candidates = new ArrayList(); - candidates.add(flow); - - FlowSpecCacheService flowSpecCacheService = Mockito - .mock(FlowSpecCacheService.class); - Mockito.when(flowSpecCacheService.getFlowSpecs()) - .thenReturn(candidates); - - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost(host); - gridAccount.setZone(zone); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - DefaultTransferControlBlock.instance(); - PutConveyorCallable callable = Mockito.mock(PutConveyorCallable.class); - Mockito.when(callable.getCandidateFlowSpecs()).thenReturn(candidates); - Mockito.when(callable.getConveyorService()).thenReturn(conveyorService); - Mockito.when(callable.getIrodsAccessObjectFactory()).thenReturn( - irodsAccessObjectFactory); - Mockito.when(callable.getTransferAttempt()).thenReturn(transferAttempt); - Mockito.when(callable.getTransfer()).thenReturn(transfer); - Mockito.when(callable.getIRODSAccountForGridAccount(gridAccount)) - .thenReturn(irodsAccount); - Mockito.when(callable.getTransferControlBlock()).thenReturn( - DefaultTransferControlBlock.instance()); - - FlowCoProcessor flowCoProcessor = new FlowCoProcessor(callable); - TransferStatus status = Mockito.mock(TransferStatus.class); - - boolean actual = flowCoProcessor.evaluateCondition(flow, status); - Assert.assertTrue("should have evaluated condition to true", actual); - - } - - @Test - public void testRunPreOpChainRunTwoSkipLastOne() throws Exception { - - String host = "test"; - String zone = "zone"; - FlowActionEnum action = FlowActionEnum.PUT; - - String LogAndContinueFqcn = LogAndContinueMicroservice.class.getName(); - String LogAndSkipChainFqcn = LogAndSkipChainMicroservice.class - .getName(); - String condFqcn = AlwaysRunConditionMicroservice.class.getName(); - - IRODSAccessObjectFactory irodsAccessObjectFactory = Mockito - .mock(IRODSAccessObjectFactory.class); - - IRODSAccount irodsAccount = IRODSAccount.instance("host", 1247, "user", - "pwd", "", "zone", ""); - - FlowSpec flow = Flow.define().forAction(action).forHost(host) - .forZone(zone).when(condFqcn) - .addPreOperationMicroservice(LogAndContinueFqcn) - .addPreOperationMicroservice(LogAndContinueFqcn) - .addPreOperationMicroservice(LogAndSkipChainFqcn) - .addPreOperationMicroservice(LogAndContinueFqcn) - .endPreOperationChain().endPreFileChain().endPostFileChain() - .endPostOperationChain().endFlowWithoutErrorHandler(); - - List candidates = new ArrayList(); - candidates.add(flow); - - FlowSpecCacheService flowSpecCacheService = Mockito - .mock(FlowSpecCacheService.class); - Mockito.when(flowSpecCacheService.getFlowSpecs()) - .thenReturn(candidates); - - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost(host); - gridAccount.setZone(zone); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - DefaultTransferControlBlock.instance(); - PutConveyorCallable callable = Mockito.mock(PutConveyorCallable.class); - Mockito.when(callable.getCandidateFlowSpecs()).thenReturn(candidates); - Mockito.when(callable.getConveyorService()).thenReturn(conveyorService); - Mockito.when(callable.getIrodsAccessObjectFactory()).thenReturn( - irodsAccessObjectFactory); - Mockito.when(callable.getTransferAttempt()).thenReturn(transferAttempt); - Mockito.when(callable.getTransfer()).thenReturn(transfer); - Mockito.when(callable.getIRODSAccountForGridAccount(gridAccount)) - .thenReturn(irodsAccount); - Mockito.when(callable.getTransferControlBlock()).thenReturn( - DefaultTransferControlBlock.instance()); - - FlowCoProcessor flowCoProcessor = new FlowCoProcessor(callable); - TransferStatus status = Mockito.mock(TransferStatus.class); - - ExecResult execResult = flowCoProcessor.executePreOperationChain(flow, - status); - Assert.assertEquals("should have gotten skip chain", - ExecResult.SKIP_THIS_CHAIN, execResult); - - } - - @Test - public void testRunPreOpChainRunTwoThenCancel() throws Exception { - - String host = "test"; - String zone = "zone"; - FlowActionEnum action = FlowActionEnum.PUT; - - String logAndContinueFqcn = LogAndContinueMicroservice.class.getName(); - String logAndCancelFqcn = LogAndCancelMicroservice.class.getName(); - String condFqcn = AlwaysRunConditionMicroservice.class.getName(); - - IRODSAccessObjectFactory irodsAccessObjectFactory = Mockito - .mock(IRODSAccessObjectFactory.class); - - IRODSAccount irodsAccount = IRODSAccount.instance("host", 1247, "user", - "pwd", "", "zone", ""); - - FlowSpec flow = Flow.define().forAction(action).forHost(host) - .forZone(zone).when(condFqcn) - .addPreOperationMicroservice(logAndContinueFqcn) - .addPreOperationMicroservice(logAndContinueFqcn) - .addPreOperationMicroservice(logAndCancelFqcn) - .addPreOperationMicroservice(logAndContinueFqcn) - .endPreOperationChain().endPreFileChain().endPostFileChain() - .endPostOperationChain().endFlowWithoutErrorHandler(); - - List candidates = new ArrayList(); - candidates.add(flow); - - FlowSpecCacheService flowSpecCacheService = Mockito - .mock(FlowSpecCacheService.class); - Mockito.when(flowSpecCacheService.getFlowSpecs()) - .thenReturn(candidates); - - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost(host); - gridAccount.setZone(zone); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - DefaultTransferControlBlock.instance(); - PutConveyorCallable callable = Mockito.mock(PutConveyorCallable.class); - Mockito.when(callable.getCandidateFlowSpecs()).thenReturn(candidates); - Mockito.when(callable.getConveyorService()).thenReturn(conveyorService); - Mockito.when(callable.getIrodsAccessObjectFactory()).thenReturn( - irodsAccessObjectFactory); - Mockito.when(callable.getTransferAttempt()).thenReturn(transferAttempt); - Mockito.when(callable.getTransfer()).thenReturn(transfer); - Mockito.when(callable.getIRODSAccountForGridAccount(gridAccount)) - .thenReturn(irodsAccount); - Mockito.when(callable.getTransferControlBlock()).thenReturn( - DefaultTransferControlBlock.instance()); - - FlowCoProcessor flowCoProcessor = new FlowCoProcessor(callable); - TransferStatus status = Mockito.mock(TransferStatus.class); - - ExecResult execResult = flowCoProcessor.executePreOperationChain(flow, - status); - Assert.assertEquals("should have gotten cancel", - ExecResult.CANCEL_OPERATION, execResult); - Assert.assertTrue("tcb should be set to cancel", callable - .getTransferControlBlock().isCancelled()); - - } - - @Test - public void testRunPreFileChain() throws Exception { - - String host = "test"; - String zone = "zone"; - FlowActionEnum action = FlowActionEnum.PUT; - - String LogAndContinueFqcn = LogAndContinueMicroservice.class.getName(); - String LogAndSkipChainFqcn = LogAndSkipChainMicroservice.class - .getName(); - String condFqcn = AlwaysRunConditionMicroservice.class.getName(); - - IRODSAccessObjectFactory irodsAccessObjectFactory = Mockito - .mock(IRODSAccessObjectFactory.class); - - IRODSAccount irodsAccount = IRODSAccount.instance("host", 1247, "user", - "pwd", "", "zone", ""); - - FlowSpec flow = Flow.define().forAction(action).forHost(host) - .forZone(zone).when(condFqcn).endPreOperationChain() - .addPreFileMicroservice(LogAndContinueFqcn) - .addPreFileMicroservice(LogAndContinueFqcn) - .addPreFileMicroservice(LogAndSkipChainFqcn) - .addPreFileMicroservice(LogAndContinueFqcn).endPreFileChain() - .endPostFileChain().endPostOperationChain() - .endFlowWithoutErrorHandler(); - - List candidates = new ArrayList(); - candidates.add(flow); - - FlowSpecCacheService flowSpecCacheService = Mockito - .mock(FlowSpecCacheService.class); - Mockito.when(flowSpecCacheService.getFlowSpecs()) - .thenReturn(candidates); - - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost(host); - gridAccount.setZone(zone); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - DefaultTransferControlBlock.instance(); - PutConveyorCallable callable = Mockito.mock(PutConveyorCallable.class); - Mockito.when(callable.getCandidateFlowSpecs()).thenReturn(candidates); - Mockito.when(callable.getConveyorService()).thenReturn(conveyorService); - Mockito.when(callable.getIrodsAccessObjectFactory()).thenReturn( - irodsAccessObjectFactory); - Mockito.when(callable.getTransferAttempt()).thenReturn(transferAttempt); - Mockito.when(callable.getTransfer()).thenReturn(transfer); - Mockito.when(callable.getIRODSAccountForGridAccount(gridAccount)) - .thenReturn(irodsAccount); - Mockito.when(callable.getTransferControlBlock()).thenReturn( - DefaultTransferControlBlock.instance()); - - FlowCoProcessor flowCoProcessor = new FlowCoProcessor(callable); - TransferStatus status = Mockito.mock(TransferStatus.class); - - ExecResult execResult = flowCoProcessor.executePreFileChain(flow, - status); - Assert.assertEquals("should have gotten skip chain", - ExecResult.SKIP_THIS_CHAIN, execResult); - - Object countObjVal = flowCoProcessor.getInvocationContext() - .getSharedProperties() - .get(LogAndContinueMicroservice.COUNT_KEY); - Assert.assertNotNull("did not get count key in invocation context"); - - int count = (Integer) countObjVal; - - Assert.assertEquals("did not count two microservice calls", 2, count); - - } - - @Test - public void testRunPostFileChain() throws Exception { - - String host = "test"; - String zone = "zone"; - FlowActionEnum action = FlowActionEnum.PUT; - - String LogAndContinueFqcn = LogAndContinueMicroservice.class.getName(); - - String condFqcn = AlwaysRunConditionMicroservice.class.getName(); - - IRODSAccessObjectFactory irodsAccessObjectFactory = Mockito - .mock(IRODSAccessObjectFactory.class); - - IRODSAccount irodsAccount = IRODSAccount.instance("host", 1247, "user", - "pwd", "", "zone", ""); - - FlowSpec flow = Flow.define().forAction(action).forHost(host) - .forZone(zone).when(condFqcn).endPreOperationChain() - .endPreFileChain().addPostFileMicroservice(LogAndContinueFqcn) - .addPostFileMicroservice(LogAndContinueFqcn).endPostFileChain() - .endPostOperationChain().endFlowWithoutErrorHandler(); - - List candidates = new ArrayList(); - candidates.add(flow); - - FlowSpecCacheService flowSpecCacheService = Mockito - .mock(FlowSpecCacheService.class); - Mockito.when(flowSpecCacheService.getFlowSpecs()) - .thenReturn(candidates); - - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost(host); - gridAccount.setZone(zone); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - DefaultTransferControlBlock.instance(); - PutConveyorCallable callable = Mockito.mock(PutConveyorCallable.class); - Mockito.when(callable.getCandidateFlowSpecs()).thenReturn(candidates); - Mockito.when(callable.getConveyorService()).thenReturn(conveyorService); - Mockito.when(callable.getIrodsAccessObjectFactory()).thenReturn( - irodsAccessObjectFactory); - Mockito.when(callable.getTransferAttempt()).thenReturn(transferAttempt); - Mockito.when(callable.getTransfer()).thenReturn(transfer); - Mockito.when(callable.getIRODSAccountForGridAccount(gridAccount)) - .thenReturn(irodsAccount); - Mockito.when(callable.getTransferControlBlock()).thenReturn( - DefaultTransferControlBlock.instance()); - - FlowCoProcessor flowCoProcessor = new FlowCoProcessor(callable); - TransferStatus status = Mockito.mock(TransferStatus.class); - - flowCoProcessor.executePostFileChain(flow, status); - - Object countObjVal = flowCoProcessor.getInvocationContext() - .getSharedProperties() - .get(LogAndContinueMicroservice.COUNT_KEY); - Assert.assertNotNull("did not get count key in invocation context"); - - int count = (Integer) countObjVal; - - Assert.assertEquals("did not count two microservice calls", 2, count); - - } -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/core/callables/PutConveyorCallableFlowSpecTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/core/callables/PutConveyorCallableFlowSpecTest.java deleted file mode 100644 index 504fb0eab..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/core/callables/PutConveyorCallableFlowSpecTest.java +++ /dev/null @@ -1,412 +0,0 @@ -package org.irods.jargon.conveyor.core.callables; - -import java.util.ArrayList; -import java.util.List; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.basic.BasicFlowManagerService; -import org.irods.jargon.conveyor.core.ConfigurationService; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.conveyor.core.GridAccountService; -import org.irods.jargon.conveyor.core.TransferAccountingManagementService; -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpec; -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpecCacheService; -import org.irods.jargon.conveyor.flowmanager.flow.Selector.FlowActionEnum; -import org.irods.jargon.conveyor.flowmanager.flow.dsl.Flow; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.AlwaysRunConditionMicroservice; -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.LogAndContinueMicroservice; -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.SkipThisFileMicroservice; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.pub.DataTransferOperations; -import org.irods.jargon.core.pub.IRODSAccessObjectFactory; -import org.irods.jargon.core.transfer.DefaultTransferControlBlock; -import org.irods.jargon.core.transfer.TransferControlBlock; -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.core.transfer.TransferStatus.TransferState; -import org.irods.jargon.core.transfer.TransferStatusCallbackListener.FileStatusCallbackResponse; -import org.irods.jargon.transfer.dao.domain.GridAccount; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.irods.jargon.transfer.dao.domain.TransferType; -import org.junit.Test; -import org.mockito.Mockito; - -public class PutConveyorCallableFlowSpecTest { - - @Test - public void testRetrieveCandidateFlowSpecs() throws Exception { - - String host = "test"; - String zone = "zone"; - FlowActionEnum action = FlowActionEnum.PUT; - - String fqcn = Microservice.class.getName(); - - FlowSpec flow = Flow.define().forAction(action).forHost(host) - .forZone(zone).onAllConditions().endPreOperationChain() - .endPreFileChain().addPostFileMicroservice(fqcn) - .endPostFileChain().endPostOperationChain() - .endFlowWithoutErrorHandler(); - - List candidates = new ArrayList(); - candidates.add(flow); - - FlowSpecCacheService flowSpecCacheService = Mockito - .mock(FlowSpecCacheService.class); - Mockito.when(flowSpecCacheService.getFlowSpecs()) - .thenReturn(candidates); - - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost(host); - gridAccount.setZone(zone); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - BasicFlowManagerService flowManagerService = Mockito - .mock(BasicFlowManagerService.class); - - Mockito.when( - flowManagerService.retrieveCandidateFlowSpecs(transferAttempt)) - .thenReturn(candidates); - Mockito.when(conveyorService.getFlowManagerService()).thenReturn( - flowManagerService); - - PutConveyorCallable callable = new PutConveyorCallable(transferAttempt, - conveyorService); - - List flowSpecs = callable.getCandidateFlowSpecs(); - Assert.assertEquals("did not get the flow spec as a candidate", 1, - flowSpecs.size()); - - } - - @Test - public void testOverallStatusCallbackTriggerPreOpChain() throws Exception { - - String host = "test"; - String zone = "zone"; - FlowActionEnum action = FlowActionEnum.PUT; - - IRODSAccount irodsAccount = IRODSAccount.instance("host", 1247, "user", - "pwd", "", "zone", ""); - - String logAndContinueFqcn = LogAndContinueMicroservice.class.getName(); - String condFqcn = AlwaysRunConditionMicroservice.class.getName(); - - FlowSpec flow = Flow.define().forAction(action).forHost(host) - .forZone(zone).when(condFqcn) - .addPreOperationMicroservice(logAndContinueFqcn) - .addPreOperationMicroservice(logAndContinueFqcn) - .endPreOperationChain().endPreFileChain().endPostFileChain() - .endPostOperationChain().endFlowWithoutErrorHandler(); - - List candidates = new ArrayList(); - candidates.add(flow); - - FlowSpecCacheService flowSpecCacheService = Mockito - .mock(FlowSpecCacheService.class); - Mockito.when(flowSpecCacheService.getFlowSpecs()) - .thenReturn(candidates); - - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost(host); - gridAccount.setZone(zone); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setLastSuccessfulPath(""); - transferAttempt.setTransfer(transfer); - - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - - IRODSAccessObjectFactory irodsAccessObjectFactory = Mockito - .mock(IRODSAccessObjectFactory.class); - Mockito.when(conveyorService.getIrodsAccessObjectFactory()).thenReturn( - irodsAccessObjectFactory); - - DataTransferOperations dto = Mockito.mock(DataTransferOperations.class); - Mockito.when( - irodsAccessObjectFactory - .getDataTransferOperations(irodsAccount)).thenReturn( - dto); - - BasicFlowManagerService flowManagerService = Mockito - .mock(BasicFlowManagerService.class); - - TransferControlBlock transferControlBlock = DefaultTransferControlBlock - .instance(); - - Mockito.when( - flowManagerService.retrieveCandidateFlowSpecs(transferAttempt)) - .thenReturn(candidates); - Mockito.when(conveyorService.getFlowManagerService()).thenReturn( - flowManagerService); - - GridAccountService gridAccountService = Mockito - .mock(GridAccountService.class); - Mockito.when(gridAccountService.irodsAccountForGridAccount(gridAccount)) - .thenReturn(irodsAccount); - Mockito.when(conveyorService.getGridAccountService()).thenReturn( - gridAccountService); - - ConfigurationService configurationService = Mockito - .mock(ConfigurationService.class); - Mockito.when( - configurationService - .buildDefaultTransferControlBlockBasedOnConfiguration( - "", irodsAccessObjectFactory)).thenReturn( - transferControlBlock); - Mockito.when(conveyorService.getConfigurationService()).thenReturn( - configurationService); - - PutConveyorCallable callable = new PutConveyorCallable(transferAttempt, - conveyorService); - - TransferStatus status = TransferStatus.instance( - TransferStatus.TransferType.PUT, "x", "x", "x", 1L, 1L, 1, 1, - 1, TransferState.OVERALL_INITIATION, gridAccount.getHost(), - gridAccount.getZone()); - - callable.setTransferControlBlock(transferControlBlock); - callable.call(); - callable.overallStatusCallback(status); - - Object countObjVal = callable.getFlowCoProcessor() - .getInvocationContext().getSharedProperties() - .get(LogAndContinueMicroservice.COUNT_KEY); - Assert.assertNotNull("did not get count key in invocation context"); - - int count = (Integer) countObjVal; - Assert.assertEquals("did not count two microservice calls", 2, count); - - } - - @Test - public void testOverallStatusCallbackTriggerPreFileChain() throws Exception { - - String host = "test"; - String zone = "zone"; - FlowActionEnum action = FlowActionEnum.PUT; - - IRODSAccount irodsAccount = IRODSAccount.instance("host", 1247, "user", - "pwd", "", "zone", ""); - - String logAndContinueFqcn = LogAndContinueMicroservice.class.getName(); - String condFqcn = AlwaysRunConditionMicroservice.class.getName(); - - FlowSpec flow = Flow.define().forAction(action).forHost(host) - .forZone(zone).when(condFqcn).endPreOperationChain() - .addPreFileMicroservice(logAndContinueFqcn) - .addPreFileMicroservice(logAndContinueFqcn).endPreFileChain() - .endPostFileChain().endPostOperationChain() - .endFlowWithoutErrorHandler(); - - List candidates = new ArrayList(); - candidates.add(flow); - - FlowSpecCacheService flowSpecCacheService = Mockito - .mock(FlowSpecCacheService.class); - Mockito.when(flowSpecCacheService.getFlowSpecs()) - .thenReturn(candidates); - - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost(host); - gridAccount.setZone(zone); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setLastSuccessfulPath(""); - transferAttempt.setTransfer(transfer); - - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - - IRODSAccessObjectFactory irodsAccessObjectFactory = Mockito - .mock(IRODSAccessObjectFactory.class); - Mockito.when(conveyorService.getIrodsAccessObjectFactory()).thenReturn( - irodsAccessObjectFactory); - - DataTransferOperations dto = Mockito.mock(DataTransferOperations.class); - Mockito.when( - irodsAccessObjectFactory - .getDataTransferOperations(irodsAccount)).thenReturn( - dto); - - BasicFlowManagerService flowManagerService = Mockito - .mock(BasicFlowManagerService.class); - - TransferControlBlock transferControlBlock = DefaultTransferControlBlock - .instance(); - - Mockito.when( - flowManagerService.retrieveCandidateFlowSpecs(transferAttempt)) - .thenReturn(candidates); - Mockito.when(conveyorService.getFlowManagerService()).thenReturn( - flowManagerService); - - GridAccountService gridAccountService = Mockito - .mock(GridAccountService.class); - Mockito.when(gridAccountService.irodsAccountForGridAccount(gridAccount)) - .thenReturn(irodsAccount); - Mockito.when(conveyorService.getGridAccountService()).thenReturn( - gridAccountService); - - ConfigurationService configurationService = Mockito - .mock(ConfigurationService.class); - Mockito.when( - configurationService - .buildDefaultTransferControlBlockBasedOnConfiguration( - "", irodsAccessObjectFactory)).thenReturn( - transferControlBlock); - Mockito.when(conveyorService.getConfigurationService()).thenReturn( - configurationService); - - PutConveyorCallable callable = new PutConveyorCallable(transferAttempt, - conveyorService); - - callable.setTransferControlBlock(transferControlBlock); - callable.call(); - TransferStatus overallStatus = TransferStatus.instance( - TransferStatus.TransferType.PUT, "x", "x", "x", 1L, 1L, 1, 1, - 1, TransferState.OVERALL_INITIATION, gridAccount.getHost(), - gridAccount.getZone()); - - // to trigger locating the flowspec - callable.overallStatusCallback(overallStatus); - - TransferStatus status = TransferStatus.instance( - TransferStatus.TransferType.PUT, "x", "x", "x", 1L, 1L, 1, 1, - 1, TransferState.IN_PROGRESS_START_FILE, gridAccount.getHost(), - gridAccount.getZone()); - - FileStatusCallbackResponse response = callable.statusCallback(status); - Assert.assertEquals("should have continue", - FileStatusCallbackResponse.CONTINUE, response); - Object countObjVal = callable.getFlowCoProcessor() - .getInvocationContext().getSharedProperties() - .get(LogAndContinueMicroservice.COUNT_KEY); - Assert.assertNotNull("did not get count key in invocation context"); - - int count = (Integer) countObjVal; - Assert.assertEquals("did not count two microservice calls", 2, count); - - } - - @Test - public void testOverallStatusCallbackTriggerPreFileChainSkipThisFile() - throws Exception { - - String host = "test"; - String zone = "zone"; - FlowActionEnum action = FlowActionEnum.PUT; - - IRODSAccount irodsAccount = IRODSAccount.instance("host", 1247, "user", - "pwd", "", "zone", ""); - - String skipFqcn = SkipThisFileMicroservice.class.getName(); - String condFqcn = AlwaysRunConditionMicroservice.class.getName(); - - FlowSpec flow = Flow.define().forAction(action).forHost(host) - .forZone(zone).when(condFqcn).endPreOperationChain() - .addPreFileMicroservice(skipFqcn) - .addPreFileMicroservice(skipFqcn).endPreFileChain() - .endPostFileChain().endPostOperationChain() - .endFlowWithoutErrorHandler(); - - List candidates = new ArrayList(); - candidates.add(flow); - - FlowSpecCacheService flowSpecCacheService = Mockito - .mock(FlowSpecCacheService.class); - Mockito.when(flowSpecCacheService.getFlowSpecs()) - .thenReturn(candidates); - - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost(host); - gridAccount.setZone(zone); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setLastSuccessfulPath(""); - transferAttempt.setTransfer(transfer); - - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - - IRODSAccessObjectFactory irodsAccessObjectFactory = Mockito - .mock(IRODSAccessObjectFactory.class); - Mockito.when(conveyorService.getIrodsAccessObjectFactory()).thenReturn( - irodsAccessObjectFactory); - - DataTransferOperations dto = Mockito.mock(DataTransferOperations.class); - Mockito.when( - irodsAccessObjectFactory - .getDataTransferOperations(irodsAccount)).thenReturn( - dto); - - BasicFlowManagerService flowManagerService = Mockito - .mock(BasicFlowManagerService.class); - - TransferControlBlock transferControlBlock = DefaultTransferControlBlock - .instance(); - - Mockito.when( - flowManagerService.retrieveCandidateFlowSpecs(transferAttempt)) - .thenReturn(candidates); - Mockito.when(conveyorService.getFlowManagerService()).thenReturn( - flowManagerService); - - GridAccountService gridAccountService = Mockito - .mock(GridAccountService.class); - Mockito.when(gridAccountService.irodsAccountForGridAccount(gridAccount)) - .thenReturn(irodsAccount); - Mockito.when(conveyorService.getGridAccountService()).thenReturn( - gridAccountService); - - ConfigurationService configurationService = Mockito - .mock(ConfigurationService.class); - Mockito.when( - configurationService - .buildDefaultTransferControlBlockBasedOnConfiguration( - "", irodsAccessObjectFactory)).thenReturn( - transferControlBlock); - Mockito.when(conveyorService.getConfigurationService()).thenReturn( - configurationService); - - TransferAccountingManagementService transferAccountingManagementService = Mockito - .mock(TransferAccountingManagementService.class); - Mockito.when(conveyorService.getTransferAccountingManagementService()) - .thenReturn(transferAccountingManagementService); - - PutConveyorCallable callable = new PutConveyorCallable(transferAttempt, - conveyorService); - - callable.setTransferControlBlock(transferControlBlock); - callable.call(); - TransferStatus overallStatus = TransferStatus.instance( - TransferStatus.TransferType.PUT, "x", "x", "x", 1L, 1L, 1, 1, - 1, TransferState.OVERALL_INITIATION, gridAccount.getHost(), - gridAccount.getZone()); - - // to trigger locating the flowspec - callable.overallStatusCallback(overallStatus); - - TransferStatus status = TransferStatus.instance( - TransferStatus.TransferType.PUT, "x", "x", "x", 1L, 1L, 1, 1, - 1, TransferState.IN_PROGRESS_START_FILE, gridAccount.getHost(), - gridAccount.getZone()); - - FileStatusCallbackResponse response = callable.statusCallback(status); - Assert.assertEquals("should have skip", - FileStatusCallbackResponse.SKIP, response); - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/flow/FlowSpecCacheServiceTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/flow/FlowSpecCacheServiceTest.java deleted file mode 100644 index f2041ae41..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/flow/FlowSpecCacheServiceTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.irods.jargon.conveyor.flowmanager.flow; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -import org.apache.commons.io.FileUtils; -import org.irods.jargon.core.utils.LocalFileUtils; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.junit.BeforeClass; -import org.junit.Test; - -public class FlowSpecCacheServiceTest { - private static Properties testingProperties = new Properties(); - @SuppressWarnings("unused") - private static org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - private static org.irods.jargon.testutils.filemanip.ScratchFileUtils scratchFileUtils = null; - public static final String IRODS_TEST_SUBDIR_PATH = "FlowSpecCacheServiceTest"; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - scratchFileUtils = new org.irods.jargon.testutils.filemanip.ScratchFileUtils( - testingProperties); - scratchFileUtils - .clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH); - } - - @Test - public void testInitBaseRule() throws Exception { - - String groovyFile = "/testFlowDsl/testInitBaseRule.groovy"; - - String scratchPath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + "/testInitBaseRule"); - - File scratchPathDestFile = new File(scratchPath); - scratchPathDestFile.mkdirs(); - scratchPathDestFile = new File(scratchPath, "testInitBaseRule.groovy"); - File groovySourceFile = LocalFileUtils - .getClasspathResourceAsFile(groovyFile); - FileUtils.copyFile(groovySourceFile, scratchPathDestFile); - FlowSpecCacheService flowSpecCacheService = new FlowSpecCacheService(); - List paths = new ArrayList(); - paths.add(scratchPath); - flowSpecCacheService.setFlowSourceLocalAbsolutePaths(paths); - flowSpecCacheService.init(); - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/flow/SelectorProcessorTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/flow/SelectorProcessorTest.java deleted file mode 100644 index 1b691a3c1..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/flow/SelectorProcessorTest.java +++ /dev/null @@ -1,142 +0,0 @@ -package org.irods.jargon.conveyor.flowmanager.flow; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.flowmanager.flow.Selector.FlowActionEnum; -import org.irods.jargon.transfer.dao.domain.GridAccount; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.irods.jargon.transfer.dao.domain.TransferType; -import org.junit.Test; - -public class SelectorProcessorTest { - - @Test - public void testCompareSelectorHostExact() { - FlowSpec flowSpec = new FlowSpec(); - flowSpec.getSelector().setHostSelector("test"); - SelectorProcessor selectorProcessor = new SelectorProcessor(); - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost("test"); - transfer.setGridAccount(gridAccount); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - boolean actual = selectorProcessor.evaluateSelectorForTransfer( - flowSpec, transferAttempt); - - Assert.assertTrue("should have evaluated as passed", actual); - - } - - @Test - public void testCompareSelectorHostWildCard() { - FlowSpec flowSpec = new FlowSpec(); - flowSpec.getSelector().setHostSelector("te*"); - SelectorProcessor selectorProcessor = new SelectorProcessor(); - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost("test"); - transfer.setGridAccount(gridAccount); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - boolean actual = selectorProcessor.evaluateSelectorForTransfer( - flowSpec, transferAttempt); - - Assert.assertTrue("should have evaluated as passed", actual); - - } - - @Test - public void testCompareSelectorHostExactNoMatch() { - FlowSpec flowSpec = new FlowSpec(); - flowSpec.getSelector().setHostSelector("testx"); - SelectorProcessor selectorProcessor = new SelectorProcessor(); - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost("test"); - transfer.setGridAccount(gridAccount); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - boolean actual = selectorProcessor.evaluateSelectorForTransfer( - flowSpec, transferAttempt); - - Assert.assertFalse("should not have evaluated as passed", actual); - - } - - @Test - public void testCompareSelectorZoneExact() { - FlowSpec flowSpec = new FlowSpec(); - flowSpec.getSelector().setZoneSelector("test"); - SelectorProcessor selectorProcessor = new SelectorProcessor(); - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setZone("test"); - transfer.setGridAccount(gridAccount); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - boolean actual = selectorProcessor.evaluateSelectorForTransfer( - flowSpec, transferAttempt); - - Assert.assertTrue("should have evaluated as passed", actual); - - } - - @Test - public void testCompareSelectorZoneWildCard() { - FlowSpec flowSpec = new FlowSpec(); - flowSpec.getSelector().setZoneSelector("te*"); - SelectorProcessor selectorProcessor = new SelectorProcessor(); - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setZone("test"); - transfer.setGridAccount(gridAccount); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - boolean actual = selectorProcessor.evaluateSelectorForTransfer( - flowSpec, transferAttempt); - - Assert.assertTrue("should have evaluated as passed", actual); - - } - - @Test - public void testCompareSelectorZoneExactNoMatch() { - FlowSpec flowSpec = new FlowSpec(); - flowSpec.getSelector().setZoneSelector("testx"); - SelectorProcessor selectorProcessor = new SelectorProcessor(); - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setZone("test"); - transfer.setGridAccount(gridAccount); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - boolean actual = selectorProcessor.evaluateSelectorForTransfer( - flowSpec, transferAttempt); - - Assert.assertFalse("should not have evaluated as passed", actual); - - } - - @Test - public void testCompareActionExact() { - FlowSpec flowSpec = new FlowSpec(); - flowSpec.getSelector().setHostSelector("test"); - flowSpec.getSelector().setFlowActionEnum(FlowActionEnum.GET); - SelectorProcessor selectorProcessor = new SelectorProcessor(); - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost("test"); - transfer.setGridAccount(gridAccount); - transfer.setTransferType(TransferType.GET); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - boolean actual = selectorProcessor.evaluateSelectorForTransfer( - flowSpec, transferAttempt); - - Assert.assertTrue("should have evaluated as passed", actual); - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowTest.java deleted file mode 100644 index 7d549593c..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowTest.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.flow.dsl; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpec; -import org.irods.jargon.conveyor.flowmanager.flow.Selector.FlowActionEnum; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.junit.Test; - -/** - * Test for building Flow via DSL - * - * @author Mike Conway - DICE - * - */ -public class FlowTest { - - @Test - public void testDefine() { - FlowHostSelectorSpecification actual = Flow.define().forAction( - FlowActionEnum.ANY); - Assert.assertEquals("did not set flow action", FlowActionEnum.ANY, - actual.getFlowSpec().getSelector().getFlowActionEnum()); - } - - @Test - public void testDefineForAnyAction() { - FlowHostSelectorSpecification actual = Flow.define().forAnyAction(); - Assert.assertEquals("did not set flow action", FlowActionEnum.ANY, - actual.getFlowSpec().getSelector().getFlowActionEnum()); - } - - @Test(expected = IllegalArgumentException.class) - public void testDefineNullAction() { - Flow.define().forAction(null); - - } - - @Test - public void testSelectHostBlahStar() throws Exception { - FlowZoneSelectorSpecification actual = Flow.define().forAnyAction() - .forHost("blah*"); - Assert.assertEquals("did not set host to blah*", "blah*", actual - .getFlowSpec().getSelector().getHostSelector()); - } - - @Test - public void testSelectHostAny() throws Exception { - FlowZoneSelectorSpecification actual = Flow.define().forAnyAction() - .forAnyHost(); - Assert.assertEquals("did not set host to *", "*", actual.getFlowSpec() - .getSelector().getHostSelector()); - } - - @Test - public void testSelectZone() throws Exception { - ConditionSpecification actual = Flow.define().forAnyAction() - .forHost("blah*").forZone("zone"); - Assert.assertEquals("did not set zone to zone", "zone", actual - .getFlowSpec().getSelector().getZoneSelector()); - } - - @Test - public void testSelectAny() throws Exception { - ConditionSpecification actual = Flow.define().forAnyAction() - .forHost("blah*").forAnyZone(); - Assert.assertEquals("did not set zone to any", "*", actual - .getFlowSpec().getSelector().getZoneSelector()); - } - - @Test - public void testAddCondition() throws Exception { - - String fqcn = FlowTestConditionMicroservice.class.getName(); - - PreOperationChainSpecification actual = Flow.define().forAnyAction() - .forHost("blah*").forZone("zone").when(fqcn); - Assert.assertNotNull("did not set condition", actual.getFlowSpec() - .getCondition()); - } - - @Test(expected = FlowSpecificationException.class) - public void testAddBogusCondition() throws Exception { - - String fqcn = "arglebargle"; - - Flow.define().forAnyAction().forHost("blah*").forZone("zone") - .when(fqcn); - - } - - @Test(expected = FlowSpecificationException.class) - public void testAddConditionNotConditionMS() throws Exception { - - Flow.define().forAnyAction().forHost("blah*").forZone("zone") - .when(Microservice.class.getName()); - - } - - @Test - public void testAddFlowOnePreOpMicroservice() throws Exception { - - String fqcn = Microservice.class.getName(); - - PreOperationChainSpecification actual = Flow.define().forAnyAction() - .forHost("blah*").forZone("zone").onAllConditions() - .addPreOperationMicroservice(fqcn); - - Assert.assertEquals("did not set one ms in pre op flow", 1, actual - .getFlowSpec().getPreOperationChain().size()); - - } - - @Test - public void testAddFlowOnePreFileMicroservice() throws Exception { - - String fqcn = Microservice.class.getName(); - - PreFileChainSpecification actual = Flow.define().forAnyAction() - .forHost("blah*").forZone("zone").onAllConditions() - .endPreOperationChain().addPreFileMicroservice(fqcn); - - Assert.assertEquals("did not set one ms in pre file flow", 1, actual - .getFlowSpec().getPreFileChain().size()); - - } - - @Test - public void testAddFlowOnePostFileMicroservice() throws Exception { - - String fqcn = Microservice.class.getName(); - - PostFileChainSpecification actual = Flow.define().forAnyAction() - .forHost("blah*").forZone("zone").onAllConditions() - .endPreOperationChain().endPreFileChain() - .addPostFileMicroservice(fqcn); - - Assert.assertEquals("did not set one ms in post file flow", 1, actual - .getFlowSpec().getPostFileChain().size()); - - } - - @Test - public void testAddFlowOnePostFileMicroserviceComplete() throws Exception { - - String fqcn = Microservice.class.getName(); - - FlowSpec actual = Flow.define().forAnyAction().forHost("blah*") - .forZone("zone").onAllConditions().endPreOperationChain() - .endPreFileChain().addPostFileMicroservice(fqcn) - .endPostFileChain().endPostOperationChain() - .endFlowWithoutErrorHandler(); - - Assert.assertNotNull("null flowspec", actual); - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowTestConditionMicroservice.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowTestConditionMicroservice.java deleted file mode 100644 index 71c78b9b8..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowTestConditionMicroservice.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.flow.dsl; - -import org.irods.jargon.conveyor.flowmanager.microservice.ConditionMicroservice; - -/** - * Dummy condition microservice for testing - * - * @author Mike Conway - * - */ -public class FlowTestConditionMicroservice extends ConditionMicroservice { - - /** - * - */ - public FlowTestConditionMicroservice() { - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowTestMicroservice.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowTestMicroservice.java deleted file mode 100644 index 68b56c396..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/flow/dsl/FlowTestMicroservice.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.flow.dsl; - -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.irods.jargon.conveyor.flowmanager.microservice.MicroserviceException; -import org.irods.jargon.core.transfer.TransferStatus; - -/** - * Dummy microservice for flow testing - * - * @author Mike Conway - DICE - * - */ -public class FlowTestMicroservice extends Microservice { - - /** - * - */ - public FlowTestMicroservice() { - } - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.flowmanager.microservice.Microservice#execute() - */ - @Override - public ExecResult execute(final TransferStatus transferStatus) - throws MicroserviceException { - return null; - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/AlwaysDontRunConditionMicroservice.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/AlwaysDontRunConditionMicroservice.java deleted file mode 100644 index 768abc03e..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/AlwaysDontRunConditionMicroservice.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice.builtins; - -import org.irods.jargon.conveyor.flowmanager.microservice.ConditionMicroservice; -import org.irods.jargon.conveyor.flowmanager.microservice.MicroserviceException; -import org.irods.jargon.core.transfer.TransferStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A stub microservice that will never say go ahead but will end normally with a - * TERMINATE_FLOW_FAIL_PRECONDITION - * - * @author Mike Conway - DICE - * - */ -public class AlwaysDontRunConditionMicroservice extends ConditionMicroservice { - - private static final Logger log = LoggerFactory - .getLogger(AlwaysDontRunConditionMicroservice.class); - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.flowmanager.microservice.ConditionMicroservice - * #execute() - */ - @Override - public ExecResult execute(final TransferStatus transferStatus) - throws MicroserviceException { - log.info("execute()"); - evaluateContext(); - return ExecResult.TERMINATE_FLOW_FAIL_PRECONDITION; - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/AlwaysRunConditionMicroservice.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/AlwaysRunConditionMicroservice.java deleted file mode 100644 index 9b30a6799..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/AlwaysRunConditionMicroservice.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice.builtins; - -import org.irods.jargon.conveyor.flowmanager.microservice.ConditionMicroservice; -import org.irods.jargon.conveyor.flowmanager.microservice.MicroserviceException; -import org.irods.jargon.core.transfer.TransferStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A stub microservice that will always say go ahead. - * - * @author Mike Conway - DICE - * - */ -public class AlwaysRunConditionMicroservice extends ConditionMicroservice { - - private static final Logger log = LoggerFactory - .getLogger(AlwaysRunConditionMicroservice.class); - - /* - * (non-Javadoc) - * - * @see - * org.irods.jargon.conveyor.flowmanager.microservice.ConditionMicroservice - * #execute() - */ - @Override - public ExecResult execute(final TransferStatus transferStatus) - throws MicroserviceException { - log.info("execute()"); - evaluateContext(); - return ExecResult.CONTINUE; - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/EnqueueTransferMicroserviceTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/EnqueueTransferMicroserviceTest.java deleted file mode 100644 index a8f24cf0e..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/EnqueueTransferMicroserviceTest.java +++ /dev/null @@ -1,270 +0,0 @@ -package org.irods.jargon.conveyor.flowmanager.microservice.builtins; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.conveyor.core.QueueManagerService; -import org.irods.jargon.conveyor.flowmanager.microservice.ContainerEnvironment; -import org.irods.jargon.conveyor.flowmanager.microservice.InvocationContext; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice.ExecResult; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.transfer.DefaultTransferControlBlock; -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.core.transfer.TransferStatus.TransferState; -import org.irods.jargon.transfer.dao.domain.GridAccount; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.irods.jargon.transfer.dao.domain.TransferType; -import org.junit.Test; -import org.mockito.Mockito; - -public class EnqueueTransferMicroserviceTest { - - @Test - public void testEnqueueTransfer() throws Exception { - - String host = "test"; - String zone = "zone"; - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost(host); - gridAccount.setZone(zone); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - transfer.setLocalAbsolutePath("local"); - transfer.setIrodsAbsolutePath("irods"); - transfer.setResourceName("resource"); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - IRODSAccount irodsAccount = IRODSAccount.instance("host", 1247, "user", - "password", "", "zone", ""); - - TransferStatus transferStatus = TransferStatus.instance( - TransferStatus.TransferType.PUT, "zoop", "blah", "", 0, 0, 0, - 0, 0, TransferState.OVERALL_INITIATION, "host", "zone"); - - DefaultTransferControlBlock.instance(); - - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - QueueManagerService queueManagerService = Mockito - .mock(QueueManagerService.class); - Mockito.when(conveyorService.getQueueManagerService()).thenReturn( - queueManagerService); - - Microservice enqueueTransferMicroservice = new EnqueueTransferMicroservice(); - InvocationContext invocationContext = new InvocationContext(); - ContainerEnvironment containerEnvironment = new ContainerEnvironment(); - containerEnvironment.setConveyorService(conveyorService); - - invocationContext.setTransferAttempt(transferAttempt); - invocationContext.setIrodsAccount(irodsAccount); - - enqueueTransferMicroservice.setInvocationContext(invocationContext); - enqueueTransferMicroservice - .setContainerEnvironment(containerEnvironment); - ExecResult result = enqueueTransferMicroservice.execute(transferStatus); - Assert.assertEquals("should get continue as exec result", - ExecResult.CONTINUE, result); - - Transfer updatedTransfer = (Transfer) invocationContext - .getSharedProperties().get( - EnqueueTransferMicroservice.ENQUEUED_TRANSFER); - - Assert.assertNotNull("no transfer in shared context", updatedTransfer); - Assert.assertEquals("local path not found", - transfer.getLocalAbsolutePath(), - updatedTransfer.getLocalAbsolutePath()); - Assert.assertEquals("irods path not found", - transfer.getIrodsAbsolutePath(), - updatedTransfer.getIrodsAbsolutePath()); - Assert.assertEquals("resource not found", transfer.getResourceName(), - updatedTransfer.getResourceName()); - - } - - @Test - public void testEnqueueTransferOverrideLocal() throws Exception { - - String host = "test"; - String zone = "zone"; - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost(host); - gridAccount.setZone(zone); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - transfer.setLocalAbsolutePath("local"); - transfer.setIrodsAbsolutePath("irods"); - transfer.setResourceName("resource"); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - IRODSAccount irodsAccount = IRODSAccount.instance("host", 1247, "user", - "password", "", "zone", ""); - - TransferStatus transferStatus = TransferStatus.instance( - TransferStatus.TransferType.PUT, "zoop", "blah", "", 0, 0, 0, - 0, 0, TransferState.OVERALL_INITIATION, "host", "zone"); - - DefaultTransferControlBlock.instance(); - - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - QueueManagerService queueManagerService = Mockito - .mock(QueueManagerService.class); - Mockito.when(conveyorService.getQueueManagerService()).thenReturn( - queueManagerService); - - Microservice enqueueTransferMicroservice = new EnqueueTransferMicroservice(); - InvocationContext invocationContext = new InvocationContext(); - ContainerEnvironment containerEnvironment = new ContainerEnvironment(); - containerEnvironment.setConveyorService(conveyorService); - - invocationContext.setTransferAttempt(transferAttempt); - invocationContext.setIrodsAccount(irodsAccount); - - invocationContext.getSharedProperties().put( - EnqueueTransferMicroservice.LOCAL_FILE_NAME, "boo"); - - enqueueTransferMicroservice.setInvocationContext(invocationContext); - enqueueTransferMicroservice - .setContainerEnvironment(containerEnvironment); - ExecResult result = enqueueTransferMicroservice.execute(transferStatus); - Assert.assertEquals("should get continue as exec result", - ExecResult.CONTINUE, result); - - Transfer updatedTransfer = (Transfer) invocationContext - .getSharedProperties().get( - EnqueueTransferMicroservice.ENQUEUED_TRANSFER); - - Assert.assertNotNull("no transfer in shared context", updatedTransfer); - Assert.assertEquals("local path not overridden", "boo", - updatedTransfer.getLocalAbsolutePath()); - Assert.assertEquals("irods path not found", - transfer.getIrodsAbsolutePath(), - updatedTransfer.getIrodsAbsolutePath()); - Assert.assertEquals("resource not found", transfer.getResourceName(), - updatedTransfer.getResourceName()); - - } - - @Test - public void testEnqueueTransferOverrideIrods() throws Exception { - - String host = "test"; - String zone = "zone"; - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost(host); - gridAccount.setZone(zone); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - transfer.setLocalAbsolutePath("local"); - transfer.setIrodsAbsolutePath("irods"); - transfer.setResourceName("resource"); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - IRODSAccount irodsAccount = IRODSAccount.instance("host", 1247, "user", - "password", "", "zone", ""); - - TransferStatus transferStatus = TransferStatus.instance( - TransferStatus.TransferType.PUT, "zoop", "blah", "", 0, 0, 0, - 0, 0, TransferState.OVERALL_INITIATION, "host", "zone"); - - DefaultTransferControlBlock.instance(); - - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - QueueManagerService queueManagerService = Mockito - .mock(QueueManagerService.class); - Mockito.when(conveyorService.getQueueManagerService()).thenReturn( - queueManagerService); - - Microservice enqueueTransferMicroservice = new EnqueueTransferMicroservice(); - InvocationContext invocationContext = new InvocationContext(); - ContainerEnvironment containerEnvironment = new ContainerEnvironment(); - containerEnvironment.setConveyorService(conveyorService); - - invocationContext.setTransferAttempt(transferAttempt); - invocationContext.setIrodsAccount(irodsAccount); - - invocationContext.getSharedProperties().put( - EnqueueTransferMicroservice.IRODS_FILE_NAME, "boo"); - - enqueueTransferMicroservice.setInvocationContext(invocationContext); - enqueueTransferMicroservice - .setContainerEnvironment(containerEnvironment); - ExecResult result = enqueueTransferMicroservice.execute(transferStatus); - Assert.assertEquals("should get continue as exec result", - ExecResult.CONTINUE, result); - - Transfer updatedTransfer = (Transfer) invocationContext - .getSharedProperties().get( - EnqueueTransferMicroservice.ENQUEUED_TRANSFER); - - Assert.assertNotNull("no transfer in shared context", updatedTransfer); - - Assert.assertEquals("irods path not updated", "boo", - updatedTransfer.getIrodsAbsolutePath()); - - } - - @Test - public void testEnqueueTransferOverrideResource() throws Exception { - - String host = "test"; - String zone = "zone"; - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost(host); - gridAccount.setZone(zone); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - transfer.setLocalAbsolutePath("local"); - transfer.setIrodsAbsolutePath("irods"); - transfer.setResourceName("resource"); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - IRODSAccount irodsAccount = IRODSAccount.instance("host", 1247, "user", - "password", "", "zone", ""); - - TransferStatus transferStatus = TransferStatus.instance( - TransferStatus.TransferType.PUT, "zoop", "blah", "", 0, 0, 0, - 0, 0, TransferState.OVERALL_INITIATION, "host", "zone"); - - DefaultTransferControlBlock.instance(); - - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - QueueManagerService queueManagerService = Mockito - .mock(QueueManagerService.class); - Mockito.when(conveyorService.getQueueManagerService()).thenReturn( - queueManagerService); - - Microservice enqueueTransferMicroservice = new EnqueueTransferMicroservice(); - InvocationContext invocationContext = new InvocationContext(); - ContainerEnvironment containerEnvironment = new ContainerEnvironment(); - containerEnvironment.setConveyorService(conveyorService); - - invocationContext.setTransferAttempt(transferAttempt); - invocationContext.setIrodsAccount(irodsAccount); - - invocationContext.getSharedProperties().put( - EnqueueTransferMicroservice.RESOURCE, "boo"); - - enqueueTransferMicroservice.setInvocationContext(invocationContext); - enqueueTransferMicroservice - .setContainerEnvironment(containerEnvironment); - ExecResult result = enqueueTransferMicroservice.execute(transferStatus); - Assert.assertEquals("should get continue as exec result", - ExecResult.CONTINUE, result); - - Transfer updatedTransfer = (Transfer) invocationContext - .getSharedProperties().get( - EnqueueTransferMicroservice.ENQUEUED_TRANSFER); - - Assert.assertNotNull("no transfer in shared context", updatedTransfer); - - Assert.assertEquals("resource path not updated", "boo", - updatedTransfer.getResourceName()); - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/ExtractBundleMicroserviceTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/ExtractBundleMicroserviceTest.java deleted file mode 100644 index 2a2ffaa38..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/ExtractBundleMicroserviceTest.java +++ /dev/null @@ -1,173 +0,0 @@ -package org.irods.jargon.conveyor.flowmanager.microservice.builtins; - -import java.io.File; -import java.util.Properties; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.conveyor.flowmanager.microservice.ContainerEnvironment; -import org.irods.jargon.conveyor.flowmanager.microservice.InvocationContext; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice.ExecResult; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.connection.IRODSServerProperties; -import org.irods.jargon.core.connection.JargonProperties; -import org.irods.jargon.core.connection.SettableJargonProperties; -import org.irods.jargon.core.pub.DataTransferOperations; -import org.irods.jargon.core.pub.EnvironmentalInfoAO; -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.core.pub.io.IRODSFile; -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.core.transfer.TransferStatus.TransferState; -import org.irods.jargon.datautils.filearchive.LocalTarFileArchiver; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.testutils.filemanip.FileGenerator; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.mockito.Mockito; - -public class ExtractBundleMicroserviceTest { - private static Properties testingProperties = new Properties(); - private static JargonProperties jargonOriginalProperties = null; - private static org.irods.jargon.testutils.filemanip.ScratchFileUtils scratchFileUtils = null; - public static final String IRODS_TEST_SUBDIR_PATH = "ExtractBundleMicroserviceTest"; - private static org.irods.jargon.testutils.IRODSTestSetupUtilities irodsTestSetupUtilities = null; - private static IRODSFileSystem irodsFileSystem = null; - private static TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - irodsFileSystem = IRODSFileSystem.instance(); - SettableJargonProperties settableJargonProperties = new SettableJargonProperties( - irodsFileSystem.getJargonProperties()); - settableJargonProperties.setInternalCacheBufferSize(-1); - settableJargonProperties.setInternalOutputStreamBufferSize(65535); - jargonOriginalProperties = settableJargonProperties; - irodsFileSystem.getIrodsSession().setJargonProperties( - settableJargonProperties); - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - scratchFileUtils = new org.irods.jargon.testutils.filemanip.ScratchFileUtils( - testingProperties); - scratchFileUtils - .clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH); - irodsTestSetupUtilities = new org.irods.jargon.testutils.IRODSTestSetupUtilities(); - irodsTestSetupUtilities.clearIrodsScratchDirectory(); - irodsTestSetupUtilities.initializeIrodsScratchDirectory(); - irodsTestSetupUtilities - .initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH); - } - - @AfterClass - public static void afterClass() throws Exception { - irodsFileSystem.closeAndEatExceptions(); - } - - @Before - public void before() throws Exception { - // be sure that normal parallel stuff is set up - irodsFileSystem.getIrodsSession().setJargonProperties( - jargonOriginalProperties); - } - - @Test - public void testExtractBundle() throws Exception { - String tarName = "testExtractBundle.tar"; - String bunSubdir = "testExtractBundle"; - - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + bunSubdir); - - String tarParentCollection = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH); - - File tarFile = new File(tarParentCollection); - tarFile = new File(tarFile.getParentFile(), tarName); - - FileGenerator - .generateManyFilesAndCollectionsInParentCollectionByAbsolutePath( - localCollectionAbsolutePath, bunSubdir, 2, 3, 2, - "testFile", ".txt", 3, 2, 1, 200 * 1024); - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - EnvironmentalInfoAO environmentalInfoAO = irodsFileSystem - .getIRODSAccessObjectFactory().getEnvironmentalInfoAO( - irodsAccount); - IRODSServerProperties props = environmentalInfoAO - .getIRODSServerPropertiesFromIRODSServer(); - - // test is only valid for post 2.4.1 - if (!props.isTheIrodsServerAtLeastAtTheGivenReleaseVersion("rods2.4.1")) { - irodsFileSystem.closeAndEatExceptions(); - return; - } - - IRODSFile irodsFile = null; - - String targetBunIrodsCollection = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH + "/" - + bunSubdir); - - String extractBunIrodsCollection = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH + "/" - + bunSubdir); - - String targetBunFileAbsPath = targetBunIrodsCollection + "/" + tarName; - irodsFile = irodsFileSystem.getIRODSFileFactory(irodsAccount) - .instanceIRODSFile(targetBunIrodsCollection); - irodsFile.mkdir(); - irodsFile.close(); - - irodsFile = irodsFileSystem.getIRODSFileFactory(irodsAccount) - .instanceIRODSFile(extractBunIrodsCollection); - irodsFile.mkdir(); - irodsFile.close(); - - LocalTarFileArchiver archiver = new LocalTarFileArchiver( - localCollectionAbsolutePath, tarFile.getAbsolutePath()); - - File tarredFile = archiver.createArchive(); - - DataTransferOperations dto = irodsFileSystem - .getIRODSAccessObjectFactory().getDataTransferOperations( - irodsAccount); - - dto.putOperation(tarredFile.getAbsolutePath(), targetBunFileAbsPath, - "", null, null); - - TransferStatus transferStatus = TransferStatus.instance( - TransferStatus.TransferType.PUT, localCollectionAbsolutePath, - targetBunFileAbsPath, "", 0, 0, 0, 0, 0, - TransferState.OVERALL_INITIATION, "host", "zone"); - - Microservice extractBundleMicroservice = new ExtractBundleMicroservice(); - InvocationContext invocationContext = new InvocationContext(); - - invocationContext.getSharedProperties().put( - ExtractBundleMicroservice.BUNDLE_TO_EXTRACT, - targetBunFileAbsPath); - invocationContext.getSharedProperties().put( - ExtractBundleMicroservice.TARGET_COLLECTION, - extractBunIrodsCollection); - - ContainerEnvironment containerEnvironment = new ContainerEnvironment(); - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - containerEnvironment.setConveyorService(conveyorService); - Mockito.when(conveyorService.getIrodsAccessObjectFactory()).thenReturn( - irodsFileSystem.getIRODSAccessObjectFactory()); - invocationContext.setIrodsAccount(irodsAccount); - extractBundleMicroservice.setInvocationContext(invocationContext); - extractBundleMicroservice.setContainerEnvironment(containerEnvironment); - - ExecResult result = extractBundleMicroservice.execute(transferStatus); - Assert.assertEquals("should get continue as exec result", - ExecResult.CONTINUE, result); - - } -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/InspectForUnbundleOperationMicroserviceTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/InspectForUnbundleOperationMicroserviceTest.java deleted file mode 100644 index 67d7352a1..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/InspectForUnbundleOperationMicroserviceTest.java +++ /dev/null @@ -1,161 +0,0 @@ -package org.irods.jargon.conveyor.flowmanager.microservice.builtins; - -import java.io.File; -import java.util.Properties; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.conveyor.flowmanager.microservice.ContainerEnvironment; -import org.irods.jargon.conveyor.flowmanager.microservice.InvocationContext; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice.ExecResult; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.connection.IRODSServerProperties; -import org.irods.jargon.core.connection.JargonProperties; -import org.irods.jargon.core.connection.SettableJargonProperties; -import org.irods.jargon.core.pub.EnvironmentalInfoAO; -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.core.pub.io.IRODSFile; -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.core.transfer.TransferStatus.TransferState; -import org.irods.jargon.datautils.filearchive.LocalTarFileArchiver; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.testutils.filemanip.FileGenerator; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.mockito.Mockito; - -public class InspectForUnbundleOperationMicroserviceTest { - - private static Properties testingProperties = new Properties(); - private static JargonProperties jargonOriginalProperties = null; - private static org.irods.jargon.testutils.filemanip.ScratchFileUtils scratchFileUtils = null; - public static final String IRODS_TEST_SUBDIR_PATH = "InspectForUnbundleOperationMicroserviceTest"; - private static org.irods.jargon.testutils.IRODSTestSetupUtilities irodsTestSetupUtilities = null; - private static IRODSFileSystem irodsFileSystem = null; - private static TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - irodsFileSystem = IRODSFileSystem.instance(); - SettableJargonProperties settableJargonProperties = new SettableJargonProperties( - irodsFileSystem.getJargonProperties()); - settableJargonProperties.setInternalCacheBufferSize(-1); - settableJargonProperties.setInternalOutputStreamBufferSize(65535); - jargonOriginalProperties = settableJargonProperties; - irodsFileSystem.getIrodsSession().setJargonProperties( - settableJargonProperties); - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - scratchFileUtils = new org.irods.jargon.testutils.filemanip.ScratchFileUtils( - testingProperties); - scratchFileUtils - .clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH); - irodsTestSetupUtilities = new org.irods.jargon.testutils.IRODSTestSetupUtilities(); - irodsTestSetupUtilities.clearIrodsScratchDirectory(); - irodsTestSetupUtilities.initializeIrodsScratchDirectory(); - irodsTestSetupUtilities - .initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH); - } - - @AfterClass - public static void afterClass() throws Exception { - irodsFileSystem.closeAndEatExceptions(); - } - - @Before - public void before() throws Exception { - // be sure that normal parallel stuff is set up - irodsFileSystem.getIrodsSession().setJargonProperties( - jargonOriginalProperties); - } - - @Test - public void testExtractBundle() throws Exception { - String tarName = "testExtractBundle.tar"; - String bunSubdir = "testExtractBundle"; - - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + bunSubdir); - - String tarParentCollection = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH); - - File tarFile = new File(tarParentCollection); - tarFile = new File(tarFile.getParentFile(), tarName); - - FileGenerator - .generateManyFilesAndCollectionsInParentCollectionByAbsolutePath( - localCollectionAbsolutePath, bunSubdir, 1, 3, 2, - "testFile", ".txt", 3, 2, 1, 2); - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - EnvironmentalInfoAO environmentalInfoAO = irodsFileSystem - .getIRODSAccessObjectFactory().getEnvironmentalInfoAO( - irodsAccount); - IRODSServerProperties props = environmentalInfoAO - .getIRODSServerPropertiesFromIRODSServer(); - - // test is only valid for post 2.4.1 - if (!props.isTheIrodsServerAtLeastAtTheGivenReleaseVersion("rods2.4.1")) { - irodsFileSystem.closeAndEatExceptions(); - return; - } - - IRODSFile irodsFile = null; - - String targetBunIrodsCollection = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH + "/" - + bunSubdir); - - String extractBunIrodsCollection = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH + "/" - + bunSubdir); - - irodsFile = irodsFileSystem.getIRODSFileFactory(irodsAccount) - .instanceIRODSFile(targetBunIrodsCollection); - irodsFile.mkdir(); - irodsFile.close(); - - irodsFile = irodsFileSystem.getIRODSFileFactory(irodsAccount) - .instanceIRODSFile(extractBunIrodsCollection); - irodsFile.mkdir(); - irodsFile.close(); - - LocalTarFileArchiver archiver = new LocalTarFileArchiver( - localCollectionAbsolutePath, tarFile.getAbsolutePath()); - - File tarredFile = archiver.createArchive(); - - TransferStatus transferStatus = TransferStatus.instance( - TransferStatus.TransferType.PUT, tarredFile.getAbsolutePath(), - "blah", "", 0, 0, 0, 0, 0, TransferState.OVERALL_INITIATION, - "host", "zone"); - - Microservice inspectForUnbundleOperationMicroservice = new InspectForUnbundleOperationMicroservice(); - InvocationContext invocationContext = new InvocationContext(); - - ContainerEnvironment containerEnvironment = new ContainerEnvironment(); - ConveyorService conveyorService = Mockito.mock(ConveyorService.class); - containerEnvironment.setConveyorService(conveyorService); - Mockito.when(conveyorService.getIrodsAccessObjectFactory()).thenReturn( - irodsFileSystem.getIRODSAccessObjectFactory()); - invocationContext.setIrodsAccount(irodsAccount); - inspectForUnbundleOperationMicroservice - .setInvocationContext(invocationContext); - inspectForUnbundleOperationMicroservice - .setContainerEnvironment(containerEnvironment); - - ExecResult result = inspectForUnbundleOperationMicroservice - .execute(transferStatus); - Assert.assertEquals("should get continue as exec result", - ExecResult.CONTINUE, result); - - } -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/LogAndAbortMicroservice.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/LogAndAbortMicroservice.java deleted file mode 100644 index da5eb9502..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/LogAndAbortMicroservice.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice.builtins; - -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.irods.jargon.conveyor.flowmanager.microservice.MicroserviceException; -import org.irods.jargon.core.transfer.TransferStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A basic microservice that will send a log message, and depending on log - * level, dump interesting things. It will return an abort flow. - * - * @author Mike Conway - DICE - * - */ -public class LogAndAbortMicroservice extends Microservice { - - private static final Logger log = LoggerFactory - .getLogger(LogAndAbortMicroservice.class); - - @Override - public ExecResult execute(final TransferStatus transferStatus) - throws MicroserviceException { - log.info("execute()"); - return ExecResult.ABORT_AND_TRIGGER_ANY_ERROR_HANDLER; - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/LogAndCancelMicroservice.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/LogAndCancelMicroservice.java deleted file mode 100644 index 2bd98d47e..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/LogAndCancelMicroservice.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice.builtins; - -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.irods.jargon.conveyor.flowmanager.microservice.MicroserviceException; -import org.irods.jargon.core.transfer.TransferStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A basic microservice that will send a log message, and depending on log - * level, dump interesting things. It will respond with a call to cancel the op - * - * @author Mike Conway - DICE - * - */ -public class LogAndCancelMicroservice extends Microservice { - - private static final Logger log = LoggerFactory - .getLogger(LogAndCancelMicroservice.class); - - @Override - public ExecResult execute(final TransferStatus transferStatus) - throws MicroserviceException { - log.info("execute()"); - return ExecResult.CANCEL_OPERATION; - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/LogAndContinueMicroservice.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/LogAndContinueMicroservice.java deleted file mode 100644 index 4879abdf8..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/LogAndContinueMicroservice.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice.builtins; - -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.irods.jargon.conveyor.flowmanager.microservice.MicroserviceException; -import org.irods.jargon.core.transfer.TransferStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A basic microservice that will send a log message, and depending on log - * level, dump interesting things. - *

- * To help with test assertions, this will also keep a count of times a - * microservice is invoked in the InvocationContext object - * - * @author Mike Conway - DICE - * - */ -public class LogAndContinueMicroservice extends Microservice { - - public static final String COUNT_KEY = "LogAndContinueMicroservice:COUNT_KEY"; - - private static final Logger log = LoggerFactory - .getLogger(LogAndContinueMicroservice.class); - - @Override - public ExecResult execute(final TransferStatus transferStatus) - throws MicroserviceException { - log.info("execute()"); - - Object countObjVal = getInvocationContext().getSharedProperties().get( - COUNT_KEY); - if (countObjVal == null) { - getInvocationContext().getSharedProperties().put(COUNT_KEY, 1); - } else { - int count = (Integer) countObjVal; - getInvocationContext().getSharedProperties() - .put(COUNT_KEY, ++count); - } - - return ExecResult.CONTINUE; - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/LogAndSkipChainMicroservice.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/LogAndSkipChainMicroservice.java deleted file mode 100644 index 9ad791b4c..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/LogAndSkipChainMicroservice.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice.builtins; - -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.irods.jargon.conveyor.flowmanager.microservice.MicroserviceException; -import org.irods.jargon.core.transfer.TransferStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A basic microservice that will send a log message, and depending on log - * level, dump interesting things. It will respond with a call to skip the rest - * of the chain - * - * @author Mike Conway - DICE - * - */ -public class LogAndSkipChainMicroservice extends Microservice { - - private static final Logger log = LoggerFactory - .getLogger(LogAndSkipChainMicroservice.class); - - @Override - public ExecResult execute(final TransferStatus transferStatus) - throws MicroserviceException { - log.info("execute()"); - return ExecResult.SKIP_THIS_CHAIN; - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/PostFileAddTestAVUMicroservice.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/PostFileAddTestAVUMicroservice.java deleted file mode 100644 index 5cd34b191..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/PostFileAddTestAVUMicroservice.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice.builtins; - -import java.io.File; - -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.irods.jargon.conveyor.flowmanager.microservice.MicroserviceException; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.DataObjectAO; -import org.irods.jargon.core.pub.domain.AvuData; -import org.irods.jargon.core.pub.io.IRODSFile; -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.core.utils.LocalFileUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A basic microservice that will send a log message, and depending on log - * level, dump interesting things. - *

- * This microservice will ask to skip any file containing the specific string - * SKIPME in the source or target of the transfer status - * - * @author Mike Conway - DICE - * - */ -public class PostFileAddTestAVUMicroservice extends Microservice { - - private static final Logger log = LoggerFactory - .getLogger(PostFileAddTestAVUMicroservice.class); - - public static final String SKIPME = "SKIPME"; - - @Override - public ExecResult execute(final TransferStatus transferStatus) - throws MicroserviceException { - log.info("execute()"); - - try { - AvuData avuData = AvuData.instance("SOURCEFILE", LocalFileUtils - .normalizePath(transferStatus.getSourceFileAbsolutePath()), - ""); - File sourceAsFile = new File( - transferStatus.getSourceFileAbsolutePath()); - IRODSFile targetAsFile = getContainerEnvironment() - .getConveyorService() - .getIrodsAccessObjectFactory() - .getIRODSFileFactory( - getInvocationContext().getIrodsAccount()) - .instanceIRODSFile( - transferStatus.getTargetFileAbsolutePath(), - sourceAsFile.getName()); - DataObjectAO dataObjectAO = getContainerEnvironment() - .getConveyorService().getIrodsAccessObjectFactory() - .getDataObjectAO(getInvocationContext().getIrodsAccount()); - log.info("adding an avu to:{}", targetAsFile.getAbsolutePath()); - dataObjectAO - .addAVUMetadata(targetAsFile.getAbsolutePath(), avuData); - log.info("avu added"); - return ExecResult.CONTINUE; - } catch (JargonException e) { - log.error("error adding avu post transfer", e); - throw new MicroserviceException("error adding avu", e); - } - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/SkipFileWithSKIPMEInTheNameMicroservice.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/SkipFileWithSKIPMEInTheNameMicroservice.java deleted file mode 100644 index 4af904178..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/SkipFileWithSKIPMEInTheNameMicroservice.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice.builtins; - -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.irods.jargon.conveyor.flowmanager.microservice.MicroserviceException; -import org.irods.jargon.core.transfer.TransferStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A basic microservice that will send a log message, and depending on log - * level, dump interesting things. - *

- * This microservice will ask to skip any file containing the specific string - * SKIPME in the source or target of the transfer status - * - * @author Mike Conway - DICE - * - */ -public class SkipFileWithSKIPMEInTheNameMicroservice extends Microservice { - - private static final Logger log = LoggerFactory - .getLogger(SkipFileWithSKIPMEInTheNameMicroservice.class); - - public static final String SKIPME = "SKIPME"; - - @Override - public ExecResult execute(final TransferStatus transferStatus) - throws MicroserviceException { - log.info("execute()"); - - boolean foundSkipMe = false; - - if (transferStatus.getSourceFileAbsolutePath().indexOf(SKIPME) > -1) { - foundSkipMe = true; - } else if (transferStatus.getTargetFileAbsolutePath().indexOf(SKIPME) > -1) { - foundSkipMe = true; - } - - if (foundSkipMe) { - return ExecResult.SKIP_THIS_FILE; - } else { - return ExecResult.CONTINUE; - } - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/SkipThisFileMicroservice.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/SkipThisFileMicroservice.java deleted file mode 100644 index aed334981..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/SkipThisFileMicroservice.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice.builtins; - -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.irods.jargon.conveyor.flowmanager.microservice.MicroserviceException; -import org.irods.jargon.core.transfer.TransferStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A basic microservice that will send a log message, and depending on log - * level, dump interesting things. - *

- * This microservice will ask to skip this file - * - * @author Mike Conway - DICE - * - */ -public class SkipThisFileMicroservice extends Microservice { - - private static final Logger log = LoggerFactory - .getLogger(SkipThisFileMicroservice.class); - - @Override - public ExecResult execute(final TransferStatus transferStatus) - throws MicroserviceException { - log.info("execute()"); - return ExecResult.SKIP_THIS_FILE; - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/TarCollectionMicroserviceTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/TarCollectionMicroserviceTest.java deleted file mode 100644 index 77eec435b..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/TarCollectionMicroserviceTest.java +++ /dev/null @@ -1,125 +0,0 @@ -package org.irods.jargon.conveyor.flowmanager.microservice.builtins; - -import java.io.File; -import java.util.Properties; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.flowmanager.microservice.ContainerEnvironment; -import org.irods.jargon.conveyor.flowmanager.microservice.InvocationContext; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice; -import org.irods.jargon.conveyor.flowmanager.microservice.Microservice.ExecResult; -import org.irods.jargon.core.connection.JargonProperties; -import org.irods.jargon.core.connection.SettableJargonProperties; -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.core.transfer.DefaultTransferControlBlock; -import org.irods.jargon.core.transfer.TransferStatus; -import org.irods.jargon.core.transfer.TransferStatus.TransferState; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.testutils.filemanip.FileGenerator; -import org.irods.jargon.transfer.dao.domain.GridAccount; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.irods.jargon.transfer.dao.domain.TransferType; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -public class TarCollectionMicroserviceTest { - - private static Properties testingProperties = new Properties(); - private static JargonProperties jargonOriginalProperties = null; - private static org.irods.jargon.testutils.filemanip.ScratchFileUtils scratchFileUtils = null; - public static final String IRODS_TEST_SUBDIR_PATH = "TarCollectionMicroserviceTest"; - private static org.irods.jargon.testutils.IRODSTestSetupUtilities irodsTestSetupUtilities = null; - private static IRODSFileSystem irodsFileSystem = null; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - irodsFileSystem = IRODSFileSystem.instance(); - SettableJargonProperties settableJargonProperties = new SettableJargonProperties( - irodsFileSystem.getJargonProperties()); - settableJargonProperties.setInternalCacheBufferSize(-1); - settableJargonProperties.setInternalOutputStreamBufferSize(65535); - jargonOriginalProperties = settableJargonProperties; - irodsFileSystem.getIrodsSession().setJargonProperties( - settableJargonProperties); - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - scratchFileUtils = new org.irods.jargon.testutils.filemanip.ScratchFileUtils( - testingProperties); - scratchFileUtils - .clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH); - irodsTestSetupUtilities = new org.irods.jargon.testutils.IRODSTestSetupUtilities(); - irodsTestSetupUtilities.clearIrodsScratchDirectory(); - irodsTestSetupUtilities.initializeIrodsScratchDirectory(); - irodsTestSetupUtilities - .initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH); - } - - @AfterClass - public static void afterClass() throws Exception { - irodsFileSystem.closeAndEatExceptions(); - } - - @Before - public void before() throws Exception { - // be sure that normal parallel stuff is set up - irodsFileSystem.getIrodsSession().setJargonProperties( - jargonOriginalProperties); - } - - @Test - public void testUntarCollectionInIRODS() throws Exception { - - String host = "test"; - String zone = "zone"; - Transfer transfer = new Transfer(); - GridAccount gridAccount = new GridAccount(); - gridAccount.setHost(host); - gridAccount.setZone(zone); - transfer.setTransferType(TransferType.PUT); - transfer.setGridAccount(gridAccount); - TransferAttempt transferAttempt = new TransferAttempt(); - transferAttempt.setTransfer(transfer); - - DefaultTransferControlBlock.instance(); - - String rootCollection = "testUntarCollectionInIRODS"; - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - TransferStatus transferStatus = TransferStatus.instance( - TransferStatus.TransferType.PUT, localCollectionAbsolutePath, - "blah", "", 0, 0, 0, 0, 0, TransferState.OVERALL_INITIATION, - "host", "zone"); - - String tarParentCollection = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH); - - File tarFile = new File(tarParentCollection); - tarFile = new File(tarFile.getParentFile(), "contents.tar"); - - FileGenerator - .generateManyFilesAndCollectionsInParentCollectionByAbsolutePath( - localCollectionAbsolutePath, rootCollection, 2, 3, 2, - "testFile", ".txt", 3, 2, 1, 200 * 1024); - - Microservice tarCollectionMicroservice = new TarCollectionMicroservice(); - InvocationContext invocationContext = new InvocationContext(); - ContainerEnvironment containerEnvironment = new ContainerEnvironment(); - tarCollectionMicroservice.setInvocationContext(invocationContext); - tarCollectionMicroservice.setContainerEnvironment(containerEnvironment); - ExecResult result = tarCollectionMicroservice.execute(transferStatus); - Assert.assertEquals("should get continue as exec result", - ExecResult.CONTINUE, result); - - String sourcePath = (String) invocationContext.getSharedProperties() - .get(EnqueueTransferMicroservice.LOCAL_FILE_NAME); - Assert.assertNotNull("no source path put in shared context", sourcePath); - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/package-info.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/package-info.java deleted file mode 100644 index f0f5b6d55..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/flowmanager/microservice/builtins/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * A small group of built-in microservices - * @author Mike Conway - DICE - * - */ -package org.irods.jargon.conveyor.flowmanager.microservice.builtins; \ No newline at end of file diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/functionaltest/ConveyorServiceFunctionalTests.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/functionaltest/ConveyorServiceFunctionalTests.java deleted file mode 100644 index 5131c24b7..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/functionaltest/ConveyorServiceFunctionalTests.java +++ /dev/null @@ -1,338 +0,0 @@ -package org.irods.jargon.conveyor.functionaltest; - -import java.io.File; -import java.util.List; -import java.util.Properties; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.core.ConfigurationPropertyConstants; -import org.irods.jargon.conveyor.core.ConveyorExecutorService.RunningStatus; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.conveyor.unittest.utils.TransferTestRunningUtilities; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.packinstr.TransferOptions.ForceOption; -import org.irods.jargon.core.pub.DataTransferOperations; -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.core.pub.io.IRODSFile; -import org.irods.jargon.core.pub.io.IRODSFileFactory; -import org.irods.jargon.core.transfer.TransferControlBlock; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.testutils.filemanip.FileGenerator; -import org.irods.jargon.transfer.dao.domain.ConfigurationProperty; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferAttempt; -import org.irods.jargon.transfer.dao.domain.TransferStateEnum; -import org.irods.jargon.transfer.dao.domain.TransferStatusEnum; -import org.irods.jargon.transfer.dao.domain.TransferType; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:transfer-dao-beans.xml", - "classpath:transfer-dao-hibernate-spring.cfg.xml" }) -@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false) -public class ConveyorServiceFunctionalTests { - - private static Properties testingProperties = new Properties(); - private static org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - private static org.irods.jargon.testutils.filemanip.ScratchFileUtils scratchFileUtils = null; - public static final String IRODS_TEST_SUBDIR_PATH = "ConveyorServiceFunctionalTests"; - private static org.irods.jargon.testutils.IRODSTestSetupUtilities irodsTestSetupUtilities = null; - private static IRODSFileSystem irodsFileSystem = null; - private static int TRANSFER_TIMEOUT = -1; - - @Autowired - private ConveyorService conveyorService; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - irodsFileSystem = IRODSFileSystem.instance(); - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - scratchFileUtils = new org.irods.jargon.testutils.filemanip.ScratchFileUtils( - testingProperties); - scratchFileUtils - .clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH); - irodsTestSetupUtilities = new org.irods.jargon.testutils.IRODSTestSetupUtilities(); - irodsTestSetupUtilities.clearIrodsScratchDirectory(); - irodsTestSetupUtilities.initializeIrodsScratchDirectory(); - irodsTestSetupUtilities - .initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH); - } - - @Before - public void setUp() throws Exception { - conveyorService.setIrodsAccessObjectFactory(irodsFileSystem - .getIRODSAccessObjectFactory()); - conveyorService.getQueueManagerService().purgeAllFromQueue(); - conveyorService.getGridAccountService().resetPassPhraseAndAccounts(); - conveyorService.getConveyorExecutorService().requestResumeFromPause(); - - } - - @After - public void tearDown() throws Exception { - conveyorService.getQueueManagerService().purgeAllFromQueue(); - } - - @Test - public void testPutToDirectoryWhereNoPermissionsCauseFailure() - throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - - conveyorService.getConfigurationService().addConfigurationProperty( - logSuccessful); - - ConfigurationProperty maxErrors = new ConfigurationProperty(); - maxErrors - .setPropertyKey(ConfigurationPropertyConstants.MAX_ERRORS_BEFORE_CANCEL_KEY); - maxErrors.setPropertyValue(5); - conveyorService.getConfigurationService().addConfigurationProperty( - maxErrors); - - String rootCollection = "testEnqueuePutTransferOperationAndWaitUntilDone"; - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromSecondaryTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - - FileGenerator - .generateManyFilesAndCollectionsInParentCollectionByAbsolutePath( - localCollectionAbsolutePath, - "testEnqueuePutTransferOperationAndWaitUntilDone", 2, - 5, 2, "testFile", ".txt", 10, 5, 100, 2000); - - IRODSFileFactory irodsFileFactory = irodsFileSystem - .getIRODSFileFactory(irodsAccount); - IRODSFile destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - File localFile = new File(localCollectionAbsolutePath); - - Transfer transfer = new Transfer(); - transfer.setIrodsAbsolutePath(destFile.getAbsolutePath()); - transfer.setLocalAbsolutePath(localFile.getAbsolutePath()); - transfer.setTransferType(TransferType.PUT); - - conveyorService.getQueueManagerService().enqueueTransferOperation( - transfer, irodsAccount); - - TransferTestRunningUtilities.waitForTransferToRunOrTimeout( - conveyorService, TRANSFER_TIMEOUT); - - List transfers = conveyorService.getQueueManagerService() - .listAllTransfersInQueue(); - Assert.assertFalse("no transfers in queue", transfers.isEmpty()); - Assert.assertEquals("should be 1 transfer..maybe test cleanup is bad", - 1, transfers.size()); - transfer = transfers.get(0); - - transfer = conveyorService.getQueueManagerService() - .initializeGivenTransferByLoadingChildren(transfer); - - Assert.assertFalse("did not create a transfer attempt", transfer - .getTransferAttempts().isEmpty()); - - Assert.assertEquals("did not get complete status", - TransferStateEnum.COMPLETE, transfer.getTransferState()); - - TransferAttempt attempts[] = new TransferAttempt[transfer - .getTransferAttempts().size()]; - attempts = transfer.getTransferAttempts().toArray(attempts); - Assert.assertEquals("should be 1 attempt", 1, attempts.length); - - TransferAttempt attempt = attempts[0]; - Assert.assertNotNull("transfer attempt not persisted", attempt.getId()); - Assert.assertEquals(TransferStatusEnum.ERROR, - attempt.getAttemptStatus()); - Assert.assertFalse("should have an error message", attempt - .getErrorMessage().isEmpty()); - } - - @Test - public void testPutThenPause() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - - conveyorService.getConfigurationService().addConfigurationProperty( - logSuccessful); - - ConfigurationProperty maxErrors = new ConfigurationProperty(); - maxErrors - .setPropertyKey(ConfigurationPropertyConstants.MAX_ERRORS_BEFORE_CANCEL_KEY); - maxErrors.setPropertyValue(5); - conveyorService.getConfigurationService().addConfigurationProperty( - maxErrors); - - String rootCollection = "testPutThenPause"; - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - - FileGenerator - .generateManyFilesAndCollectionsInParentCollectionByAbsolutePath( - localCollectionAbsolutePath, "testPutThenPause", 4, 6, - 4, "testFile", ".txt", 10, 5, 100, 2000); - - IRODSFileFactory irodsFileFactory = irodsFileSystem - .getIRODSFileFactory(irodsAccount); - IRODSFile destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - File localFile = new File(localCollectionAbsolutePath); - - Transfer transfer = new Transfer(); - transfer.setIrodsAbsolutePath(destFile.getAbsolutePath()); - transfer.setLocalAbsolutePath(localFile.getAbsolutePath()); - transfer.setTransferType(TransferType.PUT); - - conveyorService.getQueueManagerService().enqueueTransferOperation( - transfer, irodsAccount); - - while (conveyorService.getConveyorExecutorService().getRunningStatus() == RunningStatus.IDLE) { - Thread.sleep(1000); - } - - conveyorService.getConveyorExecutorService().requestPause(); - - TransferTestRunningUtilities.waitForTransferToRunOrTimeout( - conveyorService, TRANSFER_TIMEOUT); - - List transfers = conveyorService.getQueueManagerService() - .listAllTransfersInQueue(); - Assert.assertFalse("no transfers in queue", transfers.isEmpty()); - Transfer lastTransfer = transfers.get(0); - Assert.assertEquals("should be a cancelled transfer", - TransferStateEnum.CANCELLED, lastTransfer.getTransferState()); - Assert.assertEquals("should be paused", RunningStatus.PAUSED, - conveyorService.getConveyorExecutorService().getRunningStatus()); - } - - @Test - // BUG [#1672] double free or corruption caused by replication of collection - // (it has long paths, btw) on iRODS 3.3 - public void testReplicateDataObjectsInCollection() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - conveyorService.cancelQueueTimerTask(); - conveyorService.getConveyorExecutorService().requestResumeFromPause(); - - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - - conveyorService.getConfigurationService().addConfigurationProperty( - logSuccessful); - - ConfigurationProperty maxErrors = new ConfigurationProperty(); - maxErrors - .setPropertyKey(ConfigurationPropertyConstants.MAX_ERRORS_BEFORE_CANCEL_KEY); - maxErrors.setPropertyValue(5); - conveyorService.getConfigurationService().addConfigurationProperty( - maxErrors); - - String rootCollection = "testReplicateDataObjectsInCollection"; - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - - FileGenerator - .generateManyFilesAndCollectionsInParentCollectionByAbsolutePath( - localCollectionAbsolutePath, - "testReplicateDataObjectsInCollection", 2, 5, 2, - "testFile", ".txt", 10, 5, 100, 2000); - - IRODSFileFactory irodsFileFactory = irodsFileSystem - .getIRODSFileFactory(irodsAccount); - IRODSFile destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - File localFile = new File(localCollectionAbsolutePath); - - DataTransferOperations dto = irodsFileSystem - .getIRODSAccessObjectFactory().getDataTransferOperations( - irodsAccount); - - TransferControlBlock tcb = irodsFileSystem.getIrodsSession() - .buildDefaultTransferControlBlockBasedOnJargonProperties(); - tcb.getTransferOptions().setForceOption(ForceOption.USE_FORCE); - - dto.putOperation(localFile, destFile, null, tcb); - - Transfer transfer = new Transfer(); - transfer.setIrodsAbsolutePath(destFile.getAbsolutePath()); - transfer.setResourceName(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_SECONDARY_RESOURCE_KEY)); - transfer.setTransferType(TransferType.REPLICATE); - - conveyorService.getQueueManagerService().enqueueTransferOperation( - transfer, irodsAccount); - - TransferTestRunningUtilities.waitForTransferToRunOrTimeout( - conveyorService, TRANSFER_TIMEOUT); - - List transfers = conveyorService.getQueueManagerService() - .listAllTransfersInQueue(); - Assert.assertFalse("no transfers in queue", transfers.isEmpty()); - Assert.assertEquals("should be 1 transfer..maybe test cleanup is bad", - 1, transfers.size()); - transfer = transfers.get(0); - - transfer = conveyorService.getQueueManagerService() - .initializeGivenTransferByLoadingChildren(transfer); - - Assert.assertFalse("did not create a transfer attempt", transfer - .getTransferAttempts().isEmpty()); - - Assert.assertEquals("did not get complete status", - TransferStateEnum.COMPLETE, transfer.getTransferState()); - - TransferAttempt attempts[] = new TransferAttempt[transfer - .getTransferAttempts().size()]; - attempts = transfer.getTransferAttempts().toArray(attempts); - Assert.assertEquals("should be 1 attempt", 1, attempts.length); - - TransferAttempt attempt = attempts[0]; - Assert.assertNotNull("transfer attempt not persisted", attempt.getId()); - Assert.assertEquals(TransferStatusEnum.OK, attempt.getAttemptStatus()); - - } -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/functionaltest/ConveyorServicePutInspectForBundleOperationMicroserviceFunctionalTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/functionaltest/ConveyorServicePutInspectForBundleOperationMicroserviceFunctionalTest.java deleted file mode 100644 index 92c5431cb..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/functionaltest/ConveyorServicePutInspectForBundleOperationMicroserviceFunctionalTest.java +++ /dev/null @@ -1,164 +0,0 @@ -package org.irods.jargon.conveyor.functionaltest; - -import java.io.File; -import java.util.List; -import java.util.Properties; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.core.ConfigurationPropertyConstants; -import org.irods.jargon.conveyor.core.ConveyorExecutorService.RunningStatus; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.conveyor.unittest.utils.FlowTestProvisioningUtil; -import org.irods.jargon.conveyor.unittest.utils.TransferTestRunningUtilities; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.core.pub.io.IRODSFile; -import org.irods.jargon.core.pub.io.IRODSFileFactory; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.testutils.filemanip.FileGenerator; -import org.irods.jargon.transfer.dao.domain.ConfigurationProperty; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferStateEnum; -import org.irods.jargon.transfer.dao.domain.TransferType; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:transfer-dao-beans.xml", - "classpath:transfer-dao-hibernate-spring.cfg.xml" }) -@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false) -public class ConveyorServicePutInspectForBundleOperationMicroserviceFunctionalTest { - private static Properties testingProperties = new Properties(); - private static Properties transferProperties = new Properties(); - private static org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - private static org.irods.jargon.testutils.filemanip.ScratchFileUtils scratchFileUtils = null; - public static final String IRODS_TEST_SUBDIR_PATH = "ConveyorServicePutInspectForBundleOperationMicroserviceFunctionalTest"; - private static org.irods.jargon.testutils.IRODSTestSetupUtilities irodsTestSetupUtilities = null; - private static IRODSFileSystem irodsFileSystem = null; - private static int TRANSFER_TIMEOUT = -1; - - @Autowired - private ConveyorService conveyorService; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - irodsFileSystem = IRODSFileSystem.instance(); - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - transferProperties = FlowTestProvisioningUtil - .retrieveTransferProperties(); - - if (transferProperties == null) { - throw new JargonException("no transfer.properties found"); - } - - scratchFileUtils = new org.irods.jargon.testutils.filemanip.ScratchFileUtils( - testingProperties); - scratchFileUtils - .clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH); - irodsTestSetupUtilities = new org.irods.jargon.testutils.IRODSTestSetupUtilities(); - irodsTestSetupUtilities.clearIrodsScratchDirectory(); - irodsTestSetupUtilities.initializeIrodsScratchDirectory(); - irodsTestSetupUtilities - .initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH); - - // clear and provision the groovy test dsl area - - FlowTestProvisioningUtil.clearAndProvisionTestDslDirecory( - transferProperties, - "/testFlowDsl/testPutPassBundleCondition.groovy"); - } - - @Before - public void setUp() throws Exception { - conveyorService.setIrodsAccessObjectFactory(irodsFileSystem - .getIRODSAccessObjectFactory()); - conveyorService.getQueueManagerService().purgeAllFromQueue(); - conveyorService.getGridAccountService().resetPassPhraseAndAccounts(); - conveyorService.getConveyorExecutorService().requestResumeFromPause(); - - } - - @After - public void tearDown() throws Exception { - conveyorService.getQueueManagerService().purgeAllFromQueue(); - } - - @Test - public void testPutWithPostFileMetadataShouldPass() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - - conveyorService.getConfigurationService().addConfigurationProperty( - logSuccessful); - - ConfigurationProperty maxErrors = new ConfigurationProperty(); - maxErrors - .setPropertyKey(ConfigurationPropertyConstants.MAX_ERRORS_BEFORE_CANCEL_KEY); - maxErrors.setPropertyValue(5); - conveyorService.getConfigurationService().addConfigurationProperty( - maxErrors); - - String rootCollection = "testPutWithPostFileMetadataShouldPass"; - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - - FileGenerator - .generateManyFilesAndCollectionsInParentCollectionByAbsolutePath( - localCollectionAbsolutePath, - "testPutWithPostFileMetadataShouldPass", 4, 6, 4, - "testFile", ".txt", 10, 5, 1, 2); - - IRODSFileFactory irodsFileFactory = irodsFileSystem - .getIRODSFileFactory(irodsAccount); - IRODSFile destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - File localFile = new File(localCollectionAbsolutePath); - - Transfer transfer = new Transfer(); - transfer.setIrodsAbsolutePath(destFile.getAbsolutePath()); - transfer.setLocalAbsolutePath(localFile.getAbsolutePath()); - transfer.setTransferType(TransferType.PUT); - - conveyorService.getQueueManagerService().enqueueTransferOperation( - transfer, irodsAccount); - - while (conveyorService.getConveyorExecutorService().getRunningStatus() == RunningStatus.IDLE) { - Thread.sleep(1000); - } - - TransferTestRunningUtilities.waitForTransferToRunOrTimeout( - conveyorService, TRANSFER_TIMEOUT); - - List transfers = conveyorService.getQueueManagerService() - .listAllTransfersInQueue(); - Assert.assertFalse("no transfers in queue", transfers.isEmpty()); - Transfer lastTransfer = transfers.get(0); - Assert.assertEquals("should be a complete transfer", - TransferStateEnum.COMPLETE, lastTransfer.getTransferState()); - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/functionaltest/ConveyorServicePutWithPostFileMetadataFunctionalTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/functionaltest/ConveyorServicePutWithPostFileMetadataFunctionalTest.java deleted file mode 100644 index 8a9b79412..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/functionaltest/ConveyorServicePutWithPostFileMetadataFunctionalTest.java +++ /dev/null @@ -1,165 +0,0 @@ -package org.irods.jargon.conveyor.functionaltest; - -import java.io.File; -import java.util.List; -import java.util.Properties; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.core.ConfigurationPropertyConstants; -import org.irods.jargon.conveyor.core.ConveyorExecutorService.RunningStatus; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.conveyor.unittest.utils.FlowTestProvisioningUtil; -import org.irods.jargon.conveyor.unittest.utils.TransferTestRunningUtilities; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.core.pub.io.IRODSFile; -import org.irods.jargon.core.pub.io.IRODSFileFactory; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.testutils.filemanip.FileGenerator; -import org.irods.jargon.transfer.dao.domain.ConfigurationProperty; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferStateEnum; -import org.irods.jargon.transfer.dao.domain.TransferType; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:transfer-dao-beans.xml", - "classpath:transfer-dao-hibernate-spring.cfg.xml" }) -@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false) -public class ConveyorServicePutWithPostFileMetadataFunctionalTest { - - private static Properties testingProperties = new Properties(); - private static Properties transferProperties = new Properties(); - private static org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - private static org.irods.jargon.testutils.filemanip.ScratchFileUtils scratchFileUtils = null; - public static final String IRODS_TEST_SUBDIR_PATH = "ConveyorServicePutWithPostFileMetadataFunctionalTest"; - private static org.irods.jargon.testutils.IRODSTestSetupUtilities irodsTestSetupUtilities = null; - private static IRODSFileSystem irodsFileSystem = null; - private static int TRANSFER_TIMEOUT = -1; - - @Autowired - private ConveyorService conveyorService; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - irodsFileSystem = IRODSFileSystem.instance(); - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - transferProperties = FlowTestProvisioningUtil - .retrieveTransferProperties(); - - if (transferProperties == null) { - throw new JargonException("no transfer.properties found"); - } - - scratchFileUtils = new org.irods.jargon.testutils.filemanip.ScratchFileUtils( - testingProperties); - scratchFileUtils - .clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH); - irodsTestSetupUtilities = new org.irods.jargon.testutils.IRODSTestSetupUtilities(); - irodsTestSetupUtilities.clearIrodsScratchDirectory(); - irodsTestSetupUtilities.initializeIrodsScratchDirectory(); - irodsTestSetupUtilities - .initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH); - - // clear and provision the groovy test dsl area - - FlowTestProvisioningUtil.clearAndProvisionTestDslDirecory( - transferProperties, - "/testFlowDsl/testPutWithPostFileMetadata.groovy"); - } - - @Before - public void setUp() throws Exception { - conveyorService.setIrodsAccessObjectFactory(irodsFileSystem - .getIRODSAccessObjectFactory()); - conveyorService.getQueueManagerService().purgeAllFromQueue(); - conveyorService.getGridAccountService().resetPassPhraseAndAccounts(); - conveyorService.getConveyorExecutorService().requestResumeFromPause(); - - } - - @After - public void tearDown() throws Exception { - conveyorService.getQueueManagerService().purgeAllFromQueue(); - } - - @Test - public void testPutWithPostFileMetadata() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - - conveyorService.getConfigurationService().addConfigurationProperty( - logSuccessful); - - ConfigurationProperty maxErrors = new ConfigurationProperty(); - maxErrors - .setPropertyKey(ConfigurationPropertyConstants.MAX_ERRORS_BEFORE_CANCEL_KEY); - maxErrors.setPropertyValue(5); - conveyorService.getConfigurationService().addConfigurationProperty( - maxErrors); - - String rootCollection = "testPutWithPostFileMetadata"; - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - - FileGenerator - .generateManyFilesAndCollectionsInParentCollectionByAbsolutePath( - localCollectionAbsolutePath, - "testPutWithPostFileMetadata", 4, 6, 4, "testFile", - ".txt", 10, 5, 1, 2); - - IRODSFileFactory irodsFileFactory = irodsFileSystem - .getIRODSFileFactory(irodsAccount); - IRODSFile destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - File localFile = new File(localCollectionAbsolutePath); - - Transfer transfer = new Transfer(); - transfer.setIrodsAbsolutePath(destFile.getAbsolutePath()); - transfer.setLocalAbsolutePath(localFile.getAbsolutePath()); - transfer.setTransferType(TransferType.PUT); - - conveyorService.getQueueManagerService().enqueueTransferOperation( - transfer, irodsAccount); - - while (conveyorService.getConveyorExecutorService().getRunningStatus() == RunningStatus.IDLE) { - Thread.sleep(1000); - } - - TransferTestRunningUtilities.waitForTransferToRunOrTimeout( - conveyorService, TRANSFER_TIMEOUT); - - List transfers = conveyorService.getQueueManagerService() - .listAllTransfersInQueue(); - Assert.assertFalse("no transfers in queue", transfers.isEmpty()); - Transfer lastTransfer = transfers.get(0); - Assert.assertEquals("should be a complete transfer", - TransferStateEnum.COMPLETE, lastTransfer.getTransferState()); - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/functionaltest/ConveyorServicePutWithSkipFunctionalTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/functionaltest/ConveyorServicePutWithSkipFunctionalTest.java deleted file mode 100644 index 7a1dce9d8..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/functionaltest/ConveyorServicePutWithSkipFunctionalTest.java +++ /dev/null @@ -1,171 +0,0 @@ -package org.irods.jargon.conveyor.functionaltest; - -import java.io.File; -import java.util.List; -import java.util.Properties; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.core.ConfigurationPropertyConstants; -import org.irods.jargon.conveyor.core.ConveyorExecutorService.RunningStatus; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.conveyor.unittest.utils.FlowTestProvisioningUtil; -import org.irods.jargon.conveyor.unittest.utils.TransferTestRunningUtilities; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.core.pub.io.IRODSFile; -import org.irods.jargon.core.pub.io.IRODSFileFactory; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.testutils.filemanip.FileGenerator; -import org.irods.jargon.transfer.dao.domain.ConfigurationProperty; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferStateEnum; -import org.irods.jargon.transfer.dao.domain.TransferType; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:transfer-dao-beans.xml", - "classpath:transfer-dao-hibernate-spring.cfg.xml" }) -@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false) -public class ConveyorServicePutWithSkipFunctionalTest { - - private static Properties testingProperties = new Properties(); - private static Properties transferProperties = new Properties(); - private static org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - private static org.irods.jargon.testutils.filemanip.ScratchFileUtils scratchFileUtils = null; - public static final String IRODS_TEST_SUBDIR_PATH = "ConveyorServicePutWithSkipFunctionalTest"; - private static org.irods.jargon.testutils.IRODSTestSetupUtilities irodsTestSetupUtilities = null; - private static IRODSFileSystem irodsFileSystem = null; - private static int TRANSFER_TIMEOUT = -1; - - @Autowired - private ConveyorService conveyorService; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - irodsFileSystem = IRODSFileSystem.instance(); - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - transferProperties = FlowTestProvisioningUtil - .retrieveTransferProperties(); - - if (transferProperties == null) { - throw new JargonException("no transfer.properties found"); - } - - scratchFileUtils = new org.irods.jargon.testutils.filemanip.ScratchFileUtils( - testingProperties); - scratchFileUtils - .clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH); - irodsTestSetupUtilities = new org.irods.jargon.testutils.IRODSTestSetupUtilities(); - irodsTestSetupUtilities.clearIrodsScratchDirectory(); - irodsTestSetupUtilities.initializeIrodsScratchDirectory(); - irodsTestSetupUtilities - .initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH); - - // clear and provision the groovy test dsl area - - FlowTestProvisioningUtil.clearAndProvisionTestDslDirecory( - transferProperties, "/testFlowDsl/testPutWithSkipme.groovy"); - - } - - @Before - public void setUp() throws Exception { - conveyorService.setIrodsAccessObjectFactory(irodsFileSystem - .getIRODSAccessObjectFactory()); - conveyorService.getQueueManagerService().purgeAllFromQueue(); - conveyorService.getGridAccountService().resetPassPhraseAndAccounts(); - conveyorService.getConveyorExecutorService().requestResumeFromPause(); - - } - - @After - public void tearDown() throws Exception { - conveyorService.getQueueManagerService().purgeAllFromQueue(); - } - - @Test - public void testPutWithSkipmeFile() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - ConfigurationProperty logSuccessful = new ConfigurationProperty(); - logSuccessful - .setPropertyKey(ConfigurationPropertyConstants.LOG_SUCCESSFUL_FILES_KEY); - logSuccessful.setPropertyValue("true"); - - conveyorService.getConfigurationService().addConfigurationProperty( - logSuccessful); - - ConfigurationProperty maxErrors = new ConfigurationProperty(); - maxErrors - .setPropertyKey(ConfigurationPropertyConstants.MAX_ERRORS_BEFORE_CANCEL_KEY); - maxErrors.setPropertyValue(5); - conveyorService.getConfigurationService().addConfigurationProperty( - maxErrors); - - String rootCollection = "testPutWithSkipmeFile"; - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - - FileGenerator - .generateManyFilesAndCollectionsInParentCollectionByAbsolutePath( - localCollectionAbsolutePath, "testPutWithSkipmeFile", - 4, 6, 4, "testFile", ".txt", 10, 5, 1, 2); - - // generate a couple files to skip - - FileGenerator.generateFileOfFixedLengthGivenName( - localCollectionAbsolutePath, "SKIPME1.txt", 1); - FileGenerator.generateFileOfFixedLengthGivenName( - localCollectionAbsolutePath, "SKIPME2Howaboutthat.txt", 1); - - IRODSFileFactory irodsFileFactory = irodsFileSystem - .getIRODSFileFactory(irodsAccount); - IRODSFile destFile = irodsFileFactory - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - File localFile = new File(localCollectionAbsolutePath); - - Transfer transfer = new Transfer(); - transfer.setIrodsAbsolutePath(destFile.getAbsolutePath()); - transfer.setLocalAbsolutePath(localFile.getAbsolutePath()); - transfer.setTransferType(TransferType.PUT); - - conveyorService.getQueueManagerService().enqueueTransferOperation( - transfer, irodsAccount); - - while (conveyorService.getConveyorExecutorService().getRunningStatus() == RunningStatus.IDLE) { - Thread.sleep(1000); - } - - TransferTestRunningUtilities.waitForTransferToRunOrTimeout( - conveyorService, TRANSFER_TIMEOUT); - - List transfers = conveyorService.getQueueManagerService() - .listAllTransfersInQueue(); - Assert.assertFalse("no transfers in queue", transfers.isEmpty()); - Transfer lastTransfer = transfers.get(0); - Assert.assertEquals("should be a complete transfer", - TransferStateEnum.COMPLETE, lastTransfer.getTransferState()); - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/functionaltest/package-info.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/functionaltest/package-info.java deleted file mode 100644 index d0b9d6d07..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/functionaltest/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Full system functional tests - * - * @author Mike Conway - DICE (www.irods.org) - * see https://code.renci.org/gf/project/jargon/ - * - */ -package org.irods.jargon.conveyor.functionaltest; \ No newline at end of file diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/gridaccount/GridAccountConfigurationProcessorTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/gridaccount/GridAccountConfigurationProcessorTest.java deleted file mode 100644 index 573440096..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/gridaccount/GridAccountConfigurationProcessorTest.java +++ /dev/null @@ -1,120 +0,0 @@ -package org.irods.jargon.conveyor.gridaccount; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -import junit.framework.Assert; - -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -public class GridAccountConfigurationProcessorTest { - - private static Properties testingProperties = new Properties(); - private static org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - private static org.irods.jargon.testutils.filemanip.ScratchFileUtils scratchFileUtils = null; - public static final String IRODS_TEST_SUBDIR_PATH = "GridAccountServiceImplTest"; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - scratchFileUtils = new org.irods.jargon.testutils.filemanip.ScratchFileUtils( - testingProperties); - scratchFileUtils - .clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH); - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testSerializeIRODSAccountListToFile() throws Exception { - String testFileName = "testSerializeIRODSAccountListToFile.txt"; - ArrayList irodsAccounts = new ArrayList(); - irodsAccounts.add(testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, "test", "test")); - String testFileAbsPath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + "/" + testFileName); - File testFile = new File(testFileAbsPath); - GridAccountConfigurationProcessor.serializeIRODSAccountListToFile( - testFile, irodsAccounts); - Assert.assertTrue("file does not exist", testFile.exists()); - List actual = GridAccountConfigurationProcessor - .deserializeIRODSAccountListFromFile(testFile); - IRODSAccount expected = irodsAccounts.get(0); - Assert.assertEquals("did not get an account", 1, actual.size()); - Assert.assertEquals("bad host", expected.getHost(), actual.get(0) - .getHost()); - Assert.assertEquals("bad port", expected.getPort(), actual.get(0) - .getPort()); - Assert.assertEquals("bad zone", expected.getZone(), actual.get(0) - .getZone()); - Assert.assertEquals("bad user", expected.getUserName(), actual.get(0) - .getUserName()); - Assert.assertEquals("bad resource", expected - .getDefaultStorageResource(), actual.get(0) - .getDefaultStorageResource()); - Assert.assertEquals("bad home dir", expected.getHomeDirectory(), actual - .get(0).getHomeDirectory()); - Assert.assertEquals("bad auth type", - expected.getAuthenticationScheme(), actual.get(0) - .getAuthenticationScheme()); - - } - - @Test(expected = IllegalArgumentException.class) - public void testSerializeIRODSAccountListNullFile() throws Exception { - ArrayList irodsAccounts = new ArrayList(); - GridAccountConfigurationProcessor.serializeIRODSAccountListToFile(null, - irodsAccounts); - } - - @Test(expected = IllegalArgumentException.class) - public void testSerializeIRODSAccountListNullAccounts() throws Exception { - String testFileName = "testSerializeIRODSAccountListToFile.txt"; - String testFileAbsPath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + "/" + testFileName); - File testFile = new File(testFileAbsPath); - - GridAccountConfigurationProcessor.serializeIRODSAccountListToFile( - testFile, null); - } - - @Test - public void testSerializeIRODSAccountListEmptyAccounts() throws Exception { - String testFileName = "testSerializeIRODSAccountListToFile.txt"; - ArrayList irodsAccounts = new ArrayList(); - String testFileAbsPath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + "/" + testFileName); - File testFile = new File(testFileAbsPath); - - GridAccountConfigurationProcessor.serializeIRODSAccountListToFile( - testFile, irodsAccounts); - List actual = GridAccountConfigurationProcessor - .deserializeIRODSAccountListFromFile(testFile); - Assert.assertEquals("should get empty account list", 0, actual.size()); - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/synch/DefaultDiffCreatorTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/synch/DefaultDiffCreatorTest.java deleted file mode 100644 index a2a3e20cd..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/synch/DefaultDiffCreatorTest.java +++ /dev/null @@ -1,140 +0,0 @@ -package org.irods.jargon.conveyor.synch; - -import java.io.File; -import java.util.Date; -import java.util.Properties; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.datautils.tree.FileTreeModel; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.testutils.filemanip.FileGenerator; -import org.irods.jargon.transfer.dao.domain.FrequencyType; -import org.irods.jargon.transfer.dao.domain.GridAccount; -import org.irods.jargon.transfer.dao.domain.Synchronization; -import org.irods.jargon.transfer.dao.domain.SynchronizationType; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferStateEnum; -import org.irods.jargon.transfer.dao.domain.TransferType; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:transfer-dao-beans.xml", - "classpath:transfer-dao-hibernate-spring.cfg.xml" }) -@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false) -public class DefaultDiffCreatorTest { - private static Properties testingProperties = new Properties(); - private static org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - private static org.irods.jargon.testutils.filemanip.ScratchFileUtils scratchFileUtils = null; - public static final String IRODS_TEST_SUBDIR_PATH = "DefaultDiffCreatorTest"; - private static org.irods.jargon.testutils.IRODSTestSetupUtilities irodsTestSetupUtilities = null; - private static IRODSFileSystem irodsFileSystem = null; - - @Autowired - private ConveyorService conveyorService; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - irodsFileSystem = IRODSFileSystem.instance(); - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - scratchFileUtils = new org.irods.jargon.testutils.filemanip.ScratchFileUtils( - testingProperties); - scratchFileUtils - .clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH); - irodsTestSetupUtilities = new org.irods.jargon.testutils.IRODSTestSetupUtilities(); - irodsTestSetupUtilities.clearIrodsScratchDirectory(); - irodsTestSetupUtilities.initializeIrodsScratchDirectory(); - irodsTestSetupUtilities - .initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH); - } - - @Before - public void setUp() throws Exception { - conveyorService.setIrodsAccessObjectFactory(irodsFileSystem - .getIRODSAccessObjectFactory()); - conveyorService.getQueueManagerService().purgeAllFromQueue(); - conveyorService.getGridAccountService().resetPassPhraseAndAccounts(); - conveyorService.getConveyorExecutorService().requestResumeFromPause(); - - } - - @After - public void tearDown() throws Exception { - conveyorService.getQueueManagerService().purgeAllFromQueue(); - } - - @Test - public void testCreateDiff() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - - IRODSFileSystem irodsFileSystem = IRODSFileSystem.instance(); - String rootCollection = "testCreateDiff"; - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH + "/" - + rootCollection); - - File irodsRoot = (File) irodsFileSystem.getIRODSFileFactory( - irodsAccount) - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - irodsRoot.mkdirs(); - - FileGenerator.generateManyFilesInGivenDirectory(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection, "test", ".doc", 20, 1, 2); - - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - GridAccount gridAccount = conveyorService.getGridAccountService() - .findGridAccountByIRODSAccount(irodsAccount); - - AbstractSynchronizingDiffCreator diffCreator = new DefaultDiffCreator( - conveyorService, - irodsFileSystem - .getIRODSAccessObjectFactory() - .buildDefaultTransferControlBlockBasedOnJargonProperties()); - - Date now = new Date(); - Synchronization synch = new Synchronization(); - synch.setGridAccount(gridAccount); - synch.setFrequencyType(FrequencyType.EVERY_DAY); - synch.setIrodsSynchDirectory(irodsCollectionRootAbsolutePath); - synch.setLocalSynchDirectory(localCollectionAbsolutePath); - synch.setName(rootCollection); - synch.setSynchronizationMode(SynchronizationType.ONE_WAY_LOCAL_TO_IRODS); - synch.setCreatedAt(now); - synch.setUpdatedAt(now); - conveyorService.getSynchronizationManagerService() - .addOrUpdateSynchronization(synch); - - Transfer synchTransfer = new Transfer(); - synchTransfer.setGridAccount(gridAccount); - synchTransfer.setIrodsAbsolutePath(irodsCollectionRootAbsolutePath); - synchTransfer.setLocalAbsolutePath(localCollectionAbsolutePath); - synchTransfer.setSynchronization(synch); - synchTransfer.setTransferState(TransferStateEnum.ENQUEUED); - synchTransfer.setTransferType(TransferType.SYNCH); - - FileTreeModel diffModel = diffCreator.createDiff(synchTransfer); - Assert.assertNotNull("null diff model", diffModel); - - } -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/synch/DefaultSynchComponentFactoryTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/synch/DefaultSynchComponentFactoryTest.java deleted file mode 100644 index 6129587d3..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/synch/DefaultSynchComponentFactoryTest.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.irods.jargon.conveyor.synch; - -import java.util.Properties; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.core.transfer.TransferControlBlock; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.transfer.dao.domain.Synchronization; -import org.irods.jargon.transfer.dao.domain.SynchronizationType; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; -import org.springframework.transaction.annotation.Transactional; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:transfer-dao-beans.xml", - "classpath:transfer-dao-hibernate-spring.cfg.xml" }) -@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true) -@Transactional -public class DefaultSynchComponentFactoryTest { - private static Properties testingProperties = new Properties(); - private static org.irods.jargon.testutils.filemanip.ScratchFileUtils scratchFileUtils = null; - public static final String IRODS_TEST_SUBDIR_PATH = "BasicSynchronizationServiceImplTest"; - private static org.irods.jargon.testutils.IRODSTestSetupUtilities irodsTestSetupUtilities = null; - - private static IRODSFileSystem irodsFileSystem = null; - - @Autowired - private ConveyorService conveyorService; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - irodsFileSystem = IRODSFileSystem.instance(); - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - scratchFileUtils = new org.irods.jargon.testutils.filemanip.ScratchFileUtils( - testingProperties); - scratchFileUtils - .clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH); - irodsTestSetupUtilities = new org.irods.jargon.testutils.IRODSTestSetupUtilities(); - irodsTestSetupUtilities.clearIrodsScratchDirectory(); - irodsTestSetupUtilities.initializeIrodsScratchDirectory(); - irodsTestSetupUtilities - .initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH); - } - - @Before - public void setUp() throws Exception { - conveyorService.setIrodsAccessObjectFactory(irodsFileSystem - .getIRODSAccessObjectFactory()); - conveyorService.getQueueManagerService().purgeAllFromQueue(); - conveyorService.getGridAccountService().resetPassPhraseAndAccounts(); - - } - - @After - public void tearDown() throws Exception { - conveyorService.getQueueManagerService().purgeAllFromQueue(); - } - - @Test - public void testWiredIn() throws Exception { - SynchComponentFactory actual = conveyorService - .getSynchComponentFactory(); - Assert.assertNotNull("synch factory not wired in", actual); - } - - @Test - public void testGetDiffProcessorForIrodsToLocal() throws Exception { - Synchronization synch = new Synchronization(); - synch.setSynchronizationMode(SynchronizationType.ONE_WAY_LOCAL_TO_IRODS); - TransferControlBlock tcb = irodsFileSystem - .getIRODSAccessObjectFactory() - .buildDefaultTransferControlBlockBasedOnJargonProperties(); - LocalToIRODSDiffProcessor processor = (LocalToIRODSDiffProcessor) conveyorService - .getSynchComponentFactory().instanceDiffProcessor(synch, tcb); - Assert.assertNotNull("no processor returned", processor); - - } -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/synch/LocalToIRODSDiffProcessorTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/synch/LocalToIRODSDiffProcessorTest.java deleted file mode 100644 index 930bea87f..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/synch/LocalToIRODSDiffProcessorTest.java +++ /dev/null @@ -1,145 +0,0 @@ -package org.irods.jargon.conveyor.synch; - -import java.io.File; -import java.util.Date; -import java.util.Properties; - -import junit.framework.Assert; - -import org.irods.jargon.conveyor.core.ConveyorExecutorService.RunningStatus; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.datautils.tree.FileTreeDiffUtility; -import org.irods.jargon.datautils.tree.FileTreeDiffUtilityImpl; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.testutils.filemanip.FileGenerator; -import org.irods.jargon.transfer.dao.domain.FrequencyType; -import org.irods.jargon.transfer.dao.domain.GridAccount; -import org.irods.jargon.transfer.dao.domain.Synchronization; -import org.irods.jargon.transfer.dao.domain.SynchronizationType; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:transfer-dao-beans.xml", - "classpath:transfer-dao-hibernate-spring.cfg.xml" }) -@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true) -// @Transactional -public class LocalToIRODSDiffProcessorTest { - - private static org.irods.jargon.testutils.filemanip.ScratchFileUtils scratchFileUtils = null; - public static final String IRODS_TEST_SUBDIR_PATH = "BasicSynchronizationServiceImplTest"; - private static org.irods.jargon.testutils.IRODSTestSetupUtilities irodsTestSetupUtilities = null; - private static Properties testingProperties = new Properties(); - private static org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - - private static IRODSFileSystem irodsFileSystem = null; - - @Autowired - private ConveyorService conveyorService; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - irodsFileSystem = IRODSFileSystem.instance(); - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - scratchFileUtils = new org.irods.jargon.testutils.filemanip.ScratchFileUtils( - testingProperties); - scratchFileUtils - .clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH); - irodsTestSetupUtilities = new org.irods.jargon.testutils.IRODSTestSetupUtilities(); - irodsTestSetupUtilities.clearIrodsScratchDirectory(); - irodsTestSetupUtilities.initializeIrodsScratchDirectory(); - irodsTestSetupUtilities - .initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH); - } - - @Before - public void setUp() throws Exception { - conveyorService.setIrodsAccessObjectFactory(irodsFileSystem - .getIRODSAccessObjectFactory()); - conveyorService.getQueueManagerService().purgeAllFromQueue(); - conveyorService.getGridAccountService().resetPassPhraseAndAccounts(); - - } - - @After - public void tearDown() throws Exception { - conveyorService.getQueueManagerService().purgeAllFromQueue(); - } - - @Test - public void testSynchLocalDirWithSeveralFilesPlus() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - - String rootCollection = "testSynchLocalPlus"; - String localCollectionAbsolutePath = scratchFileUtils - .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection); - - String irodsCollectionRootAbsolutePath = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH + "/" - + rootCollection); - - File irodsRoot = (File) irodsFileSystem.getIRODSFileFactory( - irodsAccount) - .instanceIRODSFile(irodsCollectionRootAbsolutePath); - irodsRoot.mkdirs(); - - FileGenerator.generateManyFilesInGivenDirectory(IRODS_TEST_SUBDIR_PATH - + '/' + rootCollection, "test", ".doc", 20, 1, 2); - - conveyorService.validatePassPhrase(testingProperties - .getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - conveyorService.getGridAccountService() - .addOrUpdateGridAccountBasedOnIRODSAccount(irodsAccount); - GridAccount gridAccount = conveyorService.getGridAccountService() - .findGridAccountByIRODSAccount(irodsAccount); - - Date now = new Date(); - Synchronization synch = new Synchronization(); - synch.setGridAccount(gridAccount); - synch.setFrequencyType(FrequencyType.EVERY_DAY); - synch.setIrodsSynchDirectory(irodsCollectionRootAbsolutePath); - synch.setLocalSynchDirectory(localCollectionAbsolutePath); - synch.setName(rootCollection); - synch.setSynchronizationMode(SynchronizationType.ONE_WAY_LOCAL_TO_IRODS); - synch.setCreatedAt(now); - synch.setUpdatedAt(now); - conveyorService.getSynchronizationManagerService() - .addOrUpdateSynchronization(synch); - - conveyorService.getSynchronizationManagerService() - .triggerSynchronizationNow(synch); - Thread.sleep(1000); - - while (conveyorService.getConveyorExecutorService().getRunningStatus() != RunningStatus.IDLE) { - Thread.sleep(1000); - } - - Synchronization postSynch = conveyorService - .getSynchronizationManagerService().findById(synch.getId()); - Assert.assertNotNull("did not get post synch data", postSynch); - - FileTreeDiffUtility fileTreeDiffUtility = new FileTreeDiffUtilityImpl( - irodsAccount, irodsFileSystem.getIRODSAccessObjectFactory()); - - boolean noDiffs = fileTreeDiffUtility.verifyLocalAndIRODSTreesMatch( - new File(localCollectionAbsolutePath), - irodsCollectionRootAbsolutePath, 0L, 0L); - - Assert.assertTrue("diffs found after synch", noDiffs); - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/unittest/AllTests.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/unittest/AllTests.java deleted file mode 100644 index 442e04d7d..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/unittest/AllTests.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.irods.jargon.conveyor.unittest; - -import org.irods.jargon.conveyor.basic.BasicConveyorBootstrapperImplTest; -import org.irods.jargon.conveyor.basic.BasicConveyorServiceTest; -import org.irods.jargon.conveyor.basic.BasicFlowManagerServiceTest; -import org.irods.jargon.conveyor.basic.BasicQueueManagerServiceImplTest; -import org.irods.jargon.conveyor.basic.BasicSynchronizationServiceImplTest; -import org.irods.jargon.conveyor.basic.ConfigurationServiceImplTest; -import org.irods.jargon.conveyor.basic.GridAccountServiceImplTest; -import org.irods.jargon.conveyor.basic.TransferAccountingManagementServiceImplTest; -import org.irods.jargon.conveyor.core.ConveyorExecutorServiceImplFunctionalTest; -import org.irods.jargon.conveyor.core.ConveyorExecutorServiceImplTest; -import org.irods.jargon.conveyor.core.ConveyorQueueTimerTaskTest; -import org.irods.jargon.conveyor.core.callables.FlowCoProcessorTest; -import org.irods.jargon.conveyor.core.callables.PutConveyorCallableFlowSpecTest; -import org.irods.jargon.conveyor.flowmanager.flow.FlowSpecCacheServiceTest; -import org.irods.jargon.conveyor.flowmanager.flow.SelectorProcessorTest; -import org.irods.jargon.conveyor.flowmanager.flow.dsl.FlowTest; -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.EnqueueTransferMicroserviceTest; -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.ExtractBundleMicroserviceTest; -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.InspectForUnbundleOperationMicroserviceTest; -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.TarCollectionMicroserviceTest; -import org.irods.jargon.conveyor.functionaltest.ConveyorServiceFunctionalTests; -import org.irods.jargon.conveyor.functionaltest.ConveyorServicePutInspectForBundleOperationMicroserviceFunctionalTest; -import org.irods.jargon.conveyor.functionaltest.ConveyorServicePutWithPostFileMetadataFunctionalTest; -import org.irods.jargon.conveyor.functionaltest.ConveyorServicePutWithSkipFunctionalTest; -import org.irods.jargon.conveyor.gridaccount.GridAccountConfigurationProcessorTest; -import org.irods.jargon.conveyor.synch.DefaultDiffCreatorTest; -import org.irods.jargon.conveyor.synch.DefaultSynchComponentFactoryTest; -import org.irods.jargon.transfer.dao.ConfigurationPropertyDAOTest; -import org.irods.jargon.transfer.dao.GridAccountDAOImplTest; -import org.irods.jargon.transfer.dao.KeyStoreDAOImplTest; -import org.irods.jargon.transfer.dao.TransferDAOTest; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses({ - - ConfigurationPropertyDAOTest.class, - GridAccountDAOImplTest.class, - KeyStoreDAOImplTest.class, - TransferDAOTest.class, - ConveyorExecutorServiceImplTest.class, - BasicConveyorBootstrapperImplTest.class, - GridAccountServiceImplTest.class, - BasicConveyorServiceTest.class, - GridAccountConfigurationProcessorTest.class, - ConfigurationServiceImplTest.class, - TransferAccountingManagementServiceImplTest.class, - BasicQueueManagerServiceImplTest.class, - ConveyorExecutorServiceImplFunctionalTest.class, - ConveyorQueueTimerTaskTest.class, - ConveyorServiceFunctionalTests.class, - BasicSynchronizationServiceImplTest.class, - DefaultSynchComponentFactoryTest.class, - DefaultDiffCreatorTest.class, - FlowTest.class, - FlowSpecCacheServiceTest.class, - SelectorProcessorTest.class, - BasicFlowManagerServiceTest.class, - PutConveyorCallableFlowSpecTest.class, - FlowCoProcessorTest.class, - ConveyorServicePutWithSkipFunctionalTest.class, - ConveyorServicePutWithPostFileMetadataFunctionalTest.class, - ConveyorServicePutInspectForBundleOperationMicroserviceFunctionalTest.class, - TarCollectionMicroserviceTest.class, - EnqueueTransferMicroserviceTest.class, - ExtractBundleMicroserviceTest.class, - InspectForUnbundleOperationMicroserviceTest.class }) -/** - * Suite to run all tests (except long running and functional), further refined by settings in testing.properites. Some subtests may be shut - * off by these properties. - */ -public class AllTests { - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/unittest/package-info.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/unittest/package-info.java deleted file mode 100644 index 6c750bcf9..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/unittest/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Test suites and other test specific libraries - * @author Mike Conway - DICE (www.irods.org) - * - */ -package org.irods.jargon.conveyor.unittest; \ No newline at end of file diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/unittest/utils/FlowTestProvisioningUtil.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/unittest/utils/FlowTestProvisioningUtil.java deleted file mode 100644 index 0f30db022..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/unittest/utils/FlowTestProvisioningUtil.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.unittest.utils; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -import org.apache.commons.io.FileUtils; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.utils.LocalFileUtils; - -/** - * Utilities to provision flow directories for various unit tests - * - * @author Mike Conway - DICE - * - */ -public class FlowTestProvisioningUtil { - - public static Properties retrieveTransferProperties() - throws JargonException { - - ClassLoader loader = FlowTestProvisioningUtil.class.getClassLoader(); - InputStream in = loader.getResourceAsStream("transfer.properties"); - Properties properties = new Properties(); - - try { - properties.load(in); - } catch (IOException ioe) { - throw new JargonException("error loading test properties", ioe); - } finally { - try { - in.close(); - } catch (Exception e) { - // ignore - } - } - return properties; - } - - /** - * Given a resource name (for test/resources) clear out the dsl dir and plug - * this file in as the only dsl. - * - * @param transferProperties - * @param dslName - * @throws JargonException - */ - public static void clearAndProvisionTestDslDirecory( - final Properties transferProperties, final String dslName) - throws JargonException { - - if (transferProperties == null) { - throw new IllegalArgumentException("no transfer.properties found"); - } - - if (dslName == null || dslName.isEmpty()) { - throw new IllegalArgumentException("null dslName"); - } - - clearDslDirectory(transferProperties); - - File groovyFile = LocalFileUtils.getClasspathResourceAsFile(dslName); - - String dslDir = transferProperties.getProperty("flow.dir"); - if (dslDir == null || dslDir.isEmpty()) { - throw new JargonException("no flow.dir specified"); - } - - String userHome = System.getProperty("user.home"); - userHome = LocalFileUtils.normalizePath(userHome); - dslDir = dslDir.replaceAll("\\$\\{user.home\\}", userHome); - - File dslDirFile = new File(dslDir, groovyFile.getName()); - - try { - FileUtils.copyFile(groovyFile, dslDirFile); - } catch (IOException e) { - throw new JargonException("io exception deleting flow dir", e); - } - } - - /** - * Clear out and reinitialize the flow.dir directory specified in - * transfer.properties - * - * @param transferProperties - * @throws JargonException - */ - public static void clearDslDirectory(final Properties transferProperties) - throws JargonException { - - if (transferProperties == null) { - throw new JargonException("no transfer.properties found"); - } - - String dslDir = transferProperties.getProperty("flow.dir"); - String userHome = System.getProperty("user.home"); - userHome = LocalFileUtils.normalizePath(userHome); - dslDir = dslDir.replaceAll("\\$\\{user.home\\}", userHome); - - if (dslDir == null || dslDir.isEmpty()) { - throw new JargonException("no flow.dir specified"); - } - - File dslDirFile = new File(dslDir); - - try { - FileUtils.deleteDirectory(dslDirFile); - dslDirFile.mkdirs(); - } catch (IOException e) { - throw new JargonException("io exception deleting flow dir", e); - } - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/unittest/utils/TransferTestRunningUtilities.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/unittest/utils/TransferTestRunningUtilities.java deleted file mode 100644 index cd6fcd9c5..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/unittest/utils/TransferTestRunningUtilities.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * - */ -package org.irods.jargon.conveyor.unittest.utils; - -import org.irods.jargon.conveyor.core.ConveyorBusyException; -import org.irods.jargon.conveyor.core.ConveyorExecutorService.RunningStatus; -import org.irods.jargon.conveyor.core.ConveyorService; -import org.irods.jargon.core.exception.JargonException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Handy utilities for tests that need to run transfers via conveyer and test - * the results - * - * @author Mike Conway - DICE (www.irods.org) see - * https://code.renci.org/gf/project/jargon/ - * - */ -public class TransferTestRunningUtilities { - - private static final Logger log = LoggerFactory - .getLogger(TransferTestRunningUtilities.class); - - /** - * Given a ConveyorService running a transfer, keep pinging and - * sleeping until the queue is available, up until a timeout - * - * @param conveyorService - * @param timeoutInSeconds - * @throws JargonException - */ - public static void waitForTransferToRunOrTimeout( - final ConveyorService conveyorService, final int timeoutInSeconds) - throws JargonException { - - final long timeout = timeoutInSeconds * 1000; - final long sleepTime; - if (timeoutInSeconds == -1) { - sleepTime = 1000; - } else { - sleepTime = timeout / 10; - - } - - final long startMillis = System.currentTimeMillis(); - - long elapsed; - while (true) { - elapsed = System.currentTimeMillis() - startMillis; - if (timeoutInSeconds == -1) { - // ignore timeout - } else if (elapsed >= timeout) { - throw new JargonException("timeout!"); - } - - try { - if (conveyorService.getConveyorExecutorService() - .getRunningStatus() == RunningStatus.PAUSED) { - break; - } - conveyorService.getConveyorExecutorService() - .setBusyForAnOperation(); - conveyorService.getConveyorExecutorService() - .setOperationCompleted(); - break; - } catch (ConveyorBusyException cbe) { - try { - Thread.sleep(sleepTime); - } catch (InterruptedException e) { - break; - } - continue; - } - - } - - } - - /** - * Check the running transfer, if it's going, then wait until a certain - * number of files have been processed then exit - * - * @param conveyorService - * @param timeoutInSeconds - * @param numberOfFiles - * @throws JargonException - */ - public static void waitForTransferToTransferNFiles( - final ConveyorService conveyorService, final int timeoutInSeconds, - final int numberOfFiles) throws JargonException { - - final long timeout = timeoutInSeconds * 1000; - final long sleepTime; - if (timeoutInSeconds == -1) { - sleepTime = 1000; - } else { - sleepTime = timeout / 10; - - } - - final long startMillis = System.currentTimeMillis(); - - long elapsed; - while (true) { - elapsed = System.currentTimeMillis() - startMillis; - if (timeoutInSeconds == -1) { - // ignore timeout - } else if (elapsed >= timeout) { - throw new JargonException("timeout!"); - } - - try { - - conveyorService.getConveyorExecutorService() - .setBusyForAnOperation(); - conveyorService.getConveyorExecutorService() - .setOperationCompleted(); - break; - } catch (ConveyorBusyException cbe) { - - int nbrFilesSoFar = conveyorService - .getConveyorExecutorService() - .getNumberFilesTransferredSoFarInCurrentTransfer(); - log.info("nbr files so far:{}", nbrFilesSoFar); - if (nbrFilesSoFar >= numberOfFiles) { - break; - } - - try { - Thread.sleep(sleepTime); - } catch (InterruptedException e) { - break; - } - continue; - } - - } - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/unittest/utils/package-info.java b/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/unittest/utils/package-info.java deleted file mode 100644 index 87911137b..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/conveyor/unittest/utils/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Utilities helpful in testing - * - * @author Mike Conway - DICE (www.irods.org) - * see https://code.renci.org/gf/project/jargon/ - * - */ -package org.irods.jargon.conveyor.unittest.utils; \ No newline at end of file diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/transfer/dao/ConfigurationPropertyDAOTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/transfer/dao/ConfigurationPropertyDAOTest.java deleted file mode 100644 index 04162313f..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/transfer/dao/ConfigurationPropertyDAOTest.java +++ /dev/null @@ -1,185 +0,0 @@ -package org.irods.jargon.transfer.dao; - -import static org.junit.Assert.assertTrue; - -import java.util.Date; -import java.util.List; - -import junit.framework.Assert; - -import org.irods.jargon.transfer.dao.domain.ConfigurationProperty; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; -import org.springframework.transaction.annotation.Transactional; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:transfer-dao-beans.xml", - "classpath:transfer-dao-hibernate-spring.cfg.xml" }) -@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true) -@Transactional -public class ConfigurationPropertyDAOTest { - - @Autowired - private ConfigurationPropertyDAO configurationPropertyDAO; - - @Test - public void testSave() throws Exception { - - String testKey = "testSave"; - String testValue = "testSaveValue"; - ConfigurationProperty configProperty = new ConfigurationProperty(); - configProperty.setPropertyKey(testKey); - configProperty.setPropertyValue(testValue); - configProperty.setCreatedAt(new Date()); - configurationPropertyDAO.saveOrUpdate(configProperty); - assertTrue(configProperty.getId() != null); - - } - - @Test - public void testFindByKey() throws Exception { - - String testKey = "testFindByKey"; - String testValue = "testFindByKeyValue"; - ConfigurationProperty configProperty = new ConfigurationProperty(); - configProperty.setPropertyKey(testKey); - configProperty.setPropertyValue(testValue); - configProperty.setCreatedAt(new Date()); - configurationPropertyDAO.saveOrUpdate(configProperty); - assertTrue(configProperty.getId() != null); - - ConfigurationProperty actual = configurationPropertyDAO - .findByPropertyKey(testKey); - Assert.assertNotNull("did not find property by key", actual); - - } - - @Test - public void testFindByKeyWhenNotExists() throws Exception { - - String testKey = "testFindByKeyWhenNotExists"; - ConfigurationProperty actual = configurationPropertyDAO - .findByPropertyKey(testKey); - Assert.assertNull("expected null result", actual); - - } - - @Test(expected = IllegalArgumentException.class) - public void testSaveBlankKey() throws Exception { - - String testKey = ""; - String testValue = "testSaveValue"; - ConfigurationProperty configProperty = new ConfigurationProperty(); - configProperty.setPropertyKey(testKey); - configProperty.setPropertyValue(testValue); - configProperty.setCreatedAt(new Date()); - - configurationPropertyDAO.saveOrUpdate(configProperty); - - } - - @Test(expected = IllegalArgumentException.class) - public void testSaveNullKey() throws Exception { - - String testKey = null; - String testValue = "testSaveValue"; - ConfigurationProperty configProperty = new ConfigurationProperty(); - configProperty.setPropertyKey(testKey); - configProperty.setPropertyValue(testValue); - configProperty.setCreatedAt(new Date()); - - configurationPropertyDAO.saveOrUpdate(configProperty); - - assertTrue(configProperty.getId() != null); - - } - - @Test - public void testDelete() throws Exception { - - String testKey = "testDelete"; - String testValue = "testDeleteValue"; - ConfigurationProperty configProperty = new ConfigurationProperty(); - configProperty.setPropertyKey(testKey); - configProperty.setPropertyValue(testValue); - configProperty.setCreatedAt(new Date()); - configurationPropertyDAO.saveOrUpdate(configProperty); - - assertTrue(configProperty.getId() != null); - configurationPropertyDAO.delete(configProperty); - configProperty = configurationPropertyDAO.findById(configProperty - .getId()); - Assert.assertNull("should not get a config prop, was deleted", - configProperty); - - } - - @Test - public void testFindAll() throws Exception { - - String testKey1 = "testFindAll1"; - String testKey2 = "testFindAll2"; - - List configProperties = configurationPropertyDAO - .findAll(); - - String testValue = "testFindAllValue"; - ConfigurationProperty configProperty = new ConfigurationProperty(); - configProperty.setPropertyKey(testKey1); - configProperty.setPropertyValue(testValue); - configProperty.setCreatedAt(new Date()); - configurationPropertyDAO.saveOrUpdate(configProperty); - - configProperty = new ConfigurationProperty(); - configProperty.setPropertyKey(testKey2); - configProperty.setPropertyValue(testValue); - configProperty.setCreatedAt(new Date()); - configurationPropertyDAO.saveOrUpdate(configProperty); - - configProperties = configurationPropertyDAO.findAll(); - Assert.assertNotNull("did not find confg properties, was null", - configProperties); - Assert.assertFalse("empty config properties returned", - configProperties.isEmpty()); - - } - - @Test - public void testDeleteAllProperties() throws Exception { - - String testKey1 = "testDeleteAllProperties1"; - String testKey2 = "testDeleteAllProperties2"; - - String testValue = "testDeleteAllPropertiesValue"; - ConfigurationProperty configProperty = new ConfigurationProperty(); - configProperty.setPropertyKey(testKey1); - configProperty.setPropertyValue(testValue); - configProperty.setCreatedAt(new Date()); - configurationPropertyDAO.saveOrUpdate(configProperty); - - configProperty = new ConfigurationProperty(); - configProperty.setPropertyKey(testKey2); - configProperty.setPropertyValue(testValue); - configProperty.setCreatedAt(new Date()); - configurationPropertyDAO.saveOrUpdate(configProperty); - - List configProperties = configurationPropertyDAO - .findAll(); - Assert.assertNotNull("did not find confg properties, was null", - configProperties); - Assert.assertFalse("empty config properties returned", - configProperties.isEmpty()); - - configurationPropertyDAO.deleteAllProperties(); - configProperties = configurationPropertyDAO.findAll(); - Assert.assertNotNull("did not find confg properties, was null", - configProperties); - Assert.assertTrue("all properties should have been deleted", - configProperties.isEmpty()); - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/transfer/dao/GridAccountDAOImplTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/transfer/dao/GridAccountDAOImplTest.java deleted file mode 100644 index 5bdb1e09c..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/transfer/dao/GridAccountDAOImplTest.java +++ /dev/null @@ -1,229 +0,0 @@ -package org.irods.jargon.transfer.dao; - -import static org.junit.Assert.assertTrue; - -import java.util.List; -import java.util.Properties; - -import junit.framework.Assert; - -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.transfer.dao.domain.GridAccount; -import org.irods.jargon.transfer.util.DomainUtils; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; -import org.springframework.transaction.annotation.Transactional; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:transfer-dao-beans.xml", - "classpath:transfer-dao-hibernate-spring.cfg.xml" }) -@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true) -@Transactional -public class GridAccountDAOImplTest { - - private static Properties testingProperties = new Properties(); - private static TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - - @Autowired - private GridAccountDAO gridAccountDAO; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Test - public void testSave() throws Exception { - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - GridAccount gridAccount = DomainUtils - .gridAccountFromIRODSAccount(irodsAccount); - - assertTrue(gridAccount.getId() == null); - gridAccountDAO.save(gridAccount); - assertTrue(gridAccount.getId() != null); - - } - - @Test - public void testFindAll() throws Exception { - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - GridAccount gridAccount = DomainUtils - .gridAccountFromIRODSAccount(irodsAccount); - - gridAccountDAO.save(gridAccount); - List actual = gridAccountDAO.findAll(); - Assert.assertFalse("no results returned", actual.isEmpty()); - - } - - @Test - public void testFindByIdExists() throws Exception { - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - GridAccount gridAccount = DomainUtils - .gridAccountFromIRODSAccount(irodsAccount); - - gridAccountDAO.save(gridAccount); - GridAccount actual = gridAccountDAO.findById(gridAccount.getId()); - Assert.assertNotNull("not found", actual); - - } - - @Test - public void testFindByIdNotExists() throws Exception { - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - GridAccount gridAccount = DomainUtils - .gridAccountFromIRODSAccount(irodsAccount); - gridAccount.setId(new Long(99999999)); - - GridAccount actual = gridAccountDAO.findById(gridAccount.getId()); - Assert.assertNull("should have returned null", actual); - - } - - @Test - public void testFindByHostZoneUserNameExists() throws Exception { - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountForIRODSUserFromTestPropertiesForGivenUser( - testingProperties, "testFindByHostZoneUserNameExists", - "testFindByHostZoneUserNameExists"); - GridAccount gridAccount = DomainUtils - .gridAccountFromIRODSAccount(irodsAccount); - gridAccountDAO.save(gridAccount); - GridAccount actual = gridAccountDAO.findByHostZoneAndUserName( - irodsAccount.getHost(), irodsAccount.getZone(), - irodsAccount.getUserName()); - Assert.assertNotNull("not found", actual); - - } - - @Test - public void testFindByHostZoneUserNameNotExists() throws Exception { - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - irodsAccount.setUserName("testFindByHostZoneUserNameNotExists"); - - GridAccount actual = gridAccountDAO.findByHostZoneAndUserName( - irodsAccount.getHost(), irodsAccount.getZone(), - irodsAccount.getUserName()); - Assert.assertNull("no results should be returned", actual); - - } - - @Test(expected = IllegalArgumentException.class) - public void testFindByHostZoneUserNameHostNull() throws Exception { - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - - gridAccountDAO.findByHostZoneAndUserName(null, irodsAccount.getZone(), - irodsAccount.getUserName()); - - } - - @Test(expected = IllegalArgumentException.class) - public void testFindByHostZoneUserNameHostBlank() throws Exception { - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - - gridAccountDAO.findByHostZoneAndUserName("", irodsAccount.getZone(), - irodsAccount.getUserName()); - - } - - @Test(expected = IllegalArgumentException.class) - public void testFindByHostZoneUserNameZoneNull() throws Exception { - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - - gridAccountDAO.findByHostZoneAndUserName(irodsAccount.getUserName(), - null, irodsAccount.getUserName()); - - } - - @Test(expected = IllegalArgumentException.class) - public void testFindByHostZoneUserNameZoneBlank() throws Exception { - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - - gridAccountDAO.findByHostZoneAndUserName(irodsAccount.getUserName(), - "", irodsAccount.getUserName()); - - } - - @Test(expected = IllegalArgumentException.class) - public void testFindByHostZoneUserNameUserNull() throws Exception { - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - - gridAccountDAO.findByHostZoneAndUserName(irodsAccount.getUserName(), - irodsAccount.getZone(), null); - - } - - @Test(expected = IllegalArgumentException.class) - public void testFindByHostZoneUserNameUserBlank() throws Exception { - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - - gridAccountDAO.findByHostZoneAndUserName(irodsAccount.getUserName(), - irodsAccount.getZone(), ""); - - } - - @Test - public void testDeleteExists() throws Exception { - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - GridAccount gridAccount = DomainUtils - .gridAccountFromIRODSAccount(irodsAccount); - - gridAccountDAO.save(gridAccount); - GridAccount actual = gridAccountDAO.findById(gridAccount.getId()); - Assert.assertNotNull("not found", actual); - gridAccountDAO.delete(gridAccount); - actual = gridAccountDAO.findById(gridAccount.getId()); - Assert.assertNull("found, should have deleted", actual); - - } - - @Test - public void testDeleteNotExists() throws Exception { - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - GridAccount gridAccount = DomainUtils - .gridAccountFromIRODSAccount(irodsAccount); - gridAccount.setId(new Long(999999999)); - gridAccountDAO.delete(gridAccount); - // should just complete without error - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/transfer/dao/KeyStoreDAOImplTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/transfer/dao/KeyStoreDAOImplTest.java deleted file mode 100644 index 2eb7f160b..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/transfer/dao/KeyStoreDAOImplTest.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.irods.jargon.transfer.dao; - -import static org.junit.Assert.assertTrue; -import junit.framework.Assert; - -import org.irods.jargon.transfer.dao.domain.KeyStore; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; -import org.springframework.transaction.annotation.Transactional; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:transfer-dao-beans.xml", - "classpath:transfer-dao-hibernate-spring.cfg.xml" }) -@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true) -@Transactional -public class KeyStoreDAOImplTest { - - @Autowired - private KeyStoreDAO keyStoreDAO; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Test - public final void testSave() throws Exception { - - KeyStore keyStore = new KeyStore(); - keyStore.setId(KeyStore.KEY_STORE_PASS_PHRASE); - keyStore.setValue("blah"); - keyStoreDAO.save(keyStore); - - assertTrue(keyStore.getId() != null); - } - - @Test(expected = TransferDAOException.class) - public final void testSaveNull() throws Exception { - - KeyStore keyStore = new KeyStore(); - keyStore.setId(null); - keyStore.setValue("blah"); - keyStoreDAO.save(keyStore); - - } - - @Test - public final void testFindById() throws Exception { - KeyStore keyStore = new KeyStore(); - keyStore.setId(KeyStore.KEY_STORE_PASS_PHRASE); - keyStore.setValue("blah"); - keyStoreDAO.save(keyStore); - // now find - KeyStore found = keyStoreDAO.findById(KeyStore.KEY_STORE_PASS_PHRASE); - Assert.assertEquals("did not find value for key", "blah", - found.getValue()); - } - - @Test(expected = IllegalArgumentException.class) - public final void testFindByIdNullId() throws Exception { - keyStoreDAO.findById(null); - - } - - @Test - public final void testDelete() throws Exception { - KeyStore keyStore = new KeyStore(); - keyStore.setId(KeyStore.KEY_STORE_PASS_PHRASE); - keyStore.setValue("blah"); - keyStoreDAO.save(keyStore); - keyStoreDAO.delete(keyStore); - KeyStore found = keyStoreDAO.findById(KeyStore.KEY_STORE_PASS_PHRASE); - Assert.assertNull("should not find", found); - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/transfer/dao/SynchronizationDAOTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/transfer/dao/SynchronizationDAOTest.java deleted file mode 100644 index f61a1931e..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/transfer/dao/SynchronizationDAOTest.java +++ /dev/null @@ -1,310 +0,0 @@ -package org.irods.jargon.transfer.dao; - -import java.sql.Timestamp; -import java.util.Date; -import java.util.List; -import java.util.Properties; - -import junit.framework.Assert; - -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.transfer.dao.domain.FrequencyType; -import org.irods.jargon.transfer.dao.domain.GridAccount; -import org.irods.jargon.transfer.dao.domain.Synchronization; -import org.irods.jargon.transfer.dao.domain.SynchronizationType; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferStateEnum; -import org.irods.jargon.transfer.dao.domain.TransferStatusEnum; -import org.irods.jargon.transfer.dao.domain.TransferType; -import org.irods.jargon.transfer.util.DomainUtils; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; -import org.springframework.transaction.annotation.Transactional; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:transfer-dao-beans.xml", - "classpath:transfer-dao-hibernate-spring.cfg.xml" }) -@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true) -@Transactional -public class SynchronizationDAOTest { - - private static Properties testingProperties = new Properties(); - private static TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - - @Autowired - private SynchronizationDAO synchronizationDAO; - - @Autowired - private TransferDAO transferDAO; - - @Autowired - private GridAccountDAO gridAccountDAO; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - public TransferDAO getLocalIrodsTransferDAO() { - return transferDAO; - } - - public void setLocalIrodsTransferDAO(final TransferDAO transferDAO) { - this.transferDAO = transferDAO; - } - - public void setSynchronizationDAO( - final SynchronizationDAO synchronizationDAO) { - this.synchronizationDAO = synchronizationDAO; - } - - public void setGridAccountDAO(final GridAccountDAO gridAccountDAO) { - this.gridAccountDAO = gridAccountDAO; - } - - @Test - public void testSave() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - GridAccount gridAccount = DomainUtils - .gridAccountFromIRODSAccount(irodsAccount); - - gridAccountDAO.save(gridAccount); - Synchronization synchronization = new Synchronization(); - synchronization.setCreatedAt(new Date()); - synchronization.setFrequencyType(FrequencyType.EVERY_HOUR); - synchronization.setGridAccount(gridAccount); - synchronization.setIrodsSynchDirectory("irods/dir"); - synchronization - .setLocalSynchDirectory("local/org.irods.jargon.conveyor.synch"); - synchronization.setName("test"); - synchronization - .setSynchronizationMode(SynchronizationType.ONE_WAY_LOCAL_TO_IRODS); - synchronizationDAO.save(synchronization); - Assert.assertTrue("did not set id", synchronization.getId() > 0); - - } - - @Test - public void testFindById() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - GridAccount gridAccount = DomainUtils - .gridAccountFromIRODSAccount(irodsAccount); - gridAccountDAO.save(gridAccount); - Synchronization synchronization = new Synchronization(); - synchronization.setCreatedAt(new Date()); - synchronization.setGridAccount(gridAccount); - synchronization.setFrequencyType(FrequencyType.EVERY_HOUR); - synchronization.setIrodsSynchDirectory("irods/dir"); - synchronization - .setLocalSynchDirectory("local/org.irods.jargon.conveyor.synch"); - synchronization.setName("test"); - synchronization - .setSynchronizationMode(SynchronizationType.ONE_WAY_LOCAL_TO_IRODS); - synchronizationDAO.save(synchronization); - - Synchronization actual = synchronizationDAO.findById(synchronization - .getId()); - Assert.assertNotNull( - "did not find org.irods.jargon.conveyor.synch by id", actual); - - } - - @Test - public void testFindByName() throws Exception { - String testName = "testFindByName"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - GridAccount gridAccount = DomainUtils - .gridAccountFromIRODSAccount(irodsAccount); - gridAccountDAO.save(gridAccount); - Synchronization synchronization = new Synchronization(); - synchronization.setCreatedAt(new Date()); - synchronization.setGridAccount(gridAccount); - synchronization.setFrequencyType(FrequencyType.EVERY_HOUR); - synchronization.setIrodsSynchDirectory("irods/dir"); - synchronization - .setLocalSynchDirectory("local/org.irods.jargon.conveyor.synch"); - synchronization.setName(testName); - synchronization - .setSynchronizationMode(SynchronizationType.ONE_WAY_LOCAL_TO_IRODS); - synchronizationDAO.save(synchronization); - - Synchronization actual = synchronizationDAO.findByName(testName); - Assert.assertNotNull( - "did not find org.irods.jargon.conveyor.synch by name", actual); - } - - @Test - public void testFindAll() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - GridAccount gridAccount = DomainUtils - .gridAccountFromIRODSAccount(irodsAccount); - gridAccountDAO.save(gridAccount); - Synchronization synchronization = new Synchronization(); - synchronization.setCreatedAt(new Date()); - synchronization.setGridAccount(gridAccount); - synchronization.setFrequencyType(FrequencyType.EVERY_HOUR); - synchronization.setIrodsSynchDirectory("irods/dir"); - synchronization - .setLocalSynchDirectory("local/org.irods.jargon.conveyor.synch"); - synchronization.setName("test"); - synchronization - .setSynchronizationMode(SynchronizationType.ONE_WAY_LOCAL_TO_IRODS); - synchronizationDAO.save(synchronization); - - synchronization = new Synchronization(); - synchronization.setCreatedAt(new Date()); - synchronization.setGridAccount(gridAccount); - synchronization.setFrequencyType(FrequencyType.EVERY_HOUR); - synchronization.setIrodsSynchDirectory("irods/dirs"); - synchronization.setLocalSynchDirectory("local/sync2"); - synchronization.setName("test2"); - synchronization - .setSynchronizationMode(SynchronizationType.ONE_WAY_LOCAL_TO_IRODS); - synchronizationDAO.save(synchronization); - - List synchronizations = synchronizationDAO.findAll(); - Assert.assertTrue("did not find expected synchs", - synchronizations.size() > 0); - - } - - @Test - public void testDelete() throws Exception { - String testName = "testDelete"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - GridAccount gridAccount = DomainUtils - .gridAccountFromIRODSAccount(irodsAccount); - gridAccountDAO.save(gridAccount); - Synchronization synchronization = new Synchronization(); - synchronization.setCreatedAt(new Date()); - synchronization.setGridAccount(gridAccount); - synchronization.setFrequencyType(FrequencyType.EVERY_HOUR); - synchronization.setIrodsSynchDirectory("irods/dir"); - synchronization - .setLocalSynchDirectory("local/org.irods.jargon.conveyor.synch"); - synchronization.setName(testName); - synchronization - .setSynchronizationMode(SynchronizationType.ONE_WAY_LOCAL_TO_IRODS); - synchronizationDAO.save(synchronization); - - Synchronization actual = synchronizationDAO.findByName(testName); - synchronizationDAO.delete(actual); - - Synchronization lookUpAgain = synchronizationDAO.findByName(testName); - Assert.assertNull("did not delete org.irods.jargon.conveyor.synch", - lookUpAgain); - - } - - @Test - public void testSaveWithLocalIRODSTransfer() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - GridAccount gridAccount = DomainUtils - .gridAccountFromIRODSAccount(irodsAccount); - gridAccountDAO.save(gridAccount); - Synchronization synchronization = new Synchronization(); - synchronization.setCreatedAt(new Date()); - synchronization.setGridAccount(gridAccount); - synchronization.setFrequencyType(FrequencyType.EVERY_HOUR); - synchronization.setIrodsSynchDirectory("irods/dir"); - synchronization - .setLocalSynchDirectory("local/org.irods.jargon.conveyor.synch"); - synchronization.setName("testSaveWithLocalIRODSTransfer"); - synchronization - .setSynchronizationMode(SynchronizationType.ONE_WAY_LOCAL_TO_IRODS); - synchronizationDAO.save(synchronization); - - Transfer transfer = new Transfer(); - transfer.setCreatedAt(new Timestamp(System.currentTimeMillis())); - transfer.setIrodsAbsolutePath("/irods/path"); - transfer.setLocalAbsolutePath("/local/path"); - transfer.setSynchronization(synchronization); - transfer.setGridAccount(gridAccount); - transfer.setTransferState(TransferStateEnum.ENQUEUED); - transfer.setLastTransferStatus(TransferStatusEnum.OK); - transfer.setTransferType(TransferType.SYNCH); - synchronization.getTransfers().add(transfer); - - Assert.assertTrue("did not set id", synchronization.getId() > 0); - - Synchronization actual = synchronizationDAO.findById(synchronization - .getId()); - Assert.assertNotNull( - "did not find actual org.irods.jargon.conveyor.synch", actual); - Assert.assertTrue("did not find localIRODSTransfer in synchronization", - synchronization.getTransfers().size() > 0); - - } - - @Test - public void testSaveWithLocalIRODSTransferThenFindAllTransfers() - throws Exception { - - String testName = "testSaveWithLocalIRODSTransferThenFindAllTransfers"; - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - GridAccount gridAccount = DomainUtils - .gridAccountFromIRODSAccount(irodsAccount); - gridAccountDAO.save(gridAccount); - Synchronization synchronization = new Synchronization(); - synchronization.setCreatedAt(new Date()); - synchronization.setGridAccount(gridAccount); - synchronization.setFrequencyType(FrequencyType.EVERY_HOUR); - synchronization.setIrodsSynchDirectory(testName); - synchronization - .setLocalSynchDirectory("local/org.irods.jargon.conveyor.synch"); - synchronization.setName(testName); - synchronization - .setSynchronizationMode(SynchronizationType.ONE_WAY_LOCAL_TO_IRODS); - synchronizationDAO.save(synchronization); - - Transfer transfer = new Transfer(); - transfer.setCreatedAt(new Timestamp(System.currentTimeMillis())); - transfer.setIrodsAbsolutePath(testName); - transfer.setLocalAbsolutePath("/local/path"); - transfer.setSynchronization(synchronization); - transfer.setGridAccount(gridAccount); - transfer.setTransferState(TransferStateEnum.ENQUEUED); - transfer.setLastTransferStatus(TransferStatusEnum.OK); - transfer.setTransferType(TransferType.SYNCH); - synchronization.getTransfers().add(transfer); - - List allTransfers = transferDAO.findAll(); - - boolean foundTransfer = false; - for (Transfer actualTransfer : allTransfers) { - if (actualTransfer.getIrodsAbsolutePath().equals(testName)) { - foundTransfer = true; - Assert.assertNotNull( - "transfer did not have org.irods.jargon.conveyor.synch", - actualTransfer.getSynchronization()); - Assert.assertEquals( - "org.irods.jargon.conveyor.synch did not have proper data", - testName, actualTransfer.getSynchronization().getName()); - } - } - - Assert.assertTrue("did not find org.irods.jargon.conveyor.synch", - foundTransfer); - - } - -} diff --git a/jargon-conveyor/src/test/java/org/irods/jargon/transfer/dao/TransferDAOTest.java b/jargon-conveyor/src/test/java/org/irods/jargon/transfer/dao/TransferDAOTest.java deleted file mode 100644 index 1811f2ebd..000000000 --- a/jargon-conveyor/src/test/java/org/irods/jargon/transfer/dao/TransferDAOTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.irods.jargon.transfer.dao; - -import static org.junit.Assert.assertTrue; - -import java.sql.Timestamp; -import java.util.Properties; - -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.transfer.dao.domain.GridAccount; -import org.irods.jargon.transfer.dao.domain.Transfer; -import org.irods.jargon.transfer.dao.domain.TransferStateEnum; -import org.irods.jargon.transfer.dao.domain.TransferStatusEnum; -import org.irods.jargon.transfer.dao.domain.TransferType; -import org.irods.jargon.transfer.util.DomainUtils; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; -import org.springframework.transaction.annotation.Transactional; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:transfer-dao-beans.xml", - "classpath:transfer-dao-hibernate-spring.cfg.xml" }) -@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true) -@Transactional -public class TransferDAOTest { - - private static Properties testingProperties = new Properties(); - private static TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - - @Autowired - private TransferDAO transferDAO; - - @Autowired - private GridAccountDAO gridAccountDAO; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Test - public void testSave() throws Exception { - - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - GridAccount gridAccount = DomainUtils - .gridAccountFromIRODSAccount(irodsAccount); - gridAccountDAO.save(gridAccount); - Transfer enqueuedTransfer = new Transfer(); - enqueuedTransfer - .setCreatedAt(new Timestamp(System.currentTimeMillis())); - enqueuedTransfer.setIrodsAbsolutePath("/tmp"); - enqueuedTransfer.setLocalAbsolutePath("/tmp"); - enqueuedTransfer.setGridAccount(gridAccount); - enqueuedTransfer.setTransferType(TransferType.PUT); - enqueuedTransfer.setTransferState(TransferStateEnum.PROCESSING); - enqueuedTransfer.setLastTransferStatus(TransferStatusEnum.ERROR); - assertTrue(enqueuedTransfer.getId() == null); - transferDAO.save(enqueuedTransfer); - assertTrue(enqueuedTransfer.getId() != null); - - } - - /** - * @param localIRODSTransferDAO - * the localIRODSTransferDAO to set - */ - public void setLocalIRODSTransferDAO(final TransferDAO transferDAO) { - this.transferDAO = transferDAO; - } - -} diff --git a/jargon-conveyor/src/test/resources/log4j.properties b/jargon-conveyor/src/test/resources/log4j.properties deleted file mode 100644 index 5ebdf3ff0..000000000 --- a/jargon-conveyor/src/test/resources/log4j.properties +++ /dev/null @@ -1,11 +0,0 @@ -# Set root logger level to DEBUG and its only appender to A1. -log4j.rootLogger=WARN, A1 -log4j.logger.org.hibernate=WARN -log4j.logger.org.apache.derby=WARN -log4j.logger.org.irods.jargon.conveyor=INFO -# A1 is set to be a ConsoleAppender. -log4j.appender.A1=org.apache.log4j.ConsoleAppender - -# A1 uses PatternLayout. -log4j.appender.A1.layout=org.apache.log4j.PatternLayout -log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n diff --git a/jargon-conveyor/src/test/resources/testFlowDsl/testInitBaseRule.groovy b/jargon-conveyor/src/test/resources/testFlowDsl/testInitBaseRule.groovy deleted file mode 100644 index b2e88e6c2..000000000 --- a/jargon-conveyor/src/test/resources/testFlowDsl/testInitBaseRule.groovy +++ /dev/null @@ -1,15 +0,0 @@ -import org.irods.jargon.conveyor.flowmanager.flow.* -import org.irods.jargon.conveyor.flowmanager.flow.dsl.* - -FlowSpec flowSpec = Flow.define() - .forAnyAction() - .forAnyHost() - .forAnyZone() - .onAllConditions() - .addPreOperationMicroservice("org.irods.jargon.conveyor.flowmanager.microservice.builtins.LogAndContinueMicroservice").endPreOperationChain() - .endPreFileChain() - .endPostFileChain() - .endPostOperationChain() - .endFlowWithoutErrorHandler() - -return flowSpec \ No newline at end of file diff --git a/jargon-conveyor/src/test/resources/testFlowDsl/testPutPassBundleCondition.groovy b/jargon-conveyor/src/test/resources/testFlowDsl/testPutPassBundleCondition.groovy deleted file mode 100644 index 48929f9ec..000000000 --- a/jargon-conveyor/src/test/resources/testFlowDsl/testPutPassBundleCondition.groovy +++ /dev/null @@ -1,14 +0,0 @@ -import org.irods.jargon.conveyor.flowmanager.flow.* -import org.irods.jargon.conveyor.flowmanager.flow.dsl.* -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.InspectForBundleOperationMicroservice - -String fqcn = InspectForBundleOperationMicroservice.class.getName() - -FlowSpec flow =Flow.define().forAction(Selector.FlowActionEnum.PUT).forAnyHost().forAnyZone() - .when(fqcn) - .endPreOperationChain() - .endPreFileChain() - .endPostFileChain().endPostOperationChain() - .endFlowWithoutErrorHandler(); - -return flow \ No newline at end of file diff --git a/jargon-conveyor/src/test/resources/testFlowDsl/testPutWithPostFileMetadata.groovy b/jargon-conveyor/src/test/resources/testFlowDsl/testPutWithPostFileMetadata.groovy deleted file mode 100644 index a4934d27d..000000000 --- a/jargon-conveyor/src/test/resources/testFlowDsl/testPutWithPostFileMetadata.groovy +++ /dev/null @@ -1,14 +0,0 @@ -import org.irods.jargon.conveyor.flowmanager.flow.* -import org.irods.jargon.conveyor.flowmanager.flow.dsl.* - -FlowSpec flow = Flow.define().forAnyAction() - .forAnyHost() - .forAnyZone() - .onAllConditions() - .endPreOperationChain() - .endPreFileChain() - .addPostFileMicroservice("org.irods.jargon.conveyor.flowmanager.microservice.builtins.PostFileAddTestAVUMicroservice") - .endPostFileChain().endPostOperationChain() - .endFlowWithoutErrorHandler(); - -return flow \ No newline at end of file diff --git a/jargon-conveyor/src/test/resources/testFlowDsl/testPutWithSkipme.groovy b/jargon-conveyor/src/test/resources/testFlowDsl/testPutWithSkipme.groovy deleted file mode 100644 index 5516ee575..000000000 --- a/jargon-conveyor/src/test/resources/testFlowDsl/testPutWithSkipme.groovy +++ /dev/null @@ -1,20 +0,0 @@ -import org.irods.jargon.conveyor.flowmanager.flow.* -import org.irods.jargon.conveyor.flowmanager.flow.dsl.* -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.LogAndContinueMicroservice -import org.irods.jargon.conveyor.flowmanager.microservice.builtins.SkipThisFileMicroservice - -String logAndContinueFqcn = LogAndContinueMicroservice.class.getName(); -String skipMeFqcn = SkipThisFileMicroservice.class.getName(); - -FlowSpec flow = Flow.define().forAnyAction() - .forAnyHost() - .forAnyZone() - .onAllConditions() - .endPreOperationChain() - .addPreFileMicroservice(logAndContinueFqcn) - .addPreFileMicroservice(skipMeFqcn) - .endPreFileChain() - .endPostFileChain().endPostOperationChain() - .endFlowWithoutErrorHandler(); - -return flow \ No newline at end of file diff --git a/jargon-conveyor/src/test/resources/transfer.properties b/jargon-conveyor/src/test/resources/transfer.properties deleted file mode 100644 index 6dc9e76ac..000000000 --- a/jargon-conveyor/src/test/resources/transfer.properties +++ /dev/null @@ -1,5 +0,0 @@ -jdbc.url=jdbc:derby:${user.home}/.idrop/test/964/database/transfer;create=true -jdbc.user=transfer -jdbc.password=transfer -flow.dir=${user.home}/.idrop/idrop201/testflow - diff --git a/jargon-conveyor/test-sql/transfer-data.sql b/jargon-conveyor/test-sql/transfer-data.sql deleted file mode 100644 index c0a10a006..000000000 --- a/jargon-conveyor/test-sql/transfer-data.sql +++ /dev/null @@ -1,14 +0,0 @@ -SELECT TRANSFER.TRANSFER.ID, TRANSFER.TRANSFER.TRANSFER_STATE, - TRANSFER.TRANSFER.LAST_TRANSFER_STATUS, TRANSFER.TRANSFER.TRANSFER_TYPE, - TRANSFER.TRANSFER.LOCAL_ABSOLUTE_PATH, TRANSFER.TRANSFER.IRODS_ABSOLUTE_PATH, - TRANSFER.TRANSFER_ATTEMPT.SEQUENCE_NUMBER, TRANSFER.TRANSFER_ATTEMPT.TRANSFER_ATTEMPT_START, - TRANSFER.TRANSFER_ATTEMPT.TRANSFER_ATTEMPT_END, TRANSFER.TRANSFER_ATTEMPT.TRANSFER_ATTEMPT_STATUS, - TRANSFER.TRANSFER_ATTEMPT.ERROR_MESSAGE, TRANSFER.TRANSFER_ATTEMPT.GLOBAL_EXCEPTION, - TRANSFER.TRANSFER_ATTEMPT.GLOBAL_EXCEPTION_STACK_TRACE, TRANSFER.TRANSFER_ATTEMPT.LAST_SUCCESSFUL_PATH, - TRANSFER.TRANSFER_ATTEMPT.TOTAL_FILES_COUNT, TRANSFER.TRANSFER_ATTEMPT.TOTAL_FILES_TRANSFERRED_SO_FAR, - TRANSFER.TRANSFER_ITEM.TARGET_FILE_ABSOLUTE_PATH, TRANSFER.TRANSFER_ITEM.TRANSFER_TYPE, - TRANSFER.TRANSFER_ITEM.IS_FILE, TRANSFER.TRANSFER_ITEM.IS_SKIPPED, - TRANSFER.TRANSFER_ITEM.IS_ERROR, TRANSFER.TRANSFER_ITEM.LENGTH_IN_BYTES, - TRANSFER.TRANSFER_ITEM.ERROR_MESSAGE, TRANSFER.TRANSFER_ITEM.ERROR_STACK_TRACE - FROM - TRANSFER.TRANSFER_ITEM RIGHT OUTER JOIN TRANSFER.TRANSFER_ATTEMPT RIGHT OUTER JOIN TRANSFER.TRANSFER ON TRANSFER.TRANSFER_ATTEMPT.TRANSFER_ID = TRANSFER.TRANSFER.ID ON TRANSFER.TRANSFER_ITEM.TRANSFER_ATTEMPT_ID = TRANSFER.TRANSFER_ATTEMPT.ID diff --git a/jargon-core/src/main/java/org/irods/jargon/core/exception/InvalidIRODSUriException.java b/jargon-core/src/main/java/org/irods/jargon/core/exception/InvalidIRODSUriException.java new file mode 100644 index 000000000..7f011733c --- /dev/null +++ b/jargon-core/src/main/java/org/irods/jargon/core/exception/InvalidIRODSUriException.java @@ -0,0 +1,20 @@ +package org.irods.jargon.core.exception; + +import java.net.URI; + +/** + * Objects of this class represent the case where an iRODS URI was expected, but + * another type of URI was provided. + */ +public final class InvalidIRODSUriException extends JargonException { + + /** + * the constructor + * + * @param invalidURI the invalid URI + */ + public InvalidIRODSUriException(final URI invalidURI) { + super("The URI, " + invalidURI + ", is not an iRODS URI."); + } + +} diff --git a/jargon-core/src/main/java/org/irods/jargon/core/utils/IRODSUriUserInfo.java b/jargon-core/src/main/java/org/irods/jargon/core/utils/IRODSUriUserInfo.java new file mode 100644 index 000000000..c385e2ad5 --- /dev/null +++ b/jargon-core/src/main/java/org/irods/jargon/core/utils/IRODSUriUserInfo.java @@ -0,0 +1,228 @@ +package org.irods.jargon.core.utils; + +import java.io.ByteArrayOutputStream; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +/** + * This class manages the serializing and deserializing the user info portion of + * an irods: URI. + */ +public final class IRODSUriUserInfo { + + private static final String ZONE_INDICATOR = "."; + private static final String PASSWORD_INDICATOR = ":"; + private static final byte ESCAPE_INDICATOR = '%'; + + private static final Set USER_INFO_ALLOWED_CHARS; + + static { + final byte[] allowedMarks = new byte[] { + '-', '_', '!', '~', '*', '\'', '(', ')', ';', '&', '=', '+', + '$', ',' + }; + + final HashSet chars = new HashSet<>(); + for (byte c = '0'; c <= '9'; c++) { + chars.add(c); + } + for (byte c = 'a'; c <= 'z'; c++) { + chars.add(c); + } + for (byte c = 'A'; c <= 'Z'; c++) { + chars.add(c); + } + for (byte c : allowedMarks) { + chars.add(c); + } + USER_INFO_ALLOWED_CHARS = Collections.unmodifiableSet(chars); + } + + /** + * Creates an instance that can be used to for user authentication in a + * local or remote zone. + * + * @param user the username + * @param zone the authentication zone + * @param password the password used to authenticate the user + * @return It returns an instance. + */ + public static IRODSUriUserInfo instance( + final String user, final String zone, final String password) { + return new IRODSUriUserInfo(user, zone, password); + } + + /** + * Creates an instance that can be used to for user authentication in the + * local zone. + * + * @param user the username + * @param password the password used to authenticate the user + * @return It returns an instance. + */ + public static IRODSUriUserInfo localInstance( + final String user, final String password) + { + return new IRODSUriUserInfo(user, null, password); + } + + /** + * Creates an instance that doesn't contain authentication information for a + * local or remote zone. + * + * @param user the username + * @param zone the authentication zone + * @return It returns an instance. + */ + public static IRODSUriUserInfo unauthenticatedInstance( + final String user, final String zone) { + return new IRODSUriUserInfo(user, zone, null); + } + + /** + * Creates an instance that doesn't contain authentication information for + * the local zone. + * + * @param user the username + * @return It returns an instance. + */ + public static IRODSUriUserInfo unauthenticatedLocalInstance( + final String user) { + return new IRODSUriUserInfo(user, null, null); + } + + /** + * Creates an instance from the serialized portion of the URI. + * + * @param encodedStr The serialized user info portion of an irods URI + * @return It returns an instance or null if infoStr is + * null or empty. + */ + static IRODSUriUserInfo fromString(final String encodedStr) { + if (encodedStr == null || encodedStr.isEmpty()) { + return null; + } + + final int zIdx = encodedStr.indexOf(ZONE_INDICATOR); + final int pIdx = encodedStr.indexOf(PASSWORD_INDICATOR); + + String encodedUser = null; + String encodedZone = null; + String encodedPassword = null; + + if (zIdx < 0 && pIdx < 0) { + // Only user + encodedUser = encodedStr; + } else if (zIdx < 0 && pIdx >= 0) { + // User and password + encodedUser = encodedStr.substring(0, pIdx); + encodedPassword = encodedStr.substring(pIdx + 1); + } else if (zIdx >= 0 && pIdx <= zIdx) { + // User and zone + encodedUser = encodedStr.substring(0, zIdx); + encodedZone = encodedStr.substring(zIdx + 1); + } else { + // user, zone, and password + encodedUser = encodedStr.substring(0, zIdx); + encodedZone = encodedStr.substring(zIdx + 1, pIdx); + encodedPassword = encodedStr.substring(pIdx + 1); + } + + return new IRODSUriUserInfo(decode(encodedUser), decode(encodedZone), + decode(encodedPassword)); + } + + private static String emptyAsNull(final String value) { + return (value == null || value.isEmpty()) ? null : value; + } + + private static String decode(final String encodedValue) { + if (encodedValue == null) { + return null; + } + final byte[] encoded = encodedValue.getBytes(StandardCharsets.US_ASCII); + final ByteArrayOutputStream decoded = new ByteArrayOutputStream(); + for (int i = 0; i < encoded.length; i++) { + if (encoded[i] == ESCAPE_INDICATOR) { + final int ud = Character.digit(encoded[++i], 16); + final int ld = Character.digit(encoded[++i], 16); + decoded.write((ud << 4) + ld); + } else { + decoded.write(encoded[i]); + } + } + return new String(decoded.toByteArray(), StandardCharsets.UTF_8); + } + + private static String encode(final String value) { + final byte[] decoded = value.getBytes(StandardCharsets.UTF_8); + final ByteArrayOutputStream encoded = new ByteArrayOutputStream(); + for (byte c : decoded) { + if (USER_INFO_ALLOWED_CHARS.contains(c)) { + encoded.write(c); + } else { + final String hex = Integer.toHexString(c & 0xff).toUpperCase(); + final byte[] digits = hex.getBytes(StandardCharsets.US_ASCII); + encoded.write(ESCAPE_INDICATOR); + encoded.write(digits, 0, digits.length); + } + } + return new String(encoded.toByteArray(), StandardCharsets.US_ASCII); + } + + private final String user; + private final String zone; + private final String password; + + private IRODSUriUserInfo( + final String user, final String zone, final String password) { + if (user == null || user.isEmpty()) { + throw new IllegalArgumentException("must provide a user name"); + } + + this.user = user; + this.zone = emptyAsNull(zone); + this.password = emptyAsNull(password); + } + + /** + * Serializes the object for inclusion in an irods: URI. + * @return the user info portion of an irods: URI + */ + @Override + public String toString() { + final StringBuilder encoded = new StringBuilder(); + encoded.append(encode(user)); + if (zone != null) { + encoded.append(ZONE_INDICATOR).append(encode(zone)); + } + if (password != null) { + encoded.append(PASSWORD_INDICATOR).append(encode(password)); + } + return encoded.toString(); + } + + /** + * @return the username + */ + public String getUserName() { + return user; + } + + /** + * @return the authentication zone + */ + public String getZone() { + return zone; + } + + /** + * @return the password used for authentication of the username + */ + public String getPassword() { + return password; + } + +} diff --git a/jargon-core/src/main/java/org/irods/jargon/core/utils/IRODSUriUtils.java b/jargon-core/src/main/java/org/irods/jargon/core/utils/IRODSUriUtils.java index 94c34ad52..1a933893e 100644 --- a/jargon-core/src/main/java/org/irods/jargon/core/utils/IRODSUriUtils.java +++ b/jargon-core/src/main/java/org/irods/jargon/core/utils/IRODSUriUtils.java @@ -4,7 +4,9 @@ import java.net.URISyntaxException; import org.irods.jargon.core.connection.IRODSAccount; +import org.irods.jargon.core.exception.InvalidIRODSUriException; import org.irods.jargon.core.exception.JargonException; +import org.irods.jargon.core.exception.JargonRuntimeException; /** * Helpful methods for parsing and dealing with IRODS URIs, also supports the @@ -16,22 +18,96 @@ */ public class IRODSUriUtils { - private static final char PATH_SEPARATOR = '/'; + private static final String SCHEME = "irods"; + private static final String SCHEME_TERMINUS = "://"; + private static final String USER_INFO_TERMINUS = "@"; + private static final String PORT_INDICATOR = ":"; + private static final String PATH_SEPARATOR = "/"; + + /** + * Retrieves the user information from the URI. + * + * @param irodsURI + * {@link URI} in the irods:// format + * @return The user information if any is present, otherwise + * null. + * @throws InvalidIRODSUriException This is thrown when + * irodsURI is not an iRODS URI. + */ + public static IRODSUriUserInfo getUserInfo(final URI irodsURI) + throws InvalidIRODSUriException { + if (!isIRODSURIScheme(irodsURI)) { + throw new InvalidIRODSUriException(irodsURI); + } + return IRODSUriUserInfo.fromString(irodsURI.getRawUserInfo()); + } /** * Retrieve the iRODS user name from the URI, or * null if this componenet cannot be derived from the * URI + * + * @param irodsURI + * {@link URI} in the irods:// format + * @return {@link String} with the discovered iRODS user name, or + * null if the user name is not present. + * @throws InvalidIRODSUriException This is thrown when + * irodsURI is not an iRODS URI. + */ + public static String getUserName(final URI irodsURI) + throws InvalidIRODSUriException { + final IRODSUriUserInfo info = getUserInfo(irodsURI); + return info == null ? null : info.getUserName(); + } + + /** + * Get the zone (if available) from the URI in iRODS form. + * + * @param irodsURI + * {@link URI} in the irods:// format + * @return {@link String} with the iRODS zone, or null if not + * available. + * @throws InvalidIRODSUriException This is thrown when + * irodsURI is not an iRODS URI. + */ + public static String getZone(final URI irodsURI) + throws InvalidIRODSUriException + { + final IRODSUriUserInfo info = getUserInfo(irodsURI); + return info == null ? null : info.getZone(); + } + + /** + * Get the password (if available) from the {@link URI} in iRODS form. + * + * @param irodsURI + * {@link URI} in the irods:// format + * @return {@link String} with the iRODS password, or null if + * not available. + * @throws InvalidIRODSUriException This is thrown when + * irodsURI is not an iRODS URI. + */ + public static String getPassword(final URI irodsURI) + throws InvalidIRODSUriException { + final IRODSUriUserInfo info = getUserInfo(irodsURI); + return info == null ? null : info.getPassword(); + } + + /** + * Retrieve the iRODS user name from the {@code URI}, or null + * if this componenet cannot be derived from the {@code URI}. * * @param irodsURI * {@link URI} in the irods:// format - * @return String with the discovered iRODS user name, or + * @return {@link String} with the discovered iRODS user name, or * null if the user name is not present. + * @deprecated Use {@link IRODSUriUtils#getUserName(URI)} instead. */ + @Deprecated public static String getUserNameFromURI(final URI irodsURI) { - - URIUserParts uriUserParts = getURIUserPartsFromUserInfo(irodsURI); - return uriUserParts.getUserName(); + final IRODSUriUserInfo info = IRODSUriUserInfo.fromString( + irodsURI.getRawUserInfo()); + return info == null ? null : info.getUserName(); } /** @@ -39,14 +115,18 @@ public static String getUserNameFromURI(final URI irodsURI) { * * @param irodsURI * @return + * @deprecated Use {@link IRODSUriUtils#getUserInfo(URI)} */ - protected static URIUserParts getURIUserPartsFromUserInfo(final URI irodsURI) { + @Deprecated + protected static URIUserParts getURIUserPartsFromUserInfo( + final URI irodsURI) { String userInfo = irodsURI.getUserInfo(); if (userInfo == null || userInfo.isEmpty()) { return null; } + /* * parse out the userInfo part of the URI, which can have userName, * password, and zone info user.zone:password @@ -115,10 +195,13 @@ protected static URIUserParts getURIUserPartsFromUserInfo(final URI irodsURI) { * {@link URI} in the irods:// format * @return String with the iRODS password, or null * if not available. + * @deprecated use {@link IRODSUriUtils#getPassword(URI)} instead. */ + @Deprecated public static String getPasswordFromURI(final URI irodsURI) { - URIUserParts uriUserParts = getURIUserPartsFromUserInfo(irodsURI); - return uriUserParts.getPassword(); + final IRODSUriUserInfo info = IRODSUriUserInfo.fromString( + irodsURI.getRawUserInfo()); + return info == null ? null : info.getPassword(); } /** @@ -128,52 +211,51 @@ public static String getPasswordFromURI(final URI irodsURI) { * {@link URI} in the irods:// format * @return String with the iRODS zone, or null if * not available. + * @deprecated use {@link IRODSUriUtils#getZone(URI)} instead. */ + @Deprecated public static String getZoneFromURI(final URI irodsURI) { - URIUserParts uriUserParts = getURIUserPartsFromUserInfo(irodsURI); - return uriUserParts.getZone(); + final IRODSUriUserInfo info = IRODSUriUserInfo.fromString( + irodsURI.getRawUserInfo()); + return info == null ? null : info.getZone(); } /** - * Get the host (if available) from the URI in iRODS form. + * Get the host (if available) from a URI. * - * @param irodsURI - * {@link URI} in the irods:// format - * @return String with the iRODS host, or null if - * not available. + * @param uri the URI + * @return {@link String} with the host, or null if not + * available. */ - public static String getHostFromURI(final URI irodsURI) { - return irodsURI.getHost(); + public static String getHostFromURI(final URI uri) { + return uri.getHost(); } /** - * Get the port from the URI in iRODS form. + * Get the port from the URI in iRODS form. * - * @param irodsURI - * {@link URI} in the irods:// format - * @return int with the iRODS port. + * @param uri the URI + * @return int with the port. */ - public static int getPortFromURI(final URI irodsURI) { - return irodsURI.getPort(); + public static int getPortFromURI(final URI uri) { + return uri.getPort(); } /** - * Get the path from the URI in iRODS form. + * Get the path from the URI in iRODS form. * - * @param irodsURI - * {@link URI} in the irods:// format - * @return String with the iRODS path + * @param uri the URI + * @return {@link String} with the path */ - public static String getAbsolutePathFromURI(final URI irodsURI) { - return irodsURI.getPath(); + public static String getAbsolutePathFromURI(final URI uri) { + return uri.getPath(); } /** - * Build an IRODSAccount from the URI in iRODS - * format. + * Build an {@link IRODSAccount} from the {@link URI} in iRODS format. * * @param irodsURI - * {@link URI} in irods:// form + * {@link URI} in irods:// form * @return {@link IRODSAccount} based on the URI information * @throws JargonException * if the account cannot be built from the information in the @@ -183,29 +265,26 @@ public static IRODSAccount getIRODSAccountFromURI(final URI irodsURI) throws JargonException { if (!isIRODSURIScheme(irodsURI)) { - throw new JargonException( - "cannot derive IRODSAccount, not an iRODS uri"); + throw new InvalidIRODSUriException(irodsURI); } - URIUserParts uriUserParts = getURIUserPartsFromUserInfo(irodsURI); + final IRODSUriUserInfo info = getUserInfo(irodsURI); - if (uriUserParts.getPassword() == null - || uriUserParts.getUserName() == null - || uriUserParts.getZone() == null) { + if (info == null + || info.getPassword() == null + || info.getZone() == null) { throw new JargonException( "No user information in URI, cannot create iRODS account"); } - StringBuilder sb = new StringBuilder(); - sb.append(PATH_SEPARATOR); - sb.append(uriUserParts.getZone()); - sb.append("/home/"); - sb.append(uriUserParts.getUserName()); + final String home + = PATH_SEPARATOR + info.getZone() + + PATH_SEPARATOR + "home" + + PATH_SEPARATOR + info.getUserName(); return IRODSAccount.instance(irodsURI.getHost(), irodsURI.getPort(), - uriUserParts.getUserName(), uriUserParts.getPassword(), - sb.toString(), uriUserParts.getZone(), ""); - + info.getUserName(), info.getPassword(), home, info.getZone(), + ""); } /** @@ -217,28 +296,129 @@ public static IRODSAccount getIRODSAccountFromURI(final URI irodsURI) * iRODS URI scheme. */ public static boolean isIRODSURIScheme(final URI irodsURI) { + return SCHEME.equals(irodsURI.getScheme()); + } - boolean isURI = false; - String uriScheme = irodsURI.getScheme(); - if (uriScheme != null && uriScheme.equals("irods")) { - isURI = true; + /** + * Constructs a {@link URI} with the iRODS scheme with provided authority, + * identifying the root path for indicated host. + * + * @param host the iRODS server hosting the ICAT + * @param port the TCP port the server listens on + * @param userInfo the user information used for authentication and + * authorization + * @return the URI. + */ + public static URI buildBaseURI( + final String host, final int port, final IRODSUriUserInfo userInfo) + { + try { + final StringBuilder uriBuilder = new StringBuilder(); + uriBuilder.append(SCHEME).append(SCHEME_TERMINUS); + if (userInfo != null) { + uriBuilder.append(userInfo).append(USER_INFO_TERMINUS); + } + uriBuilder.append(host).append(PORT_INDICATOR).append(port); + uriBuilder.append(PATH_SEPARATOR); + return new URI(uriBuilder.toString()); + } catch (final URISyntaxException e) { + throw new JargonRuntimeException(e); } - return isURI; } /** - * Build a URI appropriate for a given iRODS account and absolute path. + * Constructs a {@link URI} with the iRODS scheme with provided authority, + * identifying the root path for indicated host. + * + * @param host the iRODS server hosting the ICAT + * @param port the TCP port the server listens on + * @param username the iRODS user name used for authorization + * @return the URI. + */ + public static URI buildBaseURI( + final String host, final int port, final String username) { + final IRODSUriUserInfo info = IRODSUriUserInfo.instance(username, null, + null); + return buildBaseURI(host, port, info); + } + + /** + * Constructs a {@link URI} with the iRODS scheme with provided authority, + * identifying the resource with the given path on the indicated host. + * + * @param host the iRODS server hosting the ICAT + * @param port the TCP port the server listens on + * @param userInfo the user information used for authentication and + * authorization + * @param absPath the absolute logical path to the resource + * @return the URI. + */ + public static URI buildURI( + final String host, final int port, final IRODSUriUserInfo userInfo, + final String absPath) { + try { + final URI base = buildBaseURI(host, port, userInfo); + return base.resolve(new URI(null, absPath, null)); + } catch (final URISyntaxException e) { + throw new JargonRuntimeException(e); + } + } + + /** + * Constructs a {@link URI} with the iRODS scheme with provided authority, + * identifying the resource with the given path on the indicated host. + * + * @param host the iRODS server hosting the ICAT + * @param port the TCP port the server listens on + * @param username the iRODS user name used for authorization + * @param absPath the absolute logical path to the resource + * @return the URI. + */ + public static URI buildURI( + final String host, final int port, final String username, + final String absPath) { + try { + final URI base = buildBaseURI(host, port, username); + return base.resolve(new URI(null, absPath, null)); + } catch (final URISyntaxException e) { + throw new JargonRuntimeException(e); + } + } + + /** + * Constructs a {@link URI} with the iRODS scheme with provided anonymous + * authority identifying the resource with the given path on the indicated + * host. + * + * @param host the iRODS server hosting the ICAT + * @param port the TCP port the server listens on + * @param absPath the absolute logical path to the resource + * @return the URI. + */ + public static URI buildAnonymousURI( + final String host, final int port, final String absPath) { + if (absPath == null || absPath.isEmpty()) { + throw new IllegalArgumentException("null or empty path"); + } + try { + return new URI(SCHEME, null, host, port, absPath, null, null); + } catch (final URISyntaxException e) { + throw new JargonRuntimeException(e); + } + } + + /** + * Build a URI appropriate for a given iRODS account and path. If the path + * is relative, it is assumed to be relative to the account's home + * collection. * * @param irodsAccount * {@link IRODSAccount} containing connection information - * @param isFile - * @param irodsPath - * @return - * @throws JargonException + * @param irodsPath the path + * @return the URI */ public static URI buildURIForAnAccountAndPath( - final IRODSAccount irodsAccount, final String irodsPath) - throws JargonException { + final IRODSAccount irodsAccount, final String irodsPath) { if (irodsAccount == null) { throw new IllegalArgumentException("null iRODSAccount"); @@ -249,30 +429,13 @@ public static URI buildURIForAnAccountAndPath( "null or empty irodsAbsolutePath"); } - String absPath = irodsPath; - // if this is a relative path, use the user home directory to fashion an - // absolute path - if (irodsPath.charAt(0) != '/') { - StringBuilder sb = new StringBuilder(); - sb.append(irodsAccount.getHomeDirectory()); - sb.append("/"); - sb.append(irodsPath); - absPath = sb.toString(); - } - - URI uri = null; - - try { - uri = new URI("irods", irodsAccount.getUserName(), - irodsAccount.getHost(), irodsAccount.getPort(), absPath, - null, null); - - } catch (URISyntaxException e) { - - throw new JargonException(e); - } - - return uri; + final IRODSUriUserInfo info + = IRODSUriUserInfo.unauthenticatedLocalInstance( + irodsAccount.getUserName()); + final String absPath = mkPathAbs(irodsAccount.getHomeDirectory(), + irodsPath); + return buildBaseURI(irodsAccount.getHost(), irodsAccount.getPort(), + absPath, info); } /** @@ -280,15 +443,11 @@ public static URI buildURIForAnAccountAndPath( * * @param irodsAccount * {@link IRODSAccount} containing connection information - * @param isFile - * @param irodsPath - * @return - * @throws JargonException + * @param irodsPath the path + * @return the URI */ public static URI buildURIForAnAccountWithNoUserInformationIncluded( - final IRODSAccount irodsAccount, final String irodsPath) - throws JargonException { - + final IRODSAccount irodsAccount, final String irodsPath) { if (irodsAccount == null) { throw new IllegalArgumentException("null iRODSAccount"); } @@ -298,30 +457,37 @@ public static URI buildURIForAnAccountWithNoUserInformationIncluded( "null or empty irodsAbsolutePath"); } - String absPath = irodsPath; - // if this is a relative path, use the user home directory to fashion an - // absolute path - if (irodsPath.charAt(0) != '/') { - StringBuilder sb = new StringBuilder(); - sb.append(irodsAccount.getHomeDirectory()); - sb.append("/"); - // URLEncode the iRODS path - sb.append(irodsPath); - absPath = sb.toString(); - } - - URI uri = null; + final String absPath = mkPathAbs(irodsAccount.getHomeDirectory(), + irodsPath); + return buildBaseURI(irodsAccount.getHost(), irodsAccount.getPort(), + absPath, null); + } + private static URI buildBaseURI( + final String host, final int port, final String absPath, + final IRODSUriUserInfo userInfo) { try { - uri = new URI("irods", null, irodsAccount.getHost(), - irodsAccount.getPort(), absPath, null, null); - - } catch (URISyntaxException e) { - - throw new JargonException(e); + final StringBuilder uriBuilder = new StringBuilder(); + uriBuilder.append(SCHEME).append(SCHEME_TERMINUS); + if (userInfo != null) { + uriBuilder.append(userInfo).append(USER_INFO_TERMINUS); + } + uriBuilder.append(host).append(PORT_INDICATOR).append(port); + uriBuilder.append(absPath); + return new URI(uriBuilder.toString()); + } catch (final URISyntaxException e) { + throw new JargonRuntimeException(e); } + } - return uri; + // if this is a relative path, use the user home directory to fashion an + // absolute path + private static String mkPathAbs(final String homeDir, final String path) { + if (path.startsWith(PATH_SEPARATOR)) { + return path; + } else { + return homeDir + PATH_SEPARATOR + path; + } } } @@ -331,8 +497,9 @@ public static URI buildURIForAnAccountWithNoUserInformationIncluded( * scheme * * @author Mike Conway - DICE (www.irods.org) - * + * @deprecated Use IRODSUriUserInfo */ +@Deprecated class URIUserParts { private String userName = ""; private String password = ""; diff --git a/jargon-core/src/test/java/org/irods/jargon/core/unittest/AllTests.java b/jargon-core/src/test/java/org/irods/jargon/core/unittest/AllTests.java index 88a7462eb..ef60fbde2 100644 --- a/jargon-core/src/test/java/org/irods/jargon/core/unittest/AllTests.java +++ b/jargon-core/src/test/java/org/irods/jargon/core/unittest/AllTests.java @@ -6,6 +6,7 @@ import org.irods.jargon.core.remoteexecute.RemoteExecuteServiceImplTest; import org.irods.jargon.core.security.IRODSPasswordUtilitiesTest; import org.irods.jargon.core.utils.IRODSUriUtilsTest; +import org.irods.jargon.core.utils.IRODSUriUserInfoTest; import org.irods.jargon.core.utils.LocalFileUtilsTest; import org.irods.jargon.core.utils.MiscIRODSUtilsTest; import org.junit.runner.RunWith; @@ -18,8 +19,8 @@ PackingInstructionTests.class, DomainTests.class, TransferTests.class, LocalFileUtilsTest.class, RemoteExecuteServiceImplTest.class, IRODSPasswordUtilitiesTest.class, IRODSUriUtilsTest.class, - MiscIRODSUtilsTest.class, AuthTests.class, ChecksumTests.class, - TransferRestartTests.class }) + IRODSUriUserInfoTest.class, MiscIRODSUtilsTest.class, + AuthTests.class, ChecksumTests.class, TransferRestartTests.class }) /** * Suite to run all tests (except long running and functional), further refined by settings in testing.properites. Some subtests may be shut * off by these properties. diff --git a/jargon-core/src/test/java/org/irods/jargon/core/utils/IRODSUriUserInfoTest.java b/jargon-core/src/test/java/org/irods/jargon/core/utils/IRODSUriUserInfoTest.java new file mode 100644 index 000000000..a64301284 --- /dev/null +++ b/jargon-core/src/test/java/org/irods/jargon/core/utils/IRODSUriUserInfoTest.java @@ -0,0 +1,146 @@ +package org.irods.jargon.core.utils; + +import org.junit.Assert; +import org.junit.Test; + + +/** + * Created by tedgin on 5/7/15. + */ +public final class IRODSUriUserInfoTest { + + @Test + public void testInstance() { + final IRODSUriUserInfo info = IRODSUriUserInfo.instance("user", "zone", + "password"); + Assert.assertEquals("user.zone:password", info.toString()); + } + + @Test + public void testLocalInstance() { + final IRODSUriUserInfo info = IRODSUriUserInfo.localInstance("user", + "password"); + Assert.assertEquals("user:password", info.toString()); + } + + @Test + public void testUnauthenticatedInstance() { + final IRODSUriUserInfo info = IRODSUriUserInfo.unauthenticatedInstance( + "user", "zone"); + Assert.assertEquals("user.zone", info.toString()); + } + + @Test + public void testUnauthenticatedLocalInstance() { + final IRODSUriUserInfo info + = IRODSUriUserInfo.unauthenticatedLocalInstance("user"); + Assert.assertEquals("user", info.toString()); + } + + @Test(expected = IllegalArgumentException.class) + public void testInstanceWithBlankUser() { + IRODSUriUserInfo.instance("", "zone", "password"); + } + + @Test + public void testInstanceWithBlankZone() { + final IRODSUriUserInfo info = IRODSUriUserInfo.instance("user", "", + "password"); + Assert.assertEquals(null, info.getZone()); + } + + @Test + public void testInstanceWithBlankPassword() { + final IRODSUriUserInfo info = IRODSUriUserInfo.instance("user", "zone", + ""); + Assert.assertEquals(null, info.getPassword()); + } + + @Test + public void testFromStringNull() { + Assert.assertNull(IRODSUriUserInfo.fromString(null)); + } + + @Test + public void testFromStringUserOnly() { + final IRODSUriUserInfo info = IRODSUriUserInfo.fromString("user"); + Assert.assertEquals("user", info.getUserName()); + Assert.assertEquals(null, info.getZone()); + Assert.assertEquals(null, info.getPassword()); + } + + @Test + public void testFromStringUserAndPassword() { + final IRODSUriUserInfo info = IRODSUriUserInfo.fromString( + "user:password"); + Assert.assertEquals("user", info.getUserName()); + Assert.assertEquals(null, info.getZone()); + Assert.assertEquals("password", info.getPassword()); + } + + @Test + public void testFromStringUserAndZone() { + final IRODSUriUserInfo info = IRODSUriUserInfo.fromString("user.zone"); + Assert.assertEquals("user", info.getUserName()); + Assert.assertEquals("zone", info.getZone()); + Assert.assertEquals(null, info.getPassword()); + } + + @Test + public void testFromStringUserZoneAndPassword() { + final IRODSUriUserInfo info = IRODSUriUserInfo.fromString( + "user.zone:password"); + Assert.assertEquals("user", info.getUserName()); + Assert.assertEquals("zone", info.getZone()); + Assert.assertEquals("password", info.getPassword()); + } + + @Test + public void testFromStringWithEscape() { + final IRODSUriUserInfo info = IRODSUriUserInfo.fromString( + "%00user.zone%3c:pass%c4%80word"); + Assert.assertEquals("\u0000user", info.getUserName()); + Assert.assertEquals("zone<", info.getZone()); + Assert.assertEquals("pass\u0100word", info.getPassword()); + } + + @Test + public void testToStringIntoNoEscaping() { + final IRODSUriUserInfo info = IRODSUriUserInfo.instance("0123456789", + "abcdefghijklmnopqrstuvwxyz", + "ABCDEFGHIJKLMNOPQRSTUVWXYZ-_!~*'();&=+$,"); + final String expected = + "0123456789.abcdefghijklmnopqrstuvwxyz:ABCDEFGHIJKLMNOPQRSTUVWXYZ-_!~*'();&=+$,"; + Assert.assertEquals(expected, info.toString()); + } + + @Test + public void testToStringIntoEscaping() { + final IRODSUriUserInfo info = IRODSUriUserInfo.instance(".user", + "zone:", "pass@\u0080word"); + Assert.assertEquals("%2Euser.zone%3A:pass%40%C2%80word", + info.toString()); + } + + @Test + public void testToStringIntoUserOnly() { + final IRODSUriUserInfo info = IRODSUriUserInfo.instance("user", null, + null); + Assert.assertEquals("user", info.toString()); + } + + @Test + public void testToStringIntoUserAndZone() { + final IRODSUriUserInfo info = IRODSUriUserInfo.instance("user", "zone", + null); + Assert.assertEquals("user.zone", info.toString()); + } + + @Test + public void testToStringIntoUserAndPassword() { + final IRODSUriUserInfo info = IRODSUriUserInfo.instance("user", null, + "password"); + Assert.assertEquals("user:password", info.toString()); + } + +} diff --git a/jargon-core/src/test/java/org/irods/jargon/core/utils/IRODSUriUtilsTest.java b/jargon-core/src/test/java/org/irods/jargon/core/utils/IRODSUriUtilsTest.java index 8427662dc..ffed368ee 100644 --- a/jargon-core/src/test/java/org/irods/jargon/core/utils/IRODSUriUtilsTest.java +++ b/jargon-core/src/test/java/org/irods/jargon/core/utils/IRODSUriUtilsTest.java @@ -1,161 +1,246 @@ package org.irods.jargon.core.utils; import java.net.URI; -import java.util.Properties; - -import junit.framework.Assert; import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.junit.AfterClass; -import org.junit.BeforeClass; +import org.irods.jargon.core.exception.InvalidIRODSUriException; +import org.irods.jargon.core.exception.JargonException; import org.junit.Test; -public class IRODSUriUtilsTest { +import static org.irods.jargon.core.utils.IRODSUriUtils.*; +import static org.junit.Assert.*; - private static Properties testingProperties = new Properties(); - private static org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - public static final String IRODS_TEST_SUBDIR_PATH = "IRODSUriUtilsTest"; - private static org.irods.jargon.testutils.IRODSTestSetupUtilities irodsTestSetupUtilities = null; - private static IRODSFileSystem irodsFileSystem = null; - @BeforeClass - public static void setUpBeforeClass() throws Exception { - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - new org.irods.jargon.testutils.filemanip.ScratchFileUtils( - testingProperties); - irodsTestSetupUtilities = new org.irods.jargon.testutils.IRODSTestSetupUtilities(); - irodsTestSetupUtilities.initializeIrodsScratchDirectory(); - irodsTestSetupUtilities - .initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH); - irodsFileSystem = IRODSFileSystem.instance(); - } +public class IRODSUriUtilsTest { - @AfterClass - public static void tearDownAfterClass() throws Exception { - irodsFileSystem.closeAndEatExceptions(); + @Test(expected = InvalidIRODSUriException.class) + public void testGetUserInfoFromInvalidURI() throws Exception { + getUserInfo(new URI("http://localhost")); } @Test - public void testGetUserNameFromURI() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - URI testURI = testingPropertiesHelper - .buildUriFromTestPropertiesForFileInUserDir(testingProperties, - "home/afile.txt"); - String actual = IRODSUriUtils.getUserNameFromURI(testURI); - Assert.assertNotNull("null user name", actual); - Assert.assertEquals("did not derive user name from URI", - irodsAccount.getUserName(), actual); + public void testGetUserInfoFromValidURI() throws Exception { + final URI uri = new URI("irods://user.zone:password@host:10000/"); + final IRODSUriUserInfo info = getUserInfo(uri); + assertEquals("user", info.getUserName()); + assertEquals("zone", info.getZone()); + assertEquals("password", info.getPassword()); } @Test - public void testGetPasswordFromURI() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - URI testURI = testingPropertiesHelper - .buildUriFromTestPropertiesForFileInUserDir(testingProperties, - "home/afile.txt"); - String actual = IRODSUriUtils.getPasswordFromURI(testURI); - Assert.assertNotNull("null password", actual); - Assert.assertEquals("did not derive password from URI", - irodsAccount.getPassword(), actual); + public void testGetUserName() throws Exception { + final URI uri = new URI( + "irods://user.zone:password@host.domain:10000/zone/home/user/afile.txt" + ); + final String actual = getUserName(uri); + assertEquals("did not derive user name from URI", "user", actual); } @Test - public void testGetPasswordFromURINoPassword() throws Exception { + public void testGetZone() throws Exception { + final URI uri = new URI( + "irods://user.zone:password@host.domain:10000/zone/home/user/afile.txt" + ); + assertEquals("did not derive zone from URI", "zone", getZone(uri)); + } - URI testURI = testingPropertiesHelper - .buildUriFromTestPropertiesForFileNoUserInfo(testingProperties, - "home/afile.txt"); + @Test + public void testGetZoneNoZone() throws Exception { + final URI uri = new URI( + "irods://user:password@host.domain:10000/zone/home/user/afile.txt" + ); + assertNull(getZone(uri)); + } - String actual = IRODSUriUtils.getPasswordFromURI(testURI); - Assert.assertNull("password should be null", actual); + @Test + public void testGetPassword() throws Exception { + final URI uri = new URI( + "irods://user.zone:password@host.domain:10000/zone/home/user/afile.txt" + ); + final String actual = getPassword(uri); + assertEquals("did not derive password from URI", "password", actual); } @Test - public void testGetZoneFromURI() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - URI testURI = testingPropertiesHelper - .buildUriFromTestPropertiesForFileNoUserInfo(testingProperties, - "home/afile.txt"); - String actual = IRODSUriUtils.getZoneFromURI(testURI); - Assert.assertNotNull("null zone", actual); - Assert.assertEquals("did not derive zone from URI", - irodsAccount.getZone(), actual); + public void testGetPasswordNoPassword() throws Exception { + final URI testURI = new URI( + "irods://user.zone@host.domain:10000/zone/home/user/afile.txt"); + assertNull("password should be null", getPassword(testURI)); } @Test public void testGetHostFromURI() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - URI testURI = testingPropertiesHelper - .buildUriFromTestPropertiesForFileInUserDir(testingProperties, - "home/afile.txt"); - String actual = IRODSUriUtils.getHostFromURI(testURI); - Assert.assertNotNull("null host", actual); - Assert.assertEquals("did not derive host from URI", - irodsAccount.getHost(), actual); + final URI uri = new URI( + "irods://user.zone:password@host.domain:10000/zone/home/user/afile.txt" + ); + final String actual = getHostFromURI(uri); + assertNotNull("null host", actual); + assertEquals("did not derive host from URI", "host.domain", actual); } @Test public void testGetPortFromURI() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - URI testURI = testingPropertiesHelper - .buildUriFromTestPropertiesForFileInUserDir(testingProperties, - "home/afile.txt"); - int actual = IRODSUriUtils.getPortFromURI(testURI); - Assert.assertEquals("did not derive port from URI", - irodsAccount.getPort(), actual); + final URI uri = new URI( + "irods://user.zone:password@host.domain:10000/zone/home/user/afile.txt" + ); + final int actual = IRODSUriUtils.getPortFromURI(uri); + assertEquals("did not derive port from URI", 10000, actual); } @Test public void testGetAbsolutePathFromURI() throws Exception { + final URI testURI = new URI( + "irods://user.zone:password@host.domain:10000/zone/home/user/afile.txt" + ); + final String actual = getAbsolutePathFromURI(testURI); + assertNotNull("no path returned", actual); + } + + @Test(expected = InvalidIRODSUriException.class) + public void testGetIRODSAccountFromURIInvalidURI() throws Exception { + getIRODSAccountFromURI(new URI("http://host")); + } + + @Test(expected = JargonException.class) + public void testGetIRODSAccountFromURINoUserInfo() throws Exception { + getIRODSAccountFromURI(new URI("irods://host:10000/")); + } - URI testURI = testingPropertiesHelper - .buildUriFromTestPropertiesForFileInUserDir(testingProperties, - "home/afile.txt"); - String actual = IRODSUriUtils.getAbsolutePathFromURI(testURI); - Assert.assertNotNull("no path returned", actual); + @Test(expected = JargonException.class) + public void testGetIRODSAccountFromURINoZone() throws Exception { + getIRODSAccountFromURI(new URI("irods://user:password@host:10000/")); + } + + @Test(expected = JargonException.class) + public void testGetIRODSAccountFromURINoPassword() throws Exception { + getIRODSAccountFromURI(new URI("irods://user.zone@host:10000/")); } @Test - public void testGetURIFromAccountAndPath() throws Exception { - String targetIrodsCollection = testingPropertiesHelper - .buildIRODSCollectionAbsolutePathFromTestProperties( - testingProperties, IRODS_TEST_SUBDIR_PATH); - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - URI testURI = testingPropertiesHelper - .buildUriFromTestPropertiesForFileInUserDirNoPasswordOrZone( - testingProperties, IRODS_TEST_SUBDIR_PATH); - Assert.assertEquals( - "uri not computed correctly", - testURI.toString(), - IRODSUriUtils.buildURIForAnAccountAndPath(irodsAccount, - targetIrodsCollection).toString()); + public void testGetIRODSAccountFromURIGoodUserInfo() throws Exception { + final URI uri = new URI("irods://user.zone:password@host:10000/"); + final IRODSAccount actual = getIRODSAccountFromURI(uri); + final IRODSAccount expected = IRODSAccount.instance("host", 10000, + "user", "password", "/zone/home/user", "zone", ""); + assertEquals(expected, actual); + assertEquals(expected.getZone(), actual.getZone()); + assertEquals(expected.getPassword(), actual.getPassword()); + assertEquals(expected.getHomeDirectory(), actual.getHomeDirectory()); + assertEquals(expected.getDefaultStorageResource(), + actual.getDefaultStorageResource()); + } + @Test + public void testIsIRODSURISchemeFalse() throws Exception { + final URI uri = new URI("http://host"); + assertFalse(isIRODSURIScheme(uri)); + } + + @Test + public void testIsIRODSURISchemeTrue() throws Exception { + final URI uri = new URI("irods://host"); + assertTrue(isIRODSURIScheme(uri)); + } + + @Test + public void testBuildBaseURI() throws Exception { + final URI expectedURI = new URI("irods://user@host.domain:10000/"); + final URI actualURI = buildBaseURI("host.domain", 10000, "user"); + assertEquals("uri not computed correctly", expectedURI, actualURI); + } + + @Test + public void testBuildURIUserName() throws Exception { + final URI expectedURI = new URI( + "irods://user@host.domain:10000/path/to/entity"); + final URI actualURI = buildURI("host.domain", 10000, "user", + "/path/to/entity"); + assertEquals(expectedURI, actualURI); } @Test - public void buildURIFromIRODSAccountAndThenBuildIRODSAccountFromThatURI() + public void testBuildURIUserInfo() throws Exception { + final URI expectedURI = new URI( + "irods://user.zone:password@host.domain:10000/path/to/entity"); + final IRODSUriUserInfo info = IRODSUriUserInfo.instance("user", "zone", + "password"); + final URI actualURI = buildURI("host.domain", 10000, info, + "/path/to/entity"); + assertEquals(expectedURI, actualURI); + } + + @Test + public void testBuildAnonymousURI() { + final URI uri = buildAnonymousURI("host.domain", 10000, + "/zone/home/user/afile.txt"); + assertNull("URI contains user info", uri.getUserInfo()); + } + + @Test(expected = IllegalArgumentException.class) + public void testBuildAnonymouuseURINoPath() { + buildAnonymousURI("host.domain", 10000, null); + } + + @Test + public void testEcoding() throws Exception { + final URI expectedURI = new URI( + "irods://us%5ber@host.domain:10000/path/t%20o/entity%7B"); + final URI actualURI = buildURI("host.domain", 10000, "us[er", + "/path/t o/entity{"); + assertEquals(expectedURI, actualURI); + } + + @Test(expected = IllegalArgumentException.class) + public void testBuildURIForAnAccountAndPathNoAccount() { + buildURIForAnAccountAndPath(null, "/"); + } + + @Test(expected = IllegalArgumentException.class) + public void testBuildURIForAnAccountAndPathNoPath() throws Exception { + final IRODSAccount acnt = IRODSAccount.instance("host", 10000, "user", + "password", "/zone/home/user", "zone", ""); + buildURIForAnAccountAndPath(acnt, null); + } + + @Test + public void testBuildURIForAnAccountAndAbsPath() throws Exception { + final IRODSAccount acnt = IRODSAccount.instance("host", 10000, "user", + "password", "/zone/home/user", "zone", ""); + final URI actual = buildURIForAnAccountAndPath(acnt, "/"); + assertEquals(new URI("irods://user@host:10000/"), actual); + } + + @Test + public void testBuildURIForAnAccountAndRelPath() throws Exception { + final IRODSAccount acnt = IRODSAccount.instance("host", 10000, "user", + "password", "/zone/home/user", "zone", ""); + final URI actual = buildURIForAnAccountAndPath(acnt, "file.txt"); + final URI expected = new URI( + "irods://user@host:10000/zone/home/user/file.txt"); + assertEquals(expected, actual); + } + + @Test(expected = IllegalArgumentException.class) + public void testBuildURIForAnAccountWithNoUserInformationIncludedNoAccount() + { + buildURIForAnAccountWithNoUserInformationIncluded(null, "/"); + } + + @Test(expected = IllegalArgumentException.class) + public void testBuildURIForAnAccountWithNoUserInformationIncludedNoPath() throws Exception { - IRODSAccount irodsAccount = testingPropertiesHelper - .buildIRODSAccountFromTestProperties(testingProperties); - URI testURI = irodsAccount.toURI(true); - IRODSAccount newAccount = IRODSUriUtils.getIRODSAccountFromURI(testURI); - Assert.assertNotNull("null iRODS account", newAccount); - Assert.assertEquals(irodsAccount.getHost(), newAccount.getHost()); - Assert.assertEquals(irodsAccount.getPort(), newAccount.getPort()); - Assert.assertEquals(irodsAccount.getZone(), newAccount.getZone()); - Assert.assertEquals(irodsAccount.getUserName(), - newAccount.getUserName()); - Assert.assertEquals(irodsAccount.getPassword(), - newAccount.getPassword()); + final IRODSAccount acnt = IRODSAccount.instance("host", 10000, "user", + "password", "/zone/home/user", "zone", ""); + buildURIForAnAccountWithNoUserInformationIncluded(acnt, ""); } + @Test + public void testBuildURIForAnAccountWithNoUserInformationIncluded() + throws Exception { + final IRODSAccount acnt = IRODSAccount.instance("host", 10000, "user", + "password", "/zone/home/user", "zone", ""); + final URI actual = buildURIForAnAccountWithNoUserInformationIncluded( + acnt, "/"); + assertEquals(new URI("irods://host:10000/"), actual); + } } diff --git a/pom.xml b/pom.xml index 8addc5a01..2279a80e3 100644 --- a/pom.xml +++ b/pom.xml @@ -452,7 +452,6 @@ jargon-ticket jargon-httpstream jargon-user-profile - jargon-conveyor jargon-workflow jargon-ruleservice data-profile