From f527756909453f109ac0eaea13b8e043a4d503ec Mon Sep 17 00:00:00 2001 From: GDLMadushanka Date: Tue, 26 Nov 2024 07:51:37 +0530 Subject: [PATCH 1/2] Add function param support Add function param supprot and other improvements. Related to wso2/product-micro-integrator/issues/3749 --- .../org/apache/synapse/SynapseConstants.java | 55 ------ .../config/xml/PropertyMediatorFactory.java | 6 +- .../synapse/config/xml/SynapsePath.java | 6 +- .../config/xml/SynapsePathFactory.java | 5 +- .../org/apache/synapse/mediators/Value.java | 6 +- .../expression/ast/ArgumentListNode.java | 2 +- .../expression/ast/ArrayIndexNode.java | 4 +- .../expression/ast/BinaryOperationNode.java | 6 +- .../ast/ConditionalExpressionNode.java | 7 +- .../expression/ast/ExpressionNode.java | 2 +- .../expression/ast/ExpressionResult.java | 9 +- .../expression/ast/FilterExpressionNode.java | 4 +- .../ast/HeadersAndPropertiesAccessNode.java | 20 +- .../synapse/expression/ast/LiteralNode.java | 8 +- .../expression/ast/PayloadAccessNode.java | 89 ++++++--- .../ast/PredefinedFunctionNode.java | 162 +++++++++------- .../expression/ast/SignedExpressionNode.java | 4 +- .../constants/ExpressionConstants.java | 80 ++++++++ .../expression/context/EvaluationContext.java | 85 ++++++-- .../expression/utils/ExpressionUtils.java | 25 ++- .../expression/visitor/ExpressionVisitor.java | 182 +++++++++--------- .../synapse/util/xpath/SynapseExpression.java | 63 ++++-- .../util/xpath/SynapseXPathConstants.java | 3 + .../xpath/SynapseXPathVariableContext.java | 2 + .../expression/ConditionalExpressionTest.java | 16 +- .../HeaderAndPropertyAccessTest.java | 6 +- .../PayloadAndVariableAccessTest.java | 11 +- .../expression/PreDefinedFunctionsTest.java | 133 +++++++------ .../expression/PrimitiveExpressionsTest.java | 47 +++-- 29 files changed, 620 insertions(+), 428 deletions(-) create mode 100644 modules/core/src/main/java/org/apache/synapse/util/synapse/expression/constants/ExpressionConstants.java diff --git a/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java b/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java index 02e5a89b51..4058874e53 100644 --- a/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java +++ b/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java @@ -626,59 +626,4 @@ public enum ENDPOINT_TIMEOUT_TYPE { ENDPOINT_TIMEOUT, GLOBAL_TIMEOUT, HTTP_CONNE public static final String ANALYTICS_METADATA = "ANALYTICS_METADATA"; - // Constants related to Synapse Expressions - public static final String AND = "and"; - public static final String OR = "or"; - public static final String NOT = "not"; - public static final String TO_LOWER = "toLower"; - public static final String TO_UPPER = "toUpper"; - public static final String LENGTH = "length"; - public static final String SUBSTRING = "subString"; - public static final String STARTS_WITH = "startsWith"; - public static final String ENDS_WITH = "endsWith"; - public static final String CONTAINS = "contains"; - public static final String TRIM = "trim"; - public static final String REPLACE = "replace"; - public static final String SPLIT = "split"; - public static final String INDEX_OF = "indexOf"; - public static final String ABS = "abs"; - public static final String CEIL = "ceil"; - public static final String FLOOR = "floor"; - public static final String SQRT = "sqrt"; - public static final String LOG = "log"; - public static final String POW = "pow"; - public static final String B64ENCODE = "base64encode"; - public static final String B64DECODE = "base64decode"; - public static final String URL_ENCODE = "urlEncode"; - public static final String URL_DECODE = "urlDecode"; - public static final String IS_NUMBER = "isNumber"; - public static final String IS_STRING = "isString"; - public static final String IS_ARRAY = "isArray"; - public static final String IS_OBJECT = "isObject"; - public static final String OBJECT = "object"; - public static final String ARRAY = "array"; - public static final String REGISTRY = "registry"; - public static final String EXISTS = "exists"; - public static final String XPATH = "xpath"; - public static final String SECRET = "secret"; - public static final String NOW = "now"; - public static final String FORMAT_DATE_TIME = "formatDateTime"; - public static final String CHAR_AT = "charAt"; - - public static final String ROUND = "round"; - public static final String INTEGER = "integer"; - public static final String FLOAT = "float"; - public static final String STRING = "string"; - public static final String BOOLEAN = "boolean"; - - public static final String PAYLOAD = "payload"; - public static final String PAYLOAD_$ = "$"; - public static final String SYNAPSE_EXPRESSION_IDENTIFIER_START = "${"; - public static final String SYNAPSE_EXPRESSION_IDENTIFIER_END = "}"; - public static final String AXIS2 = "axis2"; - public static final String QUERY_PARAM = "queryParams"; - public static final String URI_PARAM = "uriParams"; - - public static final String UNKNOWN = "unknown"; - public static final String VAULT_LOOKUP = "wso2:vault-lookup('"; } diff --git a/modules/core/src/main/java/org/apache/synapse/config/xml/PropertyMediatorFactory.java b/modules/core/src/main/java/org/apache/synapse/config/xml/PropertyMediatorFactory.java index 4d71c611c2..0f5716c654 100644 --- a/modules/core/src/main/java/org/apache/synapse/config/xml/PropertyMediatorFactory.java +++ b/modules/core/src/main/java/org/apache/synapse/config/xml/PropertyMediatorFactory.java @@ -22,11 +22,11 @@ import org.apache.axiom.om.OMAttribute; import org.apache.axiom.om.OMElement; import org.apache.synapse.Mediator; -import org.apache.synapse.SynapseConstants; import org.apache.synapse.SynapseException; import org.apache.synapse.mediators.Value; import org.apache.synapse.mediators.builtin.PropertyMediator; import org.apache.synapse.util.MediatorPropertyUtils; +import org.apache.synapse.util.synapse.expression.constants.ExpressionConstants; import org.apache.synapse.util.xpath.SynapseJsonPath; import org.apache.synapse.util.xpath.SynapseExpression; import org.apache.synapse.util.xpath.SynapseXPath; @@ -85,8 +85,8 @@ public Mediator createSpecificMediator(OMElement elem, Properties properties) { String nameExpression = nameAttributeValue.substring(1, nameAttributeValue.length() - 1); if(nameExpression.startsWith("json-eval(")) { new SynapseJsonPath(nameExpression.substring(10, nameExpression.length() - 1)); - } else if (nameExpression.startsWith(SynapseConstants.SYNAPSE_EXPRESSION_IDENTIFIER_START) && - nameExpression.endsWith(SynapseConstants.SYNAPSE_EXPRESSION_IDENTIFIER_END)) { + } else if (nameExpression.startsWith(ExpressionConstants.SYNAPSE_EXPRESSION_IDENTIFIER_START) && + nameExpression.endsWith(ExpressionConstants.SYNAPSE_EXPRESSION_IDENTIFIER_END)) { new SynapseExpression(nameExpression.substring(2, nameExpression.length() - 1)); } else { new SynapseXPath(nameExpression); diff --git a/modules/core/src/main/java/org/apache/synapse/config/xml/SynapsePath.java b/modules/core/src/main/java/org/apache/synapse/config/xml/SynapsePath.java index da152fa790..18619e79c5 100644 --- a/modules/core/src/main/java/org/apache/synapse/config/xml/SynapsePath.java +++ b/modules/core/src/main/java/org/apache/synapse/config/xml/SynapsePath.java @@ -4,13 +4,13 @@ import org.apache.axiom.om.xpath.AXIOMXPath; import org.apache.commons.logging.Log; import org.apache.synapse.MessageContext; -import org.apache.synapse.SynapseConstants; import org.apache.synapse.SynapseException; import org.apache.synapse.transport.util.MessageHandlerProvider; import org.apache.synapse.transport.passthru.PassThroughConstants; import org.apache.synapse.transport.passthru.Pipe; import org.apache.synapse.transport.passthru.config.PassThroughConfiguration; import org.apache.synapse.util.streaming_xpath.custom.components.ParserComponent; +import org.apache.synapse.util.synapse.expression.constants.ExpressionConstants; import org.apache.synapse.util.xpath.DOMSynapseXPathNamespaceMap; import org.jaxen.JaxenException; @@ -63,8 +63,8 @@ public SynapsePath(String path, String pathType, Log log) throws JaxenException private String inferPathType(String expression) { if (expression.startsWith("json-eval(")) { return JSON_PATH; - } else if (expression.startsWith(SynapseConstants.SYNAPSE_EXPRESSION_IDENTIFIER_START) - && expression.endsWith(SynapseConstants.SYNAPSE_EXPRESSION_IDENTIFIER_END)) { + } else if (expression.startsWith(ExpressionConstants.SYNAPSE_EXPRESSION_IDENTIFIER_START) + && expression.endsWith(ExpressionConstants.SYNAPSE_EXPRESSION_IDENTIFIER_END)) { return SYNAPSE_EXPRESSIONS_PATH; } else { return X_PATH; diff --git a/modules/core/src/main/java/org/apache/synapse/config/xml/SynapsePathFactory.java b/modules/core/src/main/java/org/apache/synapse/config/xml/SynapsePathFactory.java index d5195cd8bd..2f7e35eb49 100644 --- a/modules/core/src/main/java/org/apache/synapse/config/xml/SynapsePathFactory.java +++ b/modules/core/src/main/java/org/apache/synapse/config/xml/SynapsePathFactory.java @@ -26,6 +26,7 @@ import org.apache.synapse.SynapseConstants; import org.apache.synapse.SynapseException; import org.apache.synapse.config.SynapsePropertiesLoader; +import org.apache.synapse.util.synapse.expression.constants.ExpressionConstants; import org.apache.synapse.util.xpath.SynapseJsonPath; import org.apache.synapse.util.xpath.SynapseExpression; import org.apache.synapse.util.xpath.SynapseXPath; @@ -50,8 +51,8 @@ public static org.apache.synapse.config.xml.SynapsePath getSynapsePath(OMElement if(pathAttrib.getAttributeValue().startsWith("json-eval(")) { path = new SynapseJsonPath(pathAttrib.getAttributeValue().substring(10, pathAttrib.getAttributeValue().length() - 1)); - } else if (pathAttrib.getAttributeValue().startsWith(SynapseConstants.SYNAPSE_EXPRESSION_IDENTIFIER_START) && - pathAttrib.getAttributeValue().endsWith(SynapseConstants.SYNAPSE_EXPRESSION_IDENTIFIER_END)) { + } else if (pathAttrib.getAttributeValue().startsWith(ExpressionConstants.SYNAPSE_EXPRESSION_IDENTIFIER_START) && + pathAttrib.getAttributeValue().endsWith(ExpressionConstants.SYNAPSE_EXPRESSION_IDENTIFIER_END)) { path = new SynapseExpression(pathAttrib.getAttributeValue().substring(2, pathAttrib.getAttributeValue().length() - 1)); } else { try { diff --git a/modules/core/src/main/java/org/apache/synapse/mediators/Value.java b/modules/core/src/main/java/org/apache/synapse/mediators/Value.java index 2cef385741..63ed783e00 100644 --- a/modules/core/src/main/java/org/apache/synapse/mediators/Value.java +++ b/modules/core/src/main/java/org/apache/synapse/mediators/Value.java @@ -23,9 +23,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.synapse.MessageContext; -import org.apache.synapse.SynapseConstants; import org.apache.synapse.SynapseException; import org.apache.synapse.config.xml.SynapsePath; +import org.apache.synapse.util.synapse.expression.constants.ExpressionConstants; import org.apache.synapse.util.xpath.SynapseJsonPath; import org.apache.synapse.util.xpath.SynapseXPath; import org.apache.synapse.util.xpath.SynapseExpression; @@ -103,8 +103,8 @@ public SynapsePath getExpression() { new SynapseJsonPath(expressionString.substring(10, expressionString.length() - 1)); expression = expressionTypeKey; - } else if (expressionString.startsWith(SynapseConstants.SYNAPSE_EXPRESSION_IDENTIFIER_START) && - expressionString.endsWith(SynapseConstants.SYNAPSE_EXPRESSION_IDENTIFIER_END)) { + } else if (expressionString.startsWith(ExpressionConstants.SYNAPSE_EXPRESSION_IDENTIFIER_START) && + expressionString.endsWith(ExpressionConstants.SYNAPSE_EXPRESSION_IDENTIFIER_END)) { expression = new SynapseExpression( expressionString.substring(2, expressionString.length() - 1)); } else { diff --git a/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/ArgumentListNode.java b/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/ArgumentListNode.java index 4685beccfa..382b2aa923 100644 --- a/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/ArgumentListNode.java +++ b/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/ArgumentListNode.java @@ -40,7 +40,7 @@ public List getArguments() { } @Override - public ExpressionResult evaluate(EvaluationContext context) { + public ExpressionResult evaluate(EvaluationContext context, boolean isObjectValue) { return null; } diff --git a/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/ArrayIndexNode.java b/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/ArrayIndexNode.java index 6f4b4bf7f8..4ee245b4a9 100644 --- a/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/ArrayIndexNode.java +++ b/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/ArrayIndexNode.java @@ -35,14 +35,14 @@ public ArrayIndexNode(ArgumentListNode arguments, char separator) { } @Override - public ExpressionResult evaluate(EvaluationContext context) { + public ExpressionResult evaluate(EvaluationContext context, boolean isObjectValue) { List indexList = new ArrayList<>(); for (ExpressionNode index : indexArray) { if (index == null) { indexList.add(""); continue; } - ExpressionResult result = index.evaluate(context); + ExpressionResult result = index.evaluate(context, isObjectValue); if (result != null) { indexList.add(result.asString()); } diff --git a/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/BinaryOperationNode.java b/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/BinaryOperationNode.java index 977b2730a1..245de0e90b 100644 --- a/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/BinaryOperationNode.java +++ b/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/BinaryOperationNode.java @@ -71,9 +71,9 @@ public BinaryOperationNode(ExpressionNode left, String operator, ExpressionNode } @Override - public ExpressionResult evaluate(EvaluationContext context) throws EvaluationException { - ExpressionResult leftValue = left.evaluate(context); - ExpressionResult rightValue = right.evaluate(context); + public ExpressionResult evaluate(EvaluationContext context, boolean isObjectValue) throws EvaluationException { + ExpressionResult leftValue = left.evaluate(context, isObjectValue); + ExpressionResult rightValue = right.evaluate(context, isObjectValue); if ((leftValue == null || rightValue == null) && (operator != Operator.EQUALS && operator != Operator.NOT_EQUALS)) { throw new EvaluationException("Null inputs for " + operator + " operation: " + leftValue diff --git a/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/ConditionalExpressionNode.java b/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/ConditionalExpressionNode.java index 5b51405d60..f2aa5c840c 100644 --- a/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/ConditionalExpressionNode.java +++ b/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/ConditionalExpressionNode.java @@ -38,13 +38,14 @@ public ConditionalExpressionNode(ExpressionNode condition, ExpressionNode trueEx } @Override - public ExpressionResult evaluate(EvaluationContext context) { - ExpressionResult conditionResult = condition.evaluate(context); + public ExpressionResult evaluate(EvaluationContext context, boolean isObjectValue) throws EvaluationException { + ExpressionResult conditionResult = condition.evaluate(context, isObjectValue); if (conditionResult == null || conditionResult.isNull()) { throw new EvaluationException("Condition is null in conditional expression"); } if (conditionResult.isBoolean()) { - return conditionResult.asBoolean() ? trueExpression.evaluate(context) : falseExpression.evaluate(context); + return conditionResult.asBoolean() ? trueExpression.evaluate(context, isObjectValue) + : falseExpression.evaluate(context, isObjectValue); } else { throw new EvaluationException("Condition is not a boolean in conditional expression"); } diff --git a/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/ExpressionNode.java b/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/ExpressionNode.java index f9f63358aa..942214187d 100644 --- a/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/ExpressionNode.java +++ b/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/ExpressionNode.java @@ -25,5 +25,5 @@ * Represents a node in the AST. */ public interface ExpressionNode { - ExpressionResult evaluate(EvaluationContext context) throws EvaluationException; + ExpressionResult evaluate(EvaluationContext context, boolean isObjectValue) throws EvaluationException; } diff --git a/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/ExpressionResult.java b/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/ExpressionResult.java index 7cfe21e323..7c292abfb6 100644 --- a/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/ExpressionResult.java +++ b/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/ExpressionResult.java @@ -27,8 +27,11 @@ import com.google.gson.JsonSyntaxException; import com.google.gson.internal.LazilyParsedNumber; import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMNode; import org.apache.synapse.util.synapse.expression.exception.EvaluationException; +import java.util.List; + /** * This class represents the result of an expression evaluation. * It can hold values of different types such as String, Number, Boolean, JsonElement, and null. @@ -44,7 +47,11 @@ public ExpressionResult(String value) { this.value = value; } - public ExpressionResult(OMElement value) { + public ExpressionResult(OMNode value) { + this.value = value; + } + + public ExpressionResult(List value) { this.value = value; } diff --git a/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/FilterExpressionNode.java b/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/FilterExpressionNode.java index 35f0b1b2bd..616c2163e1 100644 --- a/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/FilterExpressionNode.java +++ b/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/FilterExpressionNode.java @@ -41,10 +41,10 @@ public FilterExpressionNode(String expression, Map argum * Not evaluating here. */ @Override - public ExpressionResult evaluate(EvaluationContext context) { + public ExpressionResult evaluate(EvaluationContext context, boolean isObjectValue) { for (Map.Entry entry : arguments.entrySet()) { if (entry.getValue() != null) { - ExpressionResult result = entry.getValue().evaluate(context); + ExpressionResult result = entry.getValue().evaluate(context, isObjectValue); if (result != null) { String regex = ExpressionUtils.escapeSpecialCharacters(entry.getKey()); String resultString = result.asString(); diff --git a/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/HeadersAndPropertiesAccessNode.java b/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/HeadersAndPropertiesAccessNode.java index d8640bd0c2..42fc3d944a 100644 --- a/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/HeadersAndPropertiesAccessNode.java +++ b/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/HeadersAndPropertiesAccessNode.java @@ -21,6 +21,7 @@ import org.apache.synapse.SynapseConstants; import org.apache.synapse.commons.property.PropertyHolder; import org.apache.synapse.commons.resolvers.ResolverException; +import org.apache.synapse.util.synapse.expression.constants.ExpressionConstants; import org.apache.synapse.util.synapse.expression.context.EvaluationContext; import org.apache.synapse.util.synapse.expression.exception.EvaluationException; @@ -34,8 +35,7 @@ public enum Type { HEADER, PROPERTY, CONFIG, - QUERY_PARAM, - PATH_PARAM + FUNCTION_PARAM } private final Type type; @@ -56,9 +56,9 @@ public HeadersAndPropertiesAccessNode(ExpressionNode node, String scope) { } @Override - public ExpressionResult evaluate(EvaluationContext context) { + public ExpressionResult evaluate(EvaluationContext context, boolean isObjectValue) throws EvaluationException { if (key != null) { - String name = key.evaluate(context).asString(); + String name = key.evaluate(context, isObjectValue).asString(); Object value; if (Type.HEADER.equals(type)) { value = context.getHeader(name); @@ -68,16 +68,22 @@ public ExpressionResult evaluate(EvaluationContext context) { } catch (ResolverException e) { throw new EvaluationException("The value of the key:[" + name + "] is null"); } + } else if (Type.FUNCTION_PARAM.equals(type)) { + value = context.getFunctionParam(name); } else { - if (SynapseConstants.URI_PARAM.equals(scope)) { + if (ExpressionConstants.URI_PARAM.equals(scope)) { value = context.getProperty("uri.var." + name, SynapseConstants.SYNAPSE); - } else if (SynapseConstants.QUERY_PARAM.equals(scope)) { + } else if (ExpressionConstants.QUERY_PARAM.equals(scope)) { value = context.getProperty("query.param." + name, SynapseConstants.SYNAPSE); } else { value = context.getProperty(name, scope); } } - return new ExpressionResult(value != null ? value.toString() : null); + if (value != null) { + return new ExpressionResult(value.toString()); + } else { + throw new EvaluationException("Could not fetch the value of the key: " + name); + } } throw new EvaluationException("Key cannot be null when accessing headers or properties"); } diff --git a/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/LiteralNode.java b/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/LiteralNode.java index 644d533744..2ecad0c3da 100644 --- a/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/LiteralNode.java +++ b/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/LiteralNode.java @@ -50,7 +50,7 @@ public LiteralNode(ArgumentListNode value, Type type) { } @Override - public ExpressionResult evaluate(EvaluationContext context) { + public ExpressionResult evaluate(EvaluationContext context, boolean isObjectValue) { switch (type) { case NUMBER: return parseNumber(value); @@ -61,7 +61,7 @@ public ExpressionResult evaluate(EvaluationContext context) { case NULL: return null; case ARRAY: - return parseArray(context); + return parseArray(context, isObjectValue); default: throw new IllegalArgumentException("Unsupported type: " + type); } @@ -83,10 +83,10 @@ private ExpressionResult parseNumber(String value) { } } - private ExpressionResult parseArray(EvaluationContext context) { + private ExpressionResult parseArray(EvaluationContext context, boolean isObjectValue) { JsonArray jsonArray = new JsonArray(); for (ExpressionNode expressionNode : parameterList.getArguments()) { - ExpressionResult result = expressionNode.evaluate(context); + ExpressionResult result = expressionNode.evaluate(context, isObjectValue); if (result.getType().equals(JsonElement.class)) { jsonArray.add(result.asJsonElement()); } else if (result.isInteger()) { diff --git a/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/PayloadAccessNode.java b/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/PayloadAccessNode.java index 6db2f2d5ae..836a4667b7 100644 --- a/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/PayloadAccessNode.java +++ b/modules/core/src/main/java/org/apache/synapse/util/synapse/expression/ast/PayloadAccessNode.java @@ -31,16 +31,18 @@ import com.jayway.jsonpath.spi.json.JsonProvider; import com.jayway.jsonpath.spi.mapper.GsonMappingProvider; import com.jayway.jsonpath.spi.mapper.MappingProvider; +import org.apache.axiom.om.OMNode; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.synapse.SynapseConstants; +import org.apache.synapse.util.synapse.expression.constants.ExpressionConstants; import org.apache.synapse.util.synapse.expression.context.EvaluationContext; import org.apache.synapse.util.synapse.expression.exception.EvaluationException; import org.apache.synapse.util.synapse.expression.utils.ExpressionUtils; +import org.apache.synapse.util.xpath.SynapseJsonPath; +import org.jaxen.JaxenException; import java.io.IOException; import java.util.EnumSet; +import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; @@ -50,7 +52,7 @@ * Resolve placeholders in the expression and evaluate the expression using JSONPath. */ public class PayloadAccessNode implements ExpressionNode { - private static final Log log = LogFactory.getLog(PayloadAccessNode.class); + private String expression; private final Map arguments; @@ -63,7 +65,7 @@ public enum Type { } private final Type type; - private ExpressionNode predefinedFunctionNode = null; + private final ExpressionNode predefinedFunctionNode; public PayloadAccessNode(String expression, Map arguments, Type type, ExpressionNode predefinedFunctionNode) { @@ -90,32 +92,29 @@ public Set