diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/bean-validator.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/bean-validator.json index f7c5e0354c6ab..b90db05804387 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/bean-validator.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/bean-validator.json @@ -33,6 +33,10 @@ "validationProviderResolver": { "index": 6, "kind": "property", "displayName": "Validation Provider Resolver", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "jakarta.validation.ValidationProviderResolver", "deprecated": false, "autowired": false, "secret": false, "description": "To use a a custom ValidationProviderResolver" }, "validatorFactory": { "index": 7, "kind": "property", "displayName": "Validator Factory", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "jakarta.validation.ValidatorFactory", "deprecated": false, "autowired": true, "secret": false, "description": "To use a custom ValidatorFactory" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "pojo", "list" ], "description": "A POJO with Jakarta Bean Validation constraints, or a List or another Iterable of them, each one validated. Text, a Map or an array has no constraints of its own and passes unchecked; no body fails" }, + "producerOut": { "carriers": [ "unchanged" ], "description": "Unchanged: a body that breaks a constraint fails with a BeanValidationException" } + }, "properties": { "label": { "index": 0, "kind": "path", "displayName": "Label", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Where label is an arbitrary text value describing the endpoint" }, "group": { "index": 1, "kind": "parameter", "displayName": "Group", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "jakarta.validation.groups.Default", "description": "To use a custom validation group" }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/chunk.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/chunk.json index edf6b67d18cb2..ae08f3605556d 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/chunk.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/chunk.json @@ -34,6 +34,10 @@ "CamelChunkResourceUri": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A URI for the template resource to use instead of the endpoint configured.", "constantName": "org.apache.camel.component.chunk.ChunkConstants#CHUNK_RESOURCE_URI" }, "CamelChunkTemplate": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The template to use instead of the endpoint configured.", "constantName": "org.apache.camel.component.chunk.ChunkConstants#CHUNK_TEMPLATE" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "any" ], "description": "The template gets the body as {$body}, as it is: text, or a Map, a List or a POJO to read from; no body prints as empty text, and bytes or a stream are not read as text. The template is the resource, or the CamelChunkTemplate header with allowTemplateFromHeader=true, never the body" }, + "producerOut": { "carriers": [ "text" ], "javaType": "java.lang.String", "description": "The text the template writes. The headers are kept" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/freemarker.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/freemarker.json index 3075b7efead38..a0f18e467cb59 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/freemarker.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/freemarker.json @@ -37,6 +37,10 @@ "CamelFreemarkerTemplate": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The template to use instead of the endpoint configured.", "constantName": "org.apache.camel.component.freemarker.FreemarkerConstants#FREEMARKER_TEMPLATE" }, "CamelFreemarkerDataModel": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Object", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The data model", "constantName": "org.apache.camel.component.freemarker.FreemarkerConstants#FREEMARKER_DATA_MODEL" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "any" ], "description": "The template gets the body as body, as it is: text, or a Map, a List or a POJO to read from; convert bytes or a stream to a String first, and no body fails ${body} unless it is written ${body!}. The template is the resource, or the CamelFreemarkerTemplate or CamelFreemarkerResourceUri header with allowTemplateFromHeader=true, and never the body" }, + "producerOut": { "carriers": [ "text" ], "javaType": "java.lang.String", "description": "The text the template writes, also when it is JSON or XML: unmarshal it to read its fields. The headers are kept" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jolt.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jolt.json index 4f7c8a6e3cec9..0638b27c7f26a 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jolt.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jolt.json @@ -34,6 +34,10 @@ "CamelJoltResourceUri": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The resource URI", "constantName": "org.apache.camel.component.jolt.JoltConstants#JOLT_RESOURCE_URI" }, "CamelJoltContext": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Map", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The context", "constantName": "org.apache.camel.component.jolt.JoltConstants#JOLT_CONTEXT" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "map", "list" ], "format": "json", "byOption": [ { "option": "inputType", "value": "JsonString", "carriers": [ "text", "bytes", "stream", "file" ] } ], "description": "Parsed JSON: a Map or a List. JSON as text, bytes, a stream or a file needs inputType=JsonString: without it the body reaches the spec unparsed, and the result is most likely null" }, + "producerOut": { "carriers": [ "map", "list" ], "format": "json", "byOption": [ { "option": "outputType", "value": "JsonString", "carriers": [ "text" ], "javaType": "java.lang.String" } ], "description": "The JSON the spec makes: a Map for an object, a List for an array; JSON text with outputType=JsonString" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowTemplateFromHeader": { "index": 1, "kind": "parameter", "displayName": "Allow Template From Header", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care." }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jslt.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jslt.json index a82c39b84d52c..d60f5f1e048d2 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jslt.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jslt.json @@ -35,6 +35,10 @@ "CamelJsltString": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The JSLT Template as String", "constantName": "org.apache.camel.component.jslt.JsltConstants#HEADER_JSLT_STRING" }, "CamelJsltResourceUri": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The resource URI", "constantName": "org.apache.camel.component.jslt.JsltConstants#HEADER_JSLT_RESOURCE_URI" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "text", "bytes", "stream", "file" ], "format": "json", "description": "JSON as text, bytes, a stream, a Reader or a java.io.File, such as the file of the file consumer. A Map, a List, a JsonNode or no body fails: marshal parsed JSON first" }, + "producerOut": { "carriers": [ "text" ], "javaType": "java.lang.String", "format": "json", "description": "The result as JSON text, pretty printed with prettyPrint=true" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/json-validator.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/json-validator.json index 48155c275cff2..ab867f3969f7e 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/json-validator.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/json-validator.json @@ -30,6 +30,10 @@ "autowiredEnabled": { "index": 3, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc." }, "objectMapper": { "index": 4, "kind": "property", "displayName": "Object Mapper", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Lookup and use the existing ObjectMapper with the given id." } }, + "bodyTypes": { + "producerIn": { "carriers": [ "text", "bytes", "stream", "file" ], "format": "json", "dependsOn": [ "headerName" ], "byOption": [ { "option": "failOnNullBody", "value": "false", "carriers": [ "null", "text", "bytes", "stream", "file" ] } ], "description": "The JSON to validate: text, bytes, a stream or a file. A Map, a POJO or no body fails: marshal it first; with headerName the header is validated instead" }, + "producerOut": { "carriers": [ "unchanged" ], "description": "Unchanged: JSON that does not match the schema, or text that is not JSON, fails with a JsonValidationException" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jsonata.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jsonata.json index d6de7d1584da8..72d92ea7c5c85 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jsonata.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jsonata.json @@ -30,6 +30,10 @@ "autowiredEnabled": { "index": 3, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc." }, "frameBinding": { "index": 4, "kind": "property", "displayName": "Frame Binding", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.jsonata.JsonataFrameBinding", "deprecated": false, "autowired": false, "secret": false, "description": "To configure custom frame bindings and inject user functions." } }, + "bodyTypes": { + "producerIn": { "carriers": [ "map", "list", "pojo" ], "format": "json", "byOption": [ { "option": "inputType", "value": "JsonString", "carriers": [ "text", "bytes", "stream", "file" ] } ], "description": "JSON data: a Map, a List, a JsonNode or another object Jackson converts. JSON as text, bytes, a stream or a file needs inputType=JsonString: without it text is read as one JSON string, and bytes or a stream fail" }, + "producerOut": { "carriers": [ "pojo" ], "javaType": "com.fasterxml.jackson.databind.JsonNode", "format": "json", "byOption": [ { "option": "outputType", "value": "JsonString", "carriers": [ "text" ], "javaType": "java.lang.String" } ], "description": "The result as a Jackson JsonNode, or as JSON text with outputType=JsonString" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jte.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jte.json index 1d04e8d7d1d21..cfc4c8d5b8aff 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jte.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jte.json @@ -38,6 +38,10 @@ "CamelJteTemplate": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The template to use instead of the endpoint configured.", "constantName": "org.apache.camel.component.jte.JteConstants#JTE_TEMPLATE" }, "CamelJteDataModel": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Object", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The data model", "constantName": "org.apache.camel.component.jte.JteConstants#JTE_DATA_MODEL" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "any" ], "description": "The template takes an org.apache.camel.component.jte.Model: the body as it is in model.body, and converted to text by model.strBody(). With allowTemplateFromHeader=true the CamelJteDataModel header replaces the model" }, + "producerOut": { "carriers": [ "text" ], "javaType": "java.lang.String", "description": "The text the template writes, with leading and trailing whitespace trimmed. The headers are kept" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/mustache.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/mustache.json index 97ba41b8eb31f..1ac15dcc8b4ad 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/mustache.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/mustache.json @@ -35,6 +35,10 @@ "CamelMustacheResourceUri": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A URI for the template resource to use instead of the endpoint.", "constantName": "org.apache.camel.component.mustache.MustacheConstants#MUSTACHE_RESOURCE_URI" }, "CamelMustacheTemplate": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The template to use instead of the endpoint configured.", "constantName": "org.apache.camel.component.mustache.MustacheConstants#MUSTACHE_TEMPLATE" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "any" ], "description": "The template gets the body as body, as it is: text, or a Map, a List or a POJO to read from; convert bytes or a stream to a String first. The template is the resource, or the CamelMustacheTemplate or CamelMustacheResourceUri header with allowTemplateFromHeader=true, and never the body" }, + "producerOut": { "carriers": [ "text" ], "javaType": "java.lang.String", "description": "The text the template writes, also when it is JSON: unmarshal it to read its fields. Values in double braces are HTML-escaped, in triple braces as they are. The headers are kept" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/mvel.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/mvel.json index 7ae1971429a6c..e66b1e10b7cf8 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/mvel.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/mvel.json @@ -34,6 +34,10 @@ "CamelMvelResourceUri": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A URI for the template resource to use instead of the endpoint configured.", "constantName": "org.apache.camel.component.mvel.MvelConstants#MVEL_RESOURCE_URI" }, "CamelMvelTemplate": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The template to use instead of the endpoint configured.", "constantName": "org.apache.camel.component.mvel.MvelConstants#MVEL_TEMPLATE" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "any" ], "description": "The template gets the body as body, as it is: no body prints as null, and bytes or a stream are not read as text. The template is the resource, or the CamelMvelTemplate header with allowTemplateFromHeader=true, never the body" }, + "producerOut": { "carriers": [ "text" ], "javaType": "java.lang.String", "description": "The text the template writes. The headers are kept" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/schematron.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/schematron.json index 4a36cefb7e7c7..2ea15ac6e3f0d 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/schematron.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/schematron.json @@ -27,6 +27,10 @@ "lazyStartProducer": { "index": 0, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." }, "autowiredEnabled": { "index": 1, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc." } }, + "bodyTypes": { + "producerIn": { "carriers": [ "text", "bytes", "stream", "file", "pojo" ], "format": "xml", "description": "The XML to validate: text, bytes, a stream, a file, a DOM or another javax.xml.transform.Source. A Map or another POJO is read as its toString(): marshal it first; no body fails" }, + "producerOut": { "carriers": [ "unchanged" ], "description": "Unchanged: the CamelSchematronValidationStatus header is SUCCESS or FAILED, and CamelSchematronValidationReport holds the SVRL report. With abort, a failed assert throws a SchematronValidationException" } + }, "properties": { "path": { "index": 0, "kind": "path", "displayName": "Path", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "The path to the schematron rules file. Can either be in class path or location in the file system." }, "abort": { "index": 1, "kind": "parameter", "displayName": "Abort", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Flag to abort the route and throw a schematron validation exception." }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/string-template.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/string-template.json index 6c156e63c2717..8eacc56d396b7 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/string-template.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/string-template.json @@ -35,6 +35,10 @@ "CamelStringTemplateVariableMap": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Map", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Map of the variables which are made available to a script or template", "constantName": "org.apache.camel.component.stringtemplate.StringTemplateConstants#STRINGTEMPLATE_VARIABLE_MAP" }, "CamelStringTemplateTemplate": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The template to use instead of the endpoint configured.", "constantName": "org.apache.camel.component.stringtemplate.StringTemplateConstants#STRINGTEMPLATE_TEMPLATE" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "any" ], "description": "The template gets the body as body, as it is: text, or a Map, a List or a POJO to read from; convert bytes or a stream to a String first. The template is the resource, or the CamelStringTemplateTemplate or CamelStringTemplateResourceUri header with allowTemplateFromHeader=true, and never the body" }, + "producerOut": { "carriers": [ "text" ], "javaType": "java.lang.String", "description": "The text the template writes, also when it is JSON or XML: unmarshal it to read its fields. The headers are kept, and the CamelStringTemplateResourceUri header is set to the uri of the resource" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/thymeleaf.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/thymeleaf.json index 5fd0193f05f47..3999546f8abcb 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/thymeleaf.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/thymeleaf.json @@ -35,6 +35,10 @@ "CamelThymeleafVariableMap": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Map", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The value of this header should be a Map with key\/values that will be override any existing key with the same name. This can be used to preconfigure common key\/values you want to reuse in your Thymeleaf endpoints.", "constantName": "org.apache.camel.component.thymeleaf.ThymeleafConstants#THYMELEAF_VARIABLE_MAP" }, "CamelThymeleafServletContext": { "index": 3, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "jakarta.servlet.ServletContext", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The ServletContext for a web application.", "constantName": "org.apache.camel.component.thymeleaf.ThymeleafConstants#THYMELEAF_SERVLET_CONTEXT" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "any" ], "description": "The template gets the body as ${body}, as it is: text, or a Map, a List or a POJO to read from; no body prints as empty text, and bytes or a stream are not read as text. The template is the resource, or the CamelThymeleafTemplate header with allowTemplateFromHeader=true, never the body" }, + "producerOut": { "carriers": [ "text" ], "javaType": "java.lang.String", "description": "The text the template writes, in its templateMode such as HTML. The headers are kept" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/velocity.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/velocity.json index 951eac85ee9f4..c33d8999d0dc4 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/velocity.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/velocity.json @@ -37,6 +37,10 @@ "CamelVelocityContext": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "org.apache.velocity.context.Context", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The velocity context to use.", "constantName": "org.apache.camel.component.velocity.VelocityConstants#VELOCITY_CONTEXT" }, "CamelVelocitySupplementalContext": { "index": 3, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Map", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "To add additional information to the used VelocityContext. The value of this header should be a Map with key\/values that will added (override any existing key with the same name). This can be used to pre setup some common key\/values you want to reuse in your velocity endpoints.", "constantName": "org.apache.camel.component.velocity.VelocityConstants#VELOCITY_SUPPLEMENTAL_CONTEXT" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "any" ], "description": "The template gets the body as body, as it is: text, or a Map, a List or a POJO to read from; convert bytes or a stream to a String first. The template is the resource, or the CamelVelocityTemplate or CamelVelocityResourceUri header with allowTemplateFromHeader=true, and never the body" }, + "producerOut": { "carriers": [ "text" ], "javaType": "java.lang.String", "description": "The text the template writes, also when it is JSON or XML: unmarshal it to read its fields. The headers are kept" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xj.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xj.json index 2af1f9038eceb..0a57d2901364b 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xj.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xj.json @@ -43,6 +43,10 @@ "CamelXsltResourceUri": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A URI for the template resource to load and use instead of the endpoint configured.", "constantName": "org.apache.camel.component.xslt.XsltConstants#XSLT_RESOURCE_URI" }, "CamelXsltStylesheet": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The template to use instead of the endpoint configured.", "constantName": "org.apache.camel.component.xslt.XsltConstants#XSLT_STYLESHEET" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "text", "bytes", "stream", "file", "pojo" ], "dependsOn": [ "source", "useJsonBody" ], "byOption": [ { "option": "transformDirection", "value": "XML2JSON", "carriers": [ "text", "bytes", "stream", "file", "pojo" ] }, { "option": "transformDirection", "value": "JSON2XML", "carriers": [ "text", "bytes", "stream", "file" ] } ], "description": "The XML for XML2JSON as text, bytes, a stream, a file, a DOM or another javax.xml.transform.Source; the JSON for JSON2XML as text, bytes, a stream or a file. A Map, a List or no body fails, unless failOnNullBody=false for no body" }, + "producerOut": { "carriers": [ "text" ], "javaType": "java.lang.String", "dependsOn": [ "resultHandlerFactory" ], "byOption": [ { "option": "output", "value": "bytes", "carriers": [ "bytes" ], "javaType": "byte[]" }, { "option": "output", "value": "DOM", "carriers": [ "pojo" ], "javaType": "org.w3c.dom.Document" }, { "option": "output", "value": "file", "carriers": [ "file" ], "javaType": "java.io.File" } ], "description": "The result of the transformation: JSON text with XML2JSON, XML text with JSON2XML. output=DOM works with JSON2XML only" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Path to the template. The following is supported by the default URIResolver. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod" }, "allowStAX": { "index": 1, "kind": "parameter", "displayName": "Allow StAX", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to allow using StAX as the javax.xml.transform.Source. You can enable this if the XSLT library supports StAX such as the Saxon library (camel-saxon). The Xalan library (default in JVM) does not support StAXSource." }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xquery.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xquery.json index 3f3346a8b7bd3..0eebafc59fc30 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xquery.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xquery.json @@ -31,6 +31,10 @@ "configurationProperties": { "index": 4, "kind": "property", "displayName": "Configuration Properties", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "java.util.Map", "deprecated": false, "autowired": false, "secret": false, "description": "To set custom Saxon configuration properties" }, "moduleURIResolver": { "index": 5, "kind": "property", "displayName": "Module URIResolver", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "net.sf.saxon.lib.ModuleURIResolver", "deprecated": false, "autowired": false, "secret": false, "description": "To use the custom ModuleURIResolver" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "text", "bytes", "stream", "file", "pojo" ], "format": "xml", "dependsOn": [ "source" ], "description": "The XML to query: text, bytes, a stream, a file, a DOM or another javax.xml.transform.Source. A Map or no body fails" }, + "producerOut": { "carriers": [ "pojo" ], "javaType": "org.w3c.dom.Document", "dependsOn": [ "resultType" ], "byOption": [ { "option": "resultsFormat", "value": "Bytes", "carriers": [ "bytes" ], "javaType": "byte[]" }, { "option": "resultsFormat", "value": "BytesSource", "carriers": [ "pojo" ], "javaType": "org.apache.camel.util.xml.BytesSource" }, { "option": "resultsFormat", "value": "DOMSource", "carriers": [ "text" ], "javaType": "java.lang.String" }, { "option": "resultsFormat", "value": "List", "carriers": [ "list" ] }, { "option": "resultsFormat", "value": "String", "carriers": [ "text" ], "javaType": "java.lang.String" }, { "option": "resultsFormat", "value": "StringSource", "carriers": [ "pojo" ], "javaType": "org.apache.camel.util.xml.StringSource" } ], "description": "The result of the query as a DOM Document. A query that gives text, a number or more than one element fails with the default DOM: set resultsFormat to String or List" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the template to load from classpath or file system" }, "allowStAX": { "index": 1, "kind": "parameter", "displayName": "Allow St AX", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to allow using StAX mode" }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/chunk-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/chunk-component.adoc index 09378c38b3165..7eded1be94874 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/chunk-component.adoc +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/chunk-component.adoc @@ -48,6 +48,8 @@ above. Camel will provide exchange information in the Chunk context (just a `Map`). The `Exchange` is transferred as: +The `body`, `header`, `headers`, `variable`, `variables` and `exception` entries are always +there; the others only when the endpoint has `allowContextMapAll=true`. [width="100%",cols="20%,80%",options="header",] @@ -75,8 +77,8 @@ a `Map`). The `Exchange` is transferred as: Camel provides two headers by which you can define a different resource location for a template or the template content itself. If any of these -headers is set, then Camel uses this over the endpoint configured -resource. This allows you to provide a dynamic template at runtime. +headers is set, and the endpoint has `allowTemplateFromHeader=true`, then Camel uses this +over the endpoint configured resource. This allows you to provide a dynamic template at runtime. == Examples diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/freemarker-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/freemarker-component.adoc index fe794292497d3..f92f067cbfc27 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/freemarker-component.adoc +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/freemarker-component.adoc @@ -66,6 +66,8 @@ The header, `fruit`, is now accessible from the `message.out.headers`. Camel will provide exchange information in the FreeMarker context (just a `Map`). The `Exchange` is transferred as: +The `body`, `header`, `headers`, `variable`, `variables` and `exception` entries are always +there; the others only when the endpoint has `allowContextMapAll=true`. [width="100%",cols="50%,50%",options="header",] |======================================================================= @@ -112,8 +114,8 @@ reloading is thus enabled. This scenario can be used in development. Camel provides two headers by which you can define a different resource location for a template or the template content itself. If any of these -headers is set, then Camel uses this over the endpoint configured -resource. This allows you to provide a dynamic template at runtime. +headers is set, and the endpoint has `allowTemplateFromHeader=true`, then Camel uses this +over the endpoint configured resource. This allows you to provide a dynamic template at runtime. == Examples @@ -288,7 +290,7 @@ Java:: [source,java] ---- from("direct:in") - .setHeader("FreemarkerResourceUri").constant("path/to/my/template.ftl") + .setHeader("CamelFreemarkerResourceUri").constant("path/to/my/template.ftl") .to("freemarker:dummy?allowTemplateFromHeader=true"); ---- @@ -298,7 +300,7 @@ XML:: ---- - + path/to/my/template.ftl @@ -314,7 +316,7 @@ YAML:: uri: direct:in steps: - setHeader: - name: FreemarkerResourceUri + name: CamelFreemarkerResourceUri expression: constant: expression: path/to/my/template.ftl diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jolt-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jolt-component.adoc index 7377730c0f55d..dde30f7c2cfa4 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jolt-component.adoc +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jolt-component.adoc @@ -52,6 +52,8 @@ include::partial$component-endpoint-headers.adoc[] For example, you could use something like +The messages of the queue are JSON text, so the examples set `inputType` and `outputType` to `JsonString`: with the default, `Hydrated`, the body must be parsed JSON (a Map or a List), such as after `unmarshal: json`, and the result is parsed JSON too. + [tabs] ==== Java:: @@ -59,7 +61,7 @@ Java:: [source,java] ---- from("activemq:My.Queue") - .to("jolt:com/acme/MyResponse.json"); + .to("jolt:com/acme/MyResponse.json?inputType=JsonString&outputType=JsonString"); ---- XML:: @@ -68,7 +70,7 @@ XML:: ---- - + ---- @@ -82,6 +84,9 @@ YAML:: steps: - to: uri: jolt:com/acme/MyResponse.json + parameters: + inputType: JsonString + outputType: JsonString ---- ==== @@ -94,7 +99,7 @@ Java:: [source,java] ---- from("activemq:My.Queue") - .to("jolt:file://myfolder/MyResponse.json?contentCache=true") + .to("jolt:file://myfolder/MyResponse.json?contentCache=true&inputType=JsonString&outputType=JsonString") .to("activemq:Another.Queue"); ---- @@ -104,7 +109,7 @@ XML:: ---- - + ---- @@ -121,6 +126,8 @@ YAML:: uri: jolt:file://myfolder/MyResponse.json parameters: contentCache: true + inputType: JsonString + outputType: JsonString - to: uri: activemq:Another.Queue ---- diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/json-validator-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/json-validator-component.adoc index 18312b8a150c5..6cda6ee33d6be 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/json-validator-component.adoc +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/json-validator-component.adoc @@ -12,7 +12,7 @@ *{component-header}* -The JSON Schema Validator component performs bean validation of the message body +The JSON Schema Validator component validates the JSON in the message body against JSON Schemas v4, v6, v7, v2019-09 draft and v2020-12(partial) using the NetworkNT JSON Schema library (https://github.com/networknt/json-schema-validator). diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jsonata-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jsonata-component.adoc index 389d7c0763c72..8a8eaf2279a16 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jsonata-component.adoc +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jsonata-component.adoc @@ -53,6 +53,8 @@ include::partial$component-endpoint-headers.adoc[] For example, you could use something like: +The messages of the queue are JSON text, so the examples set `inputType` and `outputType` to `JsonString`: with the default, `Jackson`, the body must be JSON data (a Map, a List or a JsonNode), such as after `unmarshal: json`, and the result is a JsonNode. + [tabs] ==== Java:: @@ -60,7 +62,7 @@ Java:: [source,java] ---- from("activemq:My.Queue") - .to("jsonata:com/acme/MyResponse.json"); + .to("jsonata:com/acme/MyResponse.json?inputType=JsonString&outputType=JsonString"); ---- XML:: @@ -69,7 +71,7 @@ XML:: ---- - + ---- @@ -83,6 +85,9 @@ YAML:: steps: - to: uri: jsonata:com/acme/MyResponse.json + parameters: + inputType: JsonString + outputType: JsonString ---- ==== @@ -95,7 +100,7 @@ Java:: [source,java] ---- from("activemq:My.Queue") - .to("jsonata:file://myfolder/MyResponse.json?contentCache=true") + .to("jsonata:file://myfolder/MyResponse.json?contentCache=true&inputType=JsonString&outputType=JsonString") .to("activemq:Another.Queue"); ---- @@ -105,7 +110,7 @@ XML:: ---- - + ---- @@ -122,6 +127,8 @@ YAML:: uri: jsonata:file://myfolder/MyResponse.json parameters: contentCache: true + inputType: JsonString + outputType: JsonString - to: uri: activemq:Another.Queue ---- @@ -139,7 +146,7 @@ Java:: [source,java] ---- from("activemq:My.Queue") - .to("jsonata:file://myfolder/MyResponse.json?contentCache=true&frameBinding=#customBindings") + .to("jsonata:file://myfolder/MyResponse.json?contentCache=true&inputType=JsonString&outputType=JsonString&frameBinding=#customBindings") .to("activemq:Another.Queue"); ---- @@ -149,7 +156,7 @@ XML:: ---- - + ---- @@ -166,6 +173,8 @@ YAML:: uri: jsonata:file://myfolder/MyResponse.json parameters: contentCache: true + inputType: JsonString + outputType: JsonString frameBinding: "#customBindings" - to: uri: activemq:Another.Queue diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jte-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jte-component.adoc index 931e4edb15499..cab99fe672aab 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jte-component.adoc +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jte-component.adoc @@ -81,8 +81,8 @@ message header with the key "*CamelJteDataModel*" just like this Camel provides two headers by which you can define a different resource location for a template or the template content itself. If any of these -headers is set, then Camel uses this over the endpoint configured -resource. This allows you to provide a dynamic template at runtime. +headers is set, and the endpoint has `allowTemplateFromHeader=true`, then Camel uses this +over the endpoint configured resource. This allows you to provide a dynamic template at runtime. Each distinct template text from the `CamelJteTemplate` header is compiled once, and the compiled template is kept until the component stops. So the templates in this header should come from a small, known set. diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/mustache-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/mustache-component.adoc index 1b113bc0a779c..36dc6d306f5e2 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/mustache-component.adoc +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/mustache-component.adoc @@ -51,6 +51,8 @@ include::partial$component-endpoint-headers.adoc[] Camel will provide exchange information in the Mustache context (just a `Map`). The `Exchange` is transferred as: +The `body`, `header`, `headers`, `variable`, `variables` and `exception` entries are always +there; the others only when the endpoint has `allowContextMapAll=true`. [width="100%",cols="10%,90%",options="header",] |======================================================================= @@ -77,8 +79,8 @@ Camel will provide exchange information in the Mustache context (just a Camel provides two headers by which you can define a different resource location for a template or the template content itself. If any of these -headers is set, then Camel uses this over the endpoint configured -resource. This allows you to provide a dynamic template at runtime. +headers is set, and the endpoint has `allowTemplateFromHeader=true`, then Camel uses this +over the endpoint configured resource. This allows you to provide a dynamic template at runtime. == Examples diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/mvel-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/mvel-component.adoc index d20fdfc75d95c..b8709cd862d34 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/mvel-component.adoc +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/mvel-component.adoc @@ -51,6 +51,8 @@ include::partial$component-endpoint-headers.adoc[] Camel will provide exchange information in the MVEL context (just a `Map`). The `Exchange` is transferred as: +The `body`, `header`, `headers`, `variable`, `variables` and `exception` entries are always +there; the others only when the endpoint has `allowContextMapAll=true`. [width="100%",cols="10%m,90%",options="header",] |======================================================================= @@ -79,8 +81,8 @@ never changes. Camel provides two headers by which you can define a different resource location for a template, or the template content itself. If any of these -headers is set, then Camel uses this over the endpoint configured -resource. This allows you to provide a dynamic template at runtime. +headers is set, and the endpoint has `allowTemplateFromHeader=true`, then Camel uses this +over the endpoint configured resource. This allows you to provide a dynamic template at runtime. == Examples diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/string-template-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/string-template-component.adoc index 38ec47de2aa46..141e3bd68e05a 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/string-template-component.adoc +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/string-template-component.adoc @@ -51,14 +51,15 @@ include::partial$component-endpoint-headers.adoc[] === Headers -Camel will store a reference to the resource in the message header with -key, `org.apache.camel.stringtemplate.resource`. The Resource is an -`org.springframework.core.io.Resource` object. +Camel sets the uri of the template resource in the message header +`CamelStringTemplateResourceUri`. === String Template Context Camel will provide exchange information in the String Template context (just a `Map`). The `Exchange` is transferred as: +The `body`, `header`, `headers`, `variable`, `variables` and `exception` entries are always +there; the others only when the endpoint has `allowContextMapAll=true`. [width="100%",cols="10%,90%",options="header",] |======================================================================= @@ -92,8 +93,8 @@ This scenario can be used in production when the resource never changes. Camel provides two headers by which you can define a different resource location for a template or the template content itself. If any of these -headers is set, then Camel uses this over the endpoint configured -resource. This allows you to provide a dynamic template at runtime. +headers is set, and the endpoint has `allowTemplateFromHeader=true`, then Camel uses this +over the endpoint configured resource. This allows you to provide a dynamic template at runtime. === StringTemplate Attributes diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/thymeleaf-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/thymeleaf-component.adoc index ca557310b6369..4bcb723a06ab6 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/thymeleaf-component.adoc +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/thymeleaf-component.adoc @@ -66,6 +66,8 @@ The `fruit` header is now accessible from the `message.out.headers`. Camel will provide exchange information in the Thymeleaf context (just a `Map`). The `Exchange` is transferred as: +The `body`, `header`, `headers`, `variable`, `variables` and `exception` entries are always +there; the others only when the endpoint has `allowContextMapAll=true`. [width="100%",cols="10%,90%",options="header",] |======================================================================= @@ -90,14 +92,16 @@ The `Exchange` is transferred as: |`response` |The Out message (only for InOut message exchange pattern). |======================================================================= -You can set up a custom Thymeleaf Context yourself by -setting property `allowTemplateFromHeader=true` and setting the message header `CamelThymeleafContext` like this +You can add your own variables to the Thymeleaf context with a `Map` in the message header +`CamelThymeleafVariableMap`. Camel sets the `body`, `header`, `headers`, `variable`, `variables` and +`exception` entries on top of it, and removes the header after use: ._Java-only: programmatic Thymeleaf context setup via Exchange API_ [source,java] ---- -EngineContext engineContext = new EngineContext(variableMap); -exchange.getIn().setHeader("CamelThymeleafContext", engineContext); +Map variableMap = new HashMap<>(); +variableMap.put("greeting", "Hello"); +exchange.getIn().setHeader("CamelThymeleafVariableMap", variableMap); ---- === Hot reloading @@ -112,8 +116,8 @@ when the resource never changes. Camel provides two headers by which you can define a different resource location for a template or the template content itself. If any of these -headers is set, then Camel uses this over the endpoint configured -resource. This allows you to provide a dynamic template at runtime. +headers is set, and the endpoint has `allowTemplateFromHeader=true`, then Camel uses this +over the endpoint configured resource. This allows you to provide a dynamic template at runtime. [width="100%",cols="10%,10%,80%",options="header",] |======================================================================= diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/velocity-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/velocity-component.adoc index cb102bb2f991a..a215ef6531ae3 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/velocity-component.adoc +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/velocity-component.adoc @@ -67,6 +67,8 @@ The `fruit` header is now accessible from the `message.out.headers`. Camel will provide exchange information in the Velocity context (just a `Map`). The `Exchange` is transferred as: +The `body`, `header`, `headers`, `variable`, `variables` and `exception` entries are always +there; the others only when the endpoint has `allowContextMapAll=true`. [width="100%",cols="10%,90%",options="header",] |======================================================================= @@ -195,8 +197,8 @@ when the resource never changes. Camel provides two headers by which you can define a different resource location for a template or the template content itself. If any of these -headers is set, then Camel uses this over the endpoint configured -resource. This allows you to provide a dynamic template at runtime. +headers is set, and the endpoint has `allowTemplateFromHeader=true`, then Camel uses this +over the endpoint configured resource. This allows you to provide a dynamic template at runtime. [width="100%",cols="10%,10%,80%",options="header",] |======================================================================= diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/xquery-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/xquery-component.adoc index a2d941eb0734d..f4cf0dc56d870 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/xquery-component.adoc +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/xquery-component.adoc @@ -165,7 +165,7 @@ Notice how we can reuse the namespace prefixes, *foo* in this case, in the XPath expression for easier namespace-based XQuery expressions! When you use functions in your XQuery expression, you need an explicit -type conversion which is done in the xml configuration via the *@type* +type conversion which is done in the xml configuration via the *resultType* attribute: [source,xml] diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/mvel.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/mvel.json index 760f94c5c7fdc..6b133a1c347e9 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/mvel.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/mvel.json @@ -15,6 +15,10 @@ "modelName": "mvel", "modelJavaType": "org.apache.camel.model.language.MvelExpression" }, + "bodyTypes": { + "expressionIn": { "carriers": [ "any" ], "description": "The body as it is, in request.body or message.body: there is no variable body" }, + "expressionOut": { "carriers": [ "unknown" ], "description": "What the expression returns" } + }, "properties": { "id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node." }, "expression": { "index": 1, "kind": "value", "displayName": "Expression", "group": "common", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The expression value in your chosen language syntax." }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/xquery.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/xquery.json index 3bd82a8ede96b..f136ec5a42171 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/xquery.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/xquery.json @@ -15,6 +15,10 @@ "modelName": "xquery", "modelJavaType": "org.apache.camel.model.language.XQueryExpression" }, + "bodyTypes": { + "expressionIn": { "carriers": [ "text", "bytes", "stream", "file", "pojo" ], "format": "xml", "dependsOn": [ "source" ], "description": "XML as text, bytes, a stream or a file, or a DOM or another javax.xml.transform.Source. A Map or no body fails" }, + "expressionOut": { "carriers": [ "pojo" ], "javaType": "org.w3c.dom.Document", "dependsOn": [ "resultType" ], "description": "The result of the query as a DOM Document. A query that gives text, a number or more than one element fails unless resultType is java.lang.String" } + }, "properties": { "id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node." }, "expression": { "index": 1, "kind": "value", "displayName": "Expression", "group": "common", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The expression value in your chosen language syntax." }, diff --git a/components/camel-bean-validator/src/generated/resources/META-INF/org/apache/camel/component/bean/validator/bean-validator.json b/components/camel-bean-validator/src/generated/resources/META-INF/org/apache/camel/component/bean/validator/bean-validator.json index f7c5e0354c6ab..b90db05804387 100644 --- a/components/camel-bean-validator/src/generated/resources/META-INF/org/apache/camel/component/bean/validator/bean-validator.json +++ b/components/camel-bean-validator/src/generated/resources/META-INF/org/apache/camel/component/bean/validator/bean-validator.json @@ -33,6 +33,10 @@ "validationProviderResolver": { "index": 6, "kind": "property", "displayName": "Validation Provider Resolver", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "jakarta.validation.ValidationProviderResolver", "deprecated": false, "autowired": false, "secret": false, "description": "To use a a custom ValidationProviderResolver" }, "validatorFactory": { "index": 7, "kind": "property", "displayName": "Validator Factory", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "jakarta.validation.ValidatorFactory", "deprecated": false, "autowired": true, "secret": false, "description": "To use a custom ValidatorFactory" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "pojo", "list" ], "description": "A POJO with Jakarta Bean Validation constraints, or a List or another Iterable of them, each one validated. Text, a Map or an array has no constraints of its own and passes unchecked; no body fails" }, + "producerOut": { "carriers": [ "unchanged" ], "description": "Unchanged: a body that breaks a constraint fails with a BeanValidationException" } + }, "properties": { "label": { "index": 0, "kind": "path", "displayName": "Label", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Where label is an arbitrary text value describing the endpoint" }, "group": { "index": 1, "kind": "parameter", "displayName": "Group", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "jakarta.validation.groups.Default", "description": "To use a custom validation group" }, diff --git a/components/camel-bean-validator/src/main/java/org/apache/camel/component/bean/validator/BeanValidatorEndpoint.java b/components/camel-bean-validator/src/main/java/org/apache/camel/component/bean/validator/BeanValidatorEndpoint.java index 641fa9e14d6ad..250a5d9df32d1 100644 --- a/components/camel-bean-validator/src/main/java/org/apache/camel/component/bean/validator/BeanValidatorEndpoint.java +++ b/components/camel-bean-validator/src/main/java/org/apache/camel/component/bean/validator/BeanValidatorEndpoint.java @@ -27,6 +27,9 @@ import org.apache.camel.Consumer; import org.apache.camel.Processor; import org.apache.camel.Producer; +import org.apache.camel.spi.BodyType; +import org.apache.camel.spi.BodyType.Carrier; +import org.apache.camel.spi.BodyTypes; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; @@ -42,6 +45,13 @@ */ @UriEndpoint(firstVersion = "2.3.0", scheme = "bean-validator", title = "Bean Validator", syntax = "bean-validator:label", remote = false, producerOnly = true, category = { Category.VALIDATION }) +@BodyTypes(producerIn = @BodyType(value = { Carrier.POJO, Carrier.LIST }, + description = "A POJO with Jakarta Bean Validation constraints, or a List or another" + + " Iterable of them, each one validated. Text, a Map or an array has no" + + " constraints of its own and passes unchecked; no body fails"), + producerOut = @BodyType(value = Carrier.UNCHANGED, + description = "Unchanged: a body that breaks a constraint fails with a" + + " BeanValidationException")) public class BeanValidatorEndpoint extends DefaultEndpoint { @UriPath(description = "Where label is an arbitrary text value describing the endpoint") diff --git a/components/camel-chunk/src/generated/resources/META-INF/org/apache/camel/component/chunk/chunk.json b/components/camel-chunk/src/generated/resources/META-INF/org/apache/camel/component/chunk/chunk.json index edf6b67d18cb2..ae08f3605556d 100644 --- a/components/camel-chunk/src/generated/resources/META-INF/org/apache/camel/component/chunk/chunk.json +++ b/components/camel-chunk/src/generated/resources/META-INF/org/apache/camel/component/chunk/chunk.json @@ -34,6 +34,10 @@ "CamelChunkResourceUri": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A URI for the template resource to use instead of the endpoint configured.", "constantName": "org.apache.camel.component.chunk.ChunkConstants#CHUNK_RESOURCE_URI" }, "CamelChunkTemplate": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The template to use instead of the endpoint configured.", "constantName": "org.apache.camel.component.chunk.ChunkConstants#CHUNK_TEMPLATE" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "any" ], "description": "The template gets the body as {$body}, as it is: text, or a Map, a List or a POJO to read from; no body prints as empty text, and bytes or a stream are not read as text. The template is the resource, or the CamelChunkTemplate header with allowTemplateFromHeader=true, never the body" }, + "producerOut": { "carriers": [ "text" ], "javaType": "java.lang.String", "description": "The text the template writes. The headers are kept" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/components/camel-chunk/src/main/docs/chunk-component.adoc b/components/camel-chunk/src/main/docs/chunk-component.adoc index 09378c38b3165..7eded1be94874 100644 --- a/components/camel-chunk/src/main/docs/chunk-component.adoc +++ b/components/camel-chunk/src/main/docs/chunk-component.adoc @@ -48,6 +48,8 @@ above. Camel will provide exchange information in the Chunk context (just a `Map`). The `Exchange` is transferred as: +The `body`, `header`, `headers`, `variable`, `variables` and `exception` entries are always +there; the others only when the endpoint has `allowContextMapAll=true`. [width="100%",cols="20%,80%",options="header",] @@ -75,8 +77,8 @@ a `Map`). The `Exchange` is transferred as: Camel provides two headers by which you can define a different resource location for a template or the template content itself. If any of these -headers is set, then Camel uses this over the endpoint configured -resource. This allows you to provide a dynamic template at runtime. +headers is set, and the endpoint has `allowTemplateFromHeader=true`, then Camel uses this +over the endpoint configured resource. This allows you to provide a dynamic template at runtime. == Examples diff --git a/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkEndpoint.java b/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkEndpoint.java index 701c2303acc40..197e143640800 100644 --- a/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkEndpoint.java +++ b/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkEndpoint.java @@ -36,6 +36,9 @@ import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; import org.apache.camel.component.ResourceEndpoint; +import org.apache.camel.spi.BodyType; +import org.apache.camel.spi.BodyType.Carrier; +import org.apache.camel.spi.BodyTypes; import org.apache.camel.spi.HeadersMapFactory; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; @@ -54,6 +57,14 @@ */ @UriEndpoint(firstVersion = "2.15.0", scheme = "chunk", title = "Chunk", syntax = "chunk:resourceUri", producerOnly = true, remote = false, category = { Category.TRANSFORMATION }, headersClass = ChunkConstants.class) +@BodyTypes(producerIn = @BodyType(value = Carrier.ANY, + description = "The template gets the body as {$body}, as it is: text, or a Map, a List or a" + + " POJO to read from; no body prints as empty text, and bytes or a stream" + + " are not read as text. The template is the resource, or the" + + " CamelChunkTemplate header with allowTemplateFromHeader=true, never the" + + " body"), + producerOut = @BodyType(value = Carrier.TEXT, javaType = "java.lang.String", + description = "The text the template writes. The headers are kept")) public class ChunkEndpoint extends ResourceEndpoint { private Theme theme; diff --git a/components/camel-freemarker/src/generated/resources/META-INF/org/apache/camel/component/freemarker/freemarker.json b/components/camel-freemarker/src/generated/resources/META-INF/org/apache/camel/component/freemarker/freemarker.json index 3075b7efead38..a0f18e467cb59 100644 --- a/components/camel-freemarker/src/generated/resources/META-INF/org/apache/camel/component/freemarker/freemarker.json +++ b/components/camel-freemarker/src/generated/resources/META-INF/org/apache/camel/component/freemarker/freemarker.json @@ -37,6 +37,10 @@ "CamelFreemarkerTemplate": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The template to use instead of the endpoint configured.", "constantName": "org.apache.camel.component.freemarker.FreemarkerConstants#FREEMARKER_TEMPLATE" }, "CamelFreemarkerDataModel": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Object", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The data model", "constantName": "org.apache.camel.component.freemarker.FreemarkerConstants#FREEMARKER_DATA_MODEL" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "any" ], "description": "The template gets the body as body, as it is: text, or a Map, a List or a POJO to read from; convert bytes or a stream to a String first, and no body fails ${body} unless it is written ${body!}. The template is the resource, or the CamelFreemarkerTemplate or CamelFreemarkerResourceUri header with allowTemplateFromHeader=true, and never the body" }, + "producerOut": { "carriers": [ "text" ], "javaType": "java.lang.String", "description": "The text the template writes, also when it is JSON or XML: unmarshal it to read its fields. The headers are kept" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/components/camel-freemarker/src/main/docs/freemarker-component.adoc b/components/camel-freemarker/src/main/docs/freemarker-component.adoc index fe794292497d3..f92f067cbfc27 100644 --- a/components/camel-freemarker/src/main/docs/freemarker-component.adoc +++ b/components/camel-freemarker/src/main/docs/freemarker-component.adoc @@ -66,6 +66,8 @@ The header, `fruit`, is now accessible from the `message.out.headers`. Camel will provide exchange information in the FreeMarker context (just a `Map`). The `Exchange` is transferred as: +The `body`, `header`, `headers`, `variable`, `variables` and `exception` entries are always +there; the others only when the endpoint has `allowContextMapAll=true`. [width="100%",cols="50%,50%",options="header",] |======================================================================= @@ -112,8 +114,8 @@ reloading is thus enabled. This scenario can be used in development. Camel provides two headers by which you can define a different resource location for a template or the template content itself. If any of these -headers is set, then Camel uses this over the endpoint configured -resource. This allows you to provide a dynamic template at runtime. +headers is set, and the endpoint has `allowTemplateFromHeader=true`, then Camel uses this +over the endpoint configured resource. This allows you to provide a dynamic template at runtime. == Examples @@ -288,7 +290,7 @@ Java:: [source,java] ---- from("direct:in") - .setHeader("FreemarkerResourceUri").constant("path/to/my/template.ftl") + .setHeader("CamelFreemarkerResourceUri").constant("path/to/my/template.ftl") .to("freemarker:dummy?allowTemplateFromHeader=true"); ---- @@ -298,7 +300,7 @@ XML:: ---- - + path/to/my/template.ftl @@ -314,7 +316,7 @@ YAML:: uri: direct:in steps: - setHeader: - name: FreemarkerResourceUri + name: CamelFreemarkerResourceUri expression: constant: expression: path/to/my/template.ftl diff --git a/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerEndpoint.java b/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerEndpoint.java index ab38072722161..c8d7b4b486745 100644 --- a/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerEndpoint.java +++ b/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerEndpoint.java @@ -28,6 +28,9 @@ import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; import org.apache.camel.component.ResourceEndpoint; +import org.apache.camel.spi.BodyType; +import org.apache.camel.spi.BodyType.Carrier; +import org.apache.camel.spi.BodyTypes; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; import org.apache.camel.support.ExchangeHelper; @@ -40,6 +43,15 @@ @UriEndpoint(firstVersion = "2.10.0", scheme = "freemarker", title = "Freemarker", syntax = "freemarker:resourceUri", remote = false, producerOnly = true, category = { Category.TRANSFORMATION }, headersClass = FreemarkerConstants.class) +@BodyTypes(producerIn = @BodyType(value = Carrier.ANY, + description = "The template gets the body as body, as it is: text, or a Map, a List or a" + + " POJO to read from; convert bytes or a stream to a String first, and no" + + " body fails ${body} unless it is written ${body!}. The template is the" + + " resource, or the CamelFreemarkerTemplate or CamelFreemarkerResourceUri" + + " header with allowTemplateFromHeader=true, and never the body"), + producerOut = @BodyType(value = Carrier.TEXT, javaType = "java.lang.String", + description = "The text the template writes, also when it is JSON or XML: unmarshal it to" + + " read its fields. The headers are kept")) public class FreemarkerEndpoint extends ResourceEndpoint { @UriParam(defaultValue = "false") diff --git a/components/camel-jolt/src/generated/resources/META-INF/org/apache/camel/component/jolt/jolt.json b/components/camel-jolt/src/generated/resources/META-INF/org/apache/camel/component/jolt/jolt.json index 4f7c8a6e3cec9..0638b27c7f26a 100644 --- a/components/camel-jolt/src/generated/resources/META-INF/org/apache/camel/component/jolt/jolt.json +++ b/components/camel-jolt/src/generated/resources/META-INF/org/apache/camel/component/jolt/jolt.json @@ -34,6 +34,10 @@ "CamelJoltResourceUri": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The resource URI", "constantName": "org.apache.camel.component.jolt.JoltConstants#JOLT_RESOURCE_URI" }, "CamelJoltContext": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Map", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The context", "constantName": "org.apache.camel.component.jolt.JoltConstants#JOLT_CONTEXT" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "map", "list" ], "format": "json", "byOption": [ { "option": "inputType", "value": "JsonString", "carriers": [ "text", "bytes", "stream", "file" ] } ], "description": "Parsed JSON: a Map or a List. JSON as text, bytes, a stream or a file needs inputType=JsonString: without it the body reaches the spec unparsed, and the result is most likely null" }, + "producerOut": { "carriers": [ "map", "list" ], "format": "json", "byOption": [ { "option": "outputType", "value": "JsonString", "carriers": [ "text" ], "javaType": "java.lang.String" } ], "description": "The JSON the spec makes: a Map for an object, a List for an array; JSON text with outputType=JsonString" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowTemplateFromHeader": { "index": 1, "kind": "parameter", "displayName": "Allow Template From Header", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care." }, diff --git a/components/camel-jolt/src/main/docs/jolt-component.adoc b/components/camel-jolt/src/main/docs/jolt-component.adoc index 7377730c0f55d..dde30f7c2cfa4 100644 --- a/components/camel-jolt/src/main/docs/jolt-component.adoc +++ b/components/camel-jolt/src/main/docs/jolt-component.adoc @@ -52,6 +52,8 @@ include::partial$component-endpoint-headers.adoc[] For example, you could use something like +The messages of the queue are JSON text, so the examples set `inputType` and `outputType` to `JsonString`: with the default, `Hydrated`, the body must be parsed JSON (a Map or a List), such as after `unmarshal: json`, and the result is parsed JSON too. + [tabs] ==== Java:: @@ -59,7 +61,7 @@ Java:: [source,java] ---- from("activemq:My.Queue") - .to("jolt:com/acme/MyResponse.json"); + .to("jolt:com/acme/MyResponse.json?inputType=JsonString&outputType=JsonString"); ---- XML:: @@ -68,7 +70,7 @@ XML:: ---- - + ---- @@ -82,6 +84,9 @@ YAML:: steps: - to: uri: jolt:com/acme/MyResponse.json + parameters: + inputType: JsonString + outputType: JsonString ---- ==== @@ -94,7 +99,7 @@ Java:: [source,java] ---- from("activemq:My.Queue") - .to("jolt:file://myfolder/MyResponse.json?contentCache=true") + .to("jolt:file://myfolder/MyResponse.json?contentCache=true&inputType=JsonString&outputType=JsonString") .to("activemq:Another.Queue"); ---- @@ -104,7 +109,7 @@ XML:: ---- - + ---- @@ -121,6 +126,8 @@ YAML:: uri: jolt:file://myfolder/MyResponse.json parameters: contentCache: true + inputType: JsonString + outputType: JsonString - to: uri: activemq:Another.Queue ---- diff --git a/components/camel-jolt/src/main/java/org/apache/camel/component/jolt/JoltEndpoint.java b/components/camel-jolt/src/main/java/org/apache/camel/component/jolt/JoltEndpoint.java index b5c4a65a0bf8e..bc8a1b855006a 100644 --- a/components/camel-jolt/src/main/java/org/apache/camel/component/jolt/JoltEndpoint.java +++ b/components/camel-jolt/src/main/java/org/apache/camel/component/jolt/JoltEndpoint.java @@ -32,6 +32,9 @@ import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; import org.apache.camel.component.ResourceEndpoint; +import org.apache.camel.spi.BodyType; +import org.apache.camel.spi.BodyType.Carrier; +import org.apache.camel.spi.BodyTypes; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; @@ -44,6 +47,19 @@ @UriEndpoint(firstVersion = "2.16.0", scheme = "jolt", title = "JOLT", syntax = "jolt:resourceUri", producerOnly = true, remote = false, category = { Category.TRANSFORMATION }, headersClass = JoltConstants.class) @Metadata(excludeProperties = "allowContextMapAll") +@BodyTypes(producerIn = @BodyType(value = { Carrier.MAP, Carrier.LIST }, format = "json", + byOption = @BodyType.When(option = "inputType", value = "JsonString", + carriers = { + Carrier.TEXT, Carrier.BYTES, Carrier.STREAM, + Carrier.FILE }), + description = "Parsed JSON: a Map or a List. JSON as text, bytes, a stream or a file needs" + + " inputType=JsonString: without it the body reaches the spec unparsed, and" + + " the result is most likely null"), + producerOut = @BodyType(value = { Carrier.MAP, Carrier.LIST }, format = "json", + byOption = @BodyType.When(option = "outputType", value = "JsonString", + carriers = Carrier.TEXT, javaType = "java.lang.String"), + description = "The JSON the spec makes: a Map for an object, a List for an array; JSON text" + + " with outputType=JsonString")) public class JoltEndpoint extends ResourceEndpoint { private JoltTransform transform; diff --git a/components/camel-jslt/src/generated/resources/META-INF/org/apache/camel/component/jslt/jslt.json b/components/camel-jslt/src/generated/resources/META-INF/org/apache/camel/component/jslt/jslt.json index a82c39b84d52c..d60f5f1e048d2 100644 --- a/components/camel-jslt/src/generated/resources/META-INF/org/apache/camel/component/jslt/jslt.json +++ b/components/camel-jslt/src/generated/resources/META-INF/org/apache/camel/component/jslt/jslt.json @@ -35,6 +35,10 @@ "CamelJsltString": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The JSLT Template as String", "constantName": "org.apache.camel.component.jslt.JsltConstants#HEADER_JSLT_STRING" }, "CamelJsltResourceUri": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The resource URI", "constantName": "org.apache.camel.component.jslt.JsltConstants#HEADER_JSLT_RESOURCE_URI" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "text", "bytes", "stream", "file" ], "format": "json", "description": "JSON as text, bytes, a stream, a Reader or a java.io.File, such as the file of the file consumer. A Map, a List, a JsonNode or no body fails: marshal parsed JSON first" }, + "producerOut": { "carriers": [ "text" ], "javaType": "java.lang.String", "format": "json", "description": "The result as JSON text, pretty printed with prettyPrint=true" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/components/camel-jslt/src/main/java/org/apache/camel/component/jslt/JsltEndpoint.java b/components/camel-jslt/src/main/java/org/apache/camel/component/jslt/JsltEndpoint.java index 3ca8c381dcc5b..6013f97bf94a8 100644 --- a/components/camel-jslt/src/main/java/org/apache/camel/component/jslt/JsltEndpoint.java +++ b/components/camel-jslt/src/main/java/org/apache/camel/component/jslt/JsltEndpoint.java @@ -51,6 +51,9 @@ import org.apache.camel.ValidationException; import org.apache.camel.WrappedFile; import org.apache.camel.component.ResourceEndpoint; +import org.apache.camel.spi.BodyType; +import org.apache.camel.spi.BodyType.Carrier; +import org.apache.camel.spi.BodyTypes; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; import org.apache.camel.support.ExchangeHelper; @@ -63,6 +66,12 @@ */ @UriEndpoint(firstVersion = "3.1.0", scheme = "jslt", title = "JSLT", syntax = "jslt:resourceUri", producerOnly = true, remote = false, category = { Category.TRANSFORMATION }, headersClass = JsltConstants.class) +@BodyTypes(producerIn = @BodyType(value = { Carrier.TEXT, Carrier.BYTES, Carrier.STREAM, Carrier.FILE }, format = "json", + description = "JSON as text, bytes, a stream, a Reader or a java.io.File, such as the file of" + + " the file consumer. A Map, a List, a JsonNode or no body fails: marshal" + + " parsed JSON first"), + producerOut = @BodyType(value = Carrier.TEXT, javaType = "java.lang.String", format = "json", + description = "The result as JSON text, pretty printed with prettyPrint=true")) public class JsltEndpoint extends ResourceEndpoint { private static final ObjectMapper OBJECT_MAPPER; diff --git a/components/camel-json-validator/src/generated/resources/META-INF/org/apache/camel/component/jsonvalidator/json-validator.json b/components/camel-json-validator/src/generated/resources/META-INF/org/apache/camel/component/jsonvalidator/json-validator.json index 48155c275cff2..ab867f3969f7e 100644 --- a/components/camel-json-validator/src/generated/resources/META-INF/org/apache/camel/component/jsonvalidator/json-validator.json +++ b/components/camel-json-validator/src/generated/resources/META-INF/org/apache/camel/component/jsonvalidator/json-validator.json @@ -30,6 +30,10 @@ "autowiredEnabled": { "index": 3, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc." }, "objectMapper": { "index": 4, "kind": "property", "displayName": "Object Mapper", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Lookup and use the existing ObjectMapper with the given id." } }, + "bodyTypes": { + "producerIn": { "carriers": [ "text", "bytes", "stream", "file" ], "format": "json", "dependsOn": [ "headerName" ], "byOption": [ { "option": "failOnNullBody", "value": "false", "carriers": [ "null", "text", "bytes", "stream", "file" ] } ], "description": "The JSON to validate: text, bytes, a stream or a file. A Map, a POJO or no body fails: marshal it first; with headerName the header is validated instead" }, + "producerOut": { "carriers": [ "unchanged" ], "description": "Unchanged: JSON that does not match the schema, or text that is not JSON, fails with a JsonValidationException" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/components/camel-json-validator/src/main/docs/json-validator-component.adoc b/components/camel-json-validator/src/main/docs/json-validator-component.adoc index 18312b8a150c5..6cda6ee33d6be 100644 --- a/components/camel-json-validator/src/main/docs/json-validator-component.adoc +++ b/components/camel-json-validator/src/main/docs/json-validator-component.adoc @@ -12,7 +12,7 @@ *{component-header}* -The JSON Schema Validator component performs bean validation of the message body +The JSON Schema Validator component validates the JSON in the message body against JSON Schemas v4, v6, v7, v2019-09 draft and v2020-12(partial) using the NetworkNT JSON Schema library (https://github.com/networknt/json-schema-validator). diff --git a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidatorEndpoint.java b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidatorEndpoint.java index 44713220763d3..68d8f80b72437 100644 --- a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidatorEndpoint.java +++ b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidatorEndpoint.java @@ -33,6 +33,9 @@ import org.apache.camel.ValidationException; import org.apache.camel.api.management.ManagedResource; import org.apache.camel.component.ResourceEndpoint; +import org.apache.camel.spi.BodyType; +import org.apache.camel.spi.BodyType.Carrier; +import org.apache.camel.spi.BodyTypes; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; @@ -43,6 +46,18 @@ @UriEndpoint(scheme = "json-validator", firstVersion = "2.20.0", title = "JSON Schema Validator", syntax = "json-validator:resourceUri", remote = false, producerOnly = true, category = { Category.VALIDATION }) +@BodyTypes(producerIn = @BodyType(value = { Carrier.TEXT, Carrier.BYTES, Carrier.STREAM, Carrier.FILE }, + format = "json", dependsOn = "headerName", + byOption = @BodyType.When(option = "failOnNullBody", value = "false", + carriers = { + Carrier.NULL, Carrier.TEXT, Carrier.BYTES, + Carrier.STREAM, Carrier.FILE }), + description = "The JSON to validate: text, bytes, a stream or a file. A Map, a POJO or no" + + " body fails: marshal it first; with headerName the header is validated" + + " instead"), + producerOut = @BodyType(value = Carrier.UNCHANGED, + description = "Unchanged: JSON that does not match the schema, or text that is not JSON," + + " fails with a JsonValidationException")) public class JsonValidatorEndpoint extends ResourceEndpoint { private volatile Schema schema; diff --git a/components/camel-jsonata/src/generated/resources/META-INF/org/apache/camel/component/jsonata/jsonata.json b/components/camel-jsonata/src/generated/resources/META-INF/org/apache/camel/component/jsonata/jsonata.json index d6de7d1584da8..72d92ea7c5c85 100644 --- a/components/camel-jsonata/src/generated/resources/META-INF/org/apache/camel/component/jsonata/jsonata.json +++ b/components/camel-jsonata/src/generated/resources/META-INF/org/apache/camel/component/jsonata/jsonata.json @@ -30,6 +30,10 @@ "autowiredEnabled": { "index": 3, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc." }, "frameBinding": { "index": 4, "kind": "property", "displayName": "Frame Binding", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.jsonata.JsonataFrameBinding", "deprecated": false, "autowired": false, "secret": false, "description": "To configure custom frame bindings and inject user functions." } }, + "bodyTypes": { + "producerIn": { "carriers": [ "map", "list", "pojo" ], "format": "json", "byOption": [ { "option": "inputType", "value": "JsonString", "carriers": [ "text", "bytes", "stream", "file" ] } ], "description": "JSON data: a Map, a List, a JsonNode or another object Jackson converts. JSON as text, bytes, a stream or a file needs inputType=JsonString: without it text is read as one JSON string, and bytes or a stream fail" }, + "producerOut": { "carriers": [ "pojo" ], "javaType": "com.fasterxml.jackson.databind.JsonNode", "format": "json", "byOption": [ { "option": "outputType", "value": "JsonString", "carriers": [ "text" ], "javaType": "java.lang.String" } ], "description": "The result as a Jackson JsonNode, or as JSON text with outputType=JsonString" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/components/camel-jsonata/src/main/docs/jsonata-component.adoc b/components/camel-jsonata/src/main/docs/jsonata-component.adoc index 389d7c0763c72..8a8eaf2279a16 100644 --- a/components/camel-jsonata/src/main/docs/jsonata-component.adoc +++ b/components/camel-jsonata/src/main/docs/jsonata-component.adoc @@ -53,6 +53,8 @@ include::partial$component-endpoint-headers.adoc[] For example, you could use something like: +The messages of the queue are JSON text, so the examples set `inputType` and `outputType` to `JsonString`: with the default, `Jackson`, the body must be JSON data (a Map, a List or a JsonNode), such as after `unmarshal: json`, and the result is a JsonNode. + [tabs] ==== Java:: @@ -60,7 +62,7 @@ Java:: [source,java] ---- from("activemq:My.Queue") - .to("jsonata:com/acme/MyResponse.json"); + .to("jsonata:com/acme/MyResponse.json?inputType=JsonString&outputType=JsonString"); ---- XML:: @@ -69,7 +71,7 @@ XML:: ---- - + ---- @@ -83,6 +85,9 @@ YAML:: steps: - to: uri: jsonata:com/acme/MyResponse.json + parameters: + inputType: JsonString + outputType: JsonString ---- ==== @@ -95,7 +100,7 @@ Java:: [source,java] ---- from("activemq:My.Queue") - .to("jsonata:file://myfolder/MyResponse.json?contentCache=true") + .to("jsonata:file://myfolder/MyResponse.json?contentCache=true&inputType=JsonString&outputType=JsonString") .to("activemq:Another.Queue"); ---- @@ -105,7 +110,7 @@ XML:: ---- - + ---- @@ -122,6 +127,8 @@ YAML:: uri: jsonata:file://myfolder/MyResponse.json parameters: contentCache: true + inputType: JsonString + outputType: JsonString - to: uri: activemq:Another.Queue ---- @@ -139,7 +146,7 @@ Java:: [source,java] ---- from("activemq:My.Queue") - .to("jsonata:file://myfolder/MyResponse.json?contentCache=true&frameBinding=#customBindings") + .to("jsonata:file://myfolder/MyResponse.json?contentCache=true&inputType=JsonString&outputType=JsonString&frameBinding=#customBindings") .to("activemq:Another.Queue"); ---- @@ -149,7 +156,7 @@ XML:: ---- - + ---- @@ -166,6 +173,8 @@ YAML:: uri: jsonata:file://myfolder/MyResponse.json parameters: contentCache: true + inputType: JsonString + outputType: JsonString frameBinding: "#customBindings" - to: uri: activemq:Another.Queue diff --git a/components/camel-jsonata/src/main/java/org/apache/camel/component/jsonata/JsonataEndpoint.java b/components/camel-jsonata/src/main/java/org/apache/camel/component/jsonata/JsonataEndpoint.java index 03e05b49a693f..5d3456e8955cd 100644 --- a/components/camel-jsonata/src/main/java/org/apache/camel/component/jsonata/JsonataEndpoint.java +++ b/components/camel-jsonata/src/main/java/org/apache/camel/component/jsonata/JsonataEndpoint.java @@ -29,6 +29,9 @@ import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; import org.apache.camel.component.ResourceEndpoint; +import org.apache.camel.spi.BodyType; +import org.apache.camel.spi.BodyType.Carrier; +import org.apache.camel.spi.BodyTypes; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; import org.apache.camel.support.ExchangeHelper; @@ -43,6 +46,20 @@ @UriEndpoint(firstVersion = "3.5.0", scheme = "jsonata", title = "JSONata", syntax = "jsonata:resourceUri", producerOnly = true, remote = false, category = { Category.TRANSFORMATION }) +@BodyTypes(producerIn = @BodyType(value = { Carrier.MAP, Carrier.LIST, Carrier.POJO }, format = "json", + byOption = @BodyType.When(option = "inputType", value = "JsonString", + carriers = { + Carrier.TEXT, Carrier.BYTES, Carrier.STREAM, + Carrier.FILE }), + description = "JSON data: a Map, a List, a JsonNode or another object Jackson converts. JSON" + + " as text, bytes, a stream or a file needs inputType=JsonString: without it" + + " text is read as one JSON string, and bytes or a stream fail"), + producerOut = @BodyType(value = Carrier.POJO, javaType = "com.fasterxml.jackson.databind.JsonNode", + format = "json", + byOption = @BodyType.When(option = "outputType", value = "JsonString", + carriers = Carrier.TEXT, javaType = "java.lang.String"), + description = "The result as a Jackson JsonNode, or as JSON text with" + + " outputType=JsonString")) public class JsonataEndpoint extends ResourceEndpoint { private final ObjectMapper mapper = new ObjectMapper(); diff --git a/components/camel-jte/src/generated/resources/META-INF/org/apache/camel/component/jte/jte.json b/components/camel-jte/src/generated/resources/META-INF/org/apache/camel/component/jte/jte.json index 1d04e8d7d1d21..cfc4c8d5b8aff 100644 --- a/components/camel-jte/src/generated/resources/META-INF/org/apache/camel/component/jte/jte.json +++ b/components/camel-jte/src/generated/resources/META-INF/org/apache/camel/component/jte/jte.json @@ -38,6 +38,10 @@ "CamelJteTemplate": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The template to use instead of the endpoint configured.", "constantName": "org.apache.camel.component.jte.JteConstants#JTE_TEMPLATE" }, "CamelJteDataModel": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Object", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The data model", "constantName": "org.apache.camel.component.jte.JteConstants#JTE_DATA_MODEL" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "any" ], "description": "The template takes an org.apache.camel.component.jte.Model: the body as it is in model.body, and converted to text by model.strBody(). With allowTemplateFromHeader=true the CamelJteDataModel header replaces the model" }, + "producerOut": { "carriers": [ "text" ], "javaType": "java.lang.String", "description": "The text the template writes, with leading and trailing whitespace trimmed. The headers are kept" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/components/camel-jte/src/main/docs/jte-component.adoc b/components/camel-jte/src/main/docs/jte-component.adoc index 931e4edb15499..cab99fe672aab 100644 --- a/components/camel-jte/src/main/docs/jte-component.adoc +++ b/components/camel-jte/src/main/docs/jte-component.adoc @@ -81,8 +81,8 @@ message header with the key "*CamelJteDataModel*" just like this Camel provides two headers by which you can define a different resource location for a template or the template content itself. If any of these -headers is set, then Camel uses this over the endpoint configured -resource. This allows you to provide a dynamic template at runtime. +headers is set, and the endpoint has `allowTemplateFromHeader=true`, then Camel uses this +over the endpoint configured resource. This allows you to provide a dynamic template at runtime. Each distinct template text from the `CamelJteTemplate` header is compiled once, and the compiled template is kept until the component stops. So the templates in this header should come from a small, known set. diff --git a/components/camel-jte/src/main/java/org/apache/camel/component/jte/JteEndpoint.java b/components/camel-jte/src/main/java/org/apache/camel/component/jte/JteEndpoint.java index 6a7113daa693b..b9483a7d61807 100644 --- a/components/camel-jte/src/main/java/org/apache/camel/component/jte/JteEndpoint.java +++ b/components/camel-jte/src/main/java/org/apache/camel/component/jte/JteEndpoint.java @@ -28,6 +28,9 @@ import org.apache.camel.Component; import org.apache.camel.Exchange; import org.apache.camel.component.ResourceEndpoint; +import org.apache.camel.spi.BodyType; +import org.apache.camel.spi.BodyType.Carrier; +import org.apache.camel.spi.BodyTypes; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; import org.apache.camel.support.ExchangeHelper; @@ -40,6 +43,14 @@ */ @UriEndpoint(firstVersion = "4.4.0", scheme = "jte", title = "JTE", syntax = "jte:resourceUri", remote = false, producerOnly = true, category = { Category.TRANSFORMATION }, headersClass = JteConstants.class) +@BodyTypes(producerIn = @BodyType(value = Carrier.ANY, + description = "The template takes an org.apache.camel.component.jte.Model: the body as it is" + + " in model.body, and converted to text by model.strBody(). With" + + " allowTemplateFromHeader=true the CamelJteDataModel header replaces the" + + " model"), + producerOut = @BodyType(value = Carrier.TEXT, javaType = "java.lang.String", + description = "The text the template writes, with leading and trailing whitespace trimmed." + + " The headers are kept")) public class JteEndpoint extends ResourceEndpoint { @UriParam diff --git a/components/camel-mustache/src/generated/resources/META-INF/org/apache/camel/component/mustache/mustache.json b/components/camel-mustache/src/generated/resources/META-INF/org/apache/camel/component/mustache/mustache.json index 97ba41b8eb31f..1ac15dcc8b4ad 100644 --- a/components/camel-mustache/src/generated/resources/META-INF/org/apache/camel/component/mustache/mustache.json +++ b/components/camel-mustache/src/generated/resources/META-INF/org/apache/camel/component/mustache/mustache.json @@ -35,6 +35,10 @@ "CamelMustacheResourceUri": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A URI for the template resource to use instead of the endpoint.", "constantName": "org.apache.camel.component.mustache.MustacheConstants#MUSTACHE_RESOURCE_URI" }, "CamelMustacheTemplate": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The template to use instead of the endpoint configured.", "constantName": "org.apache.camel.component.mustache.MustacheConstants#MUSTACHE_TEMPLATE" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "any" ], "description": "The template gets the body as body, as it is: text, or a Map, a List or a POJO to read from; convert bytes or a stream to a String first. The template is the resource, or the CamelMustacheTemplate or CamelMustacheResourceUri header with allowTemplateFromHeader=true, and never the body" }, + "producerOut": { "carriers": [ "text" ], "javaType": "java.lang.String", "description": "The text the template writes, also when it is JSON: unmarshal it to read its fields. Values in double braces are HTML-escaped, in triple braces as they are. The headers are kept" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/components/camel-mustache/src/main/docs/mustache-component.adoc b/components/camel-mustache/src/main/docs/mustache-component.adoc index 1b113bc0a779c..36dc6d306f5e2 100644 --- a/components/camel-mustache/src/main/docs/mustache-component.adoc +++ b/components/camel-mustache/src/main/docs/mustache-component.adoc @@ -51,6 +51,8 @@ include::partial$component-endpoint-headers.adoc[] Camel will provide exchange information in the Mustache context (just a `Map`). The `Exchange` is transferred as: +The `body`, `header`, `headers`, `variable`, `variables` and `exception` entries are always +there; the others only when the endpoint has `allowContextMapAll=true`. [width="100%",cols="10%,90%",options="header",] |======================================================================= @@ -77,8 +79,8 @@ Camel will provide exchange information in the Mustache context (just a Camel provides two headers by which you can define a different resource location for a template or the template content itself. If any of these -headers is set, then Camel uses this over the endpoint configured -resource. This allows you to provide a dynamic template at runtime. +headers is set, and the endpoint has `allowTemplateFromHeader=true`, then Camel uses this +over the endpoint configured resource. This allows you to provide a dynamic template at runtime. == Examples diff --git a/components/camel-mustache/src/main/java/org/apache/camel/component/mustache/MustacheEndpoint.java b/components/camel-mustache/src/main/java/org/apache/camel/component/mustache/MustacheEndpoint.java index 83d351081f432..7417f9a9f7c91 100644 --- a/components/camel-mustache/src/main/java/org/apache/camel/component/mustache/MustacheEndpoint.java +++ b/components/camel-mustache/src/main/java/org/apache/camel/component/mustache/MustacheEndpoint.java @@ -31,6 +31,9 @@ import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; import org.apache.camel.component.ResourceEndpoint; +import org.apache.camel.spi.BodyType; +import org.apache.camel.spi.BodyType.Carrier; +import org.apache.camel.spi.BodyTypes; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; import org.apache.camel.support.ExchangeHelper; @@ -45,6 +48,16 @@ @UriEndpoint(firstVersion = "2.12.0", scheme = "mustache", title = "Mustache", syntax = "mustache:resourceUri", remote = false, producerOnly = true, category = { Category.TRANSFORMATION }, headersClass = MustacheConstants.class) +@BodyTypes(producerIn = @BodyType(value = Carrier.ANY, + description = "The template gets the body as body, as it is: text, or a Map, a List or a" + + " POJO to read from; convert bytes or a stream to a String first. The" + + " template is the resource, or the CamelMustacheTemplate or" + + " CamelMustacheResourceUri header with allowTemplateFromHeader=true, and" + + " never the body"), + producerOut = @BodyType(value = Carrier.TEXT, javaType = "java.lang.String", + description = "The text the template writes, also when it is JSON: unmarshal it to read its" + + " fields. Values in double braces are HTML-escaped, in triple braces as they" + + " are. The headers are kept")) public class MustacheEndpoint extends ResourceEndpoint { private MustacheFactory mustacheFactory; diff --git a/components/camel-mvel/src/generated/resources/META-INF/org/apache/camel/component/mvel/mvel.json b/components/camel-mvel/src/generated/resources/META-INF/org/apache/camel/component/mvel/mvel.json index 7ae1971429a6c..e66b1e10b7cf8 100644 --- a/components/camel-mvel/src/generated/resources/META-INF/org/apache/camel/component/mvel/mvel.json +++ b/components/camel-mvel/src/generated/resources/META-INF/org/apache/camel/component/mvel/mvel.json @@ -34,6 +34,10 @@ "CamelMvelResourceUri": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A URI for the template resource to use instead of the endpoint configured.", "constantName": "org.apache.camel.component.mvel.MvelConstants#MVEL_RESOURCE_URI" }, "CamelMvelTemplate": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The template to use instead of the endpoint configured.", "constantName": "org.apache.camel.component.mvel.MvelConstants#MVEL_TEMPLATE" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "any" ], "description": "The template gets the body as body, as it is: no body prints as null, and bytes or a stream are not read as text. The template is the resource, or the CamelMvelTemplate header with allowTemplateFromHeader=true, never the body" }, + "producerOut": { "carriers": [ "text" ], "javaType": "java.lang.String", "description": "The text the template writes. The headers are kept" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/components/camel-mvel/src/generated/resources/META-INF/org/apache/camel/language/mvel/mvel.json b/components/camel-mvel/src/generated/resources/META-INF/org/apache/camel/language/mvel/mvel.json index 760f94c5c7fdc..6b133a1c347e9 100644 --- a/components/camel-mvel/src/generated/resources/META-INF/org/apache/camel/language/mvel/mvel.json +++ b/components/camel-mvel/src/generated/resources/META-INF/org/apache/camel/language/mvel/mvel.json @@ -15,6 +15,10 @@ "modelName": "mvel", "modelJavaType": "org.apache.camel.model.language.MvelExpression" }, + "bodyTypes": { + "expressionIn": { "carriers": [ "any" ], "description": "The body as it is, in request.body or message.body: there is no variable body" }, + "expressionOut": { "carriers": [ "unknown" ], "description": "What the expression returns" } + }, "properties": { "id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node." }, "expression": { "index": 1, "kind": "value", "displayName": "Expression", "group": "common", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The expression value in your chosen language syntax." }, diff --git a/components/camel-mvel/src/main/docs/mvel-component.adoc b/components/camel-mvel/src/main/docs/mvel-component.adoc index d20fdfc75d95c..b8709cd862d34 100644 --- a/components/camel-mvel/src/main/docs/mvel-component.adoc +++ b/components/camel-mvel/src/main/docs/mvel-component.adoc @@ -51,6 +51,8 @@ include::partial$component-endpoint-headers.adoc[] Camel will provide exchange information in the MVEL context (just a `Map`). The `Exchange` is transferred as: +The `body`, `header`, `headers`, `variable`, `variables` and `exception` entries are always +there; the others only when the endpoint has `allowContextMapAll=true`. [width="100%",cols="10%m,90%",options="header",] |======================================================================= @@ -79,8 +81,8 @@ never changes. Camel provides two headers by which you can define a different resource location for a template, or the template content itself. If any of these -headers is set, then Camel uses this over the endpoint configured -resource. This allows you to provide a dynamic template at runtime. +headers is set, and the endpoint has `allowTemplateFromHeader=true`, then Camel uses this +over the endpoint configured resource. This allows you to provide a dynamic template at runtime. == Examples diff --git a/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelEndpoint.java b/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelEndpoint.java index 8e67b315b5e46..df13c47cd450c 100644 --- a/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelEndpoint.java +++ b/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelEndpoint.java @@ -24,6 +24,9 @@ import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; import org.apache.camel.component.ResourceEndpoint; +import org.apache.camel.spi.BodyType; +import org.apache.camel.spi.BodyType.Carrier; +import org.apache.camel.spi.BodyTypes; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; import org.apache.camel.support.ExchangeHelper; @@ -39,6 +42,13 @@ */ @UriEndpoint(firstVersion = "2.12.0", scheme = "mvel", title = "MVEL", syntax = "mvel:resourceUri", producerOnly = true, remote = false, category = { Category.TRANSFORMATION, Category.SCRIPT }, headersClass = MvelConstants.class) +@BodyTypes(producerIn = @BodyType(value = Carrier.ANY, + description = "The template gets the body as body, as it is: no body prints as null, and" + + " bytes or a stream are not read as text. The template is the resource, or" + + " the CamelMvelTemplate header with allowTemplateFromHeader=true, never the" + + " body"), + producerOut = @BodyType(value = Carrier.TEXT, javaType = "java.lang.String", + description = "The text the template writes. The headers are kept")) public class MvelEndpoint extends ResourceEndpoint { @UriParam diff --git a/components/camel-mvel/src/main/java/org/apache/camel/language/mvel/MvelLanguage.java b/components/camel-mvel/src/main/java/org/apache/camel/language/mvel/MvelLanguage.java index 342a117c91a52..6ba3f13c8e332 100644 --- a/components/camel-mvel/src/main/java/org/apache/camel/language/mvel/MvelLanguage.java +++ b/components/camel-mvel/src/main/java/org/apache/camel/language/mvel/MvelLanguage.java @@ -22,6 +22,9 @@ import org.apache.camel.Expression; import org.apache.camel.ExpressionIllegalSyntaxException; import org.apache.camel.Predicate; +import org.apache.camel.spi.BodyType; +import org.apache.camel.spi.BodyType.Carrier; +import org.apache.camel.spi.BodyTypes; import org.apache.camel.spi.ScriptingLanguage; import org.apache.camel.spi.annotations.Language; import org.apache.camel.support.TypedLanguageSupport; @@ -31,6 +34,10 @@ * An MVEL {@link org.apache.camel.spi.Language} plugin */ @Language("mvel") +@BodyTypes(expressionIn = @BodyType(value = Carrier.ANY, + description = "The body as it is, in request.body or message.body: there is no variable" + + " body"), + expressionOut = @BodyType(value = Carrier.UNKNOWN, description = "What the expression returns")) public class MvelLanguage extends TypedLanguageSupport implements ScriptingLanguage { @Override diff --git a/components/camel-saxon/src/generated/resources/META-INF/org/apache/camel/component/xquery/xquery.json b/components/camel-saxon/src/generated/resources/META-INF/org/apache/camel/component/xquery/xquery.json index 3f3346a8b7bd3..0eebafc59fc30 100644 --- a/components/camel-saxon/src/generated/resources/META-INF/org/apache/camel/component/xquery/xquery.json +++ b/components/camel-saxon/src/generated/resources/META-INF/org/apache/camel/component/xquery/xquery.json @@ -31,6 +31,10 @@ "configurationProperties": { "index": 4, "kind": "property", "displayName": "Configuration Properties", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "java.util.Map", "deprecated": false, "autowired": false, "secret": false, "description": "To set custom Saxon configuration properties" }, "moduleURIResolver": { "index": 5, "kind": "property", "displayName": "Module URIResolver", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "net.sf.saxon.lib.ModuleURIResolver", "deprecated": false, "autowired": false, "secret": false, "description": "To use the custom ModuleURIResolver" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "text", "bytes", "stream", "file", "pojo" ], "format": "xml", "dependsOn": [ "source" ], "description": "The XML to query: text, bytes, a stream, a file, a DOM or another javax.xml.transform.Source. A Map or no body fails" }, + "producerOut": { "carriers": [ "pojo" ], "javaType": "org.w3c.dom.Document", "dependsOn": [ "resultType" ], "byOption": [ { "option": "resultsFormat", "value": "Bytes", "carriers": [ "bytes" ], "javaType": "byte[]" }, { "option": "resultsFormat", "value": "BytesSource", "carriers": [ "pojo" ], "javaType": "org.apache.camel.util.xml.BytesSource" }, { "option": "resultsFormat", "value": "DOMSource", "carriers": [ "text" ], "javaType": "java.lang.String" }, { "option": "resultsFormat", "value": "List", "carriers": [ "list" ] }, { "option": "resultsFormat", "value": "String", "carriers": [ "text" ], "javaType": "java.lang.String" }, { "option": "resultsFormat", "value": "StringSource", "carriers": [ "pojo" ], "javaType": "org.apache.camel.util.xml.StringSource" } ], "description": "The result of the query as a DOM Document. A query that gives text, a number or more than one element fails with the default DOM: set resultsFormat to String or List" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the template to load from classpath or file system" }, "allowStAX": { "index": 1, "kind": "parameter", "displayName": "Allow St AX", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to allow using StAX mode" }, diff --git a/components/camel-saxon/src/generated/resources/META-INF/org/apache/camel/language/xquery/xquery.json b/components/camel-saxon/src/generated/resources/META-INF/org/apache/camel/language/xquery/xquery.json index 3bd82a8ede96b..f136ec5a42171 100644 --- a/components/camel-saxon/src/generated/resources/META-INF/org/apache/camel/language/xquery/xquery.json +++ b/components/camel-saxon/src/generated/resources/META-INF/org/apache/camel/language/xquery/xquery.json @@ -15,6 +15,10 @@ "modelName": "xquery", "modelJavaType": "org.apache.camel.model.language.XQueryExpression" }, + "bodyTypes": { + "expressionIn": { "carriers": [ "text", "bytes", "stream", "file", "pojo" ], "format": "xml", "dependsOn": [ "source" ], "description": "XML as text, bytes, a stream or a file, or a DOM or another javax.xml.transform.Source. A Map or no body fails" }, + "expressionOut": { "carriers": [ "pojo" ], "javaType": "org.w3c.dom.Document", "dependsOn": [ "resultType" ], "description": "The result of the query as a DOM Document. A query that gives text, a number or more than one element fails unless resultType is java.lang.String" } + }, "properties": { "id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node." }, "expression": { "index": 1, "kind": "value", "displayName": "Expression", "group": "common", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The expression value in your chosen language syntax." }, diff --git a/components/camel-saxon/src/main/docs/xquery-component.adoc b/components/camel-saxon/src/main/docs/xquery-component.adoc index a2d941eb0734d..f4cf0dc56d870 100644 --- a/components/camel-saxon/src/main/docs/xquery-component.adoc +++ b/components/camel-saxon/src/main/docs/xquery-component.adoc @@ -165,7 +165,7 @@ Notice how we can reuse the namespace prefixes, *foo* in this case, in the XPath expression for easier namespace-based XQuery expressions! When you use functions in your XQuery expression, you need an explicit -type conversion which is done in the xml configuration via the *@type* +type conversion which is done in the xml configuration via the *resultType* attribute: [source,xml] diff --git a/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryEndpoint.java b/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryEndpoint.java index b6b007b2461d8..4d123f7c950e7 100644 --- a/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryEndpoint.java +++ b/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryEndpoint.java @@ -26,6 +26,9 @@ import net.sf.saxon.query.StaticQueryContext; import org.apache.camel.Category; import org.apache.camel.Component; +import org.apache.camel.spi.BodyType; +import org.apache.camel.spi.BodyType.Carrier; +import org.apache.camel.spi.BodyTypes; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; @@ -42,6 +45,28 @@ */ @UriEndpoint(firstVersion = "1.0.0", scheme = "xquery", title = "XQuery", syntax = "xquery:resourceUri", remote = false, category = { Category.TRANSFORMATION }) +@BodyTypes(producerIn = @BodyType(value = { Carrier.TEXT, Carrier.BYTES, Carrier.STREAM, Carrier.FILE, Carrier.POJO }, + format = "xml", dependsOn = "source", + description = "The XML to query: text, bytes, a stream, a file, a DOM or another" + + " javax.xml.transform.Source. A Map or no body fails"), + producerOut = @BodyType(value = Carrier.POJO, javaType = "org.w3c.dom.Document", dependsOn = "resultType", + byOption = { + @BodyType.When(option = "resultsFormat", value = "Bytes", carriers = Carrier.BYTES, + javaType = "byte[]"), + @BodyType.When(option = "resultsFormat", value = "BytesSource", + carriers = Carrier.POJO, + javaType = "org.apache.camel.util.xml.BytesSource"), + @BodyType.When(option = "resultsFormat", value = "DOMSource", + carriers = Carrier.TEXT, javaType = "java.lang.String"), + @BodyType.When(option = "resultsFormat", value = "List", carriers = Carrier.LIST), + @BodyType.When(option = "resultsFormat", value = "String", carriers = Carrier.TEXT, + javaType = "java.lang.String"), + @BodyType.When(option = "resultsFormat", value = "StringSource", + carriers = Carrier.POJO, + javaType = "org.apache.camel.util.xml.StringSource") }, + description = "The result of the query as a DOM Document. A query that gives text, a number" + + " or more than one element fails with the default DOM: set resultsFormat to" + + " String or List")) public class XQueryEndpoint extends ProcessorEndpoint { private static final Logger LOG = LoggerFactory.getLogger(XQueryEndpoint.class); diff --git a/components/camel-saxon/src/main/java/org/apache/camel/language/xquery/XQueryLanguage.java b/components/camel-saxon/src/main/java/org/apache/camel/language/xquery/XQueryLanguage.java index dfa1ec775941e..935afeb4fee6c 100644 --- a/components/camel-saxon/src/main/java/org/apache/camel/language/xquery/XQueryLanguage.java +++ b/components/camel-saxon/src/main/java/org/apache/camel/language/xquery/XQueryLanguage.java @@ -22,12 +22,23 @@ import org.apache.camel.CamelContext; import org.apache.camel.Expression; import org.apache.camel.component.xquery.XQueryBuilder; +import org.apache.camel.spi.BodyType; +import org.apache.camel.spi.BodyType.Carrier; +import org.apache.camel.spi.BodyTypes; import org.apache.camel.spi.PropertyConfigurer; import org.apache.camel.spi.annotations.Language; import org.apache.camel.support.SingleInputTypedLanguageSupport; import org.apache.camel.support.component.PropertyConfigurerSupport; @Language("xquery") +@BodyTypes(expressionIn = @BodyType(value = { Carrier.TEXT, Carrier.BYTES, Carrier.STREAM, Carrier.FILE, Carrier.POJO }, + format = "xml", dependsOn = "source", + description = "XML as text, bytes, a stream or a file, or a DOM or another" + + " javax.xml.transform.Source. A Map or no body fails"), + expressionOut = @BodyType(value = Carrier.POJO, javaType = "org.w3c.dom.Document", dependsOn = "resultType", + description = "The result of the query as a DOM Document. A query that gives text, a" + + " number or more than one element fails unless resultType is" + + " java.lang.String")) public class XQueryLanguage extends SingleInputTypedLanguageSupport implements PropertyConfigurer { private Configuration configuration; diff --git a/components/camel-schematron/src/generated/resources/META-INF/org/apache/camel/component/schematron/schematron.json b/components/camel-schematron/src/generated/resources/META-INF/org/apache/camel/component/schematron/schematron.json index 4a36cefb7e7c7..2ea15ac6e3f0d 100644 --- a/components/camel-schematron/src/generated/resources/META-INF/org/apache/camel/component/schematron/schematron.json +++ b/components/camel-schematron/src/generated/resources/META-INF/org/apache/camel/component/schematron/schematron.json @@ -27,6 +27,10 @@ "lazyStartProducer": { "index": 0, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." }, "autowiredEnabled": { "index": 1, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc." } }, + "bodyTypes": { + "producerIn": { "carriers": [ "text", "bytes", "stream", "file", "pojo" ], "format": "xml", "description": "The XML to validate: text, bytes, a stream, a file, a DOM or another javax.xml.transform.Source. A Map or another POJO is read as its toString(): marshal it first; no body fails" }, + "producerOut": { "carriers": [ "unchanged" ], "description": "Unchanged: the CamelSchematronValidationStatus header is SUCCESS or FAILED, and CamelSchematronValidationReport holds the SVRL report. With abort, a failed assert throws a SchematronValidationException" } + }, "properties": { "path": { "index": 0, "kind": "path", "displayName": "Path", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "The path to the schematron rules file. Can either be in class path or location in the file system." }, "abort": { "index": 1, "kind": "parameter", "displayName": "Abort", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Flag to abort the route and throw a schematron validation exception." }, diff --git a/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/SchematronEndpoint.java b/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/SchematronEndpoint.java index 3234327bef3f4..e5a4b10cea154 100644 --- a/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/SchematronEndpoint.java +++ b/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/SchematronEndpoint.java @@ -34,6 +34,9 @@ import org.apache.camel.component.schematron.exception.SchematronConfigException; import org.apache.camel.component.schematron.processor.ClassPathURIResolver; import org.apache.camel.component.schematron.processor.TemplatesFactory; +import org.apache.camel.spi.BodyType; +import org.apache.camel.spi.BodyType.Carrier; +import org.apache.camel.spi.BodyTypes; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; @@ -52,6 +55,15 @@ */ @UriEndpoint(firstVersion = "2.15.0", scheme = "schematron", title = "Schematron", syntax = "schematron:path", remote = false, producerOnly = true, category = { Category.VALIDATION }) +@BodyTypes(producerIn = @BodyType(value = { Carrier.TEXT, Carrier.BYTES, Carrier.STREAM, Carrier.FILE, Carrier.POJO }, + format = "xml", + description = "The XML to validate: text, bytes, a stream, a file, a DOM or another" + + " javax.xml.transform.Source. A Map or another POJO is read as its" + + " toString(): marshal it first; no body fails"), + producerOut = @BodyType(value = Carrier.UNCHANGED, + description = "Unchanged: the CamelSchematronValidationStatus header is SUCCESS or FAILED," + + " and CamelSchematronValidationReport holds the SVRL report. With abort, a" + + " failed assert throws a SchematronValidationException")) public class SchematronEndpoint extends DefaultEndpoint { private static final Logger LOG = LoggerFactory.getLogger(SchematronEndpoint.class); diff --git a/components/camel-stringtemplate/src/generated/resources/META-INF/org/apache/camel/component/stringtemplate/string-template.json b/components/camel-stringtemplate/src/generated/resources/META-INF/org/apache/camel/component/stringtemplate/string-template.json index 6c156e63c2717..8eacc56d396b7 100644 --- a/components/camel-stringtemplate/src/generated/resources/META-INF/org/apache/camel/component/stringtemplate/string-template.json +++ b/components/camel-stringtemplate/src/generated/resources/META-INF/org/apache/camel/component/stringtemplate/string-template.json @@ -35,6 +35,10 @@ "CamelStringTemplateVariableMap": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Map", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Map of the variables which are made available to a script or template", "constantName": "org.apache.camel.component.stringtemplate.StringTemplateConstants#STRINGTEMPLATE_VARIABLE_MAP" }, "CamelStringTemplateTemplate": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The template to use instead of the endpoint configured.", "constantName": "org.apache.camel.component.stringtemplate.StringTemplateConstants#STRINGTEMPLATE_TEMPLATE" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "any" ], "description": "The template gets the body as body, as it is: text, or a Map, a List or a POJO to read from; convert bytes or a stream to a String first. The template is the resource, or the CamelStringTemplateTemplate or CamelStringTemplateResourceUri header with allowTemplateFromHeader=true, and never the body" }, + "producerOut": { "carriers": [ "text" ], "javaType": "java.lang.String", "description": "The text the template writes, also when it is JSON or XML: unmarshal it to read its fields. The headers are kept, and the CamelStringTemplateResourceUri header is set to the uri of the resource" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/components/camel-stringtemplate/src/main/docs/string-template-component.adoc b/components/camel-stringtemplate/src/main/docs/string-template-component.adoc index 38ec47de2aa46..141e3bd68e05a 100644 --- a/components/camel-stringtemplate/src/main/docs/string-template-component.adoc +++ b/components/camel-stringtemplate/src/main/docs/string-template-component.adoc @@ -51,14 +51,15 @@ include::partial$component-endpoint-headers.adoc[] === Headers -Camel will store a reference to the resource in the message header with -key, `org.apache.camel.stringtemplate.resource`. The Resource is an -`org.springframework.core.io.Resource` object. +Camel sets the uri of the template resource in the message header +`CamelStringTemplateResourceUri`. === String Template Context Camel will provide exchange information in the String Template context (just a `Map`). The `Exchange` is transferred as: +The `body`, `header`, `headers`, `variable`, `variables` and `exception` entries are always +there; the others only when the endpoint has `allowContextMapAll=true`. [width="100%",cols="10%,90%",options="header",] |======================================================================= @@ -92,8 +93,8 @@ This scenario can be used in production when the resource never changes. Camel provides two headers by which you can define a different resource location for a template or the template content itself. If any of these -headers is set, then Camel uses this over the endpoint configured -resource. This allows you to provide a dynamic template at runtime. +headers is set, and the endpoint has `allowTemplateFromHeader=true`, then Camel uses this +over the endpoint configured resource. This allows you to provide a dynamic template at runtime. === StringTemplate Attributes diff --git a/components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/StringTemplateEndpoint.java b/components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/StringTemplateEndpoint.java index 8fee752f12ff9..070d095abdca8 100644 --- a/components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/StringTemplateEndpoint.java +++ b/components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/StringTemplateEndpoint.java @@ -24,6 +24,9 @@ import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; import org.apache.camel.component.ResourceEndpoint; +import org.apache.camel.spi.BodyType; +import org.apache.camel.spi.BodyType.Carrier; +import org.apache.camel.spi.BodyTypes; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; import org.apache.camel.support.ExchangeHelper; @@ -39,6 +42,16 @@ syntax = "string-template:resourceUri", producerOnly = true, remote = false, category = { Category.TRANSFORMATION, Category.SCRIPT }, headersClass = StringTemplateConstants.class) +@BodyTypes(producerIn = @BodyType(value = Carrier.ANY, + description = "The template gets the body as body, as it is: text, or a Map, a List or a" + + " POJO to read from; convert bytes or a stream to a String first. The" + + " template is the resource, or the CamelStringTemplateTemplate or" + + " CamelStringTemplateResourceUri header with allowTemplateFromHeader=true," + + " and never the body"), + producerOut = @BodyType(value = Carrier.TEXT, javaType = "java.lang.String", + description = "The text the template writes, also when it is JSON or XML: unmarshal it to" + + " read its fields. The headers are kept, and the" + + " CamelStringTemplateResourceUri header is set to the uri of the resource")) public class StringTemplateEndpoint extends ResourceEndpoint { @UriParam diff --git a/components/camel-thymeleaf/src/generated/resources/META-INF/org/apache/camel/component/thymeleaf/thymeleaf.json b/components/camel-thymeleaf/src/generated/resources/META-INF/org/apache/camel/component/thymeleaf/thymeleaf.json index 5fd0193f05f47..3999546f8abcb 100644 --- a/components/camel-thymeleaf/src/generated/resources/META-INF/org/apache/camel/component/thymeleaf/thymeleaf.json +++ b/components/camel-thymeleaf/src/generated/resources/META-INF/org/apache/camel/component/thymeleaf/thymeleaf.json @@ -35,6 +35,10 @@ "CamelThymeleafVariableMap": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Map", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The value of this header should be a Map with key\/values that will be override any existing key with the same name. This can be used to preconfigure common key\/values you want to reuse in your Thymeleaf endpoints.", "constantName": "org.apache.camel.component.thymeleaf.ThymeleafConstants#THYMELEAF_VARIABLE_MAP" }, "CamelThymeleafServletContext": { "index": 3, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "jakarta.servlet.ServletContext", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The ServletContext for a web application.", "constantName": "org.apache.camel.component.thymeleaf.ThymeleafConstants#THYMELEAF_SERVLET_CONTEXT" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "any" ], "description": "The template gets the body as ${body}, as it is: text, or a Map, a List or a POJO to read from; no body prints as empty text, and bytes or a stream are not read as text. The template is the resource, or the CamelThymeleafTemplate header with allowTemplateFromHeader=true, never the body" }, + "producerOut": { "carriers": [ "text" ], "javaType": "java.lang.String", "description": "The text the template writes, in its templateMode such as HTML. The headers are kept" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/components/camel-thymeleaf/src/main/docs/thymeleaf-component.adoc b/components/camel-thymeleaf/src/main/docs/thymeleaf-component.adoc index ca557310b6369..4bcb723a06ab6 100644 --- a/components/camel-thymeleaf/src/main/docs/thymeleaf-component.adoc +++ b/components/camel-thymeleaf/src/main/docs/thymeleaf-component.adoc @@ -66,6 +66,8 @@ The `fruit` header is now accessible from the `message.out.headers`. Camel will provide exchange information in the Thymeleaf context (just a `Map`). The `Exchange` is transferred as: +The `body`, `header`, `headers`, `variable`, `variables` and `exception` entries are always +there; the others only when the endpoint has `allowContextMapAll=true`. [width="100%",cols="10%,90%",options="header",] |======================================================================= @@ -90,14 +92,16 @@ The `Exchange` is transferred as: |`response` |The Out message (only for InOut message exchange pattern). |======================================================================= -You can set up a custom Thymeleaf Context yourself by -setting property `allowTemplateFromHeader=true` and setting the message header `CamelThymeleafContext` like this +You can add your own variables to the Thymeleaf context with a `Map` in the message header +`CamelThymeleafVariableMap`. Camel sets the `body`, `header`, `headers`, `variable`, `variables` and +`exception` entries on top of it, and removes the header after use: ._Java-only: programmatic Thymeleaf context setup via Exchange API_ [source,java] ---- -EngineContext engineContext = new EngineContext(variableMap); -exchange.getIn().setHeader("CamelThymeleafContext", engineContext); +Map variableMap = new HashMap<>(); +variableMap.put("greeting", "Hello"); +exchange.getIn().setHeader("CamelThymeleafVariableMap", variableMap); ---- === Hot reloading @@ -112,8 +116,8 @@ when the resource never changes. Camel provides two headers by which you can define a different resource location for a template or the template content itself. If any of these -headers is set, then Camel uses this over the endpoint configured -resource. This allows you to provide a dynamic template at runtime. +headers is set, and the endpoint has `allowTemplateFromHeader=true`, then Camel uses this +over the endpoint configured resource. This allows you to provide a dynamic template at runtime. [width="100%",cols="10%,10%,80%",options="header",] |======================================================================= diff --git a/components/camel-thymeleaf/src/main/java/org/apache/camel/component/thymeleaf/ThymeleafEndpoint.java b/components/camel-thymeleaf/src/main/java/org/apache/camel/component/thymeleaf/ThymeleafEndpoint.java index 28366d7689639..82c649faabf57 100644 --- a/components/camel-thymeleaf/src/main/java/org/apache/camel/component/thymeleaf/ThymeleafEndpoint.java +++ b/components/camel-thymeleaf/src/main/java/org/apache/camel/component/thymeleaf/ThymeleafEndpoint.java @@ -24,6 +24,9 @@ import org.apache.camel.ExchangePattern; import org.apache.camel.RuntimeCamelException; import org.apache.camel.component.ResourceEndpoint; +import org.apache.camel.spi.BodyType; +import org.apache.camel.spi.BodyType.Carrier; +import org.apache.camel.spi.BodyTypes; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; @@ -49,6 +52,15 @@ remote = false, producerOnly = true, category = { Category.TRANSFORMATION }, headersClass = ThymeleafConstants.class) @Metadata(excludeProperties = "contentCache") +@BodyTypes(producerIn = @BodyType(value = Carrier.ANY, + description = "The template gets the body as ${body}, as it is: text, or a Map, a List or a" + + " POJO to read from; no body prints as empty text, and bytes or a stream" + + " are not read as text. The template is the resource, or the" + + " CamelThymeleafTemplate header with allowTemplateFromHeader=true, never the" + + " body"), + producerOut = @BodyType(value = Carrier.TEXT, javaType = "java.lang.String", + description = "The text the template writes, in its templateMode such as HTML. The headers" + + " are kept")) public class ThymeleafEndpoint extends ResourceEndpoint { private TemplateEngine templateEngine; diff --git a/components/camel-velocity/src/generated/resources/META-INF/org/apache/camel/component/velocity/velocity.json b/components/camel-velocity/src/generated/resources/META-INF/org/apache/camel/component/velocity/velocity.json index 951eac85ee9f4..c33d8999d0dc4 100644 --- a/components/camel-velocity/src/generated/resources/META-INF/org/apache/camel/component/velocity/velocity.json +++ b/components/camel-velocity/src/generated/resources/META-INF/org/apache/camel/component/velocity/velocity.json @@ -37,6 +37,10 @@ "CamelVelocityContext": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "org.apache.velocity.context.Context", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The velocity context to use.", "constantName": "org.apache.camel.component.velocity.VelocityConstants#VELOCITY_CONTEXT" }, "CamelVelocitySupplementalContext": { "index": 3, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Map", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "To add additional information to the used VelocityContext. The value of this header should be a Map with key\/values that will added (override any existing key with the same name). This can be used to pre setup some common key\/values you want to reuse in your velocity endpoints.", "constantName": "org.apache.camel.component.velocity.VelocityConstants#VELOCITY_SUPPLEMENTAL_CONTEXT" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "any" ], "description": "The template gets the body as body, as it is: text, or a Map, a List or a POJO to read from; convert bytes or a stream to a String first. The template is the resource, or the CamelVelocityTemplate or CamelVelocityResourceUri header with allowTemplateFromHeader=true, and never the body" }, + "producerOut": { "carriers": [ "text" ], "javaType": "java.lang.String", "description": "The text the template writes, also when it is JSON or XML: unmarshal it to read its fields. The headers are kept" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod." }, "allowContextMapAll": { "index": 1, "kind": "parameter", "displayName": "Allow Context Map All", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API." }, diff --git a/components/camel-velocity/src/main/docs/velocity-component.adoc b/components/camel-velocity/src/main/docs/velocity-component.adoc index cb102bb2f991a..a215ef6531ae3 100644 --- a/components/camel-velocity/src/main/docs/velocity-component.adoc +++ b/components/camel-velocity/src/main/docs/velocity-component.adoc @@ -67,6 +67,8 @@ The `fruit` header is now accessible from the `message.out.headers`. Camel will provide exchange information in the Velocity context (just a `Map`). The `Exchange` is transferred as: +The `body`, `header`, `headers`, `variable`, `variables` and `exception` entries are always +there; the others only when the endpoint has `allowContextMapAll=true`. [width="100%",cols="10%,90%",options="header",] |======================================================================= @@ -195,8 +197,8 @@ when the resource never changes. Camel provides two headers by which you can define a different resource location for a template or the template content itself. If any of these -headers is set, then Camel uses this over the endpoint configured -resource. This allows you to provide a dynamic template at runtime. +headers is set, and the endpoint has `allowTemplateFromHeader=true`, then Camel uses this +over the endpoint configured resource. This allows you to provide a dynamic template at runtime. [width="100%",cols="10%,10%,80%",options="header",] |======================================================================= diff --git a/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityEndpoint.java b/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityEndpoint.java index 52317dd6bfd55..c7cfdb98fcf8f 100644 --- a/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityEndpoint.java +++ b/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityEndpoint.java @@ -28,6 +28,9 @@ import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; import org.apache.camel.component.ResourceEndpoint; +import org.apache.camel.spi.BodyType; +import org.apache.camel.spi.BodyType.Carrier; +import org.apache.camel.spi.BodyTypes; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; import org.apache.camel.support.ExchangeHelper; @@ -47,6 +50,15 @@ @UriEndpoint(firstVersion = "1.2.0", scheme = "velocity", title = "Velocity", syntax = "velocity:resourceUri", remote = false, producerOnly = true, category = { Category.TRANSFORMATION }, headersClass = VelocityConstants.class) +@BodyTypes(producerIn = @BodyType(value = Carrier.ANY, + description = "The template gets the body as body, as it is: text, or a Map, a List or a" + + " POJO to read from; convert bytes or a stream to a String first. The" + + " template is the resource, or the CamelVelocityTemplate or" + + " CamelVelocityResourceUri header with allowTemplateFromHeader=true, and" + + " never the body"), + producerOut = @BodyType(value = Carrier.TEXT, javaType = "java.lang.String", + description = "The text the template writes, also when it is JSON or XML: unmarshal it to" + + " read its fields. The headers are kept")) public class VelocityEndpoint extends ResourceEndpoint { private VelocityEngine velocityEngine; diff --git a/components/camel-xj/src/generated/resources/META-INF/org/apache/camel/component/xj/xj.json b/components/camel-xj/src/generated/resources/META-INF/org/apache/camel/component/xj/xj.json index 2af1f9038eceb..0a57d2901364b 100644 --- a/components/camel-xj/src/generated/resources/META-INF/org/apache/camel/component/xj/xj.json +++ b/components/camel-xj/src/generated/resources/META-INF/org/apache/camel/component/xj/xj.json @@ -43,6 +43,10 @@ "CamelXsltResourceUri": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A URI for the template resource to load and use instead of the endpoint configured.", "constantName": "org.apache.camel.component.xslt.XsltConstants#XSLT_RESOURCE_URI" }, "CamelXsltStylesheet": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The template to use instead of the endpoint configured.", "constantName": "org.apache.camel.component.xslt.XsltConstants#XSLT_STYLESHEET" } }, + "bodyTypes": { + "producerIn": { "carriers": [ "text", "bytes", "stream", "file", "pojo" ], "dependsOn": [ "source", "useJsonBody" ], "byOption": [ { "option": "transformDirection", "value": "XML2JSON", "carriers": [ "text", "bytes", "stream", "file", "pojo" ] }, { "option": "transformDirection", "value": "JSON2XML", "carriers": [ "text", "bytes", "stream", "file" ] } ], "description": "The XML for XML2JSON as text, bytes, a stream, a file, a DOM or another javax.xml.transform.Source; the JSON for JSON2XML as text, bytes, a stream or a file. A Map, a List or no body fails, unless failOnNullBody=false for no body" }, + "producerOut": { "carriers": [ "text" ], "javaType": "java.lang.String", "dependsOn": [ "resultHandlerFactory" ], "byOption": [ { "option": "output", "value": "bytes", "carriers": [ "bytes" ], "javaType": "byte[]" }, { "option": "output", "value": "DOM", "carriers": [ "pojo" ], "javaType": "org.w3c.dom.Document" }, { "option": "output", "value": "file", "carriers": [ "file" ], "javaType": "java.io.File" } ], "description": "The result of the transformation: JSON text with XML2JSON, XML text with JSON2XML. output=DOM works with JSON2XML only" } + }, "properties": { "resourceUri": { "index": 0, "kind": "path", "displayName": "Resource Uri", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Path to the template. The following is supported by the default URIResolver. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod" }, "allowStAX": { "index": 1, "kind": "parameter", "displayName": "Allow StAX", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to allow using StAX as the javax.xml.transform.Source. You can enable this if the XSLT library supports StAX such as the Saxon library (camel-saxon). The Xalan library (default in JVM) does not support StAXSource." }, diff --git a/components/camel-xj/src/main/java/org/apache/camel/component/xj/XJEndpoint.java b/components/camel-xj/src/main/java/org/apache/camel/component/xj/XJEndpoint.java index 6a0c7655ba833..4fe5ab7855478 100644 --- a/components/camel-xj/src/main/java/org/apache/camel/component/xj/XJEndpoint.java +++ b/components/camel-xj/src/main/java/org/apache/camel/component/xj/XJEndpoint.java @@ -24,6 +24,9 @@ import org.apache.camel.component.xslt.XsltBuilder; import org.apache.camel.component.xslt.saxon.XsltSaxonBuilder; import org.apache.camel.component.xslt.saxon.XsltSaxonEndpoint; +import org.apache.camel.spi.BodyType; +import org.apache.camel.spi.BodyType.Carrier; +import org.apache.camel.spi.BodyTypes; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; @@ -34,6 +37,31 @@ @ManagedResource(description = "Managed XJEndpoint") @UriEndpoint(firstVersion = "3.0.0", scheme = "xj", title = "XJ", syntax = "xj:resourceUri", producerOnly = true, remote = false, category = { Category.TRANSFORMATION }, headersClass = XJConstants.class) +@BodyTypes(producerIn = @BodyType(value = { Carrier.TEXT, Carrier.BYTES, Carrier.STREAM, Carrier.FILE, Carrier.POJO }, + dependsOn = { "source", "useJsonBody" }, + byOption = { + @BodyType.When(option = "transformDirection", value = "XML2JSON", + carriers = { + Carrier.TEXT, Carrier.BYTES, Carrier.STREAM, Carrier.FILE, + Carrier.POJO }), + @BodyType.When(option = "transformDirection", value = "JSON2XML", + carriers = { + Carrier.TEXT, Carrier.BYTES, Carrier.STREAM, + Carrier.FILE }) }, + description = "The XML for XML2JSON as text, bytes, a stream, a file, a DOM or another" + + " javax.xml.transform.Source; the JSON for JSON2XML as text, bytes, a stream" + + " or a file. A Map, a List or no body fails, unless failOnNullBody=false for" + + " no body"), + producerOut = @BodyType(value = Carrier.TEXT, javaType = "java.lang.String", dependsOn = "resultHandlerFactory", + byOption = { + @BodyType.When(option = "output", value = "bytes", carriers = Carrier.BYTES, + javaType = "byte[]"), + @BodyType.When(option = "output", value = "DOM", carriers = Carrier.POJO, + javaType = "org.w3c.dom.Document"), + @BodyType.When(option = "output", value = "file", carriers = Carrier.FILE, + javaType = "java.io.File") }, + description = "The result of the transformation: JSON text with XML2JSON, XML text with" + + " JSON2XML. output=DOM works with JSON2XML only")) public class XJEndpoint extends XsltSaxonEndpoint { private final JsonFactory jsonFactory = new JsonFactory(); diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/test/java/org/apache/camel/dsl/yaml/validator/TextBodyFlowTest.java b/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/test/java/org/apache/camel/dsl/yaml/validator/TextBodyFlowTest.java index 0f15009a19dcb..557ad7d9b4245 100644 --- a/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/test/java/org/apache/camel/dsl/yaml/validator/TextBodyFlowTest.java +++ b/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/test/java/org/apache/camel/dsl/yaml/validator/TextBodyFlowTest.java @@ -1051,6 +1051,62 @@ public void testTheBodyOfCachesAndSigning() { .contains("route put: to: file needs the body as text, bytes, a stream or a file")); } + @Test + public void testTheBodyOfTransformations() { + // jslt and json-validator read JSON text, so parsed data must be marshalled first; a template writes text, so a + // field read needs an unmarshal; and jolt gives parsed JSON, which the file producer cannot write + String yaml = """ + - route: + id: jslt + from: + uri: timer:tick + steps: + - setBody: + constant: '{"id": 1}' + - unmarshal: + json: {} + - to: jslt:order.json + - route: + id: check + from: + uri: timer:tick + steps: + - setBody: + constant: '{"id": 1}' + - unmarshal: + json: {} + - to: json-validator:order-schema.json + - route: + id: template + from: + uri: timer:tick + steps: + - to: velocity:order.vm + - setHeader: + name: id + simple: ${body[id]} + - route: + id: jolt + from: + uri: timer:tick + steps: + - setBody: + constant: '{"id": 1}' + - unmarshal: + json: {} + - to: jolt:spec.json + - to: file:out + """; + assertThat(lines(yaml)).hasSize(4) + .anySatisfy( + m -> assertThat(m).contains("route jslt: to: jslt needs the body as text, bytes, a stream or a file")) + .anySatisfy(m -> assertThat(m) + .contains("route check: to: json-validator needs the body as text, bytes, a stream or a file")) + .anySatisfy(m -> assertThat(m).contains("route template: simple reads a field of the body (${body[id]})")) + .anySatisfy(m -> assertThat(m) + .contains("route jolt: to: file needs the body as text, bytes, a stream or a file")); + } + @Test public void testAnOptionTheBodyDependsOnOutweighsAnotherOption() { // xslt with output bytes gives bytes, so a field read needs an unmarshal; with a resultHandlerFactory too the