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);
}
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;
}
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));
}
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);
}
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);
}
}
}
Aggregations