Search in sources :

Example 61 with Element

use of org.wso2.siddhi.query.api.annotation.Element in project carbon-business-process by wso2.

the class SOAPUtils method handleSOAPHeaderElementsInBindingOperation.

@SuppressWarnings("unchecked")
private static void handleSOAPHeaderElementsInBindingOperation(SOAPEnvelope soapEnvelope, SOAPFactory soapFactory, org.apache.ode.bpel.iapi.Message messageFromOde, Operation wsdlOperation, final javax.wsdl.extensions.soap.SOAPHeader soapHeaderElementDefinition) throws BPELFault {
    Map<String, Node> headerParts = messageFromOde.getHeaderParts();
    Message responseMessageDefinition = wsdlOperation.getOutput() != null ? wsdlOperation.getOutput().getMessage() : null;
    // If there isn't a message attribute in header element definition or if the
    // message attribute value is equal to the response message QName, then this
    // header element is part of the actual payload.
    // Refer SOAP Binding specification at http://www.w3.org/TR/wsdl#_soap-b.
    final boolean isHeaderElementAPartOfPayload = soapHeaderElementDefinition.getMessage() == null || ((wsdlOperation.getStyle() != OperationType.ONE_WAY) && soapHeaderElementDefinition.getMessage().equals(responseMessageDefinition.getQName()));
    if (soapHeaderElementDefinition.getPart() == null) {
        // Part information not found. Ignoring this header definition.
        return;
    }
    if (isHeaderElementAPartOfPayload && (responseMessageDefinition != null && responseMessageDefinition.getPart(soapHeaderElementDefinition.getPart()) == null)) {
        // we should throw a exception.
        throw new BPELFault("SOAP Header Element Definition refer unknown part.");
    }
    Element partElement = null;
    if (headerParts.size() > 0 && isHeaderElementAPartOfPayload) {
        try {
            partElement = (Element) headerParts.get(soapHeaderElementDefinition.getPart());
        } catch (ClassCastException e) {
            throw new BPELFault("SOAP Header must be a DOM Element.", e);
        }
    }
    // message payload. This is because, some headers will provided by SOAP engine.
    if (partElement == null && isHeaderElementAPartOfPayload) {
        if (messageFromOde.getPart(soapHeaderElementDefinition.getPart()) != null) {
            partElement = messageFromOde.getPart(soapHeaderElementDefinition.getPart());
        } else {
            throw new BPELFault("Missing Required part in response message.");
        }
    }
    // and can be found and extracted from the odeMessage object
    if (partElement == null && messageFromOde.getParts().size() > 0 && !isHeaderElementAPartOfPayload) {
        try {
            partElement = (Element) messageFromOde.getPart(soapHeaderElementDefinition.getPart());
        } catch (ClassCastException e) {
            throw new BPELFault("Soap header must be an element" + messageFromOde.getPart(soapHeaderElementDefinition.getPart()));
        }
    }
    // just ignore this case.
    if (partElement == null) {
        return;
    }
    org.apache.axiom.soap.SOAPHeader soapHeader = soapEnvelope.getHeader();
    if (soapHeader == null) {
        soapHeader = soapFactory.createSOAPHeader(soapEnvelope);
    }
    OMElement omPart = OMUtils.toOM(partElement, soapFactory);
    for (Iterator<OMNode> i = omPart.getChildren(); i.hasNext(); ) {
        soapHeader.addChild(i.next());
    }
}
Also used : Message(javax.wsdl.Message) BPELFault(org.wso2.carbon.bpel.core.ode.integration.BPELFault) OMNode(org.apache.axiom.om.OMNode) Node(org.w3c.dom.Node) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) OMElement(org.apache.axiom.om.OMElement) SOAPHeader(org.apache.axiom.soap.SOAPHeader) OMNode(org.apache.axiom.om.OMNode)

Example 62 with Element

use of org.wso2.siddhi.query.api.annotation.Element in project carbon-business-process by wso2.

the class SOAPUtils method populateSOAPBody.

