From 908a16cd453d53267a405887ba68b9ace46d6ce4 Mon Sep 17 00:00:00 2001 From: GDLMadushanka Date: Mon, 9 Dec 2024 08:41:03 +0530 Subject: [PATCH] Add synapse expression support to validate mediator Add synapse expression support to validate mediator --- .../apache/synapse/mediators/builtin/ValidateMediator.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/synapse/mediators/builtin/ValidateMediator.java b/modules/core/src/main/java/org/apache/synapse/mediators/builtin/ValidateMediator.java index 135b0a4e98..34f20e3655 100644 --- a/modules/core/src/main/java/org/apache/synapse/mediators/builtin/ValidateMediator.java +++ b/modules/core/src/main/java/org/apache/synapse/mediators/builtin/ValidateMediator.java @@ -57,6 +57,7 @@ import org.apache.synapse.util.resolver.ResourceMap; import org.apache.synapse.util.resolver.UserDefinedXmlSchemaURIResolver; import org.apache.synapse.util.xpath.SourceXPathSupport; +import org.apache.synapse.util.xpath.SynapseExpression; import org.apache.synapse.util.xpath.SynapseJsonPath; import org.apache.synapse.util.xpath.SynapseXPath; import org.xml.sax.SAXException; @@ -279,10 +280,11 @@ public boolean mediate(MessageContext synCtx) { String jsonPayload = null; if (sourcePath != null) { //evaluating - if (sourcePath instanceof SynapseJsonPath) { + if (sourcePath instanceof SynapseJsonPath || sourcePath instanceof SynapseExpression) { jsonPayload = sourcePath.stringValueOf(synCtx); } else { - handleException("Could not find the JSONPath evaluator for Source", synCtx); + handleException("Could not find JSONPath or Synapse Expression to extract the message " + + "to validate from the payload", synCtx); } } else { jsonPayload = JsonUtil.jsonPayloadToString(a2mc);