Search in sources :

Example 6 with HumanTaskDeploymentException

use of org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException 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)

Example 7 with HumanTaskDeploymentException

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

the class HumanTaskStore method validateServiceCreationForTaskConfig.

/**
 * When wsdl errors are there in the package, we use a dummy service creation step to validate all required parts
 * are available in the wsdl
 * @param taskConfig Task configuration object for this task package
 * @throws HumanTaskDeploymentException HumanTaskDeployment Exception is thrown when an error happens
 */
private void validateServiceCreationForTaskConfig(HumanTaskBaseConfiguration taskConfig) throws HumanTaskDeploymentException {
    try {
        WSDL11ToAxisServiceBuilder serviceBuilder = createAxisServiceBuilder(taskConfig, taskConfig.getWSDL());
        serviceBuilder.populateService();
    } catch (AxisFault e) {
        String errorMsg = "Error validating wsdl " + e.getMessage();
        throw new HumanTaskDeploymentException(errorMsg, e);
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) WSDL11ToAxisServiceBuilder(org.apache.axis2.description.WSDL11ToAxisServiceBuilder) HumanTaskDeploymentException(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException)

Example 8 with HumanTaskDeploymentException

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

the class HumanTaskStore method validateTaskConfig.

/**
 * Performance a test deployment of the task in order to avoid deployment issues due to invalid task packages
 * @param humanTaskDU
 * @return
 * @throws HumanTaskDeploymentException
 */
public void validateTaskConfig(HumanTaskDeploymentUnit humanTaskDU) throws HumanTaskDeploymentException, AxisFault {
    boolean validateTask = HumanTaskServiceComponent.getHumanTaskServer().getServerConfig().getEnableTaskValidationBeforeDeployment();
    if (validateTask) {
        TTask[] tasks = humanTaskDU.getTasks();
        if (tasks != null) {
            for (TTask task : tasks) {
                QName taskQName = new QName(humanTaskDU.getNamespace(), task.getName());
                TaskConfiguration taskConf = new TaskConfiguration(task, humanTaskDU.getTaskServiceInfo(taskQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
                if (taskConf.isErroneous()) {
                    throw new HumanTaskDeploymentException(taskConf.getDeploymentError());
                }
                validateServiceCreationForTaskConfig(taskConf);
            }
        }
        TNotification[] notifications = humanTaskDU.getNotifications();
        if (notifications != null) {
            for (TNotification notification : notifications) {
                QName notificationQName = new QName(humanTaskDU.getNamespace(), notification.getName());
                NotificationConfiguration notificationConf = new NotificationConfiguration(notification, humanTaskDU.getNotificationServiceInfo(notificationQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
                if (notificationConf.isErroneous()) {
                    throw new HumanTaskDeploymentException(notificationConf.getDeploymentError());
                }
                validateServiceCreationForTaskConfig(notificationConf);
            }
        }
        for (TNotification inlineNotification : humanTaskDU.getInlineNotifications()) {
            QName notificationQName = new QName(humanTaskDU.getNamespace(), inlineNotification.getName());
            NotificationConfiguration notificationConf = new NotificationConfiguration(inlineNotification, humanTaskDU.getNotificationServiceInfo(notificationQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
            notificationConf.setPackageStatus(humanTaskDU.getTaskPackageStatus());
            if (notificationConf.isErroneous()) {
                throw new HumanTaskDeploymentException(notificationConf.getDeploymentError());
            }
            validateServiceCreationForTaskConfig(notificationConf);
        }
    }
    return;
}
Also used : QName(javax.xml.namespace.QName) HumanTaskDeploymentException(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException) TNotification(org.wso2.carbon.humantask.TNotification) TTask(org.wso2.carbon.humantask.TTask)

Example 9 with HumanTaskDeploymentException

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

the class TaskConfiguration method initEndpointConfigs.

private void initEndpointConfigs() throws HumanTaskDeploymentException {
    if (taskDeploymentConfiguration == null) {
        throw new HumanTaskDeploymentException("Cannot find task deployment configuration.");
    }
    if (taskDeploymentConfiguration.getPublish() == null || taskDeploymentConfiguration.getPublish().getService() == null) {
        throw new HumanTaskDeploymentException("Cannot find publish element in the htconfig.xml file.");
    }
    TPublish.Service service = taskDeploymentConfiguration.getPublish().getService();
    OMElement serviceEle;
    serviceEle = HumanTaskStoreUtils.getOMElement(service.toString());
    EndpointConfiguration endpointConfig = HumanTaskStoreUtils.getEndpointConfig(serviceEle);
    if (endpointConfig != null) {
        endpointConfig.setServiceName(service.getName().getLocalPart());
        endpointConfig.setServicePort(service.getPort());
        endpointConfig.setServiceNS(service.getName().getNamespaceURI());
        endpointConfig.setBasePath(getHumanTaskDefinitionFile().getParentFile().getAbsolutePath());
        endpointConfig.setServiceDescriptionLocation(service.getServiceDescriptionReference());
        addEndpointConfiguration(endpointConfig);
    }
    if (taskDeploymentConfiguration.getCallback() == null || taskDeploymentConfiguration.getCallback().getService() == null) {
        throw new HumanTaskDeploymentException("Cannot find callback element in the htconfig.xml file.");
    }
    TCallback.Service cbService = taskDeploymentConfiguration.getCallback().getService();
    serviceEle = HumanTaskStoreUtils.getOMElement(cbService.toString());
    endpointConfig = HumanTaskStoreUtils.getEndpointConfig(serviceEle);
    if (endpointConfig != null) {
        endpointConfig.setServiceName(cbService.getName().getLocalPart());
        endpointConfig.setServicePort(cbService.getPort());
        endpointConfig.setServiceNS(cbService.getName().getNamespaceURI());
        endpointConfig.setBasePath(getHumanTaskDefinitionFile().getParentFile().getAbsolutePath());
        endpointConfig.setServiceDescriptionLocation(cbService.getServiceDescriptionReference());
        addEndpointConfiguration(endpointConfig);
    }
}
Also used : TCallback(org.wso2.carbon.humantask.core.deployment.config.TCallback) TPublish(org.wso2.carbon.humantask.core.deployment.config.TPublish) OMElement(org.apache.axiom.om.OMElement) EndpointConfiguration(org.wso2.carbon.bpel.common.config.EndpointConfiguration) HumanTaskDeploymentException(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException)

Example 10 with HumanTaskDeploymentException

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

the class HumanTaskStore method deploy.

private void deploy(HumanTaskBaseConfiguration taskConfig) throws HumanTaskDeploymentException {
    if (taskConfig != null) {
        /**
         * Creating AxisService for HI
         */
        if (log.isDebugEnabled()) {
            log.debug("Deploying task " + taskConfig.getName());
        }
        AxisService axisService;
        Definition wsdlDef = taskConfig.getWSDL();
        if (taskConfig instanceof TaskConfiguration) {
            // to get the task id as response
            wsdlDef.getPortType(taskConfig.getPortType()).getOperation(taskConfig.getOperation(), null, null).setStyle(OperationType.REQUEST_RESPONSE);
        } else {
            // ONE_WAY no feed back for NOTIFICATIONS
            wsdlDef.getPortType(taskConfig.getPortType()).getOperation(taskConfig.getOperation(), null, null).setStyle(OperationType.ONE_WAY);
        }
        WSDL11ToAxisServiceBuilder serviceBuilder = createAxisServiceBuilder(taskConfig, wsdlDef);
        try {
            axisService = createAxisService(serviceBuilder, taskConfig);
            ServiceConfigurationUtil.configureService(axisService, taskConfig.getEndpointConfiguration(taskConfig.getServiceName().getLocalPart(), taskConfig.getPortName()), getConfigContext());
            ArrayList<AxisService> serviceList = new ArrayList<AxisService>();
            serviceList.add(axisService);
            DeploymentEngine.addServiceGroup(createServiceGroupForService(axisService), serviceList, null, null, getTenantAxisConfig());
            if (log.isDebugEnabled()) {
                log.debug(" Published axis2 service " + axisService.getName() + " for task " + taskConfig.getName());
            }
        } catch (AxisFault axisFault) {
            String errMsg = "Error populating the service";
            log.error(errMsg);
            throw new HumanTaskDeploymentException(errMsg, axisFault);
        }
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) AxisService(org.apache.axis2.description.AxisService) Definition(javax.wsdl.Definition) ArrayList(java.util.ArrayList) WSDL11ToAxisServiceBuilder(org.apache.axis2.description.WSDL11ToAxisServiceBuilder) HumanTaskDeploymentException(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException)

Aggregations

HumanTaskDeploymentException (org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException)8 QName (javax.xml.namespace.QName)4 EndpointConfiguration (org.wso2.carbon.bpel.common.config.EndpointConfiguration)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Definition (javax.wsdl.Definition)2 OMElement (org.apache.axiom.om.OMElement)2 AxisFault (org.apache.axis2.AxisFault)2 WSDL11ToAxisServiceBuilder (org.apache.axis2.description.WSDL11ToAxisServiceBuilder)2 TNotification (org.wso2.carbon.humantask.TNotification)2 TTask (org.wso2.carbon.humantask.TTask)2 ArchiveBasedHumanTaskDeploymentUnitBuilder (org.wso2.carbon.humantask.core.deployment.ArchiveBasedHumanTaskDeploymentUnitBuilder)2 HumanTaskDeploymentUnit (org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentUnit)2 TPublish (org.wso2.carbon.humantask.core.deployment.config.TPublish)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 WSDLException (javax.wsdl.WSDLException)1 WSDLReader (javax.wsdl.xml.WSDLReader)1 AxisService (org.apache.axis2.description.AxisService)1 CallBackService (org.wso2.carbon.humantask.core.CallBackService)1