You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2022/03/21 14:42:34 UTC

[camel] 07/13: CAMEL-17792: Add doc about the message headers of camel-file

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

nfilotto pushed a commit to branch CAMEL-17792/doc-message-headers
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 808ca824e5a65500e9cc1f96214e92cccf24591a
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Mon Mar 21 14:17:06 2022 +0100

    CAMEL-17792: Add doc about the message headers of camel-file
---
 .../org/apache/camel/component/file/file.json      | 19 ++++-
 .../camel-file/src/main/docs/file-component.adoc   | 64 ++---------------
 .../apache/camel/component/file/FileConstants.java | 84 ++++++++++++++++++++++
 .../apache/camel/component/file/FileConsumer.java  |  4 +-
 .../apache/camel/component/file/FileEndpoint.java  |  2 +-
 .../camel/component/file/FileOperations.java       |  8 +--
 .../apache/camel/component/file/GenericFile.java   | 26 +++----
 ...GenericFileDefaultMoveExistingFileStrategy.java |  6 +-
 .../camel/component/file/GenericFileEndpoint.java  | 15 ++--
 .../component/file/GenericFilePollingConsumer.java |  2 +-
 .../camel/component/file/GenericFileProducer.java  | 20 +++---
 .../GenericFileProcessStrategySupport.java         |  3 +-
 12 files changed, 150 insertions(+), 103 deletions(-)

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 f6e6025..e34e00c 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 star [...]
     "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 t [...]
   },
+  "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 Expressio [...]
+    "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 [...]
+    "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<String, Object>", "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 configu [...]
+  },
   "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  [...]
@@ -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 disa [...]
     "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 performa [...]
-    "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.Da [...]
+    "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.ut [...]
     "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  [...]
     "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 3f50bee..397d113 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 0000000..12cedba
--- /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<String, Object>")
+    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 bd79aadb..6dedb43 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 @@ public class FileConsumer extends GenericFileConsumer<File> implements ResumeAwa
         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 dc51742..b61c4c0 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 @@ import org.slf4j.LoggerFactory;
  * 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<File> {
 
     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 cfe03cd..15232be 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 class FileOperations implements GenericFileOperations<File> {
                 // 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 class FileOperations implements GenericFileOperations<File> {
                             }
                         }
                         // 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 class FileOperations implements GenericFileOperations<File> {
     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 d848782..c04a0e9 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 @@ public class GenericFile<T> implements WrappedFile<T>, GenericFileResumable<T> {
      */
     public void populateHeaders(GenericFileMessage<T> 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 9bd9f02..e4c98f6 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 class GenericFileDefaultMoveExistingFileStrategy implements FileMoveExist
         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 d787023..8a56dbb 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<T> 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 abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint imple
     }
 
     /**
-     * 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 abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint imple
 
         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 abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint imple
             }
 
             // 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 56b74ab..fdcbc6b 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 @@ public class GenericFilePollingConsumer extends EventDrivenPollingConsumer {
 
     @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 e70d815..ac1f843 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 class GenericFileProducer<T> extends DefaultProducer {
     @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 class GenericFileProducer<T> extends DefaultProducer {
             // 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 @@ public class GenericFileProducer<T> extends DefaultProducer {
 
             // 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 class GenericFileProducer<T> extends DefaultProducer {
         // 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 class GenericFileProducer<T> extends DefaultProducer {
                 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 class GenericFileProducer<T> extends DefaultProducer {
         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 a043869..4ef342f 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 java.io.File;
 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 @@ public abstract class GenericFileProcessStrategySupport<T> extends ServiceSuppor
 
     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);