Search in sources :

Example 56 with Element

use of org.wso2.siddhi.query.api.annotation.Element in project ballerina by ballerina-lang.

the class SemanticAnalyzer method visit.

// Visitor methods
public void visit(BLangPackage pkgNode) {
    if (pkgNode.completedPhases.contains(CompilerPhase.TYPE_CHECK)) {
        return;
    }
    SymbolEnv pkgEnv = this.symTable.pkgEnvMap.get(pkgNode.symbol);
    // Visit all the imported packages
    pkgNode.imports.forEach(importNode -> analyzeDef(importNode, pkgEnv));
    // Then visit each top-level element sorted using the compilation unit
    pkgNode.topLevelNodes.forEach(topLevelNode -> analyzeDef((BLangNode) topLevelNode, pkgEnv));
    analyzeDef(pkgNode.initFunction, pkgEnv);
    analyzeDef(pkgNode.startFunction, pkgEnv);
    analyzeDef(pkgNode.stopFunction, pkgEnv);
    pkgNode.completedPhases.add(CompilerPhase.TYPE_CHECK);
}
Also used : BLangNode(org.wso2.ballerinalang.compiler.tree.BLangNode) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Example 57 with Element

use of org.wso2.siddhi.query.api.annotation.Element in project ballerina by ballerina-lang.

the class CodeGenerator method visitXMLTagName.

/**
 * Visit XML tag name and return the index of the tag name in the reference registry.
 *
 * @param tagName           Tag name expression
 * @param xmlElementEnv     Environment of the XML element of the tag
 * @param xmlElementLiteral XML element literal to which the tag name belongs to
 * @return Index of the tag name, in the reference registry
 */
private RegIndex visitXMLTagName(BLangExpression tagName, SymbolEnv xmlElementEnv, BLangXMLElementLiteral xmlElementLiteral) {
    genNode(tagName, xmlElementEnv);
    RegIndex startTagNameRegIndex = tagName.regIndex;
    // If this is a string representation of element name, generate the namespace lookup instructions
    if (tagName.getKind() != NodeKind.XML_QNAME) {
        RegIndex localNameRegIndex = getRegIndex(TypeTags.STRING);
        RegIndex uriRegIndex = getRegIndex(TypeTags.STRING);
        emit(InstructionCodes.S2QNAME, startTagNameRegIndex, localNameRegIndex, uriRegIndex);
        startTagNameRegIndex = getRegIndex(TypeTags.XML);
        generateURILookupInstructions(xmlElementLiteral.namespacesInScope, localNameRegIndex, uriRegIndex, startTagNameRegIndex, xmlElementLiteral.pos, xmlElementEnv);
        tagName.regIndex = startTagNameRegIndex;
    }
    return startTagNameRegIndex;
}
Also used : RegIndex(org.wso2.ballerinalang.programfile.Instruction.RegIndex)

Example 58 with Element

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

the class SOAPUtils method handleSoapHeaderPartDef.

private static void handleSoapHeaderPartDef(org.apache.ode.bpel.iapi.Message odeMessage, Definition wsdl, SOAPHeader header, javax.wsdl.extensions.soap.SOAPHeader headerdef, Message msgType) throws BPELFault {
    // Is this header part of the "payload" messsage?
    boolean payloadMessageHeader = headerdef.getMessage() == null || headerdef.getMessage().equals(msgType.getQName());
    boolean requiredHeader = payloadMessageHeader || (headerdef.getRequired() != null && headerdef.getRequired());
    if (requiredHeader && header == null) {
        throw new BPELFault("SOAP Header missing required element.");
    }
    if (header == null) {
        return;
    }
    Message hdrMsg = wsdl.getMessage(headerdef.getMessage());
    if (hdrMsg == null) {
        return;
    }
    Part p = hdrMsg.getPart(headerdef.getPart());
    if (p == null || p.getElementName() == null) {
        return;
    }
    OMElement headerEl = header.getFirstChildWithName(p.getElementName());
    if (requiredHeader && headerEl == null) {
        throw new BPELFault("SOAP Header missing required element: " + p.getElementName());
    }
    if (headerEl == null) {
        return;
    }
    odeMessage.setHeaderPart(p.getName(), OMUtils.toDOM(headerEl));
}
Also used : BPELFault(org.wso2.carbon.bpel.core.ode.integration.BPELFault) Message(javax.wsdl.Message) Part(javax.wsdl.Part) OMElement(org.apache.axiom.om.OMElement)

