Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
Address review comments
  • Loading branch information
GDLMadushanka committed Nov 11, 2024
1 parent f79e0df commit a220e2d
Show file tree
Hide file tree
Showing 33 changed files with 93 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ public enum ENDPOINT_TIMEOUT_TYPE { ENDPOINT_TIMEOUT, GLOBAL_TIMEOUT, HTTP_CONNE

public static final String ANALYTICS_METADATA = "ANALYTICS_METADATA";

// Constants related to SIEL
// Constants related to Synapse Expressions
public static final String AND = "and";
public static final String OR = "or";
public static final String NOT = "not";
Expand Down Expand Up @@ -670,8 +670,8 @@ public enum ENDPOINT_TIMEOUT_TYPE { ENDPOINT_TIMEOUT, GLOBAL_TIMEOUT, HTTP_CONNE

public static final String PAYLOAD = "payload";
public static final String PAYLOAD_$ = "$";
public static final String SIEL_IDENTIFIER_START = "#[";
public static final String SIEL_IDENTIFIER_END = "]";
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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.SIEL_IDENTIFIER_START) &&
nameExpression.endsWith(SynapseConstants.SIEL_IDENTIFIER_END)) {
} else if (nameExpression.startsWith(SynapseConstants.SYNAPSE_EXPRESSION_IDENTIFIER_START) &&
nameExpression.endsWith(SynapseConstants.SYNAPSE_EXPRESSION_IDENTIFIER_END)) {
new Synapse_Path(nameExpression.substring(2, nameExpression.length() - 1));
} else {
new SynapseXPath(nameExpression);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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;
Expand All @@ -27,7 +28,7 @@ public abstract class SynapsePath extends AXIOMXPath {

public static final String X_PATH = "X_PATH";
public static final String JSON_PATH = "JSON_PATH";
public static final String SIEL_PATH = "SIEL_PATH";
public static final String SYNAPSE_EXPRESSIONS_PATH = "SYNAPSE_EXPRESSIONS_PATH";
private String pathType = null;

public DOMSynapseXPathNamespaceMap domNamespaceMap = new DOMSynapseXPathNamespaceMap();
Expand Down Expand Up @@ -62,8 +63,9 @@ 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("#[") && expression.endsWith("]")) {
return SIEL_PATH;
} else if(expression.startsWith(SynapseConstants.SYNAPSE_EXPRESSION_IDENTIFIER_START)
&& expression.endsWith(SynapseConstants.SYNAPSE_EXPRESSION_IDENTIFIER_END)) {
return SYNAPSE_EXPRESSIONS_PATH;
} else {
return X_PATH;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,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.SIEL_IDENTIFIER_START) &&
pathAttrib.getAttributeValue().endsWith(SynapseConstants.SIEL_IDENTIFIER_END)) {
} else if (pathAttrib.getAttributeValue().startsWith(SynapseConstants.SYNAPSE_EXPRESSION_IDENTIFIER_START) &&
pathAttrib.getAttributeValue().endsWith(SynapseConstants.SYNAPSE_EXPRESSION_IDENTIFIER_END)) {
path = new Synapse_Path(pathAttrib.getAttributeValue().substring(2, pathAttrib.getAttributeValue().length() - 1));
} else {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ public SynapsePath getExpression() {
new SynapseJsonPath(expressionString.substring(10, expressionString.length() - 1));
expression = expressionTypeKey;

} else if (expressionString.startsWith(SynapseConstants.SIEL_IDENTIFIER_START) &&
expressionString.endsWith(SynapseConstants.SIEL_IDENTIFIER_END)) {
} else if (expressionString.startsWith(SynapseConstants.SYNAPSE_EXPRESSION_IDENTIFIER_START) &&
expressionString.endsWith(SynapseConstants.SYNAPSE_EXPRESSION_IDENTIFIER_END)) {
expression = new Synapse_Path(
expressionString.substring(2, expressionString.length() - 1));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.synapse.util.synapse_path.ast;
package org.apache.synapse.util.synapse.expression.ast;

import org.apache.synapse.util.synapse_path.context.EvaluationContext;
import org.apache.synapse.util.synapse.expression.context.EvaluationContext;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.synapse.util.synapse_path.ast;
package org.apache.synapse.util.synapse.expression.ast;

import org.apache.synapse.util.synapse_path.context.EvaluationContext;
import org.apache.synapse.util.synapse.expression.context.EvaluationContext;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.synapse.util.synapse_path.ast;
package org.apache.synapse.util.synapse.expression.ast;

import org.apache.synapse.util.synapse_path.context.EvaluationContext;
import org.apache.synapse.util.synapse_path.exception.EvaluationException;
import org.apache.synapse.util.synapse.expression.context.EvaluationContext;
import org.apache.synapse.util.synapse.expression.exception.EvaluationException;

import java.util.function.BiFunction;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
* under the License.
*/

package org.apache.synapse.util.synapse_path.ast;
package org.apache.synapse.util.synapse.expression.ast;

import org.apache.synapse.util.synapse_path.context.EvaluationContext;
import org.apache.synapse.util.synapse_path.exception.EvaluationException;
import org.apache.synapse.util.synapse.expression.context.EvaluationContext;
import org.apache.synapse.util.synapse.expression.exception.EvaluationException;

/**
* Represents a conditional expression node ( a ? b : c ) in the AST.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
* under the License.
*/

package org.apache.synapse.util.synapse_path.ast;
package org.apache.synapse.util.synapse.expression.ast;

import org.apache.synapse.util.synapse_path.context.EvaluationContext;
import org.apache.synapse.util.synapse_path.exception.EvaluationException;
import org.apache.synapse.util.synapse.expression.context.EvaluationContext;
import org.apache.synapse.util.synapse.expression.exception.EvaluationException;

/**
* Represents a node in the AST.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* under the License.
*/

package org.apache.synapse.util.synapse_path.ast;
package org.apache.synapse.util.synapse.expression.ast;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
Expand All @@ -27,7 +27,7 @@
import com.google.gson.JsonSyntaxException;
import com.google.gson.internal.LazilyParsedNumber;
import org.apache.axiom.om.OMElement;
import org.apache.synapse.util.synapse_path.exception.EvaluationException;
import org.apache.synapse.util.synapse.expression.exception.EvaluationException;

/**
* This class represents the result of an expression evaluation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.synapse.util.synapse_path.ast;
package org.apache.synapse.util.synapse.expression.ast;

import org.apache.synapse.util.synapse_path.context.EvaluationContext;
import org.apache.synapse.util.synapse_path.utils.ExpressionUtils;
import org.apache.synapse.util.synapse.expression.context.EvaluationContext;
import org.apache.synapse.util.synapse.expression.utils.ExpressionUtils;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
* under the License.
*/

package org.apache.synapse.util.synapse_path.ast;
package org.apache.synapse.util.synapse.expression.ast;

import org.apache.synapse.SynapseConstants;
import org.apache.synapse.util.synapse_path.context.EvaluationContext;
import org.apache.synapse.util.synapse_path.exception.EvaluationException;
import org.apache.synapse.util.synapse.expression.context.EvaluationContext;
import org.apache.synapse.util.synapse.expression.exception.EvaluationException;

/**
* Represents a node in the abstract syntax tree that provides access to headers and properties.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.synapse.util.synapse_path.ast;
package org.apache.synapse.util.synapse.expression.ast;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import org.apache.synapse.util.synapse_path.context.EvaluationContext;
import org.apache.synapse.util.synapse.expression.context.EvaluationContext;

/**
* Represents a leaf node in the AST that holds a literal value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.synapse.util.synapse_path.ast;
package org.apache.synapse.util.synapse.expression.ast;

import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
Expand All @@ -35,9 +35,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.SynapseConstants;
import org.apache.synapse.util.synapse_path.context.EvaluationContext;
import org.apache.synapse.util.synapse_path.exception.EvaluationException;
import org.apache.synapse.util.synapse_path.utils.ExpressionUtils;
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 java.io.IOException;
import java.util.EnumSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.synapse.util.synapse_path.ast;
package org.apache.synapse.util.synapse.expression.ast;

import com.google.gson.JsonArray;
import com.google.gson.JsonPrimitive;
import org.apache.synapse.SynapseConstants;
import org.apache.synapse.util.synapse_path.context.EvaluationContext;
import org.apache.synapse.util.synapse_path.exception.EvaluationException;
import org.apache.synapse.util.synapse_path.utils.ExpressionUtils;
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.jaxen.JaxenException;

import java.io.UnsupportedEncodingException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.synapse.util.synapse_path.ast;
package org.apache.synapse.util.synapse.expression.ast;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.util.synapse_path.context.EvaluationContext;
import org.apache.synapse.util.synapse.expression.context.EvaluationContext;

/**
* Represents a node in the AST that holds a signed expression. ex: ( -var.num1 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.synapse.util.synapse_path.context;
package org.apache.synapse.util.synapse.expression.context;

import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNode;
Expand All @@ -42,7 +42,7 @@
import static org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS;

/**
* Represents the evaluation context of the SIEL expressions.
* Represents the evaluation context of the Synapse Expressions.
* Which provides payload and headers access.
*/
public class EvaluationContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.synapse.util.synapse_path.exception;
package org.apache.synapse.util.synapse.expression.exception;

/**
* Represents an exception that occurs during the evaluation of SIEL expressions.
* Represents an exception that occurs during the evaluation of Synapse Expressions.
*/
public class EvaluationException extends RuntimeException {
public EvaluationException(String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.synapse.util.synapse_path.exception;
package org.apache.synapse.util.synapse.expression.exception;

import org.antlr.v4.runtime.RecognitionException;

/**
* Represents an exception that occurs during the parsing of SIEL expressions.
* Represents an exception that occurs during the parsing of Synapse Expressions.
*/
public class SyntaxError {
private final int line;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.synapse.util.synapse_path.exception;
package org.apache.synapse.util.synapse.expression.exception;

import org.antlr.v4.runtime.BaseErrorListener;
import org.antlr.v4.runtime.RecognitionException;
Expand All @@ -28,7 +28,7 @@
import java.util.logging.Logger;

/**
* Represents a listener that captures syntax errors during the parsing of SIEL expressions.
* Represents a listener that captures syntax errors during the parsing of Synapse Expressions.
*/
public class SyntaxErrorListener extends BaseErrorListener {
private boolean hasErrors = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
* under the License.
*/

package org.apache.synapse.util.synapse_path.utils;
package org.apache.synapse.util.synapse.expression.utils;

import java.nio.charset.Charset;

/**
* Utility class for SIEL expressions.
* Utility class for Synapse Expressions.
*/
public class ExpressionUtils {
public static String escapeSpecialCharacters(String input) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.synapse.util.synapse_path.visitor;
package org.apache.synapse.util.synapse.expression.visitor;

import org.apache.synapse.SynapseConstants;
import org.apache.synapse.util.synapse_path.ExpressionParser;
import org.apache.synapse.util.synapse_path.ExpressionParserBaseVisitor;
import org.apache.synapse.util.synapse_path.ExpressionParserVisitor;
import org.apache.synapse.util.synapse_path.ast.*;
import org.apache.synapse.util.synapse.expression.ast.*;
import org.apache.synapse.util.synapse_expression.ExpressionParser;
import org.apache.synapse.util.synapse_expression.ExpressionParserBaseVisitor;
import org.apache.synapse.util.synapse_expression.ExpressionParserVisitor;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Represents a visitor that traverses the parse tree and constructs the abstract syntax tree (AST) of the SIEL
* Represents a visitor that traverses the parse tree and constructs the abstract syntax tree (AST)
* of the Synapse Expression.
*/
public class ExpressionVisitor extends ExpressionParserBaseVisitor<ExpressionNode>
implements ExpressionParserVisitor<ExpressionNode> {
Expand Down
Loading

0 comments on commit a220e2d

Please sign in to comment.