/** * Create synapse jsonpath expression * * @param key jsonpath expression eg: json-eval($.info) * @return SynapseJsonPath */ public SynapseJsonPath createSynJsonPath(String key) { // Derive JsonPath Expression from key removing "json-eval(" & ")" String jsonPathExpr = key.trim().substring(10, key.length() - 1); SynapseJsonPath synapseJsonPath = null; try { synapseJsonPath = SynapseJsonPathFactory.getSynapseJsonPath(jsonPathExpr); } catch (JaxenException e) { handleException("Can not create SynapseJsonPath from given: " + key); } return synapseJsonPath; }
/** * Create synapse xpath expression * {} type user input is used to create real xpath expression * * @param elem the element * @param key xpath expression with {} * @return SynapseXpath */ public SynapseXPath createSynXpath(OMElement elem, String key) { //derive XPath Expression from key String xpathExpr = key.trim().substring(1, key.length() - 1); SynapseXPath synapseXPath = null; try { synapseXPath = SynapseXPathFactory.getSynapseXPath(elem, xpathExpr); } catch (JaxenException e) { handleException("Can not create Synapse Xpath from given key"); } return synapseXPath; }
/** * Create synapse xpath expression * {} type user input is used to create real xpath expression * * @param elem the element * @param key xpath expression with {} * @return SynapseXpath */ public SynapseXPath createSynXpath(OMElement elem, String key) { //derive XPath Expression from key String xpathExpr = key.trim().substring(1, key.length() - 1); SynapseXPath synapseXPath = null; try { synapseXPath = SynapseXPathFactory.getSynapseXPath(elem, xpathExpr); } catch (JaxenException e) { handleException("Can not create Synapse Xpath from given key"); } return synapseXPath; }
handleException("Text value is required for the element '" + elem.getLocalName() + "'");
handleException("The '" + name + "' attribute is required for the element '" + elem.getLocalName() + "'");
/** * Create a key instance * * @param elem OMElement * @return Key */ public Value createValue(String name, OMElement elem) { Value key = null; OMAttribute attKey = elem.getAttribute(new QName(name)); if (attKey != null) { String attributeValue = attKey.getAttributeValue(); boolean hasEscape = isEscapedExpression(attributeValue); if (!hasEscape && isDynamicKey(attributeValue)) { /** dynamic key */ SynapseXPath synXpath = createSynXpath(elem, attributeValue); key = new Value(synXpath); } else if (hasEscape) { /** escaped expr */ key = new Value(getEscapedExpression(attributeValue)); key.setNamespaces(elem); } else { /** static key */ key = new Value(attributeValue); } } else { handleException("The '" + name + "' attribute is required on the " + elem.getLocalName() + " element"); } return key; }