Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add synapse expression support for Filter mediator #2234

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.apache.synapse.mediators.FlowContinuableMediator;
import org.apache.synapse.mediators.ListMediator;
import org.apache.synapse.mediators.base.SequenceMediator;
import org.apache.synapse.util.xpath.SynapseExpression;
import org.apache.synapse.util.xpath.SynapseJsonPath;
import org.apache.synapse.util.xpath.SynapseXPath;
import org.jaxen.JaxenException;
Expand Down Expand Up @@ -144,7 +145,7 @@ public boolean mediate(MessageContext synCtx) {
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug((xpath == null ?
"Source : " + source + " against : " + regex.pattern() + " matches" :
"XPath expression : " + xpath + " evaluates to true") +
"Expression : " + xpath + " evaluates to true") +
" - executing then sequence with key : " + thenKey);
}

Expand All @@ -162,7 +163,7 @@ public boolean mediate(MessageContext synCtx) {
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug((xpath == null ?
"Source : " + source + " against : " + regex.pattern() + " matches" :
"XPath expression : " + xpath + " evaluates to true") +
"Expression : " + xpath + " evaluates to true") +
" - executing child mediators");
}

Expand All @@ -179,7 +180,7 @@ public boolean mediate(MessageContext synCtx) {
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug((xpath == null ?
"Source : " + source + " against : " + regex.pattern() + " does not match" :
"XPath expression : " + xpath + " evaluates to false") +
"Expression : " + xpath + " evaluates to false") +
" - executing the else sequence with key : " + elseKey);
}

Expand All @@ -198,7 +199,7 @@ public boolean mediate(MessageContext synCtx) {
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug((xpath == null ?
"Source : " + source + " against : " + regex.pattern() + " does not match" :
"XPath expression : " + xpath + " evaluates to false") +
"Expression : " + xpath + " evaluates to false") +
" - executing the else path child mediators");
}
ContinuationStackManager.addReliantContinuationState(synCtx, 1, getMediatorPosition());
Expand All @@ -212,7 +213,7 @@ public boolean mediate(MessageContext synCtx) {
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug((xpath == null ?
"Source : " + source + " against : " + regex.pattern() + " does not match" :
"XPath expression : " + xpath + " evaluates to false and no else path") +
"Expression : " + xpath + " evaluates to false and no else path") +
" - skipping child mediators");
}
result = true;
Expand Down Expand Up @@ -288,9 +289,11 @@ public boolean test(MessageContext synCtx) {
return xpath.booleanValueOf(synCtx);
} else if (xpath instanceof SynapseJsonPath) {
return ((SynapseJsonPath) xpath).booleanValueOf(synCtx);
} else if (xpath instanceof SynapseExpression) {
return Boolean.parseBoolean(xpath.stringValueOf(synCtx));
}
} catch (JaxenException e) {
handleException("Error evaluating XPath expression : " + xpath, e, synCtx);
handleException("Error evaluating Expression : " + xpath, e, synCtx);
}

} else if (source != null && regex != null) {
Expand Down
Loading