Search in sources :

Example 11 with HumanTaskDeploymentException

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

the class CallBackServiceImpl method inferBindingInformation.

private void inferBindingInformation(Definition wsdlDefinition) throws HumanTaskDeploymentException {
    Service serviceDef = wsdlDefinition.getService(serviceName);
    if (serviceDef == null) {
        throw new HumanTaskDeploymentException("Service element not found for callback service wsdl: " + serviceName);
    }
    Port port = serviceDef.getPort(portName);
    if (port == null) {
        throw new HumanTaskDeploymentException("Port: " + portName + " not found for Service: " + serviceName + " in the callback service wsdl");
    }
    binding = port.getBinding();
    if (binding == null) {
        throw new HumanTaskDeploymentException("Binding not found for port: " + portName + " and Service: " + serviceName + " in the callback service wsdl");
    }
}
Also used : CallBackService(org.wso2.carbon.humantask.core.CallBackService) HumanTaskDeploymentException(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException)

Example 12 with HumanTaskDeploymentException

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

the class ArchiveBasedHumanTaskDeploymentUnitBuilder method buildWSDLs.

@Override
public void buildWSDLs() throws HumanTaskDeploymentException {
    HashSet<Definition> tmpWsdlDefinitions = new HashSet<>();
    URI baseUri = humantaskDir.toURI();
    for (File file : FileUtils.directoryEntriesInPath(humantaskDir, wsdlFilter)) {
        try {
            URI uri = baseUri.relativize(file.toURI());
            if (!uri.isAbsolute()) {
                File f = new File(baseUri.getPath() + File.separator + uri.getPath());
                URI abUri = f.toURI();
                if (abUri.isAbsolute()) {
                    uri = abUri;
                }
            }
            WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
            reader.setFeature(HumanTaskConstants.JAVAX_WSDL_VERBOSE_MODE_KEY, false);
            reader.setFeature("javax.wsdl.importDocuments", true);
            Definition definition = reader.readWSDL(new HumanTaskWSDLLocator(uri));
            if (definition != null) {
                tmpWsdlDefinitions.add(definition);
            }
        } catch (WSDLException e) {
            log.error("Error processing wsdl " + file.getName());
            throw new HumanTaskDeploymentException(" Error processing wsdl ", e);
        } catch (URISyntaxException e) {
            log.error("Invalid uri in reading wsdl ", e);
            throw new HumanTaskDeploymentException(" Invalid uri in reading wsdl ", e);
        }
    }
    // Optimizing WSDLs imports. Using HashSet to avoid duplicate entices.
    HashSet<Definition> optimizedDefinitions = new HashSet<>();
    HTDeploymentConfigDocument htDeploymentConfigDocument = getHTDeploymentConfigDocument();
    // Iterating Tasks.
    THTDeploymentConfig.Task[] taskArray = htDeploymentConfigDocument.getHTDeploymentConfig().getTaskArray();
    if (taskArray != null) {
        for (THTDeploymentConfig.Task task : taskArray) {
            QName taskService = task.getPublish().getService().getName();
            Definition taskServiceDefinition = getDefinition(taskService, tmpWsdlDefinitions);
            if (log.isDebugEnabled()) {
                log.debug("Optimizing WSDL import for Task : " + task.getName());
            }
            if (taskServiceDefinition != null) {
                optimizedDefinitions.add(taskServiceDefinition);
                if (log.isDebugEnabled()) {
                    log.debug("Added WSDL for Task : " + task.getName() + ", Service : " + taskService + ", Imported/Total definition : " + optimizedDefinitions.size() + "/" + tmpWsdlDefinitions.size());
                }
            } else {
                log.warn("Can't find valid WSDL definition for Task" + task.getName() + ", Service: " + taskService);
            }
            QName callbackService = task.getCallback().getService().getName();
            Definition callbackServiceDefinition = getDefinition(callbackService, tmpWsdlDefinitions);
            if (callbackServiceDefinition != null) {
                optimizedDefinitions.add(callbackServiceDefinition);
                if (log.isDebugEnabled()) {
                    log.debug("Added WSDL for Task : " + task.getName() + ", Callback Service : " + callbackService + ", Imported/Total definition : " + optimizedDefinitions.size() + "/" + tmpWsdlDefinitions.size());
                }
            } else {
                log.warn("Can't find valid WSDL definition for Task : " + task.getName() + ", Callback Service" + callbackService);
            }
        }
    }
    // Iterating Notifications.
    THTDeploymentConfig.Notification[] notificationsArray = htDeploymentConfigDocument.getHTDeploymentConfig().getNotificationArray();
    if (notificationsArray != null) {
        for (THTDeploymentConfig.Notification notification : notificationsArray) {
            QName notificationService = notification.getPublish().getService().getName();
            Definition notificationServiceDefinition = getDefinition(notificationService, tmpWsdlDefinitions);
            if (notificationServiceDefinition != null) {
                optimizedDefinitions.add(notificationServiceDefinition);
                if (log.isDebugEnabled()) {
                    log.debug("Added WSDL for Task : " + notification.getName() + ", Callback Service : " + notificationService + ", Imported/Total definition : " + optimizedDefinitions.size() + "/" + tmpWsdlDefinitions.size());
                }
            } else {
                log.warn("Can't find valid WSDL definition for Notification " + notification.getName() + ", Service: " + notificationService);
            }
        }
    }
    // Converting HashSet to ArrayList.
    wsdlDefinitions = new ArrayList<>(optimizedDefinitions);
    if (log.isDebugEnabled()) {
        log.debug("Optimized Imported/Total definition : " + wsdlDefinitions.size() + "/" + tmpWsdlDefinitions.size());
    }
}
Also used : WSDLException(javax.wsdl.WSDLException) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) THTDeploymentConfig(org.wso2.carbon.humantask.core.deployment.config.THTDeploymentConfig) HTDeploymentConfigDocument(org.wso2.carbon.humantask.core.deployment.config.HTDeploymentConfigDocument) WSDLReader(javax.wsdl.xml.WSDLReader)

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