From 9b939681e917bd3d0a5814e3b4a61308cfd36ab3 Mon Sep 17 00:00:00 2001 From: Sanoj Punchihewa Date: Wed, 11 Dec 2024 15:15:15 +0530 Subject: [PATCH 1/4] Update Switch mediator for 4.4.0 version --- .../reference/mediators/switch-mediator.md | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/en/docs/reference/mediators/switch-mediator.md b/en/docs/reference/mediators/switch-mediator.md index 453e1a2b2..8d9b70707 100644 --- a/en/docs/reference/mediators/switch-mediator.md +++ b/en/docs/reference/mediators/switch-mediator.md @@ -1,11 +1,11 @@ # Switch Mediator -The **Switch Mediator** is an XPath or JSONPath filter. The XPath or JSONPath expression is evaluated and returns a string. This string is matched against the regular expression in each switch case, in the specified order. If a matching case is found, it is executed, and the remaining cases are not processed. If none of the case statements match and a default case is specified, the default case will be executed. +The **Switch Mediator** evaluates a Synapse expression and returns a result. This result is then matched against the regular expressions defined in each switch case, in the specified order. If a matching case is found, it is executed, and the remaining cases are not processed. If none of the case statements match the default case will be executed. ## Syntax ```xml - + mediator+ + @@ -28,44 +28,40 @@ The parameters available to configure the Switch mediator are as follows. -Source XPath -The source XPath or JSONPath to be evaluated. When specifying a JSONPath, use the format json-eval(<JSON_PATH>) , such as json-eval(getQuote.request.symbol) . If you use namespaces in the expression, click the edit icon, then click Add Namespace to map the namespace prefix to the correct URI. +Expression +The Synapse expression to be evaluated which should return a string. -Number of cases -

This parameter displays the number of cases currently added to the Switch mediator configuration.

+Cases +

This section displays the number of cases currently added to the switch mediator and option to add a new case.


- -Specify default case -Adding a default case is optional. If it is specified, it will be executed if no matching case is identified. - -## Switch-case mediator +### Adding a new case -1. To add a case, go to edit the switch and click **Add parameter** under **Case Branches**. -2. It will open a form where a regular expression can be added in the **Case Regex** parameter. By submitting, it will add an empty case under the switch mediator as a child. -3. Click on the `+` mark under a chase to add the mediator(s) you want to execute when this case matches the switching value. +1. To add a case, go to edit the switch mediator and click **Add new case** under **Cases** section. +2. It will open a form where a regular expression can be added in the **Regex Pattern** parameter. By submitting, it will add an empty case under the switch mediator as a child. +3. Click on the `+` mark under a case to add the mediator(s) you want to execute when this case matches the switching value. ## Examples -In this example, the [Property mediator]({{base_path}}/reference/mediators/property-mediator) sets the local property named `symbol` on the current message depending on the evaluation of the string. It will get the text of the symbol element and match it against the values `MSFT` and `IBM`. If the text does not match either of these symbols, the default case will be executed. +In this example, the [Variable mediator]({{base_path}}/reference/mediators/variable-mediator) sets the variable named `symbol` on the current message depending on the evaluation of the expression. The expression will get the symbol value and match it against the values `MSFT` and `IBM`. If the symbol value does not match either of these symbols, the default case will be executed. ```xml - + - - + + - + - - + + ``` From 7bd3fa06a1121f4561e1028bb9a8b3d73f2ef378 Mon Sep 17 00:00:00 2001 From: Sanoj Punchihewa Date: Thu, 12 Dec 2024 15:19:20 +0530 Subject: [PATCH 2/4] Update en/docs/reference/mediators/switch-mediator.md Co-authored-by: Dinithi Navodya Dias <33226735+DinithiDiaz@users.noreply.github.com> --- en/docs/reference/mediators/switch-mediator.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/docs/reference/mediators/switch-mediator.md b/en/docs/reference/mediators/switch-mediator.md index 8d9b70707..4695396c8 100644 --- a/en/docs/reference/mediators/switch-mediator.md +++ b/en/docs/reference/mediators/switch-mediator.md @@ -43,7 +43,7 @@ The parameters available to configure the Switch mediator are as follows. ### Adding a new case 1. To add a case, go to edit the switch mediator and click **Add new case** under **Cases** section. -2. It will open a form where a regular expression can be added in the **Regex Pattern** parameter. By submitting, it will add an empty case under the switch mediator as a child. +2. It will open a form where a regular expression can be added in the **Regex Pattern** parameter. Once submitted, it will add an empty case under the switch mediator as a child. 3. Click on the `+` mark under a case to add the mediator(s) you want to execute when this case matches the switching value. ## Examples From a462123314b4f72eb5c57657fd9ce257b99a830e Mon Sep 17 00:00:00 2001 From: Sanoj Punchihewa Date: Thu, 12 Dec 2024 15:19:31 +0530 Subject: [PATCH 3/4] Update en/docs/reference/mediators/switch-mediator.md Co-authored-by: Dinithi Navodya Dias <33226735+DinithiDiaz@users.noreply.github.com> --- en/docs/reference/mediators/switch-mediator.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/docs/reference/mediators/switch-mediator.md b/en/docs/reference/mediators/switch-mediator.md index 4695396c8..0f9543190 100644 --- a/en/docs/reference/mediators/switch-mediator.md +++ b/en/docs/reference/mediators/switch-mediator.md @@ -42,7 +42,7 @@ The parameters available to configure the Switch mediator are as follows. ### Adding a new case -1. To add a case, go to edit the switch mediator and click **Add new case** under **Cases** section. +1. To add a case, go to edit the switch mediator and click **Add new case** under the **Cases** section. 2. It will open a form where a regular expression can be added in the **Regex Pattern** parameter. Once submitted, it will add an empty case under the switch mediator as a child. 3. Click on the `+` mark under a case to add the mediator(s) you want to execute when this case matches the switching value. From 99cc11e347bc302de979547cc92e14bfb0b373a0 Mon Sep 17 00:00:00 2001 From: Sanoj Punchihewa Date: Thu, 12 Dec 2024 15:27:11 +0530 Subject: [PATCH 4/4] Fix review comments --- en/docs/reference/mediators/switch-mediator.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/en/docs/reference/mediators/switch-mediator.md b/en/docs/reference/mediators/switch-mediator.md index 0f9543190..108f4155a 100644 --- a/en/docs/reference/mediators/switch-mediator.md +++ b/en/docs/reference/mediators/switch-mediator.md @@ -42,9 +42,9 @@ The parameters available to configure the Switch mediator are as follows. ### Adding a new case -1. To add a case, go to edit the switch mediator and click **Add new case** under the **Cases** section. +1. To add a case, click on the Switch mediator to open the **Edit Switch Mediator** panel. Then click **Add new case** under the **Cases** section. 2. It will open a form where a regular expression can be added in the **Regex Pattern** parameter. Once submitted, it will add an empty case under the switch mediator as a child. -3. Click on the `+` mark under a case to add the mediator(s) you want to execute when this case matches the switching value. +3. Click on the + mark under a case to add the mediator(s) you want to execute when this case matches the switching value. ## Examples