@SuppressWarnings("unchecked")
private static void populateSOAPBody(SOAPEnvelope soapEnvelope, ElementExtensible bindingInput, boolean soap12, SOAPFactory soapFactory, Operation operation, Message messageDefinition, org.apache.ode.bpel.iapi.Message messageFromODE, boolean isRPC, boolean isRequest) throws BPELFault {
    if (soap12) {
        SOAP12Body soapBodyDefinition = getSOAP12Body(bindingInput);
        if (soapBodyDefinition != null) {
            SOAPBody soapBody;
            if (soapEnvelope.getBody() != null) {
                soapBody = soapEnvelope.getBody();
            } else {
                soapBody = soapFactory.createSOAPBody(soapEnvelope);
            }
            OMElement partHolder;
            if (isRPC) {
                String rpcWrapperElementName;
                if (isRequest) {
                    rpcWrapperElementName = operation.getName();
                } else {
                    rpcWrapperElementName = operation.getName() + "Response";
                }
                partHolder = createRPCWrapperElement(soapBody, soapFactory, new QName(soapBodyDefinition.getNamespaceURI(), rpcWrapperElementName));
            } else {
                partHolder = soapBody;
            }
            List<Part> parts = messageDefinition.getOrderedParts(soapBodyDefinition.getParts());
            for (Part p : parts) {
                Element partContent = DOMUtils.findChildByName(messageFromODE.getMessage(), new QName(null, p.getName()));
                if (partContent == null) {
                    throw new BPELFault("Missing required part in ODE Message: " + new QName(null, p.getName()));
                }
                OMElement omPartContent = OMUtils.toOM(partContent, soapFactory);
                if (isRPC) {
                    partHolder.addChild(omPartContent);
                } else {
                    for (Iterator<OMNode> i = omPartContent.getChildren(); i.hasNext(); ) {
                        partHolder.addChild(i.next());
                    }
                }
            }
        }
    } else {
        javax.wsdl.extensions.soap.SOAPBody soapBodyDefinition = getSOAP11Body(bindingInput);
        if (soapBodyDefinition != null) {
            SOAPBody soapBody;
            if (soapEnvelope.getBody() != null) {
                soapBody = soapEnvelope.getBody();
            } else {
                soapBody = soapFactory.createSOAPBody(soapEnvelope);
            }
            OMElement partHolder;
            if (isRPC) {
                String rpcWrapperElementName;
                if (isRequest) {
                    rpcWrapperElementName = operation.getName();
                } else {
                    rpcWrapperElementName = operation.getName() + "Response";
                }
                partHolder = createRPCWrapperElement(soapBody, soapFactory, new QName(soapBodyDefinition.getNamespaceURI(), rpcWrapperElementName));
            } else {
                partHolder = soapBody;
            }
            List<Part> parts = messageDefinition.getOrderedParts(soapBodyDefinition.getParts());
            for (Part p : parts) {
                Element partContent = DOMUtils.findChildByName(messageFromODE.getMessage(), new QName(null, p.getName()));
                if (partContent == null) {
                    throw new BPELFault("Missing required part in ODE Message: " + new QName(null, p.getName()));
                }
                OMElement omPartContent = OMUtils.toOM(partContent, soapFactory);
                if (isRPC) {
                    partHolder.addChild(omPartContent);
                } else {
                    for (Iterator<OMNode> i = omPartContent.getChildren(); i.hasNext(); ) {
                        partHolder.addChild(i.next());
                    }
                }
            }
        }
    }
}
Also used : SOAP12Body(javax.wsdl.extensions.soap12.SOAP12Body) BPELFault(org.wso2.carbon.bpel.core.ode.integration.BPELFault) QName(javax.xml.namespace.QName) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) OMElement(org.apache.axiom.om.OMElement) OMNode(org.apache.axiom.om.OMNode) SOAPBody(org.apache.axiom.soap.SOAPBody) Part(javax.wsdl.Part)

Example 63 with Element

use of org.wso2.siddhi.query.api.annotation.Element in project carbon-business-process by wso2.

the class ProcessConfigurationImpl method readPackageConfiguration.

private void readPackageConfiguration() {
    File depDir = du.getDeployDir();
    /*
        Read Endpoint Config for invokes
         */
    List<TDeployment.Process> processList = du.getDeploymentDescriptor().getDeploy().getProcessList();
    for (TDeployment.Process process : processList) {
        List<TInvoke> tInvokeList = process.getInvokeList();
        for (TInvoke tInvoke : tInvokeList) {
            OMElement serviceEle;
            if (tInvoke.getService() == null) {
                String errMsg = "Service element missing for the invoke element in deploy.xml";
                log.error(errMsg);
                throw new BPELDeploymentException(errMsg);
            }
            try {
                serviceEle = AXIOMUtil.stringToOM(tInvoke.getService().toString());
                OMElement endpointEle = serviceEle.getFirstElement();
                if (endpointEle == null || !endpointEle.getQName().equals(new QName(BusinessProcessConstants.BPEL_PKG_ENDPOINT_CONFIG_NS, BusinessProcessConstants.ENDPOINT))) {
                    continue;
                }
                EndpointConfiguration epConf = EndpointConfigBuilder.buildEndpointConfiguration(endpointEle, depDir.getAbsolutePath());
                epConf.setServiceName(tInvoke.getService().getName().getLocalPart());
                epConf.setServiceNS(tInvoke.getService().getName().getNamespaceURI());
                epConf.setServicePort(tInvoke.getService().getPort());
                bpelPackageConfiguration.addEndpoint(epConf);
            } catch (XMLStreamException e) {
                log.warn("Error occurred while reading endpoint configuration. " + "Endpoint config will not be applied to: " + tInvoke.getService());
            }
        }
        List<TProvide> tProvideList = process.getProvideList();
        for (TProvide tProvide : tProvideList) {
            OMElement serviceEle;
            if (tProvide.getService() == null) {
                String errMsg = "Service element missing for the provide element in deploy.xml";
                log.error(errMsg);
                throw new BPELDeploymentException(errMsg);
            }
            try {
                serviceEle = AXIOMUtil.stringToOM(tProvide.getService().toString());
                OMElement endpointEle = serviceEle.getFirstElement();
                if (endpointEle == null || !endpointEle.getQName().equals(new QName(BusinessProcessConstants.BPEL_PKG_ENDPOINT_CONFIG_NS, BusinessProcessConstants.ENDPOINT))) {
                    continue;
                }
                EndpointConfiguration epConf = EndpointConfigBuilder.buildEndpointConfiguration(endpointEle, depDir.getAbsolutePath());
                epConf.setServiceName(tProvide.getService().getName().getLocalPart());
                epConf.setServiceNS(tProvide.getService().getName().getNamespaceURI());
                epConf.setServicePort(tProvide.getService().getPort());
                bpelPackageConfiguration.addEndpoint(epConf);
            } catch (XMLStreamException e) {
                log.warn("Error occured while reading endpoint configuration. " + "Endpoint config will not be applied to: " + tProvide.getService());
            }
        }
    }
}
Also used : QName(javax.xml.namespace.QName) OMElement(org.apache.axiom.om.OMElement) TDeployment(org.apache.ode.bpel.dd.TDeployment) TInvoke(org.apache.ode.bpel.dd.TInvoke) XMLStreamException(javax.xml.stream.XMLStreamException) EndpointConfiguration(org.wso2.carbon.bpel.common.config.EndpointConfiguration) TProvide(org.apache.ode.bpel.dd.TProvide) File(java.io.File)

Example 64 with Element

use of org.wso2.siddhi.query.api.annotation.Element in project carbon-business-process by wso2.

the class ServiceTaskParseHandler method executeParse.

@Override
protected void executeParse(BpmnParse bpmnParse, BaseElement element) {
    ProcessDefinitionEntity processDefinitionEntity = bpmnParse.getCurrentProcessDefinition();
    List<ActivityImpl> activities = processDefinitionEntity.getActivities();
    for (ActivityImpl activity : activities) {
        if (activity.getId().equals(element.getId())) {
            if (log.isDebugEnabled()) {
                log.debug("Enabling data publishing for service task: " + element.getId());
            }
            activity.addExecutionListener(PvmEvent.EVENTNAME_END, new ServiceTaskCompletionListener());
        }
    }
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) ServiceTaskCompletionListener(org.wso2.carbon.bpmn.analytics.publisher.listeners.ServiceTaskCompletionListener)

Example 65 with Element

use of org.wso2.siddhi.query.api.annotation.Element in project carbon-business-process by wso2.

the class TaskOperationServiceImpl method complete.

public void complete(URI taskIdURI, final String outputStr) throws IllegalStateFault, IllegalOperationFault, IllegalArgumentFault, IllegalAccessFault {
    try {
        final Long taskId = validateTaskId(taskIdURI);
        HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<Object>() {

            public Object call() throws Exception {
                Element output = DOMUtils.stringToDOM(outputStr);
                Complete completeCommand = new Complete(getCaller(), taskId, output);
                completeCommand.execute();
                return null;
            }
        });
    } catch (Exception ex) {
        handleException(ex);
    }
}
Also used : Complete(org.wso2.carbon.humantask.core.engine.commands.Complete) Element(org.w3c.dom.Element)

Aggregations

Test (org.testng.annotations.Test)87 StreamDefinition (org.wso2.siddhi.query.api.definition.StreamDefinition)82 Query (org.wso2.siddhi.query.api.execution.query.Query)81 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)79 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)79 SiddhiApp (org.wso2.siddhi.query.api.SiddhiApp)79 Event (org.wso2.siddhi.core.event.Event)77 InputHandler (org.wso2.siddhi.core.stream.input.InputHandler)76 QueryCallback (org.wso2.siddhi.core.query.output.callback.QueryCallback)73 Element (org.w3c.dom.Element)34 OMElement (org.apache.axiom.om.OMElement)25 QName (javax.xml.namespace.QName)15 SVGCoordinates (org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates)14 ActivityInterface (org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface)13 NodeList (org.w3c.dom.NodeList)12 Element (org.wso2.siddhi.query.api.annotation.Element)12 Node (org.w3c.dom.Node)11 ArrayList (java.util.ArrayList)9 SiddhiAppCreationException (org.wso2.siddhi.core.exception.SiddhiAppCreationException)8 HashMap (java.util.HashMap)7