Example 59 with Element

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

the class SOAPUtils method buildSoapDetail.

private static OMElement buildSoapDetail(final BPELMessageContext bpelMessageContext, final MessageExchange odeMessageContext) throws AxisFault {
    Element message = odeMessageContext.getResponse().getMessage();
    QName faultName = odeMessageContext.getFault();
    Operation operation = odeMessageContext.getOperation();
    SOAPFactory soapFactory = bpelMessageContext.getSoapFactoryForCurrentMessageFlow();
    if (faultName.getNamespaceURI() == null) {
        return toFaultDetail(message, soapFactory);
    }
    Fault f = operation.getFault(faultName.getLocalPart());
    if (f == null) {
        return toFaultDetail(message, soapFactory);
    }
    // For faults, there will be exactly one part.
    Part p = (Part) f.getMessage().getParts().values().iterator().next();
    if (p == null) {
        return toFaultDetail(message, soapFactory);
    }
    Element partEl = DOMUtils.findChildByName(message, new QName(null, p.getName()));
    if (partEl == null) {
        return toFaultDetail(message, soapFactory);
    }
    Element detail = DOMUtils.findChildByName(partEl, p.getElementName());
    if (detail == null) {
        return toFaultDetail(message, soapFactory);
    }
    return OMUtils.toOM(detail, soapFactory);
}
Also used : QName(javax.xml.namespace.QName) Part(javax.wsdl.Part) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) SOAPFault(org.apache.axiom.soap.SOAPFault) Fault(javax.wsdl.Fault) AxisFault(org.apache.axis2.AxisFault) BPELFault(org.wso2.carbon.bpel.core.ode.integration.BPELFault) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) SOAPFactory(org.apache.axiom.soap.SOAPFactory)

Example 60 with Element

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

the class SOAPUtils method extractSOAPBodyParts.

private static void extractSOAPBodyParts(MessageExchange partnerRoleMessageExchange, org.apache.ode.bpel.iapi.Message messageToODE, SOAPBody omSOAPBody, List parts, String namespace, boolean isRPC) throws BPELFault {
    List<Part> messageBodyParts = partnerRoleMessageExchange.getOperation().getOutput().getMessage().getOrderedParts(parts);
    if (isRPC) {
        String rpcWrapperElementName = partnerRoleMessageExchange.getOperationName() + "Response";
        OMElement rpcWrapperElement = omSOAPBody.getFirstChildWithName(new QName(namespace, rpcWrapperElementName));
        if (rpcWrapperElement == null) {
            throw new BPELFault("Message body doesn't contain expected part wrapper: " + new QName(namespace, rpcWrapperElementName));
        }
        // children, since doc-lit rpc looks the same in ode and soap.
        for (Part partDef : messageBodyParts) {
            OMElement omPartElement = rpcWrapperElement.getFirstChildWithName(new QName(null, partDef.getName()));
            if (omPartElement == null) {
                throw new BPELFault("SOAP body doesn't contain required part: " + new QName(null, partDef.getName()));
            }
            messageToODE.setPart(omPartElement.getLocalName(), OMUtils.toDOM(omPartElement));
        }
    } else {
        // In doc-literal style, we expect the elements in the body to correspond (in order)
        // to the parts defined in the binding. All the parts should be element-typed,
        // otherwise it is a mess.
        Iterator<OMElement> omParts = omSOAPBody.getChildElements();
        for (Part partDef : messageBodyParts) {
            if (!omParts.hasNext()) {
                throw new BPELFault("SOAP body doesn't contain required part.");
            }
            OMElement omPart = omParts.next();
            if (partDef.getElementName() == null) {
                throw new BPELFault("Binding defines non element document list parts.");
            }
            if (!omPart.getQName().equals(partDef.getElementName())) {
                throw new BPELFault("Unexpected element in SOAP body: " + omPart.getQName());
            }
            Document doc = DOMUtils.newDocument();
            Element domPart = doc.createElementNS(null, partDef.getName());
            domPart.appendChild(doc.importNode(OMUtils.toDOM(omPart), true));
            messageToODE.setPart(partDef.getName(), domPart);
        }
    }
}
Also used : BPELFault(org.wso2.carbon.bpel.core.ode.integration.BPELFault) Part(javax.wsdl.Part) QName(javax.xml.namespace.QName) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) OMElement(org.apache.axiom.om.OMElement) Document(org.w3c.dom.Document)

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