From 1e20e6fc71d1ef88ffd35f69c1f7820268e84153 Mon Sep 17 00:00:00 2001 From: Nicolas Filotto Date: Mon, 21 Mar 2022 10:51:34 +0100 Subject: [PATCH 01/13] CAMEL-17792: Add doc about the message headers of camel-ehcache --- .../camel/component/ehcache/ehcache.json | 10 +++++ .../src/main/docs/ehcache-component.adoc | 43 ++----------------- .../component/ehcache/EhcacheConstants.java | 28 ++++++++++++ .../component/ehcache/EhcacheEndpoint.java | 2 +- 4 files changed, 42 insertions(+), 41 deletions(-) diff --git a/components/camel-ehcache/src/generated/resources/org/apache/camel/component/ehcache/ehcache.json b/components/camel-ehcache/src/generated/resources/org/apache/camel/component/ehcache/ehcache.json index 70075448f3991..3a79fbfa3d8dd 100644 --- a/components/camel-ehcache/src/generated/resources/org/apache/camel/component/ehcache/ehcache.json +++ b/components/camel-ehcache/src/generated/resources/org/apache/camel/component/ehcache/ehcache.json @@ -39,6 +39,16 @@ "keyType": { "kind": "property", "displayName": "Key Type", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.ehcache.EhcacheConfiguration", "configurationField": "configuration", "description": "The cache key type, default java.lang.Object" }, "valueType": { "kind": "property", "displayName": "Value Type", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.ehcache.EhcacheConfiguration", "configurationField": "configuration", "description": "The cache value type, default java.lang.Object" } }, + "headers": { + "CamelEhcacheAction": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation to be performed on the cache, valid options are:\n\n* CLEAR\n* PUT\n* PUT_ALL\n* PUT_IF_ABSENT\n* GET\n* GET_ALL\n* REMOVE\n* REMOVE_ALL\n* REPLACE" }, + "CamelEhcacheActionHasResult": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "Boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Set to true if the action has a result" }, + "CamelEhcacheActionSucceeded": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "Boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Set to true if the action was successful" }, + "CamelEhcacheKey": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "Object", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The cache key used for an action" }, + "CamelEhcacheKeys": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "Set", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A list of keys, used in\n\n* PUT_ALL\n* GET_ALL\n* REMOVE_ALL" }, + "CamelEhcacheValue": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "Object", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The value to put in the cache or the result of an operation" }, + "CamelEhcacheOldValue": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "Object", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The old value associated to a key for actions like PUT_IF_ABSENT or the\nObject used for comparison for actions like REPLACE" }, + "CamelEhcacheEventType": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "EventType", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The type of event received" } + }, "properties": { "cacheName": { "kind": "path", "displayName": "Cache Name", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "the cache name" }, "cacheManager": { "kind": "parameter", "displayName": "Cache Manager", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.ehcache.CacheManager", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.ehcache.EhcacheConfiguration", "configurationField": "configuration", "description": "The cache manager" }, diff --git a/components/camel-ehcache/src/main/docs/ehcache-component.adoc b/components/camel-ehcache/src/main/docs/ehcache-component.adoc index 1eb505542a6e2..31945d16147ec 100644 --- a/components/camel-ehcache/src/main/docs/ehcache-component.adoc +++ b/components/camel-ehcache/src/main/docs/ehcache-component.adoc @@ -51,46 +51,9 @@ include::partial$component-endpoint-options.adoc[] // endpoint options: END - - -=== Message Headers Camel - - -[width="100%",cols="10%,10%,80%",options="header",] -|======================================================================= -|Header |Type |Description - -|CamelEhcacheAction |`String` |The operation to be perfomed on the cache, valid options are: - -* CLEAR -* PUT -* PUT_ALL -* PUT_IF_ABSENT -* GET -* GET_ALL -* REMOVE -* REMOVE_ALL -* REPLACE - -|CamelEhcacheActionHasResult |Boolean |Set to true if the action has a result - -|CamelEhcacheActionSucceeded |`Boolean` |Set to true if the actionsuccedded - -|CamelEhcacheKey |Object |The cache key used for an action - -|CamelEhcacheKeys |Set |A list of keys, used in - -* PUT_ALL -* GET_ALL -* REMOVE_ALL - -|CamelEhcacheValue |Object |The value to put in the cache or the result of an operation - -|CamelEhcacheOldValue |Object |The old value associated to a key for actions like PUT_IF_ABSENT or the -Object used for comparison for actions like REPLACE - -|CamelEhcacheEventType |EventType |The type of event received -|======================================================================= +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END == Ehcache based idempotent repository example: diff --git a/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/EhcacheConstants.java b/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/EhcacheConstants.java index 8719ac7a82ac6..d9ba28a21b18b 100644 --- a/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/EhcacheConstants.java +++ b/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/EhcacheConstants.java @@ -16,14 +16,42 @@ */ package org.apache.camel.component.ehcache; +import org.apache.camel.spi.Metadata; + public interface EhcacheConstants { + @Metadata(description = "The operation to be performed on the cache, valid options are:\n" + + "\n" + + "* CLEAR\n" + + "* PUT\n" + + "* PUT_ALL\n" + + "* PUT_IF_ABSENT\n" + + "* GET\n" + + "* GET_ALL\n" + + "* REMOVE\n" + + "* REMOVE_ALL\n" + + "* REPLACE", + javaType = "String") String ACTION = "CamelEhcacheAction"; + @Metadata(description = "Set to true if the action has a result", javaType = "Boolean") String ACTION_HAS_RESULT = "CamelEhcacheActionHasResult"; + @Metadata(description = "Set to true if the action was successful", javaType = "Boolean") String ACTION_SUCCEEDED = "CamelEhcacheActionSucceeded"; + @Metadata(description = "The cache key used for an action", javaType = "Object") String KEY = "CamelEhcacheKey"; + @Metadata(description = "A list of keys, used in\n" + + "\n" + + "* PUT_ALL\n" + + "* GET_ALL\n" + + "* REMOVE_ALL\n", + javaType = "Set") String KEYS = "CamelEhcacheKeys"; + @Metadata(description = "The value to put in the cache or the result of an operation", javaType = "Object") String VALUE = "CamelEhcacheValue"; + @Metadata(description = "The old value associated to a key for actions like PUT_IF_ABSENT or the\n" + + "Object used for comparison for actions like REPLACE", + javaType = "Object") String OLD_VALUE = "CamelEhcacheOldValue"; + @Metadata(description = "The type of event received", javaType = "EventType") String EVENT_TYPE = "CamelEhcacheEventType"; String ACTION_CLEAR = "CLEAR"; diff --git a/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/EhcacheEndpoint.java b/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/EhcacheEndpoint.java index 51a6b520015c4..8b5b78bcf149f 100644 --- a/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/EhcacheEndpoint.java +++ b/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/EhcacheEndpoint.java @@ -32,7 +32,7 @@ * Perform caching operations using Ehcache. */ @UriEndpoint(firstVersion = "2.18.0", scheme = "ehcache", title = "Ehcache", syntax = "ehcache:cacheName", - category = { Category.CACHE, Category.DATAGRID, Category.CLUSTERING }) + category = { Category.CACHE, Category.DATAGRID, Category.CLUSTERING }, headersClass = EhcacheConstants.class) public class EhcacheEndpoint extends DefaultEndpoint { private static final Logger LOGGER = LoggerFactory.getLogger(EhcacheComponent.class); From 0dcdd8c5d3a4a59e2d785cd5e98cb4e8f77d1647 Mon Sep 17 00:00:00 2001 From: Nicolas Filotto Date: Mon, 21 Mar 2022 11:21:43 +0100 Subject: [PATCH 02/13] CAMEL-17792: Add doc about the message headers of camel-elasticsearch-rest --- .../component/elasticsearch/elasticsearch-rest.json | 10 ++++++++++ .../src/main/docs/elasticsearch-rest-component.adoc | 4 +++- .../elasticsearch/ElasticsearchConstants.java | 12 ++++++++++++ .../elasticsearch/ElasticsearchEndpoint.java | 2 +- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/components/camel-elasticsearch-rest/src/generated/resources/org/apache/camel/component/elasticsearch/elasticsearch-rest.json b/components/camel-elasticsearch-rest/src/generated/resources/org/apache/camel/component/elasticsearch/elasticsearch-rest.json index 01fce45cda935..d6b90ec2d2f94 100644 --- a/components/camel-elasticsearch-rest/src/generated/resources/org/apache/camel/component/elasticsearch/elasticsearch-rest.json +++ b/components/camel-elasticsearch-rest/src/generated/resources/org/apache/camel/component/elasticsearch/elasticsearch-rest.json @@ -36,6 +36,16 @@ "password": { "kind": "property", "displayName": "Password", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Password for authenticate" }, "user": { "kind": "property", "displayName": "User", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Basic authenticate user" } }, + "headers": { + "operation": { "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "org.apache.camel.component.elasticsearch.ElasticsearchOperation", "enum": [ "Index", "Update", "Bulk", "BulkIndex", "GetById", "MultiGet", "MultiSearch", "Delete", "DeleteIndex", "Search", "Exists", "Ping" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation to perform" }, + "indexId": { "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The id of the indexed document." }, + "indexName": { "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the index to act against" }, + "waitForActiveShards": { "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The index creation waits for the write consistency number of shards to be available" }, + "scrollKeepAliveMs": { "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The starting index of the response." }, + "useScroll": { "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Set to true to enable scroll usage" }, + "size": { "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The size of the response." }, + "from": { "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The starting index of the response." } + }, "properties": { "clusterName": { "kind": "path", "displayName": "Cluster Name", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.elasticsearch.ElasticsearchConfiguration", "configurationField": "configuration", "description": "Name of the cluster" }, "connectionTimeout": { "kind": "parameter", "displayName": "Connection Timeout", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 30000, "configurationClass": "org.apache.camel.component.elasticsearch.ElasticsearchConfiguration", "configurationField": "configuration", "description": "The time in ms to wait before connection will timeout." }, diff --git a/components/camel-elasticsearch-rest/src/main/docs/elasticsearch-rest-component.adoc b/components/camel-elasticsearch-rest/src/main/docs/elasticsearch-rest-component.adoc index c4557808cabf9..305f924467a52 100644 --- a/components/camel-elasticsearch-rest/src/main/docs/elasticsearch-rest-component.adoc +++ b/components/camel-elasticsearch-rest/src/main/docs/elasticsearch-rest-component.adoc @@ -50,7 +50,9 @@ include::partial$component-endpoint-options.adoc[] // endpoint options: END - +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END == Message Operations diff --git a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchConstants.java b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchConstants.java index 10f99087488f5..44d30d8132904 100644 --- a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchConstants.java +++ b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchConstants.java @@ -16,15 +16,27 @@ */ package org.apache.camel.component.elasticsearch; +import org.apache.camel.spi.Metadata; + public interface ElasticsearchConstants { + @Metadata(description = "The operation to perform", + javaType = "org.apache.camel.component.elasticsearch.ElasticsearchOperation") String PARAM_OPERATION = "operation"; + @Metadata(description = "The id of the indexed document.", javaType = "String") String PARAM_INDEX_ID = "indexId"; + @Metadata(description = "The name of the index to act against", javaType = "String") String PARAM_INDEX_NAME = "indexName"; + @Metadata(description = "The index creation waits for the write consistency number of shards to be available", + javaType = "Integer") String PARAM_WAIT_FOR_ACTIVE_SHARDS = "waitForActiveShards"; + @Metadata(description = "The starting index of the response.", javaType = "Integer") String PARAM_SCROLL_KEEP_ALIVE_MS = "scrollKeepAliveMs"; + @Metadata(description = "Set to true to enable scroll usage", javaType = "Boolean") String PARAM_SCROLL = "useScroll"; + @Metadata(description = "The size of the response.", javaType = "Integer") String PARAM_SIZE = "size"; + @Metadata(description = "The starting index of the response.", javaType = "Integer") String PARAM_FROM = "from"; String PROPERTY_SCROLL_ES_QUERY_COUNT = "CamelElasticsearchScrollQueryCount"; diff --git a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java index 87b3c75ac55e6..a6615ee27d882 100644 --- a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java +++ b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java @@ -30,7 +30,7 @@ */ @UriEndpoint(firstVersion = "2.21.0", scheme = "elasticsearch-rest", title = "Elasticsearch Rest", syntax = "elasticsearch-rest:clusterName", producerOnly = true, - category = { Category.SEARCH, Category.MONITORING }) + category = { Category.SEARCH, Category.MONITORING }, headersClass = ElasticsearchConstants.class) public class ElasticsearchEndpoint extends DefaultEndpoint { @UriParam From 825087e749a82bfce522a640f73b998198f38ad7 Mon Sep 17 00:00:00 2001 From: Nicolas Filotto Date: Mon, 21 Mar 2022 11:44:16 +0100 Subject: [PATCH 03/13] CAMEL-17792: Add doc about the message headers of camel-elsql --- .../apache/camel/component/elsql/elsql.json | 4 +++ .../src/main/docs/elsql-component.adoc | 20 ++--------- .../camel/component/elsql/ElsqlConstants.java | 36 +++++++++++++++++++ .../camel/component/elsql/ElsqlEndpoint.java | 2 +- .../camel/component/elsql/ElsqlProducer.java | 11 +++--- 5 files changed, 49 insertions(+), 24 deletions(-) create mode 100644 components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlConstants.java diff --git a/components/camel-elsql/src/generated/resources/org/apache/camel/component/elsql/elsql.json b/components/camel-elsql/src/generated/resources/org/apache/camel/component/elsql/elsql.json index 2cd8f7bcaa2ab..0b52072cc5647 100644 --- a/components/camel-elsql/src/generated/resources/org/apache/camel/component/elsql/elsql.json +++ b/components/camel-elsql/src/generated/resources/org/apache/camel/component/elsql/elsql.json @@ -30,6 +30,10 @@ "autowiredEnabled": { "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." }, "elSqlConfig": { "kind": "property", "displayName": "El Sql Config", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "com.opengamma.elsql.ElSqlConfig", "deprecated": false, "autowired": false, "secret": false, "description": "To use a specific configured ElSqlConfig. It may be better to use the databaseVendor option instead." } }, + "headers": { + "CamelSqlUpdateCount": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The number of rows updated for `update` operations, returned as an\n`Integer` object." }, + "CamelSqlRowCount": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The number of rows returned for `select` operations, returned as an\n`Integer` object." } + }, "properties": { "elsqlName": { "kind": "path", "displayName": "Elsql Name", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the elsql to use (is NAMED in the elsql file)" }, "resourceUri": { "kind": "path", "displayName": "Resource Uri", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The resource file which contains the elsql SQL statements to use. You can specify multiple resources separated by comma. The resources are loaded on the classpath by default, you can prefix with file: to load from file system. Notice you can set this option on the component and then you do not have to configure this on the endpoint." }, diff --git a/components/camel-elsql/src/main/docs/elsql-component.adoc b/components/camel-elsql/src/main/docs/elsql-component.adoc index 045fcb385f217..853587a741243 100644 --- a/components/camel-elsql/src/main/docs/elsql-component.adoc +++ b/components/camel-elsql/src/main/docs/elsql-component.adoc @@ -71,7 +71,9 @@ include::partial$component-endpoint-options.adoc[] // endpoint options: START // endpoint options: END - +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END == Result of the query @@ -87,22 +89,6 @@ headers, it provides a concise syntax for querying a sequence or some other small value into a header. It is convenient to use outputHeader and outputType together: -== Header values - -When performing `update` operations, the SQL Component stores the update -count in the following message headers: - -[width="100%",cols="10%,90%",options="header",] -|=== -|Header |Description - -|`CamelSqlUpdateCount` |The number of rows updated for `update` operations, returned as an -`Integer` object. - -|`CamelSqlRowCount` |The number of rows returned for `select` operations, returned as an -`Integer` object. -|=== - === Sample In the given route below, we want to get all the projects from the diff --git a/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlConstants.java b/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlConstants.java new file mode 100644 index 0000000000000..4b55d498c5c5c --- /dev/null +++ b/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlConstants.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.elsql; + +import org.apache.camel.component.sql.SqlConstants; +import org.apache.camel.spi.Metadata; + +public final class ElsqlConstants { + + @Metadata(label = "producer", description = "The number of rows updated for `update` operations, returned as an\n" + + "`Integer` object.", + javaType = "Integer") + public static final String SQL_UPDATE_COUNT = SqlConstants.SQL_UPDATE_COUNT; + @Metadata(label = "producer", description = "The number of rows returned for `select` operations, returned as an\n" + + "`Integer` object.", + javaType = "Integer") + public static final String SQL_ROW_COUNT = SqlConstants.SQL_ROW_COUNT; + + private ElsqlConstants() { + // Utility class + } +} diff --git a/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlEndpoint.java b/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlEndpoint.java index cc69d26d91bc8..89b3846d082dd 100644 --- a/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlEndpoint.java +++ b/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlEndpoint.java @@ -49,7 +49,7 @@ * Use ElSql to define SQL queries. Extends the SQL Component. */ @UriEndpoint(firstVersion = "2.16.0", scheme = "elsql", title = "ElSQL", syntax = "elsql:elsqlName:resourceUri", - category = { Category.DATABASE, Category.SQL }) + category = { Category.DATABASE, Category.SQL }, headersClass = ElsqlConstants.class) public class ElsqlEndpoint extends DefaultSqlEndpoint { private static final Logger LOG = LoggerFactory.getLogger(ElsqlEndpoint.class); diff --git a/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlProducer.java b/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlProducer.java index 9901a3ba33298..2a2fd1b206483 100644 --- a/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlProducer.java +++ b/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlProducer.java @@ -33,7 +33,6 @@ import org.apache.camel.ExtendedExchange; import org.apache.camel.component.sql.ResultSetIterator; import org.apache.camel.component.sql.ResultSetIteratorCompletion; -import org.apache.camel.component.sql.SqlConstants; import org.apache.camel.component.sql.SqlOutputType; import org.apache.camel.component.sql.SqlPrepareStatementStrategy; import org.apache.camel.support.DefaultProducer; @@ -131,7 +130,7 @@ public Object doInPreparedStatement(final PreparedStatement ps) throws SQLExcept for (final int count : updateCounts) { total += count; } - exchange.getIn().setHeader(SqlConstants.SQL_UPDATE_COUNT, total); + exchange.getIn().setHeader(ElsqlConstants.SQL_UPDATE_COUNT, total); } else { isResultSet = ps.execute(); if (isResultSet) { @@ -153,7 +152,7 @@ public Object doInPreparedStatement(final PreparedStatement ps) throws SQLExcept } else { exchange.getOut().setBody(data); } - exchange.getOut().setHeader(SqlConstants.SQL_ROW_COUNT, data.size()); + exchange.getOut().setHeader(ElsqlConstants.SQL_ROW_COUNT, data.size()); } else if (outputType == SqlOutputType.SelectOne) { final Object data = getEndpoint().queryForObject(rs); if (data != null) { @@ -166,14 +165,14 @@ public Object doInPreparedStatement(final PreparedStatement ps) throws SQLExcept } else { exchange.getOut().setBody(data); } - exchange.getOut().setHeader(SqlConstants.SQL_ROW_COUNT, 1); + exchange.getOut().setHeader(ElsqlConstants.SQL_ROW_COUNT, 1); } else { if (getEndpoint().isNoop()) { exchange.getOut().setBody(exchange.getIn().getBody()); } else if (getEndpoint().getOutputHeader() != null) { exchange.getOut().setBody(exchange.getIn().getBody()); } - exchange.getOut().setHeader(SqlConstants.SQL_ROW_COUNT, 0); + exchange.getOut().setHeader(ElsqlConstants.SQL_ROW_COUNT, 0); } } else { throw new IllegalArgumentException("Invalid outputType=" + outputType); @@ -181,7 +180,7 @@ public Object doInPreparedStatement(final PreparedStatement ps) throws SQLExcept } else { // if we are here, there isResultSet is false. This can happen only if we are doing an update operation or there is no result. // we can simply add the updateCount in this case. - exchange.getIn().setHeader(SqlConstants.SQL_UPDATE_COUNT, ps.getUpdateCount()); + exchange.getIn().setHeader(ElsqlConstants.SQL_UPDATE_COUNT, ps.getUpdateCount()); } } } finally { From d9308c5c63f3c1bc3934160495bd0d44c56dd8e2 Mon Sep 17 00:00:00 2001 From: Nicolas Filotto Date: Mon, 21 Mar 2022 12:15:45 +0100 Subject: [PATCH 04/13] CAMEL-17792: Add doc about the message headers of camel-etcd --- .../camel/component/etcd/etcd-keys.json | 8 +++++++ .../camel/component/etcd/etcd-stats.json | 4 ++++ .../camel/component/etcd/etcd-watch.json | 5 +++++ .../src/main/docs/etcd-keys-component.adoc | 3 +++ .../src/main/docs/etcd-stats-component.adoc | 3 +++ .../src/main/docs/etcd-watch-component.adoc | 4 +++- .../camel/component/etcd/EtcdConstants.java | 22 +++++++++++++++++++ .../component/etcd/EtcdKeysEndpoint.java | 7 ++++-- .../component/etcd/EtcdStatsEndpoint.java | 6 +++-- .../component/etcd/EtcdWatchEndpoint.java | 6 +++-- 10 files changed, 61 insertions(+), 7 deletions(-) diff --git a/components/camel-etcd/src/generated/resources/org/apache/camel/component/etcd/etcd-keys.json b/components/camel-etcd/src/generated/resources/org/apache/camel/component/etcd/etcd-keys.json index 90b36b6958a90..3d45062881047 100644 --- a/components/camel-etcd/src/generated/resources/org/apache/camel/component/etcd/etcd-keys.json +++ b/components/camel-etcd/src/generated/resources/org/apache/camel/component/etcd/etcd-keys.json @@ -35,6 +35,14 @@ "useGlobalSslContextParameters": { "kind": "property", "displayName": "Use Global Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Enable usage of global SSL context parameters." }, "userName": { "kind": "property", "displayName": "User Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.etcd.EtcdConfiguration", "configurationField": "configuration", "description": "The user name to use for basic authentication." } }, + "headers": { + "CamelEtcdAction": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The action to perform.\nSupported values:\n\n* set\n* get\n* delete" }, + "CamelEtcdNamespace": { "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The namespace" }, + "CamelEtcdPath": { "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The target path" }, + "CamelEtcdTimeout": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Long or Boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The timeout of the request in milliseconds" }, + "CamelEtcdRecursive": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "To apply an action recursively." }, + "CamelEtcdTtl": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "To set the lifespan of a key in milliseconds." } + }, "properties": { "path": { "kind": "path", "displayName": "Path", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The path the endpoint refers to" }, "recursive": { "kind": "parameter", "displayName": "Recursive", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.etcd.EtcdConfiguration", "configurationField": "configuration", "description": "To apply an action recursively." }, diff --git a/components/camel-etcd/src/generated/resources/org/apache/camel/component/etcd/etcd-stats.json b/components/camel-etcd/src/generated/resources/org/apache/camel/component/etcd/etcd-stats.json index 9eda61549d2e6..4ab6310b0d63b 100644 --- a/components/camel-etcd/src/generated/resources/org/apache/camel/component/etcd/etcd-stats.json +++ b/components/camel-etcd/src/generated/resources/org/apache/camel/component/etcd/etcd-stats.json @@ -38,6 +38,10 @@ "useGlobalSslContextParameters": { "kind": "property", "displayName": "Use Global Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Enable usage of global SSL context parameters." }, "userName": { "kind": "property", "displayName": "User Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.etcd.EtcdConfiguration", "configurationField": "configuration", "description": "The user name to use for basic authentication." } }, + "headers": { + "CamelEtcdNamespace": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The namespace" }, + "CamelEtcdPath": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The target path" } + }, "properties": { "path": { "kind": "path", "displayName": "Path", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The path the endpoint refers to" }, "recursive": { "kind": "parameter", "displayName": "Recursive", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.etcd.EtcdConfiguration", "configurationField": "configuration", "description": "To apply an action recursively." }, diff --git a/components/camel-etcd/src/generated/resources/org/apache/camel/component/etcd/etcd-watch.json b/components/camel-etcd/src/generated/resources/org/apache/camel/component/etcd/etcd-watch.json index 6d8468b491783..b75885e2f1333 100644 --- a/components/camel-etcd/src/generated/resources/org/apache/camel/component/etcd/etcd-watch.json +++ b/components/camel-etcd/src/generated/resources/org/apache/camel/component/etcd/etcd-watch.json @@ -36,6 +36,11 @@ "useGlobalSslContextParameters": { "kind": "property", "displayName": "Use Global Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Enable usage of global SSL context parameters." }, "userName": { "kind": "property", "displayName": "User Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.etcd.EtcdConfiguration", "configurationField": "configuration", "description": "The user name to use for basic authentication." } }, + "headers": { + "CamelEtcdNamespace": { "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The namespace" }, + "CamelEtcdPath": { "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The target path" }, + "CamelEtcdTimeout": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Long or Boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The timeout of the request in milliseconds" } + }, "properties": { "path": { "kind": "path", "displayName": "Path", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The path the endpoint refers to" }, "bridgeErrorHandler": { "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored." }, diff --git a/components/camel-etcd/src/main/docs/etcd-keys-component.adoc b/components/camel-etcd/src/main/docs/etcd-keys-component.adoc index 4a446eb88bd55..e94dfd3e6fb53 100644 --- a/components/camel-etcd/src/main/docs/etcd-keys-component.adoc +++ b/components/camel-etcd/src/main/docs/etcd-keys-component.adoc @@ -35,5 +35,8 @@ include::partial$component-endpoint-options.adoc[] // endpoint options: END +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END include::spring-boot:partial$starter.adoc[] diff --git a/components/camel-etcd/src/main/docs/etcd-stats-component.adoc b/components/camel-etcd/src/main/docs/etcd-stats-component.adoc index c790b15169209..e6bed0db60638 100644 --- a/components/camel-etcd/src/main/docs/etcd-stats-component.adoc +++ b/components/camel-etcd/src/main/docs/etcd-stats-component.adoc @@ -35,5 +35,8 @@ include::partial$component-endpoint-options.adoc[] // endpoint options: END +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END include::spring-boot:partial$starter.adoc[] diff --git a/components/camel-etcd/src/main/docs/etcd-watch-component.adoc b/components/camel-etcd/src/main/docs/etcd-watch-component.adoc index de48c0203a0ef..9183ab744a2ed 100644 --- a/components/camel-etcd/src/main/docs/etcd-watch-component.adoc +++ b/components/camel-etcd/src/main/docs/etcd-watch-component.adoc @@ -36,6 +36,8 @@ include::partial$component-endpoint-options.adoc[] // endpoint options: START // endpoint options: END - +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END include::spring-boot:partial$starter.adoc[] diff --git a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdConstants.java b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdConstants.java index 863d2b2296e48..c02647187ad0a 100644 --- a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdConstants.java +++ b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdConstants.java @@ -16,15 +16,37 @@ */ package org.apache.camel.component.etcd; +import org.apache.camel.spi.Metadata; + public interface EtcdConstants { + // The schemes + String SCHEME_KEYS = "etcd-keys"; + String SCHEME_STATS = "etcd-stats"; + String SCHEME_WATCH = "etcd-watch"; + String ETCD_DEFAULT_URIS = "http://localhost:2379,http://localhost:4001"; + @Metadata(label = "producer", description = "The action to perform.\n" + + "Supported values:\n" + + "\n" + + "* set\n" + + "* get\n" + + "* delete\n", + javaType = "String", applicableFor = SCHEME_KEYS) String ETCD_ACTION = "CamelEtcdAction"; + @Metadata(description = "The namespace", javaType = "String") String ETCD_NAMESPACE = "CamelEtcdNamespace"; + @Metadata(description = "The target path", javaType = "String") String ETCD_PATH = "CamelEtcdPath"; + @Metadata(label = "producer", description = "The timeout of the request in milliseconds", javaType = "Long or Boolean", + applicableFor = { SCHEME_KEYS, SCHEME_WATCH }) String ETCD_TIMEOUT = "CamelEtcdTimeout"; + @Metadata(label = "producer", description = "To apply an action recursively.", javaType = "Boolean", + applicableFor = SCHEME_KEYS) String ETCD_RECURSIVE = "CamelEtcdRecursive"; + @Metadata(label = "producer", description = "To set the lifespan of a key in milliseconds.", javaType = "Integer", + applicableFor = SCHEME_KEYS) String ETCD_TTL = "CamelEtcdTtl"; String ETCD_KEYS_ACTION_SET = "set"; diff --git a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdKeysEndpoint.java b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdKeysEndpoint.java index cab50d5b35169..ee66d9676bd9b 100644 --- a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdKeysEndpoint.java +++ b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdKeysEndpoint.java @@ -22,11 +22,14 @@ import org.apache.camel.Producer; import org.apache.camel.spi.UriEndpoint; +import static org.apache.camel.component.etcd.EtcdConstants.SCHEME_KEYS; + /** * Get, set or delete keys in etcd key-value store. */ -@UriEndpoint(firstVersion = "2.18.0", scheme = "etcd-keys", title = "Etcd Keys", producerOnly = true, - syntax = "etcd-keys:path", category = { Category.CLUSTERING, Category.DATABASE }) +@UriEndpoint(firstVersion = "2.18.0", scheme = SCHEME_KEYS, title = "Etcd Keys", producerOnly = true, + syntax = "etcd-keys:path", category = { Category.CLUSTERING, Category.DATABASE }, + headersClass = EtcdConstants.class) public class EtcdKeysEndpoint extends AbstractEtcdEndpoint { public EtcdKeysEndpoint( diff --git a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdStatsEndpoint.java b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdStatsEndpoint.java index 4771d46f87e13..8dbfcf458f2f9 100644 --- a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdStatsEndpoint.java +++ b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdStatsEndpoint.java @@ -22,11 +22,13 @@ import org.apache.camel.Producer; import org.apache.camel.spi.UriEndpoint; +import static org.apache.camel.component.etcd.EtcdConstants.SCHEME_STATS; + /** * Access etcd cluster statistcs. */ -@UriEndpoint(firstVersion = "2.18.0", scheme = "etcd-stats", title = "Etcd Stats", - syntax = "etcd-stats:path", label = "clustering,database") +@UriEndpoint(firstVersion = "2.18.0", scheme = SCHEME_STATS, title = "Etcd Stats", + syntax = "etcd-stats:path", label = "clustering,database", headersClass = EtcdConstants.class) public class EtcdStatsEndpoint extends AbstractEtcdPollingEndpoint { public EtcdStatsEndpoint( diff --git a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdWatchEndpoint.java b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdWatchEndpoint.java index 9b27647f1b895..2f0fb3d3dce9f 100644 --- a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdWatchEndpoint.java +++ b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdWatchEndpoint.java @@ -21,11 +21,13 @@ import org.apache.camel.Producer; import org.apache.camel.spi.UriEndpoint; +import static org.apache.camel.component.etcd.EtcdConstants.SCHEME_WATCH; + /** * Watch specific etcd keys or directories for changes. */ -@UriEndpoint(firstVersion = "2.18.0", scheme = "etcd-watch", title = "Etcd Watch", consumerOnly = true, - syntax = "etcd-watch:path", label = "clustering,database") +@UriEndpoint(firstVersion = "2.18.0", scheme = SCHEME_WATCH, title = "Etcd Watch", consumerOnly = true, + syntax = "etcd-watch:path", label = "clustering,database", headersClass = EtcdConstants.class) public class EtcdWatchEndpoint extends AbstractEtcdEndpoint { public EtcdWatchEndpoint( From 8e31169875b8172267760489f3472892cce99727 Mon Sep 17 00:00:00 2001 From: Nicolas Filotto Date: Mon, 21 Mar 2022 12:31:17 +0100 Subject: [PATCH 05/13] CAMEL-17792: Add doc about the message headers of camel-exec --- .../org/apache/camel/component/exec/exec.json | 11 +++++ .../src/main/docs/exec-component.adoc | 48 ++----------------- .../camel/component/exec/ExecBinding.java | 37 ++++++++++++-- .../camel/component/exec/ExecEndpoint.java | 2 +- 4 files changed, 49 insertions(+), 49 deletions(-) diff --git a/components/camel-exec/src/generated/resources/org/apache/camel/component/exec/exec.json b/components/camel-exec/src/generated/resources/org/apache/camel/component/exec/exec.json index 4a61929fa0ab0..34c87d329ce13 100644 --- a/components/camel-exec/src/generated/resources/org/apache/camel/component/exec/exec.json +++ b/components/camel-exec/src/generated/resources/org/apache/camel/component/exec/exec.json @@ -25,6 +25,17 @@ "lazyStartProducer": { "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": { "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." } }, + "headers": { + "CamelExecCommandExecutable": { "kind": "header", "displayName": "", "group": "in", "label": "in", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the system command that will be executed. Overrides\n`executable` in the URI." }, + "CamelExecCommandArgs": { "kind": "header", "displayName": "", "group": "in", "label": "in", "required": false, "javaType": "java.util.List or String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Command-line argument(s) to pass to the executed process. The argument(s)\nis\/are used literally - no quoting is applied. Overrides any existing\n`args` in the URI." }, + "CamelExecCommandOutFile": { "kind": "header", "displayName": "", "group": "in", "label": "in", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of a file, created by the executable, that should be considered\nas its output. Overrides any existing `outFile` in the URI." }, + "CamelExecCommandWorkingDir": { "kind": "header", "displayName": "", "group": "in", "label": "in", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The directory in which the command should be executed. Overrides any\nexisting `workingDir` in the URI." }, + "CamelExecCommandTimeout": { "kind": "header", "displayName": "", "group": "in", "label": "in", "required": false, "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The timeout, in milliseconds, after which the executable should be\nterminated. Overrides any existing `timeout` in the URI." }, + "CamelExecStderr": { "kind": "header", "displayName": "", "group": "out", "label": "out", "required": false, "javaType": "java.io.InputStream", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The value of this header points to the standard error stream (stderr) of\nthe executable. If no stderr is written, the value is `null`." }, + "CamelExecExitValue": { "kind": "header", "displayName": "", "group": "out", "label": "out", "required": false, "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The value of this header is the _exit value_ of the executable. Non-zero\nexit values typically indicate abnormal termination. Note that the exit\nvalue is OS-dependent." }, + "CamelExecUseStderrOnEmptyStdout": { "kind": "header", "displayName": "", "group": "in", "label": "in", "required": false, "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Indicates that when `stdout` is empty, this component will populate the\nCamel Message Body with `stderr`. This behavior is disabled (`false`) by\ndefault." }, + "CamelExecCommandLogLevel": { "kind": "header", "displayName": "", "group": "in", "label": "in", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Logging level to be used for commands during execution. The default value is DEBUG.\nPossible values are TRACE, DEBUG, INFO, WARN, ERROR or OFF (Values of LoggingLevel enum)" } + }, "properties": { "executable": { "kind": "path", "displayName": "Executable", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sets the executable to be executed. The executable must not be empty or null." }, "args": { "kind": "parameter", "displayName": "Args", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The arguments may be one or many whitespace-separated tokens." }, diff --git a/components/camel-exec/src/main/docs/exec-component.adoc b/components/camel-exec/src/main/docs/exec-component.adoc index 5f71568e0c0f2..4d37d5387e78c 100644 --- a/components/camel-exec/src/main/docs/exec-component.adoc +++ b/components/camel-exec/src/main/docs/exec-component.adoc @@ -53,51 +53,9 @@ include::partial$component-endpoint-options.adoc[] // endpoint options: END - -== Message headers - -The supported headers are defined in -`org.apache.camel.component.exec.ExecBinding`. - -[width="100%",cols="10%,10%,10%,70%",options="header",] -|======================================================================= -|Name |Type |Message |Description - -|`ExecBinding.EXEC_COMMAND_EXECUTABLE` |`String` |`in` |The name of the system command that will be executed. Overrides -`executable` in the URI. - -|`ExecBinding.EXEC_COMMAND_ARGS` |`java.util.List` |`in` |Command-line arguments to pass to the executed process. The arguments -are used literally - no quoting is applied. Overrides any existing -`args` in the URI. - -|`ExecBinding.EXEC_COMMAND_ARGS` |`String`| `in` |The arguments of the executable as a Single string where -each argument is whitespace separated (see `args` in URI option). The -arguments are used literally, no quoting is applied. Overrides any -existing `args` in the URI. - -|`ExecBinding.EXEC_COMMAND_OUT_FILE` |`String` |`in` |The name of a file, created by the executable, that should be considered -as its output. Overrides any existing `outFile` in the URI. - -|`ExecBinding.EXEC_COMMAND_TIMEOUT` |`long` |`in` |The timeout, in milliseconds, after which the executable should be -terminated. Overrides any existing `timeout` in the URI. - -|`ExecBinding.EXEC_COMMAND_WORKING_DIR` |`String` |`in` |The directory in which the command should be executed. Overrides any -existing `workingDir` in the URI. - -|`ExecBinding.EXEC_EXIT_VALUE` |`int` |`out` |The value of this header is the _exit value_ of the executable. Non-zero -exit values typically indicate abnormal termination. Note that the exit -value is OS-dependent. - -|`ExecBinding.EXEC_STDERR` |`java.io.InputStream` |`out` |The value of this header points to the standard error stream (stderr) of -the executable. If no stderr is written, the value is `null`. - -|`ExecBinding.EXEC_USE_STDERR_ON_EMPTY_STDOUT` |`boolean` |`in` |Indicates that when `stdout` is empty, this component will populate the -Camel Message Body with `stderr`. This behavior is disabled (`false`) by -default. - -|`ExecBinding.EXEC_COMMANDS_LOG_LEVEL` |`String` |`in` |Logging level to be used for commands during execution. The default value is DEBUG. -Possible values are TRACE, DEBUG, INFO, WARN, ERROR or OFF (Values of LoggingLevel enum) -|======================================================================= +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END == Message body diff --git a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecBinding.java b/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecBinding.java index 51210a794e4e2..dfcee03f0bf75 100644 --- a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecBinding.java +++ b/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecBinding.java @@ -19,6 +19,7 @@ import java.io.InputStream; import org.apache.camel.Exchange; +import org.apache.camel.spi.Metadata; /** * Represents the binding of input and output types of a {@link ExecCommandExecutor} to an {@link Exchange}. The input @@ -33,14 +34,21 @@ public interface ExecBinding { * e.g. in the URI exec:C:/Program Files/jdk/java.exe , C:/Program * Files/jdk/java.exe is the executable. */ + @Metadata(label = "in", description = "The name of the system command that will be executed. Overrides\n" + + "`executable` in the URI.", + javaType = "String") String EXEC_COMMAND_EXECUTABLE = "CamelExecCommandExecutable"; /** * The header value overrides the existing command arguments in the {@link ExecEndpoint} URI. The arguments may be a * List. In this case no parsing of the arguments is necessary. * - * @see {@link #EXEC_COMMAND_EXECUTABLE} + * @see #EXEC_COMMAND_EXECUTABLE */ + @Metadata(label = "in", description = "Command-line argument(s) to pass to the executed process. The argument(s)\n" + + "is/are used literally - no quoting is applied. Overrides any existing\n" + + "`args` in the URI.", + javaType = "java.util.List or String") String EXEC_COMMAND_ARGS = "CamelExecCommandArgs"; /** @@ -49,6 +57,9 @@ public interface ExecBinding { * * @see ExecResultConverter#toInputStream(ExecResult) */ + @Metadata(label = "in", description = "The name of a file, created by the executable, that should be considered\n" + + "as its output. Overrides any existing `outFile` in the URI.", + javaType = "String") String EXEC_COMMAND_OUT_FILE = "CamelExecCommandOutFile"; /** @@ -56,17 +67,26 @@ public interface ExecBinding { * command in the endpoint URI. If this is not configured, the working directory of the current process will be * used. */ + @Metadata(label = "in", description = "The directory in which the command should be executed. Overrides any\n" + + "existing `workingDir` in the URI.", + javaType = "String") String EXEC_COMMAND_WORKING_DIR = "CamelExecCommandWorkingDir"; /** * Specifies the amount of time, in milliseconds, after which the process of the executable should be terminated. * The default value is {@link Long#MAX_VALUE}. */ + @Metadata(label = "in", description = "The timeout, in milliseconds, after which the executable should be\n" + + "terminated. Overrides any existing `timeout` in the URI.", + javaType = "long") String EXEC_COMMAND_TIMEOUT = "CamelExecCommandTimeout"; /** * The value of this header is a {@link InputStream} with the standard error stream of the executable. */ + @Metadata(label = "out", description = "The value of this header points to the standard error stream (stderr) of\n" + + "the executable. If no stderr is written, the value is `null`.", + javaType = "java.io.InputStream") String EXEC_STDERR = "CamelExecStderr"; /** @@ -74,18 +94,29 @@ public interface ExecBinding { * exit value indicates abnormal termination.
* Note that the exit value is OS dependent. */ + @Metadata(label = "out", description = "The value of this header is the _exit value_ of the executable. Non-zero\n" + + "exit values typically indicate abnormal termination. Note that the exit\n" + + "value is OS-dependent.", + javaType = "int") String EXEC_EXIT_VALUE = "CamelExecExitValue"; /** - * The value of this header is a boolean which indicates whether or not to fallback and use stderr when stdout is - * empty. + * The value of this header is a boolean which indicates whether to fallback and use stderr when stdout is empty. */ + @Metadata(label = "in", description = "Indicates that when `stdout` is empty, this component will populate the\n" + + "Camel Message Body with `stderr`. This behavior is disabled (`false`) by\n" + + "default.", + javaType = "boolean") String EXEC_USE_STDERR_ON_EMPTY_STDOUT = "CamelExecUseStderrOnEmptyStdout"; /** * The value of this header define logging level to be used for commands during execution. The default value is * INFO. Possible values are TRACE, DEBUG, INFO, WARN, ERROR or OFF. (Values of LoggingLevel enum) */ + @Metadata(label = "in", + description = "Logging level to be used for commands during execution. The default value is DEBUG.\n" + + "Possible values are TRACE, DEBUG, INFO, WARN, ERROR or OFF (Values of LoggingLevel enum)", + javaType = "String") String EXEC_COMMAND_LOG_LEVEL = "CamelExecCommandLogLevel"; /** diff --git a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecEndpoint.java b/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecEndpoint.java index d73bed795204b..5a54d777fecab 100644 --- a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecEndpoint.java +++ b/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecEndpoint.java @@ -34,7 +34,7 @@ * Execute commands on the underlying operating system. */ @UriEndpoint(firstVersion = "2.3.0", scheme = "exec", title = "Exec", syntax = "exec:executable", producerOnly = true, - category = { Category.SYSTEM }) + category = { Category.SYSTEM }, headersClass = ExecBinding.class) public class ExecEndpoint extends DefaultEndpoint { /** From 4996515e1988e7eae47736d3420f5cf110c55348 Mon Sep 17 00:00:00 2001 From: Nicolas Filotto Date: Mon, 21 Mar 2022 12:40:54 +0100 Subject: [PATCH 06/13] CAMEL-17792: Add doc about the message headers of camel-facebook --- .../org/apache/camel/component/facebook/facebook.json | 3 +++ .../camel-facebook/src/main/docs/facebook-component.adoc | 4 +++- .../apache/camel/component/facebook/FacebookConstants.java | 3 +++ .../org/apache/camel/component/facebook/FacebookEndpoint.java | 2 +- .../org/apache/camel/component/facebook/FacebookProducer.java | 3 +-- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/components/camel-facebook/src/generated/resources/org/apache/camel/component/facebook/facebook.json b/components/camel-facebook/src/generated/resources/org/apache/camel/component/facebook/facebook.json index 0452200d82e35..d87a3a7141310 100644 --- a/components/camel-facebook/src/generated/resources/org/apache/camel/component/facebook/facebook.json +++ b/components/camel-facebook/src/generated/resources/org/apache/camel/component/facebook/facebook.json @@ -54,6 +54,9 @@ "oAuthAuthorizationURL": { "kind": "property", "displayName": "OAuth Authorization URL", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "https:\/\/www.facebook.com\/dialog\/oauth", "configurationClass": "org.apache.camel.component.facebook.config.FacebookConfiguration", "configurationField": "configuration", "description": "OAuth authorization URL" }, "oAuthPermissions": { "kind": "property", "displayName": "OAuth Permissions", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.facebook.config.FacebookConfiguration", "configurationField": "configuration", "description": "Default OAuth permissions. Comma separated permission names. See https:\/\/developers.facebook.com\/docs\/reference\/login\/#permissions for the detail" } }, + "headers": { + "CamelFacebook.rawJSON": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The raw json" } + }, "properties": { "methodName": { "kind": "path", "displayName": "Method Name", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "What operation to perform" }, "achievementURL": { "kind": "parameter", "displayName": "Achievement URL", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.net.URL", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.facebook.config.FacebookEndpointConfiguration", "configurationField": "configuration", "description": "The unique URL of the achievement" }, diff --git a/components/camel-facebook/src/main/docs/facebook-component.adoc b/components/camel-facebook/src/main/docs/facebook-component.adoc index 7c3f8bd45ae41..de92a45744ed7 100644 --- a/components/camel-facebook/src/main/docs/facebook-component.adoc +++ b/components/camel-facebook/src/main/docs/facebook-component.adoc @@ -70,7 +70,9 @@ include::partial$component-endpoint-options.adoc[] // endpoint options: END - +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END == Producer Endpoints: diff --git a/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookConstants.java b/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookConstants.java index 85f13d3ca2362..47fbd143ace5b 100644 --- a/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookConstants.java +++ b/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookConstants.java @@ -16,6 +16,8 @@ */ package org.apache.camel.component.facebook; +import org.apache.camel.spi.Metadata; + /** * Common constants. */ @@ -33,5 +35,6 @@ public interface FacebookConstants { // date format used by Facebook Reading since and until fields String FACEBOOK_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ"; + @Metadata(description = "The raw json", javaType = "String") String RAW_JSON_HEADER = FACEBOOK_PROPERTY_PREFIX + "rawJSON"; } diff --git a/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookEndpoint.java b/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookEndpoint.java index 75d8b31a6dbec..07441914fcd57 100644 --- a/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookEndpoint.java +++ b/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookEndpoint.java @@ -55,7 +55,7 @@ * locations, etc. */ @UriEndpoint(firstVersion = "2.14.0", scheme = "facebook", title = "Facebook", syntax = "facebook:methodName", - category = { Category.SOCIAL }) + category = { Category.SOCIAL }, headersClass = FacebookConstants.class) public class FacebookEndpoint extends DefaultEndpoint implements FacebookConstants { private static final Logger LOG = LoggerFactory.getLogger(FacebookEndpoint.class); diff --git a/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookProducer.java b/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookProducer.java index 3119c2ef67bb5..e70f92ad40089 100644 --- a/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookProducer.java +++ b/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookProducer.java @@ -109,8 +109,7 @@ public void run() { // copy headers exchange.getMessage().setHeaders(exchange.getIn().getHeaders()); if (rawJSON != null) { - exchange.getMessage().setHeader(FacebookConstants.FACEBOOK_PROPERTY_PREFIX + "rawJSON", - rawJSON); + exchange.getMessage().setHeader(FacebookConstants.RAW_JSON_HEADER, rawJSON); } } catch (Exception t) { From 808ca824e5a65500e9cc1f96214e92cccf24591a Mon Sep 17 00:00:00 2001 From: Nicolas Filotto Date: Mon, 21 Mar 2022 14:17:06 +0100 Subject: [PATCH 07/13] CAMEL-17792: Add doc about the message headers of camel-file --- .../org/apache/camel/component/file/file.json | 19 ++++- .../src/main/docs/file-component.adoc | 64 +------------- .../camel/component/file/FileConstants.java | 84 +++++++++++++++++++ .../camel/component/file/FileConsumer.java | 4 +- .../camel/component/file/FileEndpoint.java | 2 +- .../camel/component/file/FileOperations.java | 8 +- .../camel/component/file/GenericFile.java | 26 +++--- ...icFileDefaultMoveExistingFileStrategy.java | 6 +- .../component/file/GenericFileEndpoint.java | 15 ++-- .../file/GenericFilePollingConsumer.java | 2 +- .../component/file/GenericFileProducer.java | 20 ++--- .../GenericFileProcessStrategySupport.java | 3 +- 12 files changed, 150 insertions(+), 103 deletions(-) create mode 100644 components/camel-file/src/main/java/org/apache/camel/component/file/FileConstants.java diff --git a/components/camel-file/src/generated/resources/org/apache/camel/component/file/file.json b/components/camel-file/src/generated/resources/org/apache/camel/component/file/file.json index f6e6025eb423f..e34e00cefddb9 100644 --- a/components/camel-file/src/generated/resources/org/apache/camel/component/file/file.json +++ b/components/camel-file/src/generated/resources/org/apache/camel/component/file/file.json @@ -26,6 +26,23 @@ "lazyStartProducer": { "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": { "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." } }, + "headers": { + "CamelFileLength": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A `long` value containing the file size." }, + "CamelFileLastModified": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A `Long` value containing the last modified timestamp of the file." }, + "CamelFileLocalWorkPath": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "File", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The local work path" }, + "CamelFileNameOnly": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Only the file name (the name with no leading paths)." }, + "CamelFileName": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "(producer) Specifies the name of the file to write (relative to the endpoint\ndirectory). This name can be a `String`; a `String` with a\nxref:languages:file-language.adoc[File Language] or xref:languages:simple-language.adoc[Simple]\nexpression; or an Expression object. If it's\n`null` then Camel will auto-generate a filename based on the message\nunique ID. (consumer) Name of the consumed file as a relative file path with offset from the\nstarting directory configured on the endpoint." }, + "CamelFileNameConsumed": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the file that has been consumed" }, + "CamelFileAbsolute": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "Boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A `boolean` option specifying whether the consumed file denotes an\nabsolute path or not. Should normally be `false` for relative paths.\nAbsolute paths should normally not be used but we added to the move\noption to allow moving files to absolute paths. But can be used\nelsewhere as well." }, + "CamelFileAbsolutePath": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The absolute path to the file. For relative files this path holds the\nrelative path instead." }, + "CamelFileExtendedAttributes": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "Map", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The extended attributes of the file" }, + "CamelFileContentType": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The content type of the file" }, + "CamelFilePath": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file path. For relative files this is the starting directory + the\nrelative filename. For absolute files this is the absolute path." }, + "CamelFileRelativePath": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The relative path." }, + "CamelFileParent": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The parent path." }, + "CamelFileNameProduced": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The actual absolute filepath (path + name) for the output file that was\nwritten. This header is set by Camel and its purpose is providing\nend-users with the name of the file that was written." }, + "CamelOverruleFileName": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Object", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Is used for overruling `CamelFileName` header and use the\nvalue instead (but only once, as the producer will remove this header\nafter writing the file). The value can be only be a String. Notice that\nif the option `fileName` has been configured, then this is still being\nevaluated." } + }, "properties": { "directoryName": { "kind": "path", "displayName": "Directory Name", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.io.File", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The starting directory" }, "charset": { "kind": "parameter", "displayName": "Charset", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "This option is used to specify the encoding of the file. You can use this on the consumer, to specify the encodings of the files, which allow Camel to know the charset it should load the file content in case the file content is being accessed. Likewise when writing a file, you can use this option to specify which charset to write the file as well. Do mind that when writing the file Camel may have to read the message content into memory to be able to convert the data into the configured charset, so do not use this if you have big messages." }, @@ -64,7 +81,7 @@ "chmodDirectory": { "kind": "parameter", "displayName": "Chmod Directory", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Specify the directory permissions used when the producer creates missing directories, the chmod value must be between 000 and 777; If there is a leading digit like in 0755 we will ignore it." }, "eagerDeleteTargetFile": { "kind": "parameter", "displayName": "Eager Delete Target File", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not to eagerly delete any existing target file. This option only applies when you use fileExists=Override and the tempFileName option as well. You can use this to disable (set it to false) deleting the target file before the temp file is written. For example you may write big files and want the target file to exists during the temp file is being written. This ensure the target file is only deleted until the very last moment, just before the temp file is being renamed to the target filename. This option is also used to control whether to delete any existing files when fileExist=Move is enabled, and an existing file exists. If this option copyAndDeleteOnRenameFails false, then an exception will be thrown if an existing file existed, if its true, then the existing file is deleted before the move operation." }, "forceWrites": { "kind": "parameter", "displayName": "Force Writes", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to force syncing writes to the file system. You can turn this off if you do not want this level of guarantee, for example if writing to logs \/ audit logs etc; this would yield better performance." }, - "keepLastModified": { "kind": "parameter", "displayName": "Keep Last Modified", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Will keep the last modified timestamp from the source file (if any). Will use the Exchange.FILE_LAST_MODIFIED header to located the timestamp. This header can contain either a java.util.Date or long with the timestamp. If the timestamp exists and the option is enabled it will set this timestamp on the written file. Note: This option only applies to the file producer. You cannot use this option with any of the ftp producers." }, + "keepLastModified": { "kind": "parameter", "displayName": "Keep Last Modified", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Will keep the last modified timestamp from the source file (if any). Will use the FileConstants.FILE_LAST_MODIFIED header to located the timestamp. This header can contain either a java.util.Date or long with the timestamp. If the timestamp exists and the option is enabled it will set this timestamp on the written file. Note: This option only applies to the file producer. You cannot use this option with any of the ftp producers." }, "moveExistingFileStrategy": { "kind": "parameter", "displayName": "Move Existing File Strategy", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.file.strategy.FileMoveExistingStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "Strategy (Custom Strategy) used to move file with special naming token to use when fileExist=Move is configured. By default, there is an implementation used if no custom strategy is provided" }, "autoCreate": { "kind": "parameter", "displayName": "Auto Create", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Automatically create missing directories in the file's pathname. For the file consumer, that means creating the starting directory. For the file producer, it means the directory the files should be written to." }, "bufferSize": { "kind": "parameter", "displayName": "Buffer Size", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 131072, "description": "Buffer size in bytes used for writing files (or in case of FTP for downloading and uploading files)." }, diff --git a/components/camel-file/src/main/docs/file-component.adoc b/components/camel-file/src/main/docs/file-component.adoc index 3f50bee895d2e..397d11300b608 100644 --- a/components/camel-file/src/main/docs/file-component.adoc +++ b/components/camel-file/src/main/docs/file-component.adoc @@ -64,6 +64,10 @@ include::partial$component-endpoint-options.adoc[] // endpoint options: END +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END + [TIP] ==== *Default behavior for file producer* @@ -165,66 +169,6 @@ timestamp you can use See more examples at xref:languages:file-language.adoc[File Language] -== Message Headers - -The following headers are supported by this component: - -=== File producer only - -[width="100%",cols="10%,90%",options="header",] -|=== -|Header |Description - -|`CamelFileName` |Specifies the name of the file to write (relative to the endpoint -directory). This name can be a `String`; a `String` with a -xref:languages:file-language.adoc[File Language] or xref:languages:simple-language.adoc[Simple] -expression; or an Expression object. If it's -`null` then Camel will auto-generate a filename based on the message -unique ID. - -|`CamelFileNameProduced` |The actual absolute filepath (path + name) for the output file that was -written. This header is set by Camel and its purpose is providing -end-users with the name of the file that was written. - -|`CamelOverruleFileName` |Is used for overruling `CamelFileName` header and use the -value instead (but only once, as the producer will remove this header -after writing the file). The value can be only be a String. Notice that -if the option `fileName` has been configured, then this is still being -evaluated. -|=== - -=== File consumer only - -[width="100%",cols="10%,90%",options="header",] -|=== -|Header |Description - -|`CamelFileName` |Name of the consumed file as a relative file path with offset from the -starting directory configured on the endpoint. - -|`CamelFileNameOnly` |Only the file name (the name with no leading paths). - -|`CamelFileAbsolute` |A `boolean` option specifying whether the consumed file denotes an -absolute path or not. Should normally be `false` for relative paths. -Absolute paths should normally not be used but we added to the move -option to allow moving files to absolute paths. But can be used -elsewhere as well. - -|`CamelFileAbsolutePath` |The absolute path to the file. For relative files this path holds the -relative path instead. - -|`CamelFilePath` |The file path. For relative files this is the starting directory + the -relative filename. For absolute files this is the absolute path. - -|`CamelFileRelativePath` |The relative path. - -|`CamelFileParent` |The parent path. - -|`CamelFileLength` |A `long` value containing the file size. - -|`CamelFileLastModified` |A `Long` value containing the last modified timestamp of the file. -|=== - == Batch Consumer This component implements the Batch Consumer. diff --git a/components/camel-file/src/main/java/org/apache/camel/component/file/FileConstants.java b/components/camel-file/src/main/java/org/apache/camel/component/file/FileConstants.java new file mode 100644 index 0000000000000..12cedba0e2b99 --- /dev/null +++ b/components/camel-file/src/main/java/org/apache/camel/component/file/FileConstants.java @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.file; + +import org.apache.camel.Exchange; +import org.apache.camel.spi.Metadata; + +public final class FileConstants { + + @Metadata(label = "consumer", description = "A `long` value containing the file size.", javaType = "long") + public static final String FILE_LENGTH = Exchange.FILE_LENGTH; + @Metadata(label = "consumer", description = "A `Long` value containing the last modified timestamp of the file.", + javaType = "long") + public static final String FILE_LAST_MODIFIED = Exchange.FILE_LAST_MODIFIED; + @Metadata(label = "producer", description = "The local work path", javaType = "File") + public static final String FILE_LOCAL_WORK_PATH = Exchange.FILE_LOCAL_WORK_PATH; + @Metadata(description = "Only the file name (the name with no leading paths).", javaType = "String") + public static final String FILE_NAME_ONLY = Exchange.FILE_NAME_ONLY; + @Metadata(description = "(producer) Specifies the name of the file to write (relative to the endpoint\n" + + "directory). This name can be a `String`; a `String` with a\n" + + "xref:languages:file-language.adoc[File Language] or xref:languages:simple-language.adoc[Simple]\n" + + + "expression; or an Expression object. If it's\n" + + "`null` then Camel will auto-generate a filename based on the message\n" + + "unique ID. (consumer) Name of the consumed file as a relative file path with offset from the\n" + + "starting directory configured on the endpoint.", + javaType = "String") + public static final String FILE_NAME = Exchange.FILE_NAME; + @Metadata(label = "consumer", description = "The name of the file that has been consumed", javaType = "String") + public static final String FILE_NAME_CONSUMED = Exchange.FILE_NAME_CONSUMED; + @Metadata(label = "consumer", description = "A `boolean` option specifying whether the consumed file denotes an\n" + + "absolute path or not. Should normally be `false` for relative paths.\n" + + "Absolute paths should normally not be used but we added to the move\n" + + "option to allow moving files to absolute paths. But can be used\n" + + "elsewhere as well.", + javaType = "Boolean") + public static final String FILE_ABSOLUTE = "CamelFileAbsolute"; + @Metadata(label = "consumer", description = "The absolute path to the file. For relative files this path holds the\n" + + "relative path instead.", + javaType = "String") + public static final String FILE_ABSOLUTE_PATH = "CamelFileAbsolutePath"; + @Metadata(label = "consumer", description = "The extended attributes of the file", javaType = "Map") + public static final String FILE_EXTENDED_ATTRIBUTES = "CamelFileExtendedAttributes"; + @Metadata(label = "consumer", description = "The content type of the file", javaType = "String") + public static final String FILE_CONTENT_TYPE = Exchange.FILE_CONTENT_TYPE; + @Metadata(label = "consumer", description = "The file path. For relative files this is the starting directory + the\n" + + "relative filename. For absolute files this is the absolute path.", + javaType = "String") + public static final String FILE_PATH = Exchange.FILE_PATH; + @Metadata(label = "consumer", description = "The relative path.", javaType = "String") + public static final String FILE_RELATIVE_PATH = "CamelFileRelativePath"; + @Metadata(description = "The parent path.", javaType = "String") + public static final String FILE_PARENT = Exchange.FILE_PARENT; + @Metadata(label = "producer", description = "The actual absolute filepath (path + name) for the output file that was\n" + + "written. This header is set by Camel and its purpose is providing\n" + + "end-users with the name of the file that was written.", + javaType = "String") + public static final String FILE_NAME_PRODUCED = Exchange.FILE_NAME_PRODUCED; + @Metadata(label = "producer", description = "Is used for overruling `CamelFileName` header and use the\n" + + "value instead (but only once, as the producer will remove this header\n" + + "after writing the file). The value can be only be a String. Notice that\n" + + "if the option `fileName` has been configured, then this is still being\n" + + "evaluated.", + javaType = "Object") + public static final String OVERRULE_FILE_NAME = Exchange.OVERRULE_FILE_NAME; + + private FileConstants() { + // Utility class + } +} diff --git a/components/camel-file/src/main/java/org/apache/camel/component/file/FileConsumer.java b/components/camel-file/src/main/java/org/apache/camel/component/file/FileConsumer.java index bd79aadb00552..6dedb43cd186b 100644 --- a/components/camel-file/src/main/java/org/apache/camel/component/file/FileConsumer.java +++ b/components/camel-file/src/main/java/org/apache/camel/component/file/FileConsumer.java @@ -288,10 +288,10 @@ protected void updateFileHeaders(GenericFile file, Message message) { file.setFileLength(length); file.setLastModified(modified); if (length >= 0) { - message.setHeader(Exchange.FILE_LENGTH, length); + message.setHeader(FileConstants.FILE_LENGTH, length); } if (modified >= 0) { - message.setHeader(Exchange.FILE_LAST_MODIFIED, modified); + message.setHeader(FileConstants.FILE_LAST_MODIFIED, modified); } } diff --git a/components/camel-file/src/main/java/org/apache/camel/component/file/FileEndpoint.java b/components/camel-file/src/main/java/org/apache/camel/component/file/FileEndpoint.java index dc51742c65677..b61c4c0119e57 100644 --- a/components/camel-file/src/main/java/org/apache/camel/component/file/FileEndpoint.java +++ b/components/camel-file/src/main/java/org/apache/camel/component/file/FileEndpoint.java @@ -47,7 +47,7 @@ * Read and write files. */ @UriEndpoint(firstVersion = "1.0.0", scheme = "file", title = "File", syntax = "file:directoryName", - category = { Category.FILE, Category.CORE }) + category = { Category.FILE, Category.CORE }, headersClass = FileConstants.class) public class FileEndpoint extends GenericFileEndpoint { private static final Logger LOG = LoggerFactory.getLogger(FileEndpoint.class); diff --git a/components/camel-file/src/main/java/org/apache/camel/component/file/FileOperations.java b/components/camel-file/src/main/java/org/apache/camel/component/file/FileOperations.java index cfe03cd712973..15232be6b27b8 100644 --- a/components/camel-file/src/main/java/org/apache/camel/component/file/FileOperations.java +++ b/components/camel-file/src/main/java/org/apache/camel/component/file/FileOperations.java @@ -321,7 +321,7 @@ public boolean storeFile(String fileName, Exchange exchange, long size) throws G // a full file to file copy, as the local work copy is to be // deleted afterwards anyway // local work path - File local = exchange.getIn().getHeader(Exchange.FILE_LOCAL_WORK_PATH, File.class); + File local = exchange.getIn().getHeader(FileConstants.FILE_LOCAL_WORK_PATH, File.class); if (local != null && local.exists()) { boolean renamed = writeFileByLocalWorkPath(local, file); if (renamed) { @@ -340,7 +340,7 @@ public boolean storeFile(String fileName, Exchange exchange, long size) throws G } } // clear header as we have renamed the file - exchange.getIn().setHeader(Exchange.FILE_LOCAL_WORK_PATH, null); + exchange.getIn().setHeader(FileConstants.FILE_LOCAL_WORK_PATH, null); // return as the operation is complete, we just renamed // the local work file // to the target. @@ -415,12 +415,12 @@ public boolean storeFile(String fileName, Exchange exchange, long size) throws G private void keepLastModified(Exchange exchange, File file) { if (endpoint.isKeepLastModified()) { Long last; - Date date = exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, Date.class); + Date date = exchange.getIn().getHeader(FileConstants.FILE_LAST_MODIFIED, Date.class); if (date != null) { last = date.getTime(); } else { // fallback and try a long - last = exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, Long.class); + last = exchange.getIn().getHeader(FileConstants.FILE_LAST_MODIFIED, Long.class); } if (last != null) { boolean result = file.setLastModified(last); diff --git a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFile.java b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFile.java index d848782251107..c04a0e9ecc35e 100644 --- a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFile.java +++ b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFile.java @@ -150,43 +150,43 @@ private GenericFileMessage commonBindToExchange(Exchange exchange) { */ public void populateHeaders(GenericFileMessage message, boolean isProbeContentTypeFromEndpoint) { if (message != null) { - message.setHeader(Exchange.FILE_NAME_ONLY, getFileNameOnly()); - message.setHeader(Exchange.FILE_NAME, getFileName()); - message.setHeader(Exchange.FILE_NAME_CONSUMED, getFileName()); - message.setHeader("CamelFileAbsolute", isAbsolute()); - message.setHeader("CamelFileAbsolutePath", getAbsoluteFilePath()); + message.setHeader(FileConstants.FILE_NAME_ONLY, getFileNameOnly()); + message.setHeader(FileConstants.FILE_NAME, getFileName()); + message.setHeader(FileConstants.FILE_NAME_CONSUMED, getFileName()); + message.setHeader(FileConstants.FILE_ABSOLUTE, isAbsolute()); + message.setHeader(FileConstants.FILE_ABSOLUTE_PATH, getAbsoluteFilePath()); if (extendedAttributes != null) { - message.setHeader("CamelFileExtendedAttributes", extendedAttributes); + message.setHeader(FileConstants.FILE_EXTENDED_ATTRIBUTES, extendedAttributes); } if ((isProbeContentTypeFromEndpoint || probeContentType) && file instanceof File) { File f = (File) file; Path path = f.toPath(); try { - message.setHeader(Exchange.FILE_CONTENT_TYPE, Files.probeContentType(path)); + message.setHeader(FileConstants.FILE_CONTENT_TYPE, Files.probeContentType(path)); } catch (Exception e) { // just ignore the exception } } if (isAbsolute()) { - message.setHeader(Exchange.FILE_PATH, getAbsoluteFilePath()); + message.setHeader(FileConstants.FILE_PATH, getAbsoluteFilePath()); } else { // we must normalize path according to protocol if we build our // own paths String path = normalizePathToProtocol(getEndpointPath() + File.separator + getRelativeFilePath()); - message.setHeader(Exchange.FILE_PATH, path); + message.setHeader(FileConstants.FILE_PATH, path); } - message.setHeader("CamelFileRelativePath", getRelativeFilePath()); - message.setHeader(Exchange.FILE_PARENT, getParent()); + message.setHeader(FileConstants.FILE_RELATIVE_PATH, getRelativeFilePath()); + message.setHeader(FileConstants.FILE_PARENT, getParent()); if (getFileLength() >= 0) { - message.setHeader(Exchange.FILE_LENGTH, getFileLength()); + message.setHeader(FileConstants.FILE_LENGTH, getFileLength()); } if (getLastModified() > 0) { - message.setHeader(Exchange.FILE_LAST_MODIFIED, getLastModified()); + message.setHeader(FileConstants.FILE_LAST_MODIFIED, getLastModified()); message.setHeader(Exchange.MESSAGE_TIMESTAMP, getLastModified()); } } diff --git a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileDefaultMoveExistingFileStrategy.java b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileDefaultMoveExistingFileStrategy.java index 9bd9f021823ba..e4c98f67b590c 100644 --- a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileDefaultMoveExistingFileStrategy.java +++ b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileDefaultMoveExistingFileStrategy.java @@ -46,9 +46,9 @@ public boolean moveExistingFile(GenericFileEndpoint endpoint, GenericFileOperati Exchange dummy = endpoint.createExchange(); String parent = FileUtil.onlyPath(fileName); String onlyName = FileUtil.stripPath(fileName); - dummy.getIn().setHeader(Exchange.FILE_NAME, fileName); - dummy.getIn().setHeader(Exchange.FILE_NAME_ONLY, onlyName); - dummy.getIn().setHeader(Exchange.FILE_PARENT, parent); + dummy.getIn().setHeader(FileConstants.FILE_NAME, fileName); + dummy.getIn().setHeader(FileConstants.FILE_NAME_ONLY, onlyName); + dummy.getIn().setHeader(FileConstants.FILE_PARENT, parent); String to = endpoint.getMoveExisting().evaluate(dummy, String.class); diff --git a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java index d7870236202d8..8a56dbb97999b 100644 --- a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java +++ b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java @@ -141,7 +141,7 @@ public abstract class GenericFileEndpoint extends ScheduledPollEndpoint imple + "if an existing file existed, if its true, then the existing file is deleted before the move operation.") protected boolean eagerDeleteTargetFile = true; @UriParam(label = "producer,advanced", description = "Will keep the last modified timestamp from the source file " - + "(if any). Will use the Exchange.FILE_LAST_MODIFIED header to located the timestamp. This header can " + + "(if any). Will use the FileConstants.FILE_LAST_MODIFIED header to located the timestamp. This header can " + "contain either a java.util.Date or long with the timestamp. If the timestamp exists and the option is " + "enabled it will set this timestamp on the written file. Note: This option only applies to the file " + "producer. You cannot use this option with any of the ftp producers.") @@ -1416,10 +1416,11 @@ public boolean isKeepLastModified() { } /** - * Will keep the last modified timestamp from the source file (if any). Will use the Exchange.FILE_LAST_MODIFIED - * header to located the timestamp. This header can contain either a java.util.Date or long with the timestamp. If - * the timestamp exists and the option is enabled it will set this timestamp on the written file. Note: This option - * only applies to the file producer. You cannot use this option with any of the ftp producers. + * Will keep the last modified timestamp from the source file (if any). Will use the + * FileConstants.FILE_LAST_MODIFIED header to located the timestamp. This header can contain either a java.util.Date + * or long with the timestamp. If the timestamp exists and the option is enabled it will set this timestamp on the + * written file. Note: This option only applies to the file producer. You cannot use this option with any of the ftp + * producers. */ public void setKeepLastModified(boolean keepLastModified) { this.keepLastModified = keepLastModified; @@ -1521,7 +1522,7 @@ public void configureMessage(GenericFile file, Message message) { if (flatten) { // when flatten the file name should not contain any paths - message.setHeader(Exchange.FILE_NAME, file.getFileNameOnly()); + message.setHeader(FileConstants.FILE_NAME, file.getFileNameOnly()); } else { // compute name to set on header that should be relative to starting // directory @@ -1538,7 +1539,7 @@ public void configureMessage(GenericFile file, Message message) { } // adjust filename - message.setHeader(Exchange.FILE_NAME, name); + message.setHeader(FileConstants.FILE_NAME, name); } } diff --git a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFilePollingConsumer.java b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFilePollingConsumer.java index 56b74ab75a749..fdcbc6b57dd00 100644 --- a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFilePollingConsumer.java +++ b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFilePollingConsumer.java @@ -207,7 +207,7 @@ protected int doReceive(long timeout) { @Override public void process(Exchange exchange) throws Exception { - Object name = exchange.getIn().getHeader(Exchange.FILE_NAME); + Object name = exchange.getIn().getHeader(FileConstants.FILE_NAME); if (name != null) { LOG.debug("Received file: {}", name); } diff --git a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileProducer.java b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileProducer.java index e70d815cd1404..ac1f8435b63b0 100644 --- a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileProducer.java +++ b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileProducer.java @@ -63,7 +63,7 @@ public String normalizePath(String name) { @Override public void process(Exchange exchange) throws Exception { // store any existing file header which we want to keep and propagate - final String existing = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class); + final String existing = exchange.getIn().getHeader(FileConstants.FILE_NAME, String.class); // create the target file name String target = createFileName(exchange); @@ -84,7 +84,7 @@ public void process(Exchange exchange) throws Exception { // once (by design) exchange.getIn().removeHeader(Exchange.OVERRULE_FILE_NAME); // and restore existing file name - exchange.getIn().setHeader(Exchange.FILE_NAME, existing); + exchange.getIn().setHeader(FileConstants.FILE_NAME, existing); } } @@ -234,7 +234,7 @@ protected void processExchange(Exchange exchange, String target) throws Exceptio // let's store the name we really used in the header, so end-users // can retrieve it - exchange.getIn().setHeader(Exchange.FILE_NAME_PRODUCED, target); + exchange.getIn().setHeader(FileConstants.FILE_NAME_PRODUCED, target); } catch (Exception e) { handleFailedWrite(exchange, e); } @@ -300,7 +300,7 @@ public String createFileName(Exchange exchange) { // overrule takes precedence Object value; - Object overrule = exchange.getIn().getHeader(Exchange.OVERRULE_FILE_NAME); + Object overrule = exchange.getIn().getHeader(FileConstants.OVERRULE_FILE_NAME); if (overrule != null) { if (overrule instanceof Expression) { value = overrule; @@ -308,19 +308,19 @@ public String createFileName(Exchange exchange) { value = exchange.getContext().getTypeConverter().convertTo(String.class, exchange, overrule); } } else { - value = exchange.getIn().getHeader(Exchange.FILE_NAME); + value = exchange.getIn().getHeader(FileConstants.FILE_NAME); } // if we have an overrule then override the existing header to use the // overrule computed name from this point forward if (overrule != null) { - exchange.getIn().setHeader(Exchange.FILE_NAME, value); + exchange.getIn().setHeader(FileConstants.FILE_NAME, value); } if (value instanceof String && StringHelper.hasStartToken((String) value, "simple")) { LOG.warn( "Simple expression: {} detected in header: {} of type String. This feature has been removed (see CAMEL-6748).", - value, Exchange.FILE_NAME); + value, FileConstants.FILE_NAME); } // expression support @@ -393,13 +393,13 @@ public String createTempFileName(Exchange exchange, String fileName) { String answer = fileName; String tempName; - if (exchange.getIn().getHeader(Exchange.FILE_NAME) == null) { + if (exchange.getIn().getHeader(FileConstants.FILE_NAME) == null) { // its a generated filename then add it to header so we can evaluate // the expression - exchange.getIn().setHeader(Exchange.FILE_NAME, FileUtil.stripPath(fileName)); + exchange.getIn().setHeader(FileConstants.FILE_NAME, FileUtil.stripPath(fileName)); tempName = endpoint.getTempFileName().evaluate(exchange, String.class); // and remove it again after evaluation - exchange.getIn().removeHeader(Exchange.FILE_NAME); + exchange.getIn().removeHeader(FileConstants.FILE_NAME); } else { tempName = endpoint.getTempFileName().evaluate(exchange, String.class); } diff --git a/components/camel-file/src/main/java/org/apache/camel/component/file/strategy/GenericFileProcessStrategySupport.java b/components/camel-file/src/main/java/org/apache/camel/component/file/strategy/GenericFileProcessStrategySupport.java index a043869fded73..4ef342f989454 100644 --- a/components/camel-file/src/main/java/org/apache/camel/component/file/strategy/GenericFileProcessStrategySupport.java +++ b/components/camel-file/src/main/java/org/apache/camel/component/file/strategy/GenericFileProcessStrategySupport.java @@ -21,6 +21,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; import org.apache.camel.Exchange; +import org.apache.camel.component.file.FileConstants; import org.apache.camel.component.file.GenericFile; import org.apache.camel.component.file.GenericFileEndpoint; import org.apache.camel.component.file.GenericFileExclusiveReadLockStrategy; @@ -152,7 +153,7 @@ protected GenericFile renameFile(GenericFileOperations operations, Generic protected void deleteLocalWorkFile(Exchange exchange) { // delete local work file, if it was used (eg by ftp component) - File local = exchange.getIn().getHeader(Exchange.FILE_LOCAL_WORK_PATH, File.class); + File local = exchange.getIn().getHeader(FileConstants.FILE_LOCAL_WORK_PATH, File.class); if (local != null && local.exists()) { boolean deleted = FileUtil.deleteFile(local); LOG.trace("Local work file: {} was deleted: {}", local, deleted); From 630251fea4dece1426b7628ef377b998e1ba0d28 Mon Sep 17 00:00:00 2001 From: Nicolas Filotto Date: Mon, 21 Mar 2022 14:43:52 +0100 Subject: [PATCH 08/13] CAMEL-17792: Add doc about the message headers of camel-file-watch --- .../component/file/watch/file-watch.json | 12 ++++ .../src/main/docs/file-watch-component.adoc | 42 +------------ .../file/watch/FileWatchComponent.java | 1 - .../file/watch/FileWatchConstants.java | 60 +++++++++++++++++++ .../file/watch/FileWatchConsumer.java | 21 +++---- .../file/watch/FileWatchEndpoint.java | 2 +- .../file/watch/FileWatchComponentTest.java | 2 +- .../watch/FileWatchComponentTestBase.java | 2 +- 8 files changed, 89 insertions(+), 53 deletions(-) create mode 100644 components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchConstants.java diff --git a/components/camel-file-watch/src/generated/resources/org/apache/camel/component/file/watch/file-watch.json b/components/camel-file-watch/src/generated/resources/org/apache/camel/component/file/watch/file-watch.json index 321974facdb33..8577608ead9c5 100644 --- a/components/camel-file-watch/src/generated/resources/org/apache/camel/component/file/watch/file-watch.json +++ b/components/camel-file-watch/src/generated/resources/org/apache/camel/component/file/watch/file-watch.json @@ -30,6 +30,18 @@ "useFileHashing": { "kind": "property", "displayName": "Use File Hashing", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Enables or disables file hashing to detect duplicate events. If you disable this, you can get some events multiple times on some platforms and JDKs. Check java.nio.file.WatchService limitations for your target platform." }, "autowiredEnabled": { "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." } }, + "headers": { + "CamelFileEventType": { "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Type of event. Possible values: CREATE, DELETE, MODIFY." }, + "CamelFileNameOnly": { "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Only the file name (the name with no leading paths)." }, + "CamelFileAbsolute": { "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "Boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A `boolean` option specifying whether the consumed file denotes an\nabsolute path or not. Should normally be `false` for relative paths.\nAbsolute paths should normally not be used but we added to the move\noption to allow moving files to absolute paths. But can be used\nelsewhere as well." }, + "CamelFileAbsolutePath": { "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The absolute path to the file. For relative files this path holds the\nrelative path instead." }, + "CamelFilePath": { "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file path. For relative files this is the starting directory + the\nrelative filename. For absolute files this is the absolute path." }, + "CamelFileName": { "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Name of the consumed file as a relative file path with offset from the\nstarting directory configured on the endpoint." }, + "CamelFileRelativePath": { "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The relative path." }, + "CamelFileNameConsumed": { "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the file that has been consumed" }, + "CamelFileParent": { "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The parent path." }, + "CamelFileLastModified": { "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A `Long` value containing the last modified timestamp of the file." } + }, "properties": { "path": { "kind": "path", "displayName": "Path", "group": "consumer", "label": "consumer", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Path of directory to consume events from." }, "antInclude": { "kind": "parameter", "displayName": "Ant Include", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "**", "description": "ANT style pattern to match files. The file is matched against path relative to endpoint path. Pattern must be also relative (not starting with slash)" }, diff --git a/components/camel-file-watch/src/main/docs/file-watch-component.adoc b/components/camel-file-watch/src/main/docs/file-watch-component.adoc index 2f9b72d02e91b..30d6001cdfad0 100644 --- a/components/camel-file-watch/src/main/docs/file-watch-component.adoc +++ b/components/camel-file-watch/src/main/docs/file-watch-component.adoc @@ -30,7 +30,9 @@ include::partial$component-endpoint-options.adoc[] // endpoint options: START // endpoint options: END - +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END == Examples: @@ -59,42 +61,4 @@ from("file-watch://some-directory?events=MODIFY&recursive=false") .to("file:some-directory/snapshots"); ---- -== Message Headers - -The following headers are supported by this component: - -=== File Watch consumer only - -[width="100%",cols="10%,90%",options="header",] -|=== -|Header |Description - -|`CamelFileEventType` |Type of event. Possible values: CREATE, DELETE, MODIFY. -The java type of this header is String - -|`CamelFileName` |Name of the consumed file as a relative file path with offset from the -starting directory configured on the endpoint. - -|`CamelFileNameOnly` |Only the file name (the name with no leading paths). - -|`CamelFileAbsolute` |A `boolean` option specifying whether the consumed file denotes an -absolute path or not. Should normally be `false` for relative paths. -Absolute paths should normally not be used but we added to the move -option to allow moving files to absolute paths. But can be used -elsewhere as well. - -|`CamelFileAbsolutePath` |The absolute path to the file. For relative files this path holds the -relative path instead. - -|`CamelFilePath` |The file path. For relative files this is the starting directory + the -relative filename. For absolute files this is the absolute path. - -|`CamelFileRelativePath` |The relative path. - -|`CamelFileParent` |The parent path. - -|`CamelFileLastModified` |A `Long` value containing the last modified timestamp of the file. -|=== - - include::spring-boot:partial$starter.adoc[] diff --git a/components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchComponent.java b/components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchComponent.java index 5805f9ed4adb2..45f53f22f170a 100644 --- a/components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchComponent.java +++ b/components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchComponent.java @@ -30,7 +30,6 @@ */ @Component("file-watch") public class FileWatchComponent extends DefaultComponent { - public static final String EVENT_TYPE_HEADER = "CamelFileEventType"; @Metadata(label = "consumer", description = "The number of concurrent consumers. Increase this value, if your route is slow to prevent buffering in queue.", diff --git a/components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchConstants.java b/components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchConstants.java new file mode 100644 index 0000000000000..17242c3dc5f3f --- /dev/null +++ b/components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchConstants.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.file.watch; + +import org.apache.camel.Exchange; +import org.apache.camel.spi.Metadata; + +public final class FileWatchConstants { + + @Metadata(description = "Type of event. Possible values: CREATE, DELETE, MODIFY.", javaType = "String") + public static final String EVENT_TYPE_HEADER = "CamelFileEventType"; + @Metadata(description = "Only the file name (the name with no leading paths).", javaType = "String") + public static final String FILE_NAME_ONLY = Exchange.FILE_NAME_ONLY; + @Metadata(description = "A `boolean` option specifying whether the consumed file denotes an\n" + + "absolute path or not. Should normally be `false` for relative paths.\n" + + "Absolute paths should normally not be used but we added to the move\n" + + "option to allow moving files to absolute paths. But can be used\n" + + "elsewhere as well.", + javaType = "Boolean") + public static final String FILE_ABSOLUTE = "CamelFileAbsolute"; + @Metadata(description = "The absolute path to the file. For relative files this path holds the\n" + + "relative path instead.", + javaType = "String") + public static final String FILE_ABSOLUTE_PATH = "CamelFileAbsolutePath"; + @Metadata(description = "The file path. For relative files this is the starting directory + the\n" + + "relative filename. For absolute files this is the absolute path.", + javaType = "String") + public static final String FILE_PATH = Exchange.FILE_PATH; + @Metadata(description = "Name of the consumed file as a relative file path with offset from the\n" + + "starting directory configured on the endpoint.", + javaType = "String") + public static final String FILE_NAME = Exchange.FILE_NAME; + @Metadata(description = "The relative path.", javaType = "String") + public static final String FILE_RELATIVE_PATH = "CamelFileRelativePath"; + @Metadata(description = "The name of the file that has been consumed", javaType = "String") + public static final String FILE_NAME_CONSUMED = Exchange.FILE_NAME_CONSUMED; + @Metadata(description = "The parent path.", javaType = "String") + public static final String FILE_PARENT = Exchange.FILE_PARENT; + @Metadata(description = "A `Long` value containing the last modified timestamp of the file.", + javaType = "long") + public static final String FILE_LAST_MODIFIED = Exchange.FILE_LAST_MODIFIED; + + private FileWatchConstants() { + // Utility class + } +} diff --git a/components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchConsumer.java b/components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchConsumer.java index 59141eca58759..59675972b44b0 100644 --- a/components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchConsumer.java +++ b/components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchConsumer.java @@ -143,21 +143,22 @@ private Exchange prepareExchange(FileEvent event) { File file = event.getEventPath().toFile(); Message message = exchange.getIn(); message.setBody(file); - message.setHeader(FileWatchComponent.EVENT_TYPE_HEADER, event.getEventType().name()); - message.setHeader(Exchange.FILE_NAME_ONLY, event.getEventPath().getFileName().toString()); - message.setHeader("CamelFileAbsolute", true); + message.setHeader(FileWatchConstants.EVENT_TYPE_HEADER, event.getEventType().name()); + message.setHeader(FileWatchConstants.FILE_NAME_ONLY, event.getEventPath().getFileName().toString()); + message.setHeader(FileWatchConstants.FILE_ABSOLUTE, true); final String absolutePath = PathUtils.normalizeToString(event.getEventPath().toAbsolutePath()); - message.setHeader("CamelFileAbsolutePath", absolutePath); - message.setHeader(Exchange.FILE_PATH, absolutePath); + message.setHeader(FileWatchConstants.FILE_ABSOLUTE_PATH, absolutePath); + message.setHeader(FileWatchConstants.FILE_PATH, absolutePath); final String relativePath = PathUtils.normalizeToString(baseDirectory.relativize(event.getEventPath())); - message.setHeader(Exchange.FILE_NAME, relativePath); - message.setHeader("CamelFileRelativePath", relativePath); - message.setHeader(Exchange.FILE_NAME_CONSUMED, relativePath); + message.setHeader(FileWatchConstants.FILE_NAME, relativePath); + message.setHeader(FileWatchConstants.FILE_RELATIVE_PATH, relativePath); + message.setHeader(FileWatchConstants.FILE_NAME_CONSUMED, relativePath); - message.setHeader(Exchange.FILE_PARENT, PathUtils.normalizeToString(event.getEventPath().getParent().toAbsolutePath())); - message.setHeader(Exchange.FILE_LAST_MODIFIED, event.getEventDate()); + message.setHeader(FileWatchConstants.FILE_PARENT, + PathUtils.normalizeToString(event.getEventPath().getParent().toAbsolutePath())); + message.setHeader(FileWatchConstants.FILE_LAST_MODIFIED, event.getEventDate()); message.setHeader(Exchange.MESSAGE_TIMESTAMP, event.getEventDate()); return exchange; diff --git a/components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchEndpoint.java b/components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchEndpoint.java index f38ed75fc4590..6fe3ded90e1da 100644 --- a/components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchEndpoint.java +++ b/components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchEndpoint.java @@ -37,7 +37,7 @@ * Get notified about file events in a directory using {@link java.nio.file.WatchService}. */ @UriEndpoint(firstVersion = "3.0.0", scheme = "file-watch", title = "File Watch", syntax = "file-watch:path", - category = { Category.FILE }, consumerOnly = true) + category = { Category.FILE }, consumerOnly = true, headersClass = FileWatchConstants.class) public class FileWatchEndpoint extends DefaultEndpoint implements MultipleConsumersSupport { @UriPath(label = "consumer", description = "Path of directory to consume events from.") @Metadata(required = true) diff --git a/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTest.java b/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTest.java index 6b2527579b030..05e2132bf4d45 100644 --- a/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTest.java +++ b/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTest.java @@ -122,7 +122,7 @@ public void testCreateBatch() throws Exception { MockEndpoint mock = getMockEndpoint("mock:watchAll"); mock.expectedMessageCount(10); mock.expectedMessagesMatches(exchange -> exchange.getIn() - .getHeader(FileWatchComponent.EVENT_TYPE_HEADER, FileEventEnum.class) == FileEventEnum.CREATE); + .getHeader(FileWatchConstants.EVENT_TYPE_HEADER, FileEventEnum.class) == FileEventEnum.CREATE); for (int i = 0; i < 10; i++) { createFile(testPath(), i + ""); diff --git a/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTestBase.java b/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTestBase.java index ac9fd29d41c25..1a9d9f25b00b3 100644 --- a/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTestBase.java +++ b/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTestBase.java @@ -47,7 +47,7 @@ public class FileWatchComponentTestBase extends CamelTestSupport { static void assertFileEvent(String expectedFileName, FileEventEnum expectedEventType, Exchange exchange) { assertEquals(expectedFileName, exchange.getIn().getBody(File.class).getName()); - assertEquals(expectedEventType, exchange.getIn().getHeader(FileWatchComponent.EVENT_TYPE_HEADER, FileEventEnum.class)); + assertEquals(expectedEventType, exchange.getIn().getHeader(FileWatchConstants.EVENT_TYPE_HEADER, FileEventEnum.class)); } public void beforeEach(ExtensionContext context) throws Exception { From 808555f64b57f6ef67a05c75996e77a9a9994c3b Mon Sep 17 00:00:00 2001 From: Nicolas Filotto Date: Mon, 21 Mar 2022 14:52:36 +0100 Subject: [PATCH 09/13] CAMEL-17792: Add doc about the message headers of camel-flatpack --- .../camel/component/flatpack/flatpack.json | 3 ++ .../src/main/docs/flatpack-component.adoc | 15 ++------- .../component/flatpack/FlatpackConstants.java | 31 +++++++++++++++++++ .../component/flatpack/FlatpackEndpoint.java | 4 +-- 4 files changed, 39 insertions(+), 14 deletions(-) create mode 100644 components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackConstants.java diff --git a/components/camel-flatpack/src/generated/resources/org/apache/camel/component/flatpack/flatpack.json b/components/camel-flatpack/src/generated/resources/org/apache/camel/component/flatpack/flatpack.json index 9de2d96d8c9be..1dd426e625c51 100644 --- a/components/camel-flatpack/src/generated/resources/org/apache/camel/component/flatpack/flatpack.json +++ b/components/camel-flatpack/src/generated/resources/org/apache/camel/component/flatpack/flatpack.json @@ -26,6 +26,9 @@ "lazyStartProducer": { "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": { "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." } }, + "headers": { + "CamelFlatpackCounter": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The current row index. For `splitRows=false` the counter is the total\nnumber of rows." } + }, "properties": { "type": { "kind": "path", "displayName": "Type", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.flatpack.FlatpackType", "enum": [ "fixed", "delim" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "delim", "description": "Whether to use fixed or delimiter" }, "resourceUri": { "kind": "path", "displayName": "Resource Uri", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "URL for loading the flatpack mapping file from classpath or file system" }, diff --git a/components/camel-flatpack/src/main/docs/flatpack-component.adoc b/components/camel-flatpack/src/main/docs/flatpack-component.adoc index 781060b269c22..9dbbb5ac5b998 100644 --- a/components/camel-flatpack/src/main/docs/flatpack-component.adoc +++ b/components/camel-flatpack/src/main/docs/flatpack-component.adoc @@ -45,6 +45,9 @@ include::partial$component-endpoint-options.adoc[] // endpoint options: START // endpoint options: END +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END == Examples @@ -55,18 +58,6 @@ the `foo.pzmap.xml` file configuration. * `flatpack:foo` creates a delimited endpoint called `foo` with no file configuration. -== Message Headers - -Camel will store the following headers on the IN message: - -[width="100%",cols="50%,50%",options="header",] -|======================================================================= -|Header |Description - -|`camelFlatpackCounter` |The current row index. For `splitRows=false` the counter is the total -number of rows. -|======================================================================= - == Message Body The component delivers the data in the IN message as a diff --git a/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackConstants.java b/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackConstants.java new file mode 100644 index 0000000000000..5e6c3962f3e19 --- /dev/null +++ b/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackConstants.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.flatpack; + +import org.apache.camel.spi.Metadata; + +public final class FlatpackConstants { + + @Metadata(label = "producer", description = "The current row index. For `splitRows=false` the counter is the total\n" + + "number of rows.", + javaType = "int") + public static final String FLATPACK_COUNTER = "CamelFlatpackCounter"; + + private FlatpackConstants() { + // Utility class + } +} diff --git a/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackEndpoint.java b/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackEndpoint.java index 8b5d315c39de7..eb00dcfae842c 100644 --- a/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackEndpoint.java +++ b/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackEndpoint.java @@ -49,7 +49,7 @@ * Parse fixed width and delimited files using the FlatPack library. */ @UriEndpoint(firstVersion = "1.4.0", scheme = "flatpack", title = "Flatpack", syntax = "flatpack:type:resourceUri", - category = { Category.TRANSFORMATION }) + category = { Category.TRANSFORMATION }, headersClass = FlatpackConstants.class) public class FlatpackEndpoint extends DefaultPollingEndpoint { private LoadBalancer loadBalancer = new RoundRobinLoadBalancer(); @@ -101,7 +101,7 @@ public void processDataSet(Exchange originalExchange, DataSet dataSet, int count Exchange exchange = ExchangeHelper.createCorrelatedCopy(originalExchange, false); Message in = exchange.getIn(); in.setBody(dataSet); - in.setHeader("CamelFlatpackCounter", counter); + in.setHeader(FlatpackConstants.FLATPACK_COUNTER, counter); loadBalancer.process(exchange); } From 646f23b8ec81362d78ba9bb11de3d7467dc91c3e Mon Sep 17 00:00:00 2001 From: Nicolas Filotto Date: Mon, 21 Mar 2022 15:07:18 +0100 Subject: [PATCH 10/13] CAMEL-17792: Add doc about the message headers of camel-flink --- .../org/apache/camel/component/flink/flink.json | 6 ++++++ .../camel-flink/src/main/docs/flink-component.adoc | 4 +++- .../org/apache/camel/component/flink/FlinkConstants.java | 9 ++++++--- .../org/apache/camel/component/flink/FlinkEndpoint.java | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/components/camel-flink/src/generated/resources/org/apache/camel/component/flink/flink.json b/components/camel-flink/src/generated/resources/org/apache/camel/component/flink/flink.json index f41e472fd3175..08ce612d9f088 100644 --- a/components/camel-flink/src/generated/resources/org/apache/camel/component/flink/flink.json +++ b/components/camel-flink/src/generated/resources/org/apache/camel/component/flink/flink.json @@ -28,6 +28,12 @@ "lazyStartProducer": { "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": { "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." } }, + "headers": { + "CamelFlinkDataSet": { "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Object", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The dataset" }, + "CamelFlinkDataSetCallback": { "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "org.apache.camel.component.flink.DataSetCallback", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The dataset callback" }, + "CamelFlinkDataStream": { "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Object", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The data stream" }, + "CamelFlinkDataStreamCallback": { "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "org.apache.camel.component.flink.DataStreamCallback", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The data stream callback" } + }, "properties": { "endpointType": { "kind": "path", "displayName": "Endpoint Type", "group": "producer", "label": "", "required": true, "type": "object", "javaType": "org.apache.camel.component.flink.EndpointType", "enum": [ "dataset", "datastream" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Type of the endpoint (dataset, datastream)." }, "collect": { "kind": "parameter", "displayName": "Collect", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Indicates if results should be collected or counted." }, diff --git a/components/camel-flink/src/main/docs/flink-component.adoc b/components/camel-flink/src/main/docs/flink-component.adoc index d8daa8a93aa93..bfb8ee01b703f 100644 --- a/components/camel-flink/src/main/docs/flink-component.adoc +++ b/components/camel-flink/src/main/docs/flink-component.adoc @@ -56,7 +56,9 @@ include::partial$component-endpoint-options.adoc[] // endpoint options: START // endpoint options: END - +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END == Flink DataSet Callback diff --git a/components/camel-flink/src/main/java/org/apache/camel/component/flink/FlinkConstants.java b/components/camel-flink/src/main/java/org/apache/camel/component/flink/FlinkConstants.java index 29ae2b75f6af2..5816c342ef763 100644 --- a/components/camel-flink/src/main/java/org/apache/camel/component/flink/FlinkConstants.java +++ b/components/camel-flink/src/main/java/org/apache/camel/component/flink/FlinkConstants.java @@ -16,14 +16,17 @@ */ package org.apache.camel.component.flink; +import org.apache.camel.spi.Metadata; + public final class FlinkConstants { + @Metadata(description = "The dataset", javaType = "Object") public static final String FLINK_DATASET_HEADER = "CamelFlinkDataSet"; - + @Metadata(description = "The dataset callback", javaType = "org.apache.camel.component.flink.DataSetCallback") public static final String FLINK_DATASET_CALLBACK_HEADER = "CamelFlinkDataSetCallback"; - + @Metadata(description = "The data stream", javaType = "Object") public static final String FLINK_DATASTREAM_HEADER = "CamelFlinkDataStream"; - + @Metadata(description = "The data stream callback", javaType = "org.apache.camel.component.flink.DataStreamCallback") public static final String FLINK_DATASTREAM_CALLBACK_HEADER = "CamelFlinkDataStreamCallback"; private FlinkConstants() { diff --git a/components/camel-flink/src/main/java/org/apache/camel/component/flink/FlinkEndpoint.java b/components/camel-flink/src/main/java/org/apache/camel/component/flink/FlinkEndpoint.java index 384beab4f38c4..27c207e06eb2c 100644 --- a/components/camel-flink/src/main/java/org/apache/camel/component/flink/FlinkEndpoint.java +++ b/components/camel-flink/src/main/java/org/apache/camel/component/flink/FlinkEndpoint.java @@ -32,7 +32,7 @@ * Send DataSet jobs to an Apache Flink cluster. */ @UriEndpoint(firstVersion = "2.18.0", scheme = "flink", title = "Flink", syntax = "flink:endpointType", producerOnly = true, - category = { Category.TRANSFORMATION, Category.BIGDATA, Category.STREAMS }) + category = { Category.TRANSFORMATION, Category.BIGDATA, Category.STREAMS }, headersClass = FlinkConstants.class) public class FlinkEndpoint extends DefaultEndpoint { @UriPath From 9f5d1d88ac7e9b9c114103ae15910a636e4efbd2 Mon Sep 17 00:00:00 2001 From: Nicolas Filotto Date: Mon, 21 Mar 2022 15:10:45 +0100 Subject: [PATCH 11/13] CAMEL-17792: Add doc about the message headers of camel-fop --- .../resources/org/apache/camel/component/fop/fop.json | 3 +++ components/camel-fop/src/main/docs/fop-component.adoc | 4 +++- .../java/org/apache/camel/component/fop/FopConstants.java | 3 +++ .../main/java/org/apache/camel/component/fop/FopEndpoint.java | 2 +- .../main/java/org/apache/camel/component/fop/FopProducer.java | 2 +- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/components/camel-fop/src/generated/resources/org/apache/camel/component/fop/fop.json b/components/camel-fop/src/generated/resources/org/apache/camel/component/fop/fop.json index f2cceb23675a1..eeb805eb64ad2 100644 --- a/components/camel-fop/src/generated/resources/org/apache/camel/component/fop/fop.json +++ b/components/camel-fop/src/generated/resources/org/apache/camel/component/fop/fop.json @@ -25,6 +25,9 @@ "lazyStartProducer": { "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": { "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." } }, + "headers": { + "CamelFop.Output.Format": { "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The output format" } + }, "properties": { "outputType": { "kind": "path", "displayName": "Output Type", "group": "producer", "label": "", "required": true, "type": "object", "javaType": "org.apache.camel.component.fop.FopOutputType", "enum": [ "pdf", "ps", "pcl", "png", "jpeg", "svg", "xml", "mif", "rtf", "txt" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The primary output format is PDF but other output formats are also supported." }, "fopFactory": { "kind": "parameter", "displayName": "Fop Factory", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "org.apache.fop.apps.FopFactory", "deprecated": false, "autowired": false, "secret": false, "description": "Allows to use a custom configured or implementation of org.apache.fop.apps.FopFactory." }, diff --git a/components/camel-fop/src/main/docs/fop-component.adoc b/components/camel-fop/src/main/docs/fop-component.adoc index fda4885f07181..2c76678431f39 100644 --- a/components/camel-fop/src/main/docs/fop-component.adoc +++ b/components/camel-fop/src/main/docs/fop-component.adoc @@ -81,7 +81,9 @@ include::partial$component-endpoint-options.adoc[] // endpoint options: START // endpoint options: END - +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END == Configuration file diff --git a/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopConstants.java b/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopConstants.java index 78c872392e8ce..bdb358dc5fe8d 100644 --- a/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopConstants.java +++ b/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopConstants.java @@ -16,9 +16,12 @@ */ package org.apache.camel.component.fop; +import org.apache.camel.spi.Metadata; + public interface FopConstants { String CAMEL_FOP_RENDER = "CamelFop.Render."; String CAMEL_FOP_ENCRYPT = "CamelFop.Encrypt."; String CAMEL_FOP_RENDERER_OPTIONS = "CamelFop.RendererOptions."; + @Metadata(description = "The output format", javaType = "String") String CAMEL_FOP_OUTPUT_FORMAT = "CamelFop.Output.Format"; } diff --git a/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopEndpoint.java b/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopEndpoint.java index 01967b8585bee..97bc0e05f8443 100644 --- a/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopEndpoint.java +++ b/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopEndpoint.java @@ -35,7 +35,7 @@ * Render messages into PDF and other output formats supported by Apache FOP. */ @UriEndpoint(firstVersion = "2.10.0", scheme = "fop", title = "FOP", syntax = "fop:outputType", producerOnly = true, - category = { Category.FILE, Category.TRANSFORMATION }) + category = { Category.FILE, Category.TRANSFORMATION }, headersClass = FopConstants.class) public class FopEndpoint extends DefaultEndpoint { @UriPath diff --git a/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopProducer.java b/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopProducer.java index 82c225b4de606..89c8f58084257 100644 --- a/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopProducer.java +++ b/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopProducer.java @@ -73,7 +73,7 @@ public void process(Exchange exchange) throws Exception { private String getOutputFormat(Exchange exchange) { String headerOutputFormat = exchange.getIn().getHeader(FopConstants.CAMEL_FOP_OUTPUT_FORMAT, String.class); if (headerOutputFormat != null) { - // it may be a short hand + // it may be a shorthand FopOutputType type = exchange.getContext().getTypeConverter().tryConvertTo(FopOutputType.class, exchange, headerOutputFormat); if (type != null) { From 23c8ac8323ee6e1699a5d4c9b3d15cfee0ffa13d Mon Sep 17 00:00:00 2001 From: Nicolas Filotto Date: Mon, 21 Mar 2022 15:17:08 +0100 Subject: [PATCH 12/13] CAMEL-17792: Add doc about the message headers of camel-freemarker --- .../camel/component/freemarker/freemarker.json | 5 +++++ .../src/main/docs/freemarker-component.adoc | 14 +++----------- .../component/freemarker/FreemarkerConstants.java | 9 +++++++-- .../component/freemarker/FreemarkerEndpoint.java | 2 +- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/components/camel-freemarker/src/generated/resources/org/apache/camel/component/freemarker/freemarker.json b/components/camel-freemarker/src/generated/resources/org/apache/camel/component/freemarker/freemarker.json index 2999d12b0ece6..5389cc58d5595 100644 --- a/components/camel-freemarker/src/generated/resources/org/apache/camel/component/freemarker/freemarker.json +++ b/components/camel-freemarker/src/generated/resources/org/apache/camel/component/freemarker/freemarker.json @@ -29,6 +29,11 @@ "autowiredEnabled": { "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." }, "configuration": { "kind": "property", "displayName": "Configuration", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "freemarker.template.Configuration", "deprecated": false, "autowired": false, "secret": false, "description": "To use an existing freemarker.template.Configuration instance as the configuration." } }, + "headers": { + "CamelFreemarkerResourceUri": { "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\nconfigured." }, + "CamelFreemarkerTemplate": { "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." }, + "CamelFreemarkerDataModel": { "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Object", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The data model" } + }, "properties": { "resourceUri": { "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 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": { "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 af6a03675b832..7a063ee5b998f 100644 --- a/components/camel-freemarker/src/main/docs/freemarker-component.adoc +++ b/components/camel-freemarker/src/main/docs/freemarker-component.adoc @@ -119,17 +119,9 @@ 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. -[width="100%",cols="10%,10%,80%",options="header",] -|======================================================================= -|Header |Type |Description - -|FreemarkerConstants.FREEMARKER_RESOURCE |org.springframework.core.io.Resource |The template resource. - -|FreemarkerConstants.FREEMARKER_RESOURCE_URI |String |A URI for the template resource to use instead of the endpoint -configured. - -|FreemarkerConstants.FREEMARKER_TEMPLATE |String |The template to use instead of the endpoint configured. -|======================================================================= +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END == Samples diff --git a/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerConstants.java b/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerConstants.java index 96e7ca63b7b31..0f9ece28ba942 100644 --- a/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerConstants.java +++ b/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerConstants.java @@ -16,15 +16,20 @@ */ package org.apache.camel.component.freemarker; +import org.apache.camel.spi.Metadata; + /** * Freemarker Constants */ public final class FreemarkerConstants { + @Metadata(description = "A URI for the template resource to use instead of the endpoint\n" + + "configured.", + javaType = "String") public static final String FREEMARKER_RESOURCE_URI = "CamelFreemarkerResourceUri"; - + @Metadata(description = "The template to use instead of the endpoint configured.", javaType = "String") public static final String FREEMARKER_TEMPLATE = "CamelFreemarkerTemplate"; - + @Metadata(description = "The data model", javaType = "Object") public static final String FREEMARKER_DATA_MODEL = "CamelFreemarkerDataModel"; private FreemarkerConstants() { 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 4f96403b7954e..9ab930b1110ab 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 @@ -37,7 +37,7 @@ * Transform messages using FreeMarker templates. */ @UriEndpoint(firstVersion = "2.10.0", scheme = "freemarker", title = "Freemarker", syntax = "freemarker:resourceUri", - producerOnly = true, category = { Category.TRANSFORMATION }) + producerOnly = true, category = { Category.TRANSFORMATION }, headersClass = FreemarkerConstants.class) public class FreemarkerEndpoint extends ResourceEndpoint { @UriParam(defaultValue = "false") From 9f58ec6dc1d9cb1db056e65064321264ac885be7 Mon Sep 17 00:00:00 2001 From: Nicolas Filotto Date: Mon, 21 Mar 2022 15:39:04 +0100 Subject: [PATCH 13/13] CAMEL-17792: Add doc about the message headers of camel-ftp --- .../camel/component/file/remote/ftp.json | 14 ++++++- .../camel/component/file/remote/ftps.json | 14 ++++++- .../camel/component/file/remote/sftp.json | 14 ++++++- .../src/main/docs/ftp-component.adoc | 41 ++----------------- .../src/main/docs/ftps-component.adoc | 3 ++ .../src/main/docs/sftp-component.adoc | 3 ++ .../component/file/remote/FtpConstants.java | 27 ++++++++++++ .../component/file/remote/FtpConsumer.java | 4 +- .../FtpDefaultMoveExistingFileStrategy.java | 6 +-- .../component/file/remote/FtpEndpoint.java | 2 +- .../component/file/remote/FtpOperations.java | 6 +-- .../component/file/remote/FtpsEndpoint.java | 2 +- .../component/file/remote/RemoteFile.java | 2 +- .../file/remote/RemoteFileProducer.java | 4 +- .../component/file/remote/SftpConsumer.java | 4 +- .../SftpDefaultMoveExistingFileStrategy.java | 6 +-- .../component/file/remote/SftpEndpoint.java | 2 +- .../component/file/remote/SftpOperations.java | 6 +-- 18 files changed, 97 insertions(+), 63 deletions(-) diff --git a/components/camel-ftp/src/generated/resources/org/apache/camel/component/file/remote/ftp.json b/components/camel-ftp/src/generated/resources/org/apache/camel/component/file/remote/ftp.json index 9ca26fd720df7..ad4739633bfc5 100644 --- a/components/camel-ftp/src/generated/resources/org/apache/camel/component/file/remote/ftp.json +++ b/components/camel-ftp/src/generated/resources/org/apache/camel/component/file/remote/ftp.json @@ -28,6 +28,18 @@ "lazyStartProducer": { "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": { "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." } }, + "headers": { + "CamelFileLength": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A `long` value containing the file size." }, + "CamelFileLastModified": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A `Long` value containing the last modified timestamp of the file." }, + "CamelFileName": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Specifies the output file name (relative to the endpoint directory) to\nbe used for the output message when sending to the endpoint. If this is\nnot present and no expression either, then a generated message ID is\nused as the filename instead." }, + "CamelFileNameOnly": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Only the file name (the name with no leading paths)." }, + "CamelFileParent": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The parent path." }, + "CamelRemoteFileInputStream": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "java.io.InputStream", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The remote file input stream." }, + "CamelFileLocalWorkPath": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Path to the local work file, if local work directory is used." }, + "CamelFtpReplyCode": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The FTP client reply code" }, + "CamelFtpReplyString": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The FTP client reply string" }, + "CamelFileHost": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The remote hostname." } + }, "properties": { "host": { "kind": "path", "displayName": "Host", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.file.remote.FtpConfiguration", "configurationField": "configuration", "description": "Hostname of the FTP server" }, "port": { "kind": "path", "displayName": "Port", "group": "common", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.file.remote.FtpConfiguration", "configurationField": "configuration", "description": "Port of the FTP server" }, @@ -75,7 +87,7 @@ "chmod": { "kind": "parameter", "displayName": "Chmod", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.file.remote.FtpConfiguration", "configurationField": "configuration", "description": "Allows you to set chmod on the stored file. For example chmod=640." }, "disconnectOnBatchComplete": { "kind": "parameter", "displayName": "Disconnect On Batch Complete", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not to disconnect from remote FTP server right after a Batch upload is complete. disconnectOnBatchComplete will only disconnect the current connection to the FTP server." }, "eagerDeleteTargetFile": { "kind": "parameter", "displayName": "Eager Delete Target File", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not to eagerly delete any existing target file. This option only applies when you use fileExists=Override and the tempFileName option as well. You can use this to disable (set it to false) deleting the target file before the temp file is written. For example you may write big files and want the target file to exists during the temp file is being written. This ensure the target file is only deleted until the very last moment, just before the temp file is being renamed to the target filename. This option is also used to control whether to delete any existing files when fileExist=Move is enabled, and an existing file exists. If this option copyAndDeleteOnRenameFails false, then an exception will be thrown if an existing file existed, if its true, then the existing file is deleted before the move operation." }, - "keepLastModified": { "kind": "parameter", "displayName": "Keep Last Modified", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Will keep the last modified timestamp from the source file (if any). Will use the Exchange.FILE_LAST_MODIFIED header to located the timestamp. This header can contain either a java.util.Date or long with the timestamp. If the timestamp exists and the option is enabled it will set this timestamp on the written file. Note: This option only applies to the file producer. You cannot use this option with any of the ftp producers." }, + "keepLastModified": { "kind": "parameter", "displayName": "Keep Last Modified", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Will keep the last modified timestamp from the source file (if any). Will use the FileConstants.FILE_LAST_MODIFIED header to located the timestamp. This header can contain either a java.util.Date or long with the timestamp. If the timestamp exists and the option is enabled it will set this timestamp on the written file. Note: This option only applies to the file producer. You cannot use this option with any of the ftp producers." }, "moveExistingFileStrategy": { "kind": "parameter", "displayName": "Move Existing File Strategy", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.file.strategy.FileMoveExistingStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "Strategy (Custom Strategy) used to move file with special naming token to use when fileExist=Move is configured. By default, there is an implementation used if no custom strategy is provided" }, "sendNoop": { "kind": "parameter", "displayName": "Send Noop", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.file.remote.FtpConfiguration", "configurationField": "configuration", "description": "Whether to send a noop command as a pre-write check before uploading files to the FTP server. This is enabled by default as a validation of the connection is still valid, which allows to silently re-connect to be able to upload the file. However if this causes problems, you can turn this option off." }, "activePortRange": { "kind": "parameter", "displayName": "Active Port Range", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.file.remote.FtpConfiguration", "configurationField": "configuration", "description": "Set the client side port range in active mode. The syntax is: minPort-maxPort Both port numbers are inclusive, eg 10000-19999 to include all 1xxxx ports." }, diff --git a/components/camel-ftp/src/generated/resources/org/apache/camel/component/file/remote/ftps.json b/components/camel-ftp/src/generated/resources/org/apache/camel/component/file/remote/ftps.json index 5341b68d1541e..df82c74ac3f97 100644 --- a/components/camel-ftp/src/generated/resources/org/apache/camel/component/file/remote/ftps.json +++ b/components/camel-ftp/src/generated/resources/org/apache/camel/component/file/remote/ftps.json @@ -29,6 +29,18 @@ "autowiredEnabled": { "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." }, "useGlobalSslContextParameters": { "kind": "property", "displayName": "Use Global Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Enable usage of global SSL context parameters." } }, + "headers": { + "CamelFileLength": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A `long` value containing the file size." }, + "CamelFileLastModified": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A `Long` value containing the last modified timestamp of the file." }, + "CamelFileName": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Specifies the output file name (relative to the endpoint directory) to\nbe used for the output message when sending to the endpoint. If this is\nnot present and no expression either, then a generated message ID is\nused as the filename instead." }, + "CamelFileNameOnly": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Only the file name (the name with no leading paths)." }, + "CamelFileParent": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The parent path." }, + "CamelRemoteFileInputStream": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "java.io.InputStream", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The remote file input stream." }, + "CamelFileLocalWorkPath": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Path to the local work file, if local work directory is used." }, + "CamelFtpReplyCode": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The FTP client reply code" }, + "CamelFtpReplyString": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The FTP client reply string" }, + "CamelFileHost": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The remote hostname." } + }, "properties": { "host": { "kind": "path", "displayName": "Host", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.file.remote.FtpsConfiguration", "configurationField": "configuration", "description": "Hostname of the FTP server" }, "port": { "kind": "path", "displayName": "Port", "group": "common", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.file.remote.FtpsConfiguration", "configurationField": "configuration", "description": "Port of the FTP server" }, @@ -76,7 +88,7 @@ "chmod": { "kind": "parameter", "displayName": "Chmod", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.file.remote.FtpsConfiguration", "configurationField": "configuration", "description": "Allows you to set chmod on the stored file. For example chmod=640." }, "disconnectOnBatchComplete": { "kind": "parameter", "displayName": "Disconnect On Batch Complete", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not to disconnect from remote FTP server right after a Batch upload is complete. disconnectOnBatchComplete will only disconnect the current connection to the FTP server." }, "eagerDeleteTargetFile": { "kind": "parameter", "displayName": "Eager Delete Target File", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not to eagerly delete any existing target file. This option only applies when you use fileExists=Override and the tempFileName option as well. You can use this to disable (set it to false) deleting the target file before the temp file is written. For example you may write big files and want the target file to exists during the temp file is being written. This ensure the target file is only deleted until the very last moment, just before the temp file is being renamed to the target filename. This option is also used to control whether to delete any existing files when fileExist=Move is enabled, and an existing file exists. If this option copyAndDeleteOnRenameFails false, then an exception will be thrown if an existing file existed, if its true, then the existing file is deleted before the move operation." }, - "keepLastModified": { "kind": "parameter", "displayName": "Keep Last Modified", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Will keep the last modified timestamp from the source file (if any). Will use the Exchange.FILE_LAST_MODIFIED header to located the timestamp. This header can contain either a java.util.Date or long with the timestamp. If the timestamp exists and the option is enabled it will set this timestamp on the written file. Note: This option only applies to the file producer. You cannot use this option with any of the ftp producers." }, + "keepLastModified": { "kind": "parameter", "displayName": "Keep Last Modified", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Will keep the last modified timestamp from the source file (if any). Will use the FileConstants.FILE_LAST_MODIFIED header to located the timestamp. This header can contain either a java.util.Date or long with the timestamp. If the timestamp exists and the option is enabled it will set this timestamp on the written file. Note: This option only applies to the file producer. You cannot use this option with any of the ftp producers." }, "moveExistingFileStrategy": { "kind": "parameter", "displayName": "Move Existing File Strategy", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.file.strategy.FileMoveExistingStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "Strategy (Custom Strategy) used to move file with special naming token to use when fileExist=Move is configured. By default, there is an implementation used if no custom strategy is provided" }, "sendNoop": { "kind": "parameter", "displayName": "Send Noop", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.file.remote.FtpsConfiguration", "configurationField": "configuration", "description": "Whether to send a noop command as a pre-write check before uploading files to the FTP server. This is enabled by default as a validation of the connection is still valid, which allows to silently re-connect to be able to upload the file. However if this causes problems, you can turn this option off." }, "activePortRange": { "kind": "parameter", "displayName": "Active Port Range", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.file.remote.FtpsConfiguration", "configurationField": "configuration", "description": "Set the client side port range in active mode. The syntax is: minPort-maxPort Both port numbers are inclusive, eg 10000-19999 to include all 1xxxx ports." }, diff --git a/components/camel-ftp/src/generated/resources/org/apache/camel/component/file/remote/sftp.json b/components/camel-ftp/src/generated/resources/org/apache/camel/component/file/remote/sftp.json index c1c3cfefc5106..369601c513a87 100644 --- a/components/camel-ftp/src/generated/resources/org/apache/camel/component/file/remote/sftp.json +++ b/components/camel-ftp/src/generated/resources/org/apache/camel/component/file/remote/sftp.json @@ -27,6 +27,18 @@ "lazyStartProducer": { "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": { "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." } }, + "headers": { + "CamelFileLength": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A `long` value containing the file size." }, + "CamelFileLastModified": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A `Long` value containing the last modified timestamp of the file." }, + "CamelFileName": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Specifies the output file name (relative to the endpoint directory) to\nbe used for the output message when sending to the endpoint. If this is\nnot present and no expression either, then a generated message ID is\nused as the filename instead." }, + "CamelFileNameOnly": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Only the file name (the name with no leading paths)." }, + "CamelFileParent": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The parent path." }, + "CamelRemoteFileInputStream": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "java.io.InputStream", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The remote file input stream." }, + "CamelFileLocalWorkPath": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Path to the local work file, if local work directory is used." }, + "CamelFtpReplyCode": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The FTP client reply code" }, + "CamelFtpReplyString": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The FTP client reply string" }, + "CamelFileHost": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The remote hostname." } + }, "properties": { "host": { "kind": "path", "displayName": "Host", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.file.remote.SftpConfiguration", "configurationField": "configuration", "description": "Hostname of the FTP server" }, "port": { "kind": "path", "displayName": "Port", "group": "common", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.file.remote.SftpConfiguration", "configurationField": "configuration", "description": "Port of the FTP server" }, @@ -71,7 +83,7 @@ "chmodDirectory": { "kind": "parameter", "displayName": "Chmod Directory", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.file.remote.SftpConfiguration", "configurationField": "configuration", "description": "Allows you to set chmod during path creation. For example chmod=640." }, "disconnectOnBatchComplete": { "kind": "parameter", "displayName": "Disconnect On Batch Complete", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not to disconnect from remote FTP server right after a Batch upload is complete. disconnectOnBatchComplete will only disconnect the current connection to the FTP server." }, "eagerDeleteTargetFile": { "kind": "parameter", "displayName": "Eager Delete Target File", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not to eagerly delete any existing target file. This option only applies when you use fileExists=Override and the tempFileName option as well. You can use this to disable (set it to false) deleting the target file before the temp file is written. For example you may write big files and want the target file to exists during the temp file is being written. This ensure the target file is only deleted until the very last moment, just before the temp file is being renamed to the target filename. This option is also used to control whether to delete any existing files when fileExist=Move is enabled, and an existing file exists. If this option copyAndDeleteOnRenameFails false, then an exception will be thrown if an existing file existed, if its true, then the existing file is deleted before the move operation." }, - "keepLastModified": { "kind": "parameter", "displayName": "Keep Last Modified", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Will keep the last modified timestamp from the source file (if any). Will use the Exchange.FILE_LAST_MODIFIED header to located the timestamp. This header can contain either a java.util.Date or long with the timestamp. If the timestamp exists and the option is enabled it will set this timestamp on the written file. Note: This option only applies to the file producer. You cannot use this option with any of the ftp producers." }, + "keepLastModified": { "kind": "parameter", "displayName": "Keep Last Modified", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Will keep the last modified timestamp from the source file (if any). Will use the FileConstants.FILE_LAST_MODIFIED header to located the timestamp. This header can contain either a java.util.Date or long with the timestamp. If the timestamp exists and the option is enabled it will set this timestamp on the written file. Note: This option only applies to the file producer. You cannot use this option with any of the ftp producers." }, "moveExistingFileStrategy": { "kind": "parameter", "displayName": "Move Existing File Strategy", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.file.strategy.FileMoveExistingStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "Strategy (Custom Strategy) used to move file with special naming token to use when fileExist=Move is configured. By default, there is an implementation used if no custom strategy is provided" }, "sendNoop": { "kind": "parameter", "displayName": "Send Noop", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.file.remote.SftpConfiguration", "configurationField": "configuration", "description": "Whether to send a noop command as a pre-write check before uploading files to the FTP server. This is enabled by default as a validation of the connection is still valid, which allows to silently re-connect to be able to upload the file. However if this causes problems, you can turn this option off." }, "autoCreate": { "kind": "parameter", "displayName": "Auto Create", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Automatically create missing directories in the file's pathname. For the file consumer, that means creating the starting directory. For the file producer, it means the directory the files should be written to." }, diff --git a/components/camel-ftp/src/main/docs/ftp-component.adoc b/components/camel-ftp/src/main/docs/ftp-component.adoc index 0a482f6ebef98..ec38d77ca7487 100644 --- a/components/camel-ftp/src/main/docs/ftp-component.adoc +++ b/components/camel-ftp/src/main/docs/ftp-component.adoc @@ -84,7 +84,9 @@ include::partial$component-endpoint-options.adoc[] // endpoint options: START // endpoint options: END - +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END == FTPS component default trust store @@ -202,43 +204,6 @@ restricted to the FTP_ROOT folder. That prevents you from moving files outside the FTP area. If you want to move files to another area you can use soft links and move files into a soft linked folder. -== Message Headers - -The following message headers can be used to affect the behavior of the -component - -[width="100%",cols="50%,50%",options="header",] -|======================================================================= -|Header |Description - -|`CamelFileName` |Specifies the output file name (relative to the endpoint directory) to -be used for the output message when sending to the endpoint. If this is -not present and no expression either, then a generated message ID is -used as the filename instead. - -|`CamelFileNameProduced` |The actual filepath (path + name) for the output file that was written. -This header is set by Camel and its purpose is providing end-users the -name of the file that was written. - -|`CamelFileNameConsumed` |The file name of the file consumed - -|`CamelFileHost` |The remote hostname. - -|`CamelFileLocalWorkPath` |Path to the local work file, if local work directory is used. -|======================================================================= - -In addition the FTP/FTPS consumer and producer will enrich the Camel -`Message` with the following headers - -[width="100%",cols="50%,50%",options="header",] -|======================================================================= -|Header |Description - -|`CamelFtpReplyCode` |The FTP client reply code (the type is a integer) - -|`CamelFtpReplyString` |The FTP client reply string -|======================================================================= - == Exchange Properties Camel sets the following exchange properties diff --git a/components/camel-ftp/src/main/docs/ftps-component.adoc b/components/camel-ftp/src/main/docs/ftps-component.adoc index 6b0b3d5375662..85c8b84a89cbc 100644 --- a/components/camel-ftp/src/main/docs/ftps-component.adoc +++ b/components/camel-ftp/src/main/docs/ftps-component.adoc @@ -42,6 +42,9 @@ include::partial$component-endpoint-options.adoc[] // endpoint options: START // endpoint options: END +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END == More Information diff --git a/components/camel-ftp/src/main/docs/sftp-component.adoc b/components/camel-ftp/src/main/docs/sftp-component.adoc index 6d41b7eb870f0..a5953a88a9651 100644 --- a/components/camel-ftp/src/main/docs/sftp-component.adoc +++ b/components/camel-ftp/src/main/docs/sftp-component.adoc @@ -41,6 +41,9 @@ include::partial$component-endpoint-options.adoc[] // endpoint options: START // endpoint options: END +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END == More Information diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConstants.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConstants.java index 4c7588997731b..9d568c882140e 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConstants.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConstants.java @@ -16,13 +16,40 @@ */ package org.apache.camel.component.file.remote; +import org.apache.camel.Exchange; +import org.apache.camel.spi.Metadata; + /** * Constants */ public final class FtpConstants { + @Metadata(label = "consumer", description = "A `long` value containing the file size.", javaType = "long") + public static final String FILE_LENGTH = Exchange.FILE_LENGTH; + @Metadata(label = "consumer", description = "A `Long` value containing the last modified timestamp of the file.", + javaType = "long") + public static final String FILE_LAST_MODIFIED = Exchange.FILE_LAST_MODIFIED; + @Metadata(description = "Specifies the output file name (relative to the endpoint directory) to\n" + + "be used for the output message when sending to the endpoint. If this is\n" + + "not present and no expression either, then a generated message ID is\n" + + "used as the filename instead.", + javaType = "String") + public static final String FILE_NAME = Exchange.FILE_NAME; + @Metadata(description = "Only the file name (the name with no leading paths).", javaType = "String") + public static final String FILE_NAME_ONLY = Exchange.FILE_NAME_ONLY; + @Metadata(description = "The parent path.", javaType = "String") + public static final String FILE_PARENT = Exchange.FILE_PARENT; + @Metadata(description = "The remote file input stream.", javaType = "java.io.InputStream") + public static final String REMOTE_FILE_INPUT_STREAM = RemoteFileComponent.REMOTE_FILE_INPUT_STREAM; + @Metadata(description = "Path to the local work file, if local work directory is used.", javaType = "String") + public static final String FILE_LOCAL_WORK_PATH = Exchange.FILE_LOCAL_WORK_PATH; + + @Metadata(description = "The FTP client reply code", javaType = "int") public static final String FTP_REPLY_CODE = "CamelFtpReplyCode"; + @Metadata(description = "The FTP client reply string", javaType = "String") public static final String FTP_REPLY_STRING = "CamelFtpReplyString"; + @Metadata(description = "The remote hostname.", javaType = "String") + public static final String FILE_HOST = "CamelFileHost"; private FtpConstants() { } diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java index 1066539e0aac3..1b51b21abba0b 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java @@ -321,10 +321,10 @@ protected void updateFileHeaders(GenericFile file, Message message) { file.setFileLength(length); file.setLastModified(modified); if (length >= 0) { - message.setHeader(Exchange.FILE_LENGTH, length); + message.setHeader(FtpConstants.FILE_LENGTH, length); } if (modified >= 0) { - message.setHeader(Exchange.FILE_LAST_MODIFIED, modified); + message.setHeader(FtpConstants.FILE_LAST_MODIFIED, modified); } } diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpDefaultMoveExistingFileStrategy.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpDefaultMoveExistingFileStrategy.java index 48225bc6f7c9a..31df2a83c28fa 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpDefaultMoveExistingFileStrategy.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpDefaultMoveExistingFileStrategy.java @@ -51,9 +51,9 @@ public boolean moveExistingFile(GenericFileEndpoint endpoint, GenericFileOperati //any leading separator String parent = FileUtil.stripLeadingSeparator(FileUtil.onlyPath(fileName)); String onlyName = FileUtil.stripPath(fileName); - dummy.getIn().setHeader(Exchange.FILE_NAME, fileName); - dummy.getIn().setHeader(Exchange.FILE_NAME_ONLY, onlyName); - dummy.getIn().setHeader(Exchange.FILE_PARENT, parent); + dummy.getIn().setHeader(FtpConstants.FILE_NAME, fileName); + dummy.getIn().setHeader(FtpConstants.FILE_NAME_ONLY, onlyName); + dummy.getIn().setHeader(FtpConstants.FILE_PARENT, parent); String to = endpoint.getMoveExisting().evaluate(dummy, String.class); // we only support relative paths for the ftp component, so strip any diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java index 58d878e8df74c..0220456e0c2fc 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java @@ -48,7 +48,7 @@ */ @UriEndpoint(firstVersion = "1.1.0", scheme = "ftp", extendsScheme = "file", title = "FTP", syntax = "ftp:host:port/directoryName", alternativeSyntax = "ftp:username:password@host:port/directoryName", - category = { Category.FILE }) + category = { Category.FILE }, headersClass = FtpConstants.class) @Metadata(excludeProperties = "appendChars,readLockIdempotentReleaseAsync,readLockIdempotentReleaseAsyncPoolSize," + "readLockIdempotentReleaseDelay,readLockIdempotentReleaseExecutorService," + "directoryMustExist,extendedAttributes,probeContentType,startingDirectoryMustExist," diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java index b1da0ecc72805..965bf334a2f40 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java @@ -434,7 +434,7 @@ public boolean retrieveFile(String name, Exchange exchange, long size) throws Ge @Override public void releaseRetrievedFileResources(Exchange exchange) throws GenericFileOperationFailedException { - InputStream is = exchange.getIn().getHeader(RemoteFileComponent.REMOTE_FILE_INPUT_STREAM, InputStream.class); + InputStream is = exchange.getIn().getHeader(FtpConstants.REMOTE_FILE_INPUT_STREAM, InputStream.class); if (is != null) { try { @@ -480,7 +480,7 @@ private boolean retrieveFileToStreamInBody(String name, Exchange exchange) throw if (endpoint.getConfiguration().isStreamDownload()) { InputStream is = client.retrieveFileStream(remoteName); target.setBody(is); - exchange.getIn().setHeader(RemoteFileComponent.REMOTE_FILE_INPUT_STREAM, is); + exchange.getIn().setHeader(FtpConstants.REMOTE_FILE_INPUT_STREAM, is); result = true; } else { // read the entire file into memory in the byte array @@ -568,7 +568,7 @@ private boolean retrieveFileToFileInLocalWorkDirectory(String name, Exchange exc os = new FileOutputStream(temp, append); // set header with the path to the local work file - exchange.getIn().setHeader(Exchange.FILE_LOCAL_WORK_PATH, local.getPath()); + exchange.getIn().setHeader(FtpConstants.FILE_LOCAL_WORK_PATH, local.getPath()); } catch (Exception e) { throw new GenericFileOperationFailedException("Cannot create new local work file: " + local); diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java index fac83e02578a2..801051e2f0dba 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java @@ -45,7 +45,7 @@ */ @UriEndpoint(firstVersion = "2.2.0", scheme = "ftps", extendsScheme = "file", title = "FTPS", syntax = "ftps:host:port/directoryName", alternativeSyntax = "ftps:username:password@host:port/directoryName", - label = "file") + label = "file", headersClass = FtpConstants.class) @Metadata(excludeProperties = "appendChars,readLockIdempotentReleaseAsync,readLockIdempotentReleaseAsyncPoolSize," + "readLockIdempotentReleaseDelay,readLockIdempotentReleaseExecutorService," + "directoryMustExist,extendedAttributes,probeContentType,startingDirectoryMustExist," diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFile.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFile.java index 6fa94a67eaf50..e2c539128bada 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFile.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFile.java @@ -39,7 +39,7 @@ public void populateHeaders(GenericFileMessage message) { // in other file based components, false may be passed // as the second argument. super.populateHeaders(message, false); - message.setHeader("CamelFileHost", getHostname()); + message.setHeader(FtpConstants.FILE_HOST, getHostname()); } } diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java index 78e13236eb6f0..29c6269ee5053 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java @@ -52,7 +52,7 @@ public String normalizePath(String name) { @Override public void process(Exchange exchange) throws Exception { // store any existing file header which we want to keep and propagate - final String existing = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class); + final String existing = exchange.getIn().getHeader(FtpConstants.FILE_NAME, String.class); // create the target file name String target = createFileName(exchange); @@ -64,7 +64,7 @@ public void process(Exchange exchange) throws Exception { // (by design) exchange.getIn().removeHeader(Exchange.OVERRULE_FILE_NAME); // and restore existing file name - exchange.getIn().setHeader(Exchange.FILE_NAME, existing); + exchange.getIn().setHeader(FtpConstants.FILE_NAME, existing); } } diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java index 55dd15b074a77..67b438fcd004b 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java @@ -300,10 +300,10 @@ protected void updateFileHeaders(GenericFile file, Message messa file.setFileLength(length); file.setLastModified(modified); if (length >= 0) { - message.setHeader(Exchange.FILE_LENGTH, length); + message.setHeader(FtpConstants.FILE_LENGTH, length); } if (modified >= 0) { - message.setHeader(Exchange.FILE_LAST_MODIFIED, modified); + message.setHeader(FtpConstants.FILE_LAST_MODIFIED, modified); } } } diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpDefaultMoveExistingFileStrategy.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpDefaultMoveExistingFileStrategy.java index f139fbb7d017e..7c5623e6d8acb 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpDefaultMoveExistingFileStrategy.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpDefaultMoveExistingFileStrategy.java @@ -48,9 +48,9 @@ public boolean moveExistingFile(GenericFileEndpoint endpoint, GenericFileOperati //any leading separator String parent = FileUtil.stripLeadingSeparator(FileUtil.onlyPath(fileName)); String onlyName = FileUtil.stripPath(fileName); - dummy.getIn().setHeader(Exchange.FILE_NAME, fileName); - dummy.getIn().setHeader(Exchange.FILE_NAME_ONLY, onlyName); - dummy.getIn().setHeader(Exchange.FILE_PARENT, parent); + dummy.getIn().setHeader(FtpConstants.FILE_NAME, fileName); + dummy.getIn().setHeader(FtpConstants.FILE_NAME_ONLY, onlyName); + dummy.getIn().setHeader(FtpConstants.FILE_PARENT, parent); String to = endpoint.getMoveExisting().evaluate(dummy, String.class); diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpEndpoint.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpEndpoint.java index 5a26d75d3b730..a1e660814f71f 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpEndpoint.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpEndpoint.java @@ -31,7 +31,7 @@ * Upload and download files to/from SFTP servers. */ @UriEndpoint(firstVersion = "1.1.0", scheme = "sftp", extendsScheme = "file", title = "SFTP", - syntax = "sftp:host:port/directoryName", label = "file") + syntax = "sftp:host:port/directoryName", label = "file", headersClass = FtpConstants.class) @Metadata(excludeProperties = "appendChars,bufferSize,siteCommand," + "directoryMustExist,extendedAttributes,probeContentType,startingDirectoryMustExist," + "startingDirectoryMustHaveAccess,forceWrites,copyAndDeleteOnRenameFail," diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java index 26fd3ada9ad9b..0d33723289638 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java @@ -760,7 +760,7 @@ public synchronized boolean retrieveFile(String name, Exchange exchange, long si @Override public synchronized void releaseRetrievedFileResources(Exchange exchange) throws GenericFileOperationFailedException { - InputStream is = exchange.getIn().getHeader(RemoteFileComponent.REMOTE_FILE_INPUT_STREAM, InputStream.class); + InputStream is = exchange.getIn().getHeader(FtpConstants.REMOTE_FILE_INPUT_STREAM, InputStream.class); if (is != null) { try { @@ -801,7 +801,7 @@ private boolean retrieveFileToStreamInBody(String name, Exchange exchange) throw if (endpoint.getConfiguration().isStreamDownload()) { target.setBody(is); - exchange.getIn().setHeader(RemoteFileComponent.REMOTE_FILE_INPUT_STREAM, is); + exchange.getIn().setHeader(FtpConstants.REMOTE_FILE_INPUT_STREAM, is); } else { // read the entire file into memory in the byte array ByteArrayOutputStream bos = new ByteArrayOutputStream(); @@ -868,7 +868,7 @@ private boolean retrieveFileToFileInLocalWorkDirectory(String name, Exchange exc os = new FileOutputStream(temp); // set header with the path to the local work file - exchange.getIn().setHeader(Exchange.FILE_LOCAL_WORK_PATH, local.getPath()); + exchange.getIn().setHeader(FtpConstants.FILE_LOCAL_WORK_PATH, local.getPath()); } catch (Exception e) { throw new GenericFileOperationFailedException("Cannot create new local work file: " + local); }