Search in sources :

Example 1 with HumanTaskDeploymentException

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

the class HumanTaskStore method createCallBackService.

private void createCallBackService(TaskConfiguration taskConf) throws HumanTaskDeploymentException {
    EndpointConfiguration endpointConfig = taskConf.getEndpointConfiguration(taskConf.getCallbackServiceName().getLocalPart(), taskConf.getCallbackPortName());
    CallBackServiceImpl callbackService = new CallBackServiceImpl(tenantId, taskConf.getCallbackServiceName(), taskConf.getCallbackPortName(), taskConf.getName(), taskConf.getResponseWSDL(), taskConf.getResponseOperation(), endpointConfig);
    taskConf.setCallBackService(callbackService);
}
Also used : EndpointConfiguration(org.wso2.carbon.bpel.common.config.EndpointConfiguration) CallBackServiceImpl(org.wso2.carbon.humantask.core.integration.CallBackServiceImpl)

Example 2 with HumanTaskDeploymentException

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

the class HumanTaskStore method deploy.

/**
 * This will simply deploy the new task and will not perform removal of existing tasks, which should be done prior to
 * deploying this task
 * @param humanTaskDU
 * @return List of task configuration Qnames deployed
 * @throws HumanTaskDeploymentException
 */
public List<QName> deploy(HumanTaskDeploymentUnit humanTaskDU) throws HumanTaskDeploymentException {
    List<QName> taskConfigsInPackage = new ArrayList<QName>();
    TTask[] tasks = humanTaskDU.getTasks();
    List<HumanTaskBaseConfiguration> configurations = new ArrayList<HumanTaskBaseConfiguration>();
    if (tasks != null) {
        for (TTask task : tasks) {
            QName taskQName = new QName(humanTaskDU.getNamespace(), task.getName());
            if (log.isDebugEnabled()) {
                log.debug(" Adding task " + task.getName() + "to task configuration");
            }
            TaskConfiguration taskConf = new TaskConfiguration(task, humanTaskDU.getTaskServiceInfo(taskQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
            taskConf.setPackageStatus(humanTaskDU.getTaskPackageStatus());
            configurations.add(taskConf);
            if (!taskConf.isErroneous()) {
                createCallBackService(taskConf);
                if (taskConf.getPackageStatus() == TaskPackageStatus.ACTIVE) {
                    deploy(taskConf);
                // activeTaskConfigurationQNameMap.put(taskQName, taskConf.getName());
                }
            }
        }
    }
    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());
            notificationConf.setPackageStatus(humanTaskDU.getTaskPackageStatus());
            configurations.add(notificationConf);
            if (!notificationConf.isErroneous()) {
                // Deploy the axis2 service only for the active version of the task/notification
                if (notificationConf.getPackageStatus() == TaskPackageStatus.ACTIVE) {
                    deploy(notificationConf);
                // activeTaskConfigurationQNameMap.put(notificationQName, notificationConf.getName());
                }
            }
        }
    }
    // condition if a service name is deployed with same name outside of this task package
    for (HumanTaskBaseConfiguration configuration : configurations) {
        taskConfigurations.add(configuration);
        taskBaseConfigurationHashMap.put(configuration.getName(), configuration);
        taskConfigsInPackage.add(configuration.getName());
        if (configuration.getPackageStatus() == TaskPackageStatus.ACTIVE) {
            activeTaskConfigurationQNameMap.put(configuration.getDefinitionName(), configuration.getName());
        }
    }
    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());
        taskConfigurations.add(notificationConf);
        taskConfigsInPackage.add(notificationConf.getName());
        taskBaseConfigurationHashMap.put(notificationConf.getName(), notificationConf);
        if (notificationConf.getPackageStatus() == TaskPackageStatus.ACTIVE) {
            activeTaskConfigurationQNameMap.put(notificationQName, notificationConf.getName());
        }
    }
    taskConfigurationsInTaskPackage.put(humanTaskDU.getName(), taskConfigsInPackage);
    return taskConfigsInPackage;
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) TNotification(org.wso2.carbon.humantask.TNotification) TTask(org.wso2.carbon.humantask.TTask)

Example 3 with HumanTaskDeploymentException

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

the class NotificationConfiguration method initEndpointConfigs.

private void initEndpointConfigs() throws HumanTaskDeploymentException {
    TPublish.Service service = notificationDeploymentConfiguration.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);
    }
}
Also used : TPublish(org.wso2.carbon.humantask.core.deployment.config.TPublish) OMElement(org.apache.axiom.om.OMElement) EndpointConfiguration(org.wso2.carbon.bpel.common.config.EndpointConfiguration)

Example 4 with HumanTaskDeploymentException

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

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

the class HumanTaskStore method findHumanTaskPackageInFileSystem.

/**
 * This method provides the extracted human task package location in file system.
 * If human task package does not exist in file system then package will be exported from registry.
 * If human task package does not exist in registry then package will be imported to registry from file system.
 * If registry and file location don't have extracted human task package content then exception will be thrown
 *
 * @param dudao
 * @return File
 * @throws HumanTaskDeploymentException
 */
private File findHumanTaskPackageInFileSystem(DeploymentUnitDAO dudao, File archiveFile) throws Exception {
    String duName = dudao.getName();
    log.info("Looking for HumanTask package in file system for deployment unit " + duName);
    File humanTaskDUDirectory = new File(humanTaskDeploymentRepo, duName);
    String registryCollectionPath = HumanTaskPackageRepositoryUtils.getResourcePathForHumanTaskPackageContent(dudao.getPackageName(), dudao.getName());
    try {
        if (humanTaskDUDirectory.exists()) {
            if (!tenantConfigRegistry.resourceExists(registryCollectionPath)) {
                // Import human task package content to registry from file system
                repository.restoreHumanTaskPackageContentInRegistry(dudao, archiveFile);
            }
            return humanTaskDUDirectory;
        } else {
            if (tenantConfigRegistry.resourceExists(registryCollectionPath)) {
                if (!humanTaskDUDirectory.exists() && !humanTaskDUDirectory.mkdirs()) {
                    String errMsg = "Error creating HumanTask deployment unit repository for " + "tenant " + tenantId;
                    log.error(errMsg);
                    log.error("Failed to load HumanTask deployment unit " + duName + " due to above error.");
                    throw new HumanTaskDeploymentException(errMsg);
                }
                // Export human task package content from registry to file system
                RegistryClientUtils.exportFromRegistry(humanTaskDUDirectory, registryCollectionPath, tenantConfigRegistry);
                return humanTaskDUDirectory;
            } else {
                String errMsg = "Expected resource: " + registryCollectionPath + " not found in the registry";
                log.error(errMsg);
                throw new HumanTaskDeploymentException(errMsg);
            }
        }
    } catch (RegistryException re) {
        String errMsg = "Error while exporting deployment unit: " + duName + " to file system from the " + "registry.";
        log.error(errMsg, re);
        throw new HumanTaskDeploymentException(errMsg, re);
    }
}
Also used : HumanTaskDeploymentException(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException) File(java.io.File) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException)

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