This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 4ae391d67f8 camel-azure-files: add more constant headers 4ae391d67f8 is described below commit 4ae391d67f8e6667feb8fd95bbc5a062a361d189 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Mon Jan 6 15:05:09 2025 +0100 camel-azure-files: add more constant headers --- .../camel/catalog/components/azure-files.json | 23 ++-- .../camel/component/file/azure/azure-files.json | 23 ++-- .../camel/component/file/azure/FilesConstants.java | 84 ++++++++++++++ .../camel/component/file/azure/FilesConsumer.java | 4 +- .../camel/component/file/azure/FilesEndpoint.java | 2 +- .../camel/component/file/azure/FilesHeaders.java | 53 --------- .../component/file/azure/FilesOperations.java | 15 +-- .../AzureFilesCloudEventDataTypeTransformer.java | 8 +- .../ROOT/pages/camel-4x-upgrade-guide-4_10.adoc | 4 + .../endpoint/dsl/FilesEndpointBuilderFactory.java | 122 ++++++++++++++++++--- 10 files changed, 238 insertions(+), 100 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/azure-files.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/azure-files.json index 00067cfbb86..202ab536271 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/azure-files.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/azure-files.json @@ -31,14 +31,21 @@ "healthCheckProducerEnabled": { "index": 4, "kind": "property", "displayName": "Health Check Producer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer [...] }, "headers": { - "CamelFileLength": { "index": 0, "kind": "header", "displayName": "", "group": "both", "label": "both", "required": false, "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A long value containing the file size. For producer, known length helps if the body converts to InputStream more efficiently than to bytes array.", "constantName": "org.apache.camel.component.file.azure.FilesHeaders#FILE_LENGTH" }, - "CamelFileLastModified": { "index": 1, "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.", "constantName": "org.apache.camel.component.file.azure.FilesHeaders#FILE_LAST_MODIFIED" }, - "CamelFileName": { "index": 2, "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 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.", "const [...] - "CamelFileNameOnly": { "index": 3, "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).", "constantName": "org.apache.camel.component.file.azure.FilesHeaders#FILE_NAME_ONLY" }, - "CamelFileParent": { "index": 4, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The parent path.", "constantName": "org.apache.camel.component.file.azure.FilesHeaders#FILE_PARENT" }, - "CamelRemoteFileInputStream": { "index": 5, "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.", "constantName": "org.apache.camel.component.file.azure.FilesHeaders#REMOTE_FILE_INPUT_STREAM" }, - "CamelFileLocalWorkPath": { "index": 6, "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.", "constantName": "org.apache.camel.component.file.azure.FilesHeaders#FILE_LOCAL_WORK_PATH" }, - "CamelFileHost": { "index": 7, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The remote hostname.", "constantName": "org.apache.camel.component.file.azure.FilesHeaders#FILE_HOST" } + "CamelFileLength": { "index": 0, "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.", "constantName": "org.apache.camel.component.file.azure.FilesConstants#FILE_LENGTH" }, + "CamelFileLastModified": { "index": 1, "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.", "constantName": "org.apache.camel.component.file.azure.FilesConstants#FILE_LAST_MODIFIED" }, + "CamelFileNameOnly": { "index": 2, "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Only the file name (the name with no leading paths).", "constantName": "org.apache.camel.component.file.azure.FilesConstants#FILE_NAME_ONLY" }, + "CamelFileName": { "index": 3, "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 directory). This name can be a String; a String with a file or simple Language expression; or an Expression object. If it's null then Camel will auto-generate a filename bas [...] + "CamelFileNameConsumed": { "index": 4, "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", "constantName": "org.apache.camel.component.file.azure.FilesConstants#FILE_NAME_CONSUMED" }, + "CamelFileAbsolute": { "index": 5, "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 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 abs [...] + "CamelFileAbsolutePath": { "index": 6, "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 relative path instead.", "constantName": "org.apache.camel.component.file.azure.FilesConstants#FILE_ABSOLUTE_PATH" }, + "CamelFilePath": { "index": 7, "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. For absolute files this is the absolute path.", "constantName": "org.apache.camel.component.file.azure.FilesConstants#FILE_PATH" }, + "CamelFileRelativePath": { "index": 8, "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The relative path.", "constantName": "org.apache.camel.component.file.azure.FilesConstants#FILE_RELATIVE_PATH" }, + "CamelFileParent": { "index": 9, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The parent path.", "constantName": "org.apache.camel.component.file.azure.FilesConstants#FILE_PARENT" }, + "CamelFileNameProduced": { "index": 10, "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 written. This header is set by Camel and its purpose is providing end-users with the name of the file that was written.", "constantName": "org.apache.camel.compo [...] + "CamelOverruleFileName": { "index": 11, "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 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 c [...] + "CamelRemoteFileInputStream": { "index": 12, "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.", "constantName": "org.apache.camel.component.file.azure.FilesConstants#REMOTE_FILE_INPUT_STREAM" }, + "CamelFileLocalWorkPath": { "index": 13, "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.", "constantName": "org.apache.camel.component.file.azure.FilesConstants#FILE_LOCAL_WORK_PATH" }, + "CamelFileHost": { "index": 14, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The remote hostname.", "constantName": "org.apache.camel.component.file.azure.FilesConstants#FILE_HOST" } }, "properties": { "account": { "index": 0, "kind": "path", "displayName": "Account", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.file.azure.FilesConfiguration", "configurationField": "configuration", "description": "The account to use" }, diff --git a/components/camel-azure/camel-azure-files/src/generated/resources/META-INF/org/apache/camel/component/file/azure/azure-files.json b/components/camel-azure/camel-azure-files/src/generated/resources/META-INF/org/apache/camel/component/file/azure/azure-files.json index 00067cfbb86..202ab536271 100644 --- a/components/camel-azure/camel-azure-files/src/generated/resources/META-INF/org/apache/camel/component/file/azure/azure-files.json +++ b/components/camel-azure/camel-azure-files/src/generated/resources/META-INF/org/apache/camel/component/file/azure/azure-files.json @@ -31,14 +31,21 @@ "healthCheckProducerEnabled": { "index": 4, "kind": "property", "displayName": "Health Check Producer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer [...] }, "headers": { - "CamelFileLength": { "index": 0, "kind": "header", "displayName": "", "group": "both", "label": "both", "required": false, "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A long value containing the file size. For producer, known length helps if the body converts to InputStream more efficiently than to bytes array.", "constantName": "org.apache.camel.component.file.azure.FilesHeaders#FILE_LENGTH" }, - "CamelFileLastModified": { "index": 1, "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.", "constantName": "org.apache.camel.component.file.azure.FilesHeaders#FILE_LAST_MODIFIED" }, - "CamelFileName": { "index": 2, "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 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.", "const [...] - "CamelFileNameOnly": { "index": 3, "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).", "constantName": "org.apache.camel.component.file.azure.FilesHeaders#FILE_NAME_ONLY" }, - "CamelFileParent": { "index": 4, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The parent path.", "constantName": "org.apache.camel.component.file.azure.FilesHeaders#FILE_PARENT" }, - "CamelRemoteFileInputStream": { "index": 5, "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.", "constantName": "org.apache.camel.component.file.azure.FilesHeaders#REMOTE_FILE_INPUT_STREAM" }, - "CamelFileLocalWorkPath": { "index": 6, "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.", "constantName": "org.apache.camel.component.file.azure.FilesHeaders#FILE_LOCAL_WORK_PATH" }, - "CamelFileHost": { "index": 7, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The remote hostname.", "constantName": "org.apache.camel.component.file.azure.FilesHeaders#FILE_HOST" } + "CamelFileLength": { "index": 0, "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.", "constantName": "org.apache.camel.component.file.azure.FilesConstants#FILE_LENGTH" }, + "CamelFileLastModified": { "index": 1, "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.", "constantName": "org.apache.camel.component.file.azure.FilesConstants#FILE_LAST_MODIFIED" }, + "CamelFileNameOnly": { "index": 2, "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Only the file name (the name with no leading paths).", "constantName": "org.apache.camel.component.file.azure.FilesConstants#FILE_NAME_ONLY" }, + "CamelFileName": { "index": 3, "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 directory). This name can be a String; a String with a file or simple Language expression; or an Expression object. If it's null then Camel will auto-generate a filename bas [...] + "CamelFileNameConsumed": { "index": 4, "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", "constantName": "org.apache.camel.component.file.azure.FilesConstants#FILE_NAME_CONSUMED" }, + "CamelFileAbsolute": { "index": 5, "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 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 abs [...] + "CamelFileAbsolutePath": { "index": 6, "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 relative path instead.", "constantName": "org.apache.camel.component.file.azure.FilesConstants#FILE_ABSOLUTE_PATH" }, + "CamelFilePath": { "index": 7, "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. For absolute files this is the absolute path.", "constantName": "org.apache.camel.component.file.azure.FilesConstants#FILE_PATH" }, + "CamelFileRelativePath": { "index": 8, "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The relative path.", "constantName": "org.apache.camel.component.file.azure.FilesConstants#FILE_RELATIVE_PATH" }, + "CamelFileParent": { "index": 9, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The parent path.", "constantName": "org.apache.camel.component.file.azure.FilesConstants#FILE_PARENT" }, + "CamelFileNameProduced": { "index": 10, "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 written. This header is set by Camel and its purpose is providing end-users with the name of the file that was written.", "constantName": "org.apache.camel.compo [...] + "CamelOverruleFileName": { "index": 11, "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 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 c [...] + "CamelRemoteFileInputStream": { "index": 12, "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.", "constantName": "org.apache.camel.component.file.azure.FilesConstants#REMOTE_FILE_INPUT_STREAM" }, + "CamelFileLocalWorkPath": { "index": 13, "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.", "constantName": "org.apache.camel.component.file.azure.FilesConstants#FILE_LOCAL_WORK_PATH" }, + "CamelFileHost": { "index": 14, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The remote hostname.", "constantName": "org.apache.camel.component.file.azure.FilesConstants#FILE_HOST" } }, "properties": { "account": { "index": 0, "kind": "path", "displayName": "Account", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.file.azure.FilesConfiguration", "configurationField": "configuration", "description": "The account to use" }, diff --git a/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesConstants.java b/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesConstants.java new file mode 100644 index 00000000000..b74de0e451b --- /dev/null +++ b/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesConstants.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.azure; + +import org.apache.camel.Exchange; +import org.apache.camel.component.file.remote.RemoteFileComponent; +import org.apache.camel.spi.Metadata; + +public final class FilesConstants { + + @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 = "consumer", 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" + + " directory). This name can be a `String`; a `String` with a" + + " file or simple Language expression; or an Expression object. If it's" + + " `null` then Camel will auto-generate a filename based on the message" + + " unique ID. (consumer) Name of the consumed file as a relative file path with offset from the" + + " 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" + + " 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.", + 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" + + " relative path instead.", + javaType = "String") + public static final String FILE_ABSOLUTE_PATH = "CamelFileAbsolutePath"; + @Metadata(label = "consumer", description = "The file path. For relative files this is the starting directory." + + " 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" + + " written. This header is set by Camel and its purpose is providing" + + " 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" + + " 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.", + javaType = "Object") + public static final String OVERRULE_FILE_NAME = Exchange.OVERRULE_FILE_NAME; + + @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 remote hostname.", javaType = "String") + public static final String FILE_HOST = "CamelFileHost"; + + private FilesConstants() { + } +} diff --git a/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesConsumer.java b/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesConsumer.java index e11f4635906..4a8bd13cbd9 100644 --- a/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesConsumer.java +++ b/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesConsumer.java @@ -249,8 +249,8 @@ public class FilesConsumer extends RemoteFileConsumer<ShareFileItem> { @Override protected void updateFileHeaders(GenericFile<ShareFileItem> file, Message message) { - message.setHeader(FilesHeaders.FILE_LENGTH, file.getFileLength()); - message.setHeader(FilesHeaders.FILE_LAST_MODIFIED, file.getLastModified()); + message.setHeader(FilesConstants.FILE_LENGTH, file.getFileLength()); + message.setHeader(FilesConstants.FILE_LAST_MODIFIED, file.getLastModified()); } @Override diff --git a/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesEndpoint.java b/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesEndpoint.java index 8770cfeca78..ccbce1eaba6 100644 --- a/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesEndpoint.java +++ b/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesEndpoint.java @@ -42,7 +42,7 @@ import org.apache.camel.util.ObjectHelper; @UriEndpoint(firstVersion = "3.22.0", scheme = FilesComponent.SCHEME, extendsScheme = "file", title = "Azure Files", syntax = FilesComponent.SCHEME + ":account/share", category = { Category.CLOUD, Category.FILE }, - headersClass = FilesHeaders.class) + headersClass = FilesConstants.class) @Metadata(excludeProperties = "appendChars,readLockIdempotentReleaseAsync,readLockIdempotentReleaseAsyncPoolSize," + "readLockIdempotentReleaseDelay,readLockIdempotentReleaseExecutorService," + "directoryMustExist,extendedAttributes,probeContentType,startingDirectoryMustExist," diff --git a/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesHeaders.java b/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesHeaders.java deleted file mode 100644 index 885c1bea9a9..00000000000 --- a/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesHeaders.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.azure; - -import org.apache.camel.Exchange; -import org.apache.camel.component.file.remote.RemoteFileComponent; -import org.apache.camel.spi.Metadata; - -public final class FilesHeaders { - - @Metadata(label = "both", description = "A `long` value containing the file size. For producer," - + " known length helps if the body converts to InputStream" - + " more efficiently than to bytes array.", - 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 remote hostname.", javaType = "String") - public static final String FILE_HOST = "CamelFileHost"; - - private FilesHeaders() { - } -} diff --git a/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesOperations.java b/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesOperations.java index d7733614650..d669187fbbe 100644 --- a/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesOperations.java +++ b/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesOperations.java @@ -174,7 +174,6 @@ public class FilesOperations extends NormalizedOperations { public boolean renameFile(String from, String to) throws GenericFileOperationFailedException { // by observation both paths are absolute paths on the share log.trace("renameFile({}, {})", from, to); - try { return renameRemote(getFileClient(from), FilesPath.ensureRelative(to)); } catch (RuntimeException e) { @@ -193,13 +192,10 @@ public class FilesOperations extends NormalizedOperations { @Override public boolean buildDirectory(String directory) throws GenericFileOperationFailedException { - boolean success = existsDirectory(directory); - if (!success) { success = buildDirectoryStepByStep(directory); } - return success; } @@ -215,7 +211,6 @@ public class FilesOperations extends NormalizedOperations { return false; } } - return true; } @@ -248,8 +243,7 @@ public class FilesOperations extends NormalizedOperations { @Override public void releaseRetrievedFileResources(Exchange exchange) throws GenericFileOperationFailedException { log.trace("releaseRetrievedFileResources({})", exchange.getExchangeId()); - var is = exchange.getIn().getHeader(FilesHeaders.REMOTE_FILE_INPUT_STREAM, InputStream.class); - + var is = exchange.getIn().getHeader(FilesConstants.REMOTE_FILE_INPUT_STREAM, InputStream.class); if (is != null) { IOHelper.close(is); } @@ -257,7 +251,7 @@ public class FilesOperations extends NormalizedOperations { @SuppressWarnings({ "unchecked", "resource" }) private boolean retrieveFileToBody(String name, Exchange exchange) throws GenericFileOperationFailedException { - boolean success = false; + boolean success; GenericFile<ShareFileItem> target = (GenericFile<ShareFileItem>) exchange .getProperty(FileComponent.FILE_EXCHANGE_FILE); org.apache.camel.util.ObjectHelper.notNull(target, @@ -275,7 +269,7 @@ public class FilesOperations extends NormalizedOperations { log.trace("Prepared {} for download as opened input stream.", remoteName); InputStream is = cwd().getFileClient(remoteName).openInputStream(); target.setBody(is); - exchange.getIn().setHeader(FilesHeaders.REMOTE_FILE_INPUT_STREAM, is); + exchange.getIn().setHeader(FilesConstants.REMOTE_FILE_INPUT_STREAM, is); success = true; } else { log.trace("Downloading {} to byte[] body.", remoteName); @@ -351,7 +345,7 @@ public class FilesOperations extends NormalizedOperations { os = new FileOutputStream(inProgress, append); // set header with the path to the local work file - exchange.getIn().setHeader(FilesHeaders.FILE_LOCAL_WORK_PATH, local.getPath()); + exchange.getIn().setHeader(FilesConstants.FILE_LOCAL_WORK_PATH, local.getPath()); } catch (Exception e) { throw new GenericFileOperationFailedException("Cannot create new local work file: " + local, e); @@ -708,7 +702,6 @@ public class FilesOperations extends NormalizedOperations { } private ShareServiceClient createClient() { - var builder = new ShareServiceClientBuilder().endpoint(HTTPS + "://" + configuration.getHost()); var sharedKey = configuration.getSharedKey(); if (configuration.getCredentialType().equals(CredentialType.SHARED_ACCOUNT_KEY) && sharedKey != null) { diff --git a/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/transform/AzureFilesCloudEventDataTypeTransformer.java b/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/transform/AzureFilesCloudEventDataTypeTransformer.java index 298828e0cf9..686c2763608 100644 --- a/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/transform/AzureFilesCloudEventDataTypeTransformer.java +++ b/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/transform/AzureFilesCloudEventDataTypeTransformer.java @@ -22,7 +22,7 @@ import java.util.Map; import org.apache.camel.Message; import org.apache.camel.cloudevents.CloudEvent; import org.apache.camel.cloudevents.CloudEvents; -import org.apache.camel.component.file.azure.FilesHeaders; +import org.apache.camel.component.file.azure.FilesConstants; import org.apache.camel.spi.DataType; import org.apache.camel.spi.DataTypeTransformer; import org.apache.camel.spi.Transformer; @@ -44,12 +44,12 @@ public class AzureFilesCloudEventDataTypeTransformer extends Transformer { headers.putIfAbsent(CloudEvent.CAMEL_CLOUD_EVENT_VERSION, cloudEvent.version()); headers.put(CloudEvent.CAMEL_CLOUD_EVENT_TYPE, "org.apache.camel.event.azure.storage.files.poll"); - if (message.getHeaders().containsKey(FilesHeaders.FILE_HOST)) { + if (message.getHeaders().containsKey(FilesConstants.FILE_HOST)) { headers.put(CloudEvent.CAMEL_CLOUD_EVENT_SOURCE, - "azure.storage.files." + message.getHeader(FilesHeaders.FILE_HOST, String.class)); + "azure.storage.files." + message.getHeader(FilesConstants.FILE_HOST, String.class)); } - headers.put(CloudEvent.CAMEL_CLOUD_EVENT_SUBJECT, message.getHeader(FilesHeaders.FILE_NAME, String.class)); + headers.put(CloudEvent.CAMEL_CLOUD_EVENT_SUBJECT, message.getHeader(FilesConstants.FILE_NAME, String.class)); headers.put(CloudEvent.CAMEL_CLOUD_EVENT_TIME, cloudEvent.getEventTime(message.getExchange())); headers.put(CloudEvent.CAMEL_CLOUD_EVENT_CONTENT_TYPE, CloudEvent.APPLICATION_OCTET_STREAM_MIME_TYPE); } diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_10.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_10.adoc index 453f12fd47a..95ca3ff9ca0 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_10.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_10.adoc @@ -6,6 +6,10 @@ from both 4.0 to 4.1 and 4.1 to 4.2. == Upgrading Camel 4.9 to 4.10 +=== camel-azure-files + +The class `org.apache.camel.component.file.azure.FilesHeaders` has been renamed to `org.apache.camel.component.file.azure.FilesConstants`. + === camel-file The `camel-file` consumer has been optimized when filtering file names using name matching only, diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/FilesEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/FilesEndpointBuilderFactory.java index 9fe36b476fe..6557c2a2f4f 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/FilesEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/FilesEndpointBuilderFactory.java @@ -4256,13 +4256,11 @@ public interface FilesEndpointBuilderFactory { private static final FilesHeaderNameBuilder INSTANCE = new FilesHeaderNameBuilder(); /** - * A long value containing the file size. For producer, known length - * helps if the body converts to InputStream more efficiently than to - * bytes array. + * A long value containing the file size. * * The option is a: {@code long} type. * - * Group: both + * Group: consumer * * @return the name of the header {@code FileLength}. */ @@ -4282,10 +4280,24 @@ public interface FilesEndpointBuilderFactory { return "CamelFileLastModified"; } /** - * 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. + * Only the file name (the name with no leading paths). + * + * The option is a: {@code String} type. + * + * Group: consumer + * + * @return the name of the header {@code FileNameOnly}. + */ + public String fileNameOnly() { + return "CamelFileNameOnly"; + } + /** + * (producer) Specifies the name of the file to write (relative to the + * endpoint directory). This name can be a String; a String with a file + * or simple Language expression; or an Expression object. If it's null + * then Camel will auto-generate a filename based on the message unique + * ID. (consumer) Name of the consumed file as a relative file path with + * offset from the starting directory configured on the endpoint. * * The option is a: {@code String} type. * @@ -4297,16 +4309,70 @@ public interface FilesEndpointBuilderFactory { return "CamelFileName"; } /** - * Only the file name (the name with no leading paths). + * The name of the file that has been consumed. * * The option is a: {@code String} type. * - * Group: common + * Group: consumer * - * @return the name of the header {@code FileNameOnly}. + * @return the name of the header {@code FileNameConsumed}. */ - public String fileNameOnly() { - return "CamelFileNameOnly"; + public String fileNameConsumed() { + return "CamelFileNameConsumed"; + } + /** + * 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. + * + * The option is a: {@code Boolean} type. + * + * Group: consumer + * + * @return the name of the header {@code FileAbsolute}. + */ + public String fileAbsolute() { + return "CamelFileAbsolute"; + } + /** + * The absolute path to the file. For relative files this path holds the + * relative path instead. + * + * The option is a: {@code String} type. + * + * Group: consumer + * + * @return the name of the header {@code FileAbsolutePath}. + */ + public String fileAbsolutePath() { + return "CamelFileAbsolutePath"; + } + /** + * The file path. For relative files this is the starting directory. For + * absolute files this is the absolute path. + * + * The option is a: {@code String} type. + * + * Group: consumer + * + * @return the name of the header {@code FilePath}. + */ + public String filePath() { + return "CamelFilePath"; + } + /** + * The relative path. + * + * The option is a: {@code String} type. + * + * Group: consumer + * + * @return the name of the header {@code FileRelativePath}. + */ + public String fileRelativePath() { + return "CamelFileRelativePath"; } /** * The parent path. @@ -4320,6 +4386,36 @@ public interface FilesEndpointBuilderFactory { public String fileParent() { return "CamelFileParent"; } + /** + * 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. + * + * The option is a: {@code String} type. + * + * Group: producer + * + * @return the name of the header {@code FileNameProduced}. + */ + public String fileNameProduced() { + return "CamelFileNameProduced"; + } + /** + * 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. + * + * The option is a: {@code Object} type. + * + * Group: producer + * + * @return the name of the header {@code OverruleFileName}. + */ + public String overruleFileName() { + return "CamelOverruleFileName"; + } /** * The remote file input stream. *