You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2022/01/10 13:50:26 UTC
[camel-kamelets] branch ex-field-strict-check updated (4444389 -> aab736a)
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a change to branch ex-field-strict-check
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git.
omit 4444389 Extract Field Action: Sanitize/check the header name if set and avoid clashes
omit 283b3dc Extract Field Action: Sanitize/check the header name if set and avoid clashes
omit 17cdbf2 Extract Field Action: Sanitize/check the header name if set and avoid clashes
omit 6cea257 Extract Field Action: Add the possibility of setting the header name in case of headerOutput is true
omit 2c83271 Extract Field Action: Add the possibility of setting the header name in case of headerOutput is true
add 9b3109c Extract Field Action: Add the possibility of setting the header name in case of headerOutput is true
add ba03d9f Extract Field Action: Add the possibility of setting the header name in case of headerOutput is true
new c83d05e Extract Field Action: Sanitize/check the header name if set and avoid clashes
new 6fbc1fc Extract Field Action: Sanitize/check the header name if set and avoid clashes
new aab736a Extract Field Action: Sanitize/check the header name if set and avoid clashes
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (4444389)
\
N -- N -- N refs/heads/ex-field-strict-check (aab736a)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
[camel-kamelets] 01/03: Extract Field Action: Sanitize/check the header name if set and avoid clashes
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch ex-field-strict-check
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
commit c83d05ec9350ebe10b2ad704342cc50fcc2505d6
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Jan 10 14:45:17 2022 +0100
Extract Field Action: Sanitize/check the header name if set and avoid clashes
---
kamelets/extract-field-action.kamelet.yaml | 10 ++++++++
.../kamelets/utils/transform/ExtractField.java | 28 ++++++++++++++++++----
.../kamelets/extract-field-action.kamelet.yaml | 10 ++++++++
3 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/kamelets/extract-field-action.kamelet.yaml b/kamelets/extract-field-action.kamelet.yaml
index 32e83b8..562952c 100644
--- a/kamelets/extract-field-action.kamelet.yaml
+++ b/kamelets/extract-field-action.kamelet.yaml
@@ -61,6 +61,13 @@ spec:
description: A custom name for the header containing the extracted field
default: "none"
type: string
+ strictHeaderCheck:
+ title: Strict Header Check
+ description: If enable the action will check if the header output name (custom or default) has been used already in the exchange. If so, the extracted field will be stored in the message body, if not, the extracted field will be stored in the selected header (custom or default).
+ type: boolean
+ default: false
+ x-descriptors:
+ - 'urn:alm:descriptor:com.tectonic.ui:checkbox'
type: object
dependencies:
- "github:apache.camel-kamelets:camel-kamelets-utils:main-SNAPSHOT"
@@ -91,6 +98,9 @@ spec:
- set-property:
name: "headerOutputName"
constant: "{{headerOutputName}}"
+ - set-property:
+ name: "strictHeaderCheck"
+ constant: "{{strictHeaderCheck}}"
- bean: "org.apache.camel.kamelets.utils.transform.ExtractField"
- choice:
when:
diff --git a/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/transform/ExtractField.java b/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/transform/ExtractField.java
index fcfc675..72a2758 100644
--- a/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/transform/ExtractField.java
+++ b/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/transform/ExtractField.java
@@ -27,7 +27,7 @@ import java.util.Map;
public class ExtractField {
- public void process(@ExchangeProperty("field") String field, @ExchangeProperty("headerOutput") boolean headerOutput, @ExchangeProperty("headerOutputName") String headerOutputName, Exchange ex) {
+ public void process(@ExchangeProperty("field") String field, @ExchangeProperty("headerOutput") boolean headerOutput, @ExchangeProperty("headerOutputName") String headerOutputName, @ExchangeProperty("strictHeaderCheck") boolean strictHeaderCheck, Exchange ex) {
final String EXTRACTED_FIELD_HEADER = "CamelKameletsExtractFieldName";
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonNodeBody = ex.getMessage().getBody(JsonNode.class);
@@ -35,12 +35,32 @@ public class ExtractField {
if (!headerOutput) {
ex.getMessage().setBody(body.get(field));
} else {
- if ("none".equalsIgnoreCase(headerOutputName)) {
- ex.getMessage().setHeader(EXTRACTED_FIELD_HEADER, body.get(field));
+ if (!strictHeaderCheck) {
+ if ("none".equalsIgnoreCase(headerOutputName)) {
+ ex.getMessage().setHeader(EXTRACTED_FIELD_HEADER, body.get(field));
+ } else {
+ ex.getMessage().setHeader(headerOutputName, body.get(field));
+ }
} else {
- ex.getMessage().setHeader(headerOutputName, body.get(field));
+ if (checkHeaderExistence(EXTRACTED_FIELD_HEADER, ex) || checkHeaderExistence(headerOutputName, ex)) {
+ ex.getMessage().setBody(body.get(field));
+ } else {
+ if ("none".equalsIgnoreCase(headerOutputName)) {
+ ex.getMessage().setHeader(EXTRACTED_FIELD_HEADER, body.get(field));
+ } else {
+ ex.getMessage().setHeader(headerOutputName, body.get(field));
+ }
+ }
}
}
}
+ private final boolean checkHeaderExistence(String headerName, Exchange exchange) {
+ if (exchange.getMessage().getHeaders().containsKey(headerName)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
}
diff --git a/library/camel-kamelets/src/main/resources/kamelets/extract-field-action.kamelet.yaml b/library/camel-kamelets/src/main/resources/kamelets/extract-field-action.kamelet.yaml
index 32e83b8..562952c 100644
--- a/library/camel-kamelets/src/main/resources/kamelets/extract-field-action.kamelet.yaml
+++ b/library/camel-kamelets/src/main/resources/kamelets/extract-field-action.kamelet.yaml
@@ -61,6 +61,13 @@ spec:
description: A custom name for the header containing the extracted field
default: "none"
type: string
+ strictHeaderCheck:
+ title: Strict Header Check
+ description: If enable the action will check if the header output name (custom or default) has been used already in the exchange. If so, the extracted field will be stored in the message body, if not, the extracted field will be stored in the selected header (custom or default).
+ type: boolean
+ default: false
+ x-descriptors:
+ - 'urn:alm:descriptor:com.tectonic.ui:checkbox'
type: object
dependencies:
- "github:apache.camel-kamelets:camel-kamelets-utils:main-SNAPSHOT"
@@ -91,6 +98,9 @@ spec:
- set-property:
name: "headerOutputName"
constant: "{{headerOutputName}}"
+ - set-property:
+ name: "strictHeaderCheck"
+ constant: "{{strictHeaderCheck}}"
- bean: "org.apache.camel.kamelets.utils.transform.ExtractField"
- choice:
when:
[camel-kamelets] 02/03: Extract Field Action: Sanitize/check the header name if set and avoid clashes
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch ex-field-strict-check
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
commit 6fbc1fc6e3c5ff04284f00f2c026a73d903426de
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Jan 10 14:46:44 2022 +0100
Extract Field Action: Sanitize/check the header name if set and avoid clashes
---
kamelets/extract-field-action.kamelet.yaml | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kamelets/extract-field-action.kamelet.yaml b/kamelets/extract-field-action.kamelet.yaml
index 562952c..b13561f 100644
--- a/kamelets/extract-field-action.kamelet.yaml
+++ b/kamelets/extract-field-action.kamelet.yaml
@@ -41,7 +41,9 @@ spec:
The optional parameter headerOutputName allows the user to specify a custom header name instead of the default 'CamelKameletsExtractFieldName'. This parameter must be used in conjunction with headerOutput.
If no headerOutputName parameter will be provided, the default 'CamelKameletsExtractFieldName' will be used.
- The headerOutput/headerOutputName parameters are particulary useful in case you would like to reuse an extracted field as parameter for another header, for example.
+ The optional parameter strictHeaderCheck allows to user to enable a strict header name check. If enabled the action will check if the header output name (custom or default) has been used already in the exchange. If so, the extracted field will be stored in the message body, if not, the extracted field will be stored in the selected header (custom or default).
+
+ The headerOutput/headerOutputName/strictHeaderCheck parameters are particulary useful in case you would like to reuse an extracted field as parameter for another header, for example.
required:
- field
properties:
@@ -63,7 +65,7 @@ spec:
type: string
strictHeaderCheck:
title: Strict Header Check
- description: If enable the action will check if the header output name (custom or default) has been used already in the exchange. If so, the extracted field will be stored in the message body, if not, the extracted field will be stored in the selected header (custom or default).
+ description: If enabled the action will check if the header output name (custom or default) has been used already in the exchange. If so, the extracted field will be stored in the message body, if not, the extracted field will be stored in the selected header (custom or default).
type: boolean
default: false
x-descriptors:
[camel-kamelets] 03/03: Extract Field Action: Sanitize/check the header name if set and avoid clashes
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch ex-field-strict-check
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
commit aab736a11131a80e268c1a95a03627884743390c
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Jan 10 14:47:09 2022 +0100
Extract Field Action: Sanitize/check the header name if set and avoid clashes
---
.../src/main/resources/kamelets/extract-field-action.kamelet.yaml | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/library/camel-kamelets/src/main/resources/kamelets/extract-field-action.kamelet.yaml b/library/camel-kamelets/src/main/resources/kamelets/extract-field-action.kamelet.yaml
index 562952c..b13561f 100644
--- a/library/camel-kamelets/src/main/resources/kamelets/extract-field-action.kamelet.yaml
+++ b/library/camel-kamelets/src/main/resources/kamelets/extract-field-action.kamelet.yaml
@@ -41,7 +41,9 @@ spec:
The optional parameter headerOutputName allows the user to specify a custom header name instead of the default 'CamelKameletsExtractFieldName'. This parameter must be used in conjunction with headerOutput.
If no headerOutputName parameter will be provided, the default 'CamelKameletsExtractFieldName' will be used.
- The headerOutput/headerOutputName parameters are particulary useful in case you would like to reuse an extracted field as parameter for another header, for example.
+ The optional parameter strictHeaderCheck allows to user to enable a strict header name check. If enabled the action will check if the header output name (custom or default) has been used already in the exchange. If so, the extracted field will be stored in the message body, if not, the extracted field will be stored in the selected header (custom or default).
+
+ The headerOutput/headerOutputName/strictHeaderCheck parameters are particulary useful in case you would like to reuse an extracted field as parameter for another header, for example.
required:
- field
properties:
@@ -63,7 +65,7 @@ spec:
type: string
strictHeaderCheck:
title: Strict Header Check
- description: If enable the action will check if the header output name (custom or default) has been used already in the exchange. If so, the extracted field will be stored in the message body, if not, the extracted field will be stored in the selected header (custom or default).
+ description: If enabled the action will check if the header output name (custom or default) has been used already in the exchange. If so, the extracted field will be stored in the message body, if not, the extracted field will be stored in the selected header (custom or default).
type: boolean
default: false
x-descriptors: