Search in sources :

Example 1 with ArchiveBasedHumanTaskDeploymentUnitBuilder

use of org.wso2.carbon.humantask.core.deployment.ArchiveBasedHumanTaskDeploymentUnitBuilder in project carbon-business-process by wso2.

the class HumanTaskStore method createNewDeploymentUnit.

/**
 * Creates a new deployment unit from the given information
 * @param humanTaskFile
 * @param tenantId
 * @param version
 * @param md5sum
 * @return
 * @throws HumanTaskDeploymentException
 */
public HumanTaskDeploymentUnit createNewDeploymentUnit(File humanTaskFile, int tenantId, long version, String md5sum) throws HumanTaskDeploymentException {
    try {
        ArchiveBasedHumanTaskDeploymentUnitBuilder builder = new ArchiveBasedHumanTaskDeploymentUnitBuilder(humanTaskFile, tenantId, version, md5sum);
        HumanTaskDeploymentUnit newHumanTaskDeploymentUnit = builder.createNewHumanTaskDeploymentUnit();
        return newHumanTaskDeploymentUnit;
    } catch (HumanTaskDeploymentException deploymentException) {
        if (log.isDebugEnabled()) {
            log.debug("humanTask:" + humanTaskFile.getName() + " deployment failed, removing the extracted human task directory.");
        }
        String versionedName = FilenameUtils.removeExtension(humanTaskFile.getName()) + HumanTaskConstants.VERSION_SEPARATOR + version;
        deleteHumanTaskPackageFromRepo(versionedName);
        throw deploymentException;
    }
}
Also used : ArchiveBasedHumanTaskDeploymentUnitBuilder(org.wso2.carbon.humantask.core.deployment.ArchiveBasedHumanTaskDeploymentUnitBuilder) HumanTaskDeploymentException(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException) HumanTaskDeploymentUnit(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentUnit)

Example 2 with ArchiveBasedHumanTaskDeploymentUnitBuilder

use of org.wso2.carbon.humantask.core.deployment.ArchiveBasedHumanTaskDeploymentUnitBuilder in project carbon-business-process by wso2.

the class HumanTaskStore method reloadExistingTaskVersions.

/**
 * Reload existing task versions for a given deployment unit
 * @param existingDeploymentUnitsForPackage
 * @param archiveFile
 * @param md5sum
 * @throws HumanTaskDeploymentException
 */
public void reloadExistingTaskVersions(List<DeploymentUnitDAO> existingDeploymentUnitsForPackage, File archiveFile, String md5sum, boolean isMasterServer) throws Exception {
    // deployment units list should not be null, having a safety check anyway
    if (existingDeploymentUnitsForPackage == null) {
        return;
    }
    if (log.isDebugEnabled()) {
        log.debug("Reloading existing task versions for human task archive [ " + archiveFile.getName() + "]");
    }
    for (DeploymentUnitDAO dao : existingDeploymentUnitsForPackage) {
        if (!isMasterServer) {
            // We need to avoid deployment of already loaded packages
            String versionedName = dao.getName();
            List<QName> qNames = taskConfigurationsInTaskPackage.get(versionedName);
            if (qNames != null && qNames.size() > 0) {
                // This dao is already loaded
                if (log.isDebugEnabled()) {
                    log.debug("This is already loaded package, skipping " + versionedName);
                }
                continue;
            }
        }
        try {
            File taskDirectory = findHumanTaskPackageInFileSystem(dao, archiveFile);
            ArchiveBasedHumanTaskDeploymentUnitBuilder deploymentUnitBuilder = null;
            if (log.isDebugEnabled()) {
                log.debug("Loading task : " + dao.getName());
            }
            if (taskDirectory.exists()) {
                // This is an existing task configuration
                deploymentUnitBuilder = new ArchiveBasedHumanTaskDeploymentUnitBuilder(taskDirectory, tenantId, dao.getVersion(), dao.getPackageName(), dao.getChecksum());
            } else if (dao.getStatus() == TaskPackageStatus.ACTIVE) {
                // This node is a salve node and task is being reloaded or new version has been deployed on master
                deploymentUnitBuilder = new ArchiveBasedHumanTaskDeploymentUnitBuilder(archiveFile, tenantId, dao.getVersion(), md5sum);
            } else {
                String errMsg = "Error loading task. Cannot find the task directory for retired task " + dao.getName();
                log.error(errMsg);
                throw new HumanTaskDeploymentException(errMsg);
            }
            // Check whether this is a new version deployment on a slave node
            if (!isMasterServer && dao.getStatus() == TaskPackageStatus.ACTIVE) {
                String currentDeployedVersion = loadedPackages.get(dao.getPackageName());
                if (currentDeployedVersion != null && currentDeployedVersion.equals(dao.getName()) == false) {
                    // This is a new version on the salve node  , retire the existing version
                    retireTaskPackageConfigurations(currentDeployedVersion);
                }
            }
            HumanTaskDeploymentUnit taskDeploymentUnit = deploymentUnitBuilder.createNewHumanTaskDeploymentUnit();
            taskDeploymentUnit.setTaskPackageStatus(dao.getStatus());
            deploy(taskDeploymentUnit);
            if (dao.getStatus() == TaskPackageStatus.ACTIVE) {
                // Add the active package to the loaded packages
                loadedPackages.put(dao.getPackageName(), dao.getName());
            }
        } catch (HumanTaskDeploymentException e) {
            String errMsg = "Error loading the task configuration ";
            log.error(errMsg, e);
            throw e;
        }
    }
}
Also used : DeploymentUnitDAO(org.wso2.carbon.humantask.core.dao.DeploymentUnitDAO) QName(javax.xml.namespace.QName) ArchiveBasedHumanTaskDeploymentUnitBuilder(org.wso2.carbon.humantask.core.deployment.ArchiveBasedHumanTaskDeploymentUnitBuilder) HumanTaskDeploymentException(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException) File(java.io.File) HumanTaskDeploymentUnit(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentUnit)

Aggregations

ArchiveBasedHumanTaskDeploymentUnitBuilder (org.wso2.carbon.humantask.core.deployment.ArchiveBasedHumanTaskDeploymentUnitBuilder)2 HumanTaskDeploymentException (org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException)2 HumanTaskDeploymentUnit (org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentUnit)2 File (java.io.File)1 QName (javax.xml.namespace.QName)1 DeploymentUnitDAO (org.wso2.carbon.humantask.core.dao.DeploymentUnitDAO)1