Skip to content

Commit

Permalink
Add synapse expression support for Filter mediator
Browse files Browse the repository at this point in the history
  • Loading branch information
SanojPunchihewa committed Nov 14, 2024
1 parent c3515a4 commit ab2eb70
Showing 1 changed file with 9 additions and 6 deletions.
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

0 comments on commit ab2eb70

Please sign in to comment.