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 2021/05/05 11:08:07 UTC

[camel-kamelets] branch main updated: Generalize the idea for checking the body in action like replace field etc.

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git


The following commit(s) were added to refs/heads/main by this push:
     new dbd85e0  Generalize the idea for checking the body in action like replace field etc.
dbd85e0 is described below

commit dbd85e08236e54b6e4d8a867de89f6644edce734
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed May 5 13:07:23 2021 +0200

    Generalize the idea for checking the body in action like replace field etc.
---
 .../org/apache/camel/kamelets/utils/transform/ReplaceField.java   | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/transform/ReplaceField.java b/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/transform/ReplaceField.java
index 2aabe36..9ec117c 100644
--- a/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/transform/ReplaceField.java
+++ b/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/transform/ReplaceField.java
@@ -34,7 +34,13 @@ public class ReplaceField {
         List<String> enabledFields = new ArrayList<>();
         List<String> disabledFields = new ArrayList<>();
         List<String> renameFields = new ArrayList<>();
-        Map<Object, Object> body = ex.getMessage().getMandatoryBody(Map.class);
+        Map<Object, Object> body = ex.getMessage().getBody(Map.class);
+        if (body == null) {
+            String val = ex.getMessage().getMandatoryBody(String.class);
+            body = new HashMap<>();
+            // TODO: make this configurable
+            body.put("content", val);
+        }
         if (ObjectHelper.isNotEmpty(enabled)) {
             enabledFields = Arrays.stream(enabled.split(",")).collect(Collectors.toList());
         }