From 01184f3e6160e3e1640a7333569fcfad926321f3 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Thu, 14 May 2026 14:38:04 +0200 Subject: [PATCH] CAMEL-23508: camel-elasticsearch-rest-client - align Exchange header constant names with Camel naming convention Rename the Exchange header string values in ElasticSearchRestClientConstant from raw uppercase (ID, SEARCH_QUERY, INDEX_SETTINGS, INDEX_NAME, OPERATION) to the Camel naming convention (CamelElasticsearchId, CamelElasticsearchSearchQuery, CamelElasticsearchIndexSettings, CamelElasticsearchIndexName, CamelElasticsearchOperation). The Java field names are unchanged so routes referencing the constants symbolically continue to work. Routes using the literal string value must be updated. Adds an entry to the 4.21 upgrade guide and regenerates the affected component metadata, catalog, and endpoint DSL. Closes #23212 --- .../components/elasticsearch-rest-client.json | 10 +++---- .../client/elasticsearch-rest-client.json | 10 +++---- .../elasticsearch-rest-client-component.adoc | 18 +++++------ .../ElasticSearchRestClientConstant.java | 10 +++---- ...earchRestClientEndpointBuilderFactory.java | 30 +++++++++---------- 5 files changed, 39 insertions(+), 39 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/elasticsearch-rest-client.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/elasticsearch-rest-client.json index 213078da96f18..880b96d42f4ce 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/elasticsearch-rest-client.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/elasticsearch-rest-client.json @@ -38,11 +38,11 @@ "user": { "index": 11, "kind": "property", "displayName": "User", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Username" } }, "headers": { - "ID": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "ID of the object to index or retrieve or delete", "constantName": "org.apache.camel.component.elasticsearch.rest.client.ElasticSearchRestClientConstant#ID" }, - "SEARCH_QUERY": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The JSON Query to perform for search", "constantName": "org.apache.camel.component.elasticsearch.rest.client.ElasticSearchRestClientConstant#SEARCH_QUERY" }, - "INDEX_SETTINGS": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Advanced - The JSON Index Settings and\/or Mappings Query to perform to create an index", "constantName": "org.apache.camel.component.elasticsearch.rest.client.ElasticSearchRestClientConstant#INDEX_SETTINGS" }, - "INDEX_NAME": { "index": 3, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The Index name", "constantName": "org.apache.camel.component.elasticsearch.rest.client.ElasticSearchRestClientConstant#INDEX_NAME" }, - "OPERATION": { "index": 4, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "org.apache.camel.component.elasticsearch.rest.client.ElasticsearchRestClientOperation", "enum": [ "INDEX_OR_UPDATE", "GET_BY_ID", "DELETE", "CREATE_INDEX", "DELETE_INDEX", "SEARCH" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation to perform", "constantName": "org.apache.camel.component.elasticsearch.rest.client.ElasticSearchRestClientConstant#OPERATION" } + "CamelElasticsearchId": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "ID of the object to index or retrieve or delete", "constantName": "org.apache.camel.component.elasticsearch.rest.client.ElasticSearchRestClientConstant#ID" }, + "CamelElasticsearchSearchQuery": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The JSON Query to perform for search", "constantName": "org.apache.camel.component.elasticsearch.rest.client.ElasticSearchRestClientConstant#SEARCH_QUERY" }, + "CamelElasticsearchIndexSettings": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Advanced - The JSON Index Settings and\/or Mappings Query to perform to create an index", "constantName": "org.apache.camel.component.elasticsearch.rest.client.ElasticSearchRestClientConstant#INDEX_SETTINGS" }, + "CamelElasticsearchIndexName": { "index": 3, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The Index name", "constantName": "org.apache.camel.component.elasticsearch.rest.client.ElasticSearchRestClientConstant#INDEX_NAME" }, + "CamelElasticsearchOperation": { "index": 4, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "org.apache.camel.component.elasticsearch.rest.client.ElasticsearchRestClientOperation", "enum": [ "INDEX_OR_UPDATE", "GET_BY_ID", "DELETE", "CREATE_INDEX", "DELETE_INDEX", "SEARCH" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation to perform", "constantName": "org.apache.camel.component.elasticsearch.rest.client.ElasticSearchRestClientConstant#OPERATION" } }, "properties": { "clusterName": { "index": 0, "kind": "path", "displayName": "Cluster Name", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Cluster Name" }, diff --git a/components/camel-elasticsearch-rest-client/src/generated/resources/META-INF/org/apache/camel/component/elasticsearch/rest/client/elasticsearch-rest-client.json b/components/camel-elasticsearch-rest-client/src/generated/resources/META-INF/org/apache/camel/component/elasticsearch/rest/client/elasticsearch-rest-client.json index 213078da96f18..880b96d42f4ce 100644 --- a/components/camel-elasticsearch-rest-client/src/generated/resources/META-INF/org/apache/camel/component/elasticsearch/rest/client/elasticsearch-rest-client.json +++ b/components/camel-elasticsearch-rest-client/src/generated/resources/META-INF/org/apache/camel/component/elasticsearch/rest/client/elasticsearch-rest-client.json @@ -38,11 +38,11 @@ "user": { "index": 11, "kind": "property", "displayName": "User", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Username" } }, "headers": { - "ID": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "ID of the object to index or retrieve or delete", "constantName": "org.apache.camel.component.elasticsearch.rest.client.ElasticSearchRestClientConstant#ID" }, - "SEARCH_QUERY": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The JSON Query to perform for search", "constantName": "org.apache.camel.component.elasticsearch.rest.client.ElasticSearchRestClientConstant#SEARCH_QUERY" }, - "INDEX_SETTINGS": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Advanced - The JSON Index Settings and\/or Mappings Query to perform to create an index", "constantName": "org.apache.camel.component.elasticsearch.rest.client.ElasticSearchRestClientConstant#INDEX_SETTINGS" }, - "INDEX_NAME": { "index": 3, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The Index name", "constantName": "org.apache.camel.component.elasticsearch.rest.client.ElasticSearchRestClientConstant#INDEX_NAME" }, - "OPERATION": { "index": 4, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "org.apache.camel.component.elasticsearch.rest.client.ElasticsearchRestClientOperation", "enum": [ "INDEX_OR_UPDATE", "GET_BY_ID", "DELETE", "CREATE_INDEX", "DELETE_INDEX", "SEARCH" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation to perform", "constantName": "org.apache.camel.component.elasticsearch.rest.client.ElasticSearchRestClientConstant#OPERATION" } + "CamelElasticsearchId": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "ID of the object to index or retrieve or delete", "constantName": "org.apache.camel.component.elasticsearch.rest.client.ElasticSearchRestClientConstant#ID" }, + "CamelElasticsearchSearchQuery": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The JSON Query to perform for search", "constantName": "org.apache.camel.component.elasticsearch.rest.client.ElasticSearchRestClientConstant#SEARCH_QUERY" }, + "CamelElasticsearchIndexSettings": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Advanced - The JSON Index Settings and\/or Mappings Query to perform to create an index", "constantName": "org.apache.camel.component.elasticsearch.rest.client.ElasticSearchRestClientConstant#INDEX_SETTINGS" }, + "CamelElasticsearchIndexName": { "index": 3, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The Index name", "constantName": "org.apache.camel.component.elasticsearch.rest.client.ElasticSearchRestClientConstant#INDEX_NAME" }, + "CamelElasticsearchOperation": { "index": 4, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "org.apache.camel.component.elasticsearch.rest.client.ElasticsearchRestClientOperation", "enum": [ "INDEX_OR_UPDATE", "GET_BY_ID", "DELETE", "CREATE_INDEX", "DELETE_INDEX", "SEARCH" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation to perform", "constantName": "org.apache.camel.component.elasticsearch.rest.client.ElasticSearchRestClientConstant#OPERATION" } }, "properties": { "clusterName": { "index": 0, "kind": "path", "displayName": "Cluster Name", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Cluster Name" }, diff --git a/components/camel-elasticsearch-rest-client/src/main/docs/elasticsearch-rest-client-component.adoc b/components/camel-elasticsearch-rest-client/src/main/docs/elasticsearch-rest-client-component.adoc index ef10bccd473dd..7edde332bf8b1 100644 --- a/components/camel-elasticsearch-rest-client/src/main/docs/elasticsearch-rest-client-component.adoc +++ b/components/camel-elasticsearch-rest-client/src/main/docs/elasticsearch-rest-client-component.adoc @@ -63,14 +63,14 @@ You can set the name of the target index from the `indexName` URI parameter opti You must provide the index id of the content to delete either in the message body, or via a message header with the key `ID` . |`CREATE_INDEX` | |Creates the specified `indexName` and returns a `boolean` value as the message exchange body, indicating whether the operation was successful. -You can set the name of the target index to create from the `indexName` URI parameter option, or by providing a message header with the key `INDEX_NAME`. -You may also provide a header with the key `INDEX_SETTINGS` where the value is a JSON String representation of the index settings. +You can set the name of the target index to create from the `indexName` URI parameter option, or by providing a message header with the key `CamelElasticsearchIndexName`. +You may also provide a header with the key `CamelElasticsearchIndexSettings` where the value is a JSON String representation of the index settings. |`DELETE_INDEX` | |Deletes the specified `indexName` and returns a `boolean` value as the message exchange body, indicating whether the operation was successful. -You can set the name of the target index to create from the `indexName` URI parameter option, or by providing a message header with the key `INDEX_NAME`. +You can set the name of the target index to create from the `indexName` URI parameter option, or by providing a message header with the key `CamelElasticsearchIndexName`. |`SEARCH` |`Map` (optional) |Search for content with either a `Map` of `String` keys & values of query criteria. Or a JSON string representation of the query. Matching documents are returned as a JSON string set on the message exchange body. -You can set the JSON query String by providing a message header with the key `SEARCH_QUERY`. +You can set the JSON query String by providing a message header with the key `CamelElasticsearchSearchQuery`. You can set the message exchange body to a `Map` of `String` keys & values for the query criteria. |=== @@ -93,7 +93,7 @@ To update existing indexed content, provide the `ID` message header and the mess [source,java] ---- from("direct:index") - .setHeader("ID").constant("1") + .setHeader("CamelElasticsearchId").constant("1") .setBody().constant("{\"content\": \"ElasticSearch REST Client With Camel\"}") .to("elasticsearch-rest-client://myCluster?operation=INDEX_OR_UPDATE&indexName=myIndex"); ---- @@ -103,7 +103,7 @@ from("direct:index") [source,java] ---- from("direct:getById") - .setHeader("ID").constant("1") + .setHeader("CamelElasticsearchId").constant("1") .to("elasticsearch-rest-client://myCluster?operation=GET_BY_ID&indexName=myIndex"); ---- @@ -114,7 +114,7 @@ To delete indexed content, provide the `ID` message header. [source,java] ---- from("direct:getById") - .setHeader("ID").constant("1") + .setHeader("CamelElasticsearchId").constant("1") .to("elasticsearch-rest-client://myCluster?operation=DELETE&indexName=myIndex"); ---- @@ -138,7 +138,7 @@ String indexSettings = "{\"settings\":{\"number_of_replicas\": 1,\"number_of_sha [source,java] ---- from("direct:createIndex") - .setHeader("INDEX_SETTINGS").constant(indexSettings) + .setHeader("CamelElasticsearchIndexSettings").constant(indexSettings) .to("elasticsearch-rest-client://myCluster?operation=CREATE_INDEX&indexName=myIndex"); ---- @@ -159,7 +159,7 @@ Search with a JSON query. [source,java] ---- from("direct:search") - .setHeader("SEARCH_QUERY").constant("{\"query\":{\"match\":{\"content\":\"ElasticSearch With Camel\"}}}") + .setHeader("CamelElasticsearchSearchQuery").constant("{\"query\":{\"match\":{\"content\":\"ElasticSearch With Camel\"}}}") .to("elasticsearch-rest-client://myCluster?operation=SEARCH&indexName=myIndex"); ---- diff --git a/components/camel-elasticsearch-rest-client/src/main/java/org/apache/camel/component/elasticsearch/rest/client/ElasticSearchRestClientConstant.java b/components/camel-elasticsearch-rest-client/src/main/java/org/apache/camel/component/elasticsearch/rest/client/ElasticSearchRestClientConstant.java index c5a4623f3160d..d1ebaf42a72d9 100644 --- a/components/camel-elasticsearch-rest-client/src/main/java/org/apache/camel/component/elasticsearch/rest/client/ElasticSearchRestClientConstant.java +++ b/components/camel-elasticsearch-rest-client/src/main/java/org/apache/camel/component/elasticsearch/rest/client/ElasticSearchRestClientConstant.java @@ -21,21 +21,21 @@ public class ElasticSearchRestClientConstant { @Metadata(description = " ID of the object to index or retrieve or delete", javaType = "String") - public static final String ID = "ID"; + public static final String ID = "CamelElasticsearchId"; @Metadata(description = "The JSON Query to perform for search", javaType = "String") - public static final String SEARCH_QUERY = "SEARCH_QUERY"; + public static final String SEARCH_QUERY = "CamelElasticsearchSearchQuery"; @Metadata(description = "Advanced - The JSON Index Settings and/or Mappings Query to perform to create an index", javaType = "String") - public static final String INDEX_SETTINGS = "INDEX_SETTINGS"; + public static final String INDEX_SETTINGS = "CamelElasticsearchIndexSettings"; @Metadata(description = "The Index name", javaType = "String") - public static final String INDEX_NAME = "INDEX_NAME"; + public static final String INDEX_NAME = "CamelElasticsearchIndexName"; @Metadata(description = "The operation to perform", javaType = "org.apache.camel.component.elasticsearch.rest.client.ElasticsearchRestClientOperation") - public static final String OPERATION = "OPERATION"; + public static final String OPERATION = "CamelElasticsearchOperation"; public static final int SOCKET_CONNECTION_TIMEOUT = 30000; public static final int SNIFFER_INTERVAL_AND_FAILURE_DELAY = 60000; diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ElasticsearchRestClientEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ElasticsearchRestClientEndpointBuilderFactory.java index 7f20c6a328dda..2fb262566a8db 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ElasticsearchRestClientEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ElasticsearchRestClientEndpointBuilderFactory.java @@ -466,10 +466,10 @@ public static class ElasticsearchRestClientHeaderNameBuilder { * * Group: producer * - * @return the name of the header {@code ID}. + * @return the name of the header {@code ElasticsearchId}. */ - public String iD() { - return "ID"; + public String elasticsearchId() { + return "CamelElasticsearchId"; } /** * The JSON Query to perform for search. @@ -478,10 +478,10 @@ public String iD() { * * Group: producer * - * @return the name of the header {@code SEARCH_QUERY}. + * @return the name of the header {@code ElasticsearchSearchQuery}. */ - public String searchQuery() { - return "SEARCH_QUERY"; + public String elasticsearchSearchQuery() { + return "CamelElasticsearchSearchQuery"; } /** * Advanced - The JSON Index Settings and/or Mappings Query to perform @@ -491,10 +491,10 @@ public String searchQuery() { * * Group: producer * - * @return the name of the header {@code INDEX_SETTINGS}. + * @return the name of the header {@code ElasticsearchIndexSettings}. */ - public String indexSettings() { - return "INDEX_SETTINGS"; + public String elasticsearchIndexSettings() { + return "CamelElasticsearchIndexSettings"; } /** * The Index name. @@ -503,10 +503,10 @@ public String indexSettings() { * * Group: producer * - * @return the name of the header {@code INDEX_NAME}. + * @return the name of the header {@code ElasticsearchIndexName}. */ - public String indexName() { - return "INDEX_NAME"; + public String elasticsearchIndexName() { + return "CamelElasticsearchIndexName"; } /** * The operation to perform. @@ -516,10 +516,10 @@ public String indexName() { * * Group: producer * - * @return the name of the header {@code OPERATION}. + * @return the name of the header {@code ElasticsearchOperation}. */ - public String oPERATION() { - return "OPERATION"; + public String elasticsearchOperation() { + return "CamelElasticsearchOperation"; } } static ElasticsearchRestClientEndpointBuilder endpointBuilder(String componentName, String path) {