Package org.apache.synapse.mediators.eip
Class EIPUtils
- java.lang.Object
-
- org.apache.synapse.mediators.eip.EIPUtils
-
public class EIPUtils extends Object
Utility methods for the EIP mediators
-
-
Constructor Summary
Constructors Constructor Description EIPUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
createSynapseEIPTemplateProperty(MessageContext synCtxt, String templateName, String paramName, Object value)
static org.apache.axiom.soap.SOAPEnvelope
encloseWithElement(org.apache.axiom.soap.SOAPEnvelope envelope, org.apache.axiom.om.OMElement encloseElement)
Enclose children of the soap body with a specific elementstatic void
enrichEnvelope(org.apache.axiom.soap.SOAPEnvelope envelope, org.apache.axiom.soap.SOAPEnvelope enricher, MessageContext synCtxt, SynapseXPath expression)
Merge two SOAP envelopes using the given XPath expression that specifies the element that enriches the first envelope from the secondstatic void
enrichEnvelope(org.apache.axiom.soap.SOAPEnvelope envelope, MessageContext synCtxt, SynapseXPath expression)
Modifies the envelope based on the provided XPath expression element that enriches the first envelope from the secondstatic Object
formatJsonPathResponse(Object input)
Formats the response from jsonpath operations JayWay json-path response have additional elements like "members"(for objects) and "elements"(for arrays) This method will correct such strings by removing additional elements.static List<org.apache.axiom.om.OMNode>
getDetachedMatchingElements(org.apache.axiom.soap.SOAPEnvelope envelope, MessageContext synCtxt, SynapseXPath expression)
Return the set of detached elements specified by the XPath over the given envelopestatic com.google.gson.JsonElement
getJSONElement(MessageContext messageContext, SynapseJsonPath jsonPath)
Evaluate JSON path and retrieve the result as JsonElement.static com.google.gson.JsonElement
getJSONObjectAsElement(MessageContext messageContext, SynapseJsonPath jsonPath)
Evaluate JSON path and retrieve the result as JsonElement while checking if the evaluated results are nothing other than JSON objects.static List
getMatchingElements(org.apache.axiom.soap.SOAPEnvelope envelope, MessageContext synCtxt, SynapseXPath expression)
Return the set of elements specified by the XPath over the given envelopestatic List
getMatchingElements(org.apache.axiom.soap.SOAPEnvelope envelope, SynapseXPath expression)
Return the set of elements specified by the XPath over the given envelopestatic String
getTemplatePropertyMapping(String templateName, String parameter)
Util functions related to EIP Templatesstatic void
mergeJsonObjects(com.google.gson.JsonObject primaryPayload, com.google.gson.JsonObject secondaryPayload)
This merges two json objects into one.static void
setJsonPathConfiguration()
Set default configuration for Jayway JsonPath by providing the JsonProviders and Mapping providersstatic com.google.gson.JsonElement
tryParseJsonString(com.google.gson.JsonParser parser, String inputJson)
Given a json string and a parser this method will return the parsed string.
-
-
-
Method Detail
-
getMatchingElements
public static List getMatchingElements(org.apache.axiom.soap.SOAPEnvelope envelope, SynapseXPath expression) throws org.jaxen.JaxenException
Return the set of elements specified by the XPath over the given envelope- Parameters:
envelope
- SOAPEnvelope from which the elements will be extractedexpression
- SynapseXPath expression describing the elements to be extracted- Returns:
- List OMElements in the envelope matching the expression
- Throws:
org.jaxen.JaxenException
- if the XPath expression evaluation fails
-
getMatchingElements
public static List getMatchingElements(org.apache.axiom.soap.SOAPEnvelope envelope, MessageContext synCtxt, SynapseXPath expression) throws org.jaxen.JaxenException
Return the set of elements specified by the XPath over the given envelope- Parameters:
envelope
- SOAPEnvelope from which the elements will be extractedexpression
- SynapseXPath expression describing the elements to be extracted- Returns:
- List OMElements in the envelope matching the expression
- Throws:
org.jaxen.JaxenException
- if the XPath expression evaluation fails
-
getDetachedMatchingElements
public static List<org.apache.axiom.om.OMNode> getDetachedMatchingElements(org.apache.axiom.soap.SOAPEnvelope envelope, MessageContext synCtxt, SynapseXPath expression) throws org.jaxen.JaxenException
Return the set of detached elements specified by the XPath over the given envelope- Parameters:
envelope
- SOAPEnvelope from which the elements will be extractedexpression
- SynapseXPath expression describing the elements to be extracted- Returns:
- List detached OMElements in the envelope matching the expression
- Throws:
org.jaxen.JaxenException
- if the XPath expression evaluation fails
-
enrichEnvelope
public static void enrichEnvelope(org.apache.axiom.soap.SOAPEnvelope envelope, MessageContext synCtxt, SynapseXPath expression) throws org.jaxen.JaxenException
Modifies the envelope based on the provided XPath expression element that enriches the first envelope from the second- Parameters:
envelope
- SOAPEnvelope to be enriched with the contentexpression
- SynapseXPath describing the enriching element- Throws:
org.jaxen.JaxenException
- on failing of processing the xpath
-
enrichEnvelope
public static void enrichEnvelope(org.apache.axiom.soap.SOAPEnvelope envelope, org.apache.axiom.soap.SOAPEnvelope enricher, MessageContext synCtxt, SynapseXPath expression) throws org.jaxen.JaxenException
Merge two SOAP envelopes using the given XPath expression that specifies the element that enriches the first envelope from the second- Parameters:
envelope
- SOAPEnvelope to be enriched with the contentexpression
- SynapseXPath describing the enriching element- Throws:
org.jaxen.JaxenException
- on failing of processing the xpath
-
getTemplatePropertyMapping
public static String getTemplatePropertyMapping(String templateName, String parameter)
Util functions related to EIP Templates
-
createSynapseEIPTemplateProperty
public static void createSynapseEIPTemplateProperty(MessageContext synCtxt, String templateName, String paramName, Object value)
-
encloseWithElement
public static org.apache.axiom.soap.SOAPEnvelope encloseWithElement(org.apache.axiom.soap.SOAPEnvelope envelope, org.apache.axiom.om.OMElement encloseElement)
Enclose children of the soap body with a specific element- Parameters:
envelope
- SOAPEnvelope which is to be enclosedencloseElement
- enclosing element- Returns:
- modified SOAPEnvelope
-
getJSONElement
public static com.google.gson.JsonElement getJSONElement(MessageContext messageContext, SynapseJsonPath jsonPath)
Evaluate JSON path and retrieve the result as JsonElement. If multiple matches found, combine matching results in a comma separated list and parse as a JSON array.- Parameters:
messageContext
- messageContext which contains the JSON payload.- Returns:
- JsonArray or a JsonPrimitive depending on the JsonPath response.
-
getJSONObjectAsElement
public static com.google.gson.JsonElement getJSONObjectAsElement(MessageContext messageContext, SynapseJsonPath jsonPath) throws com.google.gson.JsonParseException, JSONObjectExtensionException
Evaluate JSON path and retrieve the result as JsonElement while checking if the evaluated results are nothing other than JSON objects. Also, whenever there are multiple JSON objects as the result, merge them together.- Parameters:
messageContext
- messageContext which contains the JSON payload.- Returns:
- JsonArray or a JsonPrimitive depending on the JsonPath response.
- Throws:
com.google.gson.JsonParseException
JSONObjectExtensionException
-
tryParseJsonString
public static com.google.gson.JsonElement tryParseJsonString(com.google.gson.JsonParser parser, String inputJson)
Given a json string and a parser this method will return the parsed string.- Parameters:
parser
- JSON parser instance.inputJson
- input JSON string.- Returns:
- parsed JsonElement.
-
formatJsonPathResponse
public static Object formatJsonPathResponse(Object input)
Formats the response from jsonpath operations JayWay json-path response have additional elements like "members"(for objects) and "elements"(for arrays) This method will correct such strings by removing additional elements.- Parameters:
input
- input jsonElement.- Returns:
- corrected jsonObject.
-
mergeJsonObjects
public static void mergeJsonObjects(com.google.gson.JsonObject primaryPayload, com.google.gson.JsonObject secondaryPayload)
This merges two json objects into one. The PrimaryPayload will have the merged object- Parameters:
primaryPayload
- The json object where the key value pairs will be addedsecondaryPayload
- The json object whose key value pair will be added to primaryPayload
-
setJsonPathConfiguration
public static void setJsonPathConfiguration()
Set default configuration for Jayway JsonPath by providing the JsonProviders and Mapping providers
-
-