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 92d4df814ea7 CAMEL-23931: Enhance preSort to support sorting by name,
modified, and size
92d4df814ea7 is described below
commit 92d4df814ea711973bec7e8f5e5630113145cbf5
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Jul 8 07:04:39 2026 +0200
CAMEL-23931: Enhance preSort to support sorting by name, modified, and size
Enhanced the preSort option on file-based consumers (File, FTP, FTPS, SFTP,
Azure Files, SMB) from a boolean to a String supporting name, modified, size
(and -name, -modified, -size for descending). true/false remain backward
compatible. This allows combining preSort=modified with
eagerMaxMessagesPerPoll
and maxMessagesPerPoll to efficiently consume the N oldest/newest files
without
creating Exchange objects for every file on the server.
Closes #24503
Co-Authored-By: Claude Opus 4.6 <[email protected]>
---
.../camel/catalog/components/azure-files.json | 2 +-
.../org/apache/camel/catalog/components/file.json | 2 +-
.../org/apache/camel/catalog/components/ftp.json | 2 +-
.../org/apache/camel/catalog/components/ftps.json | 2 +-
.../apache/camel/catalog/components/mina-sftp.json | 2 +-
.../org/apache/camel/catalog/components/sftp.json | 2 +-
.../org/apache/camel/catalog/components/smb.json | 2 +-
.../file/azure/FilesEndpointConfigurer.java | 6 +-
.../camel/component/file/azure/azure-files.json | 2 +-
.../camel/component/file/azure/FilesConsumer.java | 21 ++++-
.../component/file/FileEndpointConfigurer.java | 6 +-
.../org/apache/camel/component/file/file.json | 2 +-
.../apache/camel/component/file/FileConsumer.java | 20 +++-
.../camel/component/file/GenericFileEndpoint.java | 27 ++++--
.../file/remote/AbstractSftpConsumer.java | 21 ++++-
.../file/remote/FtpEndpointConfigurer.java | 6 +-
.../file/remote/SftpEndpointConfigurer.java | 6 +-
.../apache/camel/component/file/remote/ftp.json | 2 +-
.../apache/camel/component/file/remote/ftps.json | 2 +-
.../apache/camel/component/file/remote/sftp.json | 2 +-
.../camel/component/file/remote/FtpConsumer.java | 20 +++-
.../component/file/remote/SftpPreSortTest.java | 102 +++++++++++++++++++++
.../remote/mina/MinaSftpEndpointConfigurer.java | 6 +-
.../component/file/remote/mina/mina-sftp.json | 2 +-
.../camel/component/smb/SmbEndpointConfigurer.java | 6 +-
.../org/apache/camel/component/smb/smb.json | 2 +-
.../apache/camel/component/smb/SmbConsumer.java | 20 +++-
.../ROOT/pages/camel-4x-upgrade-guide-4_22.adoc | 16 ++++
.../endpoint/dsl/FileEndpointBuilderFactory.java | 30 ++----
.../endpoint/dsl/FilesEndpointBuilderFactory.java | 30 ++----
.../endpoint/dsl/FtpEndpointBuilderFactory.java | 30 ++----
.../endpoint/dsl/FtpsEndpointBuilderFactory.java | 30 ++----
.../dsl/MinaSftpEndpointBuilderFactory.java | 30 ++----
.../endpoint/dsl/SftpEndpointBuilderFactory.java | 30 ++----
.../endpoint/dsl/SmbEndpointBuilderFactory.java | 30 ++----
35 files changed, 314 insertions(+), 207 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 0ce6003fcb1c..ff1037a93927 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
@@ -62,7 +62,7 @@
"moveFailed": { "index": 11, "kind": "parameter", "displayName": "Move
Failed", "group": "consumer", "label": "consumer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "description": "Sets the move failure expression based
on Simple language. For example, to move files into a .error subdirectory use:
.error. Note: When moving the files to the fail location Camel will handle the
error and will not pick up [...]
"noop": { "index": 12, "kind": "parameter", "displayName": "Noop",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "If true, the file is not moved or
deleted in any way. This option is good for readonly data, or for ETL type
requirements. If noop=true, Camel will set idempotent=true as well, to avoid
consuming the same files over and o [...]
"preMove": { "index": 13, "kind": "parameter", "displayName": "Pre Move",
"group": "consumer", "label": "consumer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Expression (such as File Language) used to
dynamically set the filename when moving it before processing. For example to
move in-progress files into the order directory set this value to order." },
- "preSort": { "index": 14, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You may want to do this in case you need to
operate on the files in a sorte [...]
+ "preSort": { "index": 14, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "enum",
"javaType": "java.lang.String", "enum": [ "true", "false", "name", "-name",
"modified", "-modified", "size", "-size" ], "deprecated": false, "autowired":
false, "secret": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You [...]
"recursive": { "index": 15, "kind": "parameter", "displayName":
"Recursive", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "If a directory,
will look for files in all the sub-directories as well." },
"resumeDownload": { "index": 16, "kind": "parameter", "displayName":
"Resume Download", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "Configures
whether resume download is enabled. In addition the options localWorkDirectory
must be configured so downloaded files are stored in a local directory, which
is required to support resuming [...]
"sendEmptyMessageWhenIdle": { "index": 17, "kind": "parameter",
"displayName": "Send Empty Message When Idle", "group": "consumer", "label":
"consumer", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
false, "description": "If the polling consumer did not poll any files, you can
enable this option to send an empty message (no body) instead." },
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/file.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/file.json
index 2972afac9dc5..942c55647425 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/file.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/file.json
@@ -59,7 +59,7 @@
"moveFailed": { "index": 6, "kind": "parameter", "displayName": "Move
Failed", "group": "consumer", "label": "consumer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "description": "Sets the move failure expression based
on Simple language. For example, to move files into a .error subdirectory use:
.error. Note: When moving the files to the fail location Camel will handle the
error and will not pick up [...]
"noop": { "index": 7, "kind": "parameter", "displayName": "Noop", "group":
"consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "If true, the file is not moved or
deleted in any way. This option is good for readonly data, or for ETL type
requirements. If noop=true, Camel will set idempotent=true as well, to avoid
consuming the same files over and ov [...]
"preMove": { "index": 8, "kind": "parameter", "displayName": "Pre Move",
"group": "consumer", "label": "consumer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Expression (such as File Language) used to
dynamically set the filename when moving it before processing. For example to
move in-progress files into the order directory set this value to order." },
- "preSort": { "index": 9, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You may want to do this in case you need to
operate on the files in a sorted [...]
+ "preSort": { "index": 9, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "enum",
"javaType": "java.lang.String", "enum": [ "true", "false", "name", "-name",
"modified", "-modified", "size", "-size" ], "deprecated": false, "autowired":
false, "secret": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You m [...]
"recursive": { "index": 10, "kind": "parameter", "displayName":
"Recursive", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "If a directory,
will look for files in all the sub-directories as well." },
"sendEmptyMessageWhenIdle": { "index": 11, "kind": "parameter",
"displayName": "Send Empty Message When Idle", "group": "consumer", "label":
"consumer", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
false, "description": "If the polling consumer did not poll any files, you can
enable this option to send an empty message (no body) instead." },
"bridgeErrorHandler": { "index": 12, "kind": "parameter", "displayName":
"Bridge Error Handler", "group": "consumer (advanced)", "label":
"consumer,advanced", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Allows for bridging the consumer to the
Camel routing Error Handler, which mean any exceptions (if possible) occurred
while the Camel consumer is trying to pickup incoming [...]
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/ftp.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/ftp.json
index 7ab2d6b4192d..966143f968c1 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/ftp.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/ftp.json
@@ -70,7 +70,7 @@
"moveFailed": { "index": 16, "kind": "parameter", "displayName": "Move
Failed", "group": "consumer", "label": "consumer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "description": "Sets the move failure expression based
on Simple language. For example, to move files into a .error subdirectory use:
.error. Note: When moving the files to the fail location Camel will handle the
error and will not pick up [...]
"noop": { "index": 17, "kind": "parameter", "displayName": "Noop",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "If true, the file is not moved or
deleted in any way. This option is good for readonly data, or for ETL type
requirements. If noop=true, Camel will set idempotent=true as well, to avoid
consuming the same files over and o [...]
"preMove": { "index": 18, "kind": "parameter", "displayName": "Pre Move",
"group": "consumer", "label": "consumer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Expression (such as File Language) used to
dynamically set the filename when moving it before processing. For example to
move in-progress files into the order directory set this value to order." },
- "preSort": { "index": 19, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You may want to do this in case you need to
operate on the files in a sorte [...]
+ "preSort": { "index": 19, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "enum",
"javaType": "java.lang.String", "enum": [ "true", "false", "name", "-name",
"modified", "-modified", "size", "-size" ], "deprecated": false, "autowired":
false, "secret": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You [...]
"recursive": { "index": 20, "kind": "parameter", "displayName":
"Recursive", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "If a directory,
will look for files in all the sub-directories as well." },
"resumeDownload": { "index": 21, "kind": "parameter", "displayName":
"Resume Download", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "Configures
whether resume download is enabled. This must be supported by the FTP server
(almost all FTP servers support it). In addition, the options
localWorkDirectory must be configured so downloade [...]
"sendEmptyMessageWhenIdle": { "index": 22, "kind": "parameter",
"displayName": "Send Empty Message When Idle", "group": "consumer", "label":
"consumer", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
false, "description": "If the polling consumer did not poll any files, you can
enable this option to send an empty message (no body) instead." },
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/ftps.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/ftps.json
index 741f62beb210..9d38913f4853 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/ftps.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/ftps.json
@@ -71,7 +71,7 @@
"moveFailed": { "index": 16, "kind": "parameter", "displayName": "Move
Failed", "group": "consumer", "label": "consumer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "description": "Sets the move failure expression based
on Simple language. For example, to move files into a .error subdirectory use:
.error. Note: When moving the files to the fail location Camel will handle the
error and will not pick up [...]
"noop": { "index": 17, "kind": "parameter", "displayName": "Noop",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "If true, the file is not moved or
deleted in any way. This option is good for readonly data, or for ETL type
requirements. If noop=true, Camel will set idempotent=true as well, to avoid
consuming the same files over and o [...]
"preMove": { "index": 18, "kind": "parameter", "displayName": "Pre Move",
"group": "consumer", "label": "consumer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Expression (such as File Language) used to
dynamically set the filename when moving it before processing. For example to
move in-progress files into the order directory set this value to order." },
- "preSort": { "index": 19, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You may want to do this in case you need to
operate on the files in a sorte [...]
+ "preSort": { "index": 19, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "enum",
"javaType": "java.lang.String", "enum": [ "true", "false", "name", "-name",
"modified", "-modified", "size", "-size" ], "deprecated": false, "autowired":
false, "secret": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You [...]
"recursive": { "index": 20, "kind": "parameter", "displayName":
"Recursive", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "If a directory,
will look for files in all the sub-directories as well." },
"resumeDownload": { "index": 21, "kind": "parameter", "displayName":
"Resume Download", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "Configures
whether resume download is enabled. This must be supported by the FTP server
(almost all FTP servers support it). In addition, the options
localWorkDirectory must be configured so downloade [...]
"sendEmptyMessageWhenIdle": { "index": 22, "kind": "parameter",
"displayName": "Send Empty Message When Idle", "group": "consumer", "label":
"consumer", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
false, "description": "If the polling consumer did not poll any files, you can
enable this option to send an empty message (no body) instead." },
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/mina-sftp.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/mina-sftp.json
index 850194684f3f..fdbdf04dd450 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/mina-sftp.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/mina-sftp.json
@@ -66,7 +66,7 @@
"moveFailed": { "index": 13, "kind": "parameter", "displayName": "Move
Failed", "group": "consumer", "label": "consumer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "description": "Sets the move failure expression based
on Simple language. For example, to move files into a .error subdirectory use:
.error. Note: When moving the files to the fail location Camel will handle the
error and will not pick up [...]
"noop": { "index": 14, "kind": "parameter", "displayName": "Noop",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "If true, the file is not moved or
deleted in any way. This option is good for readonly data, or for ETL type
requirements. If noop=true, Camel will set idempotent=true as well, to avoid
consuming the same files over and o [...]
"preMove": { "index": 15, "kind": "parameter", "displayName": "Pre Move",
"group": "consumer", "label": "consumer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Expression (such as File Language) used to
dynamically set the filename when moving it before processing. For example to
move in-progress files into the order directory set this value to order." },
- "preSort": { "index": 16, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You may want to do this in case you need to
operate on the files in a sorte [...]
+ "preSort": { "index": 16, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "enum",
"javaType": "java.lang.String", "enum": [ "true", "false", "name", "-name",
"modified", "-modified", "size", "-size" ], "deprecated": false, "autowired":
false, "secret": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You [...]
"recursive": { "index": 17, "kind": "parameter", "displayName":
"Recursive", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "If a directory,
will look for files in all the sub-directories as well." },
"sendEmptyMessageWhenIdle": { "index": 18, "kind": "parameter",
"displayName": "Send Empty Message When Idle", "group": "consumer", "label":
"consumer", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
false, "description": "If the polling consumer did not poll any files, you can
enable this option to send an empty message (no body) instead." },
"streamDownload": { "index": 19, "kind": "parameter", "displayName":
"Stream Download", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.file.remote.mina.MinaSftpConfiguration",
"configurationField": "configuration", "description": "Sets the download method
to use when not using a local working directo [...]
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/sftp.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/sftp.json
index 9d255f2c4537..1a191263db0f 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/sftp.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/sftp.json
@@ -73,7 +73,7 @@
"moveFailed": { "index": 14, "kind": "parameter", "displayName": "Move
Failed", "group": "consumer", "label": "consumer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "description": "Sets the move failure expression based
on Simple language. For example, to move files into a .error subdirectory use:
.error. Note: When moving the files to the fail location Camel will handle the
error and will not pick up [...]
"noop": { "index": 15, "kind": "parameter", "displayName": "Noop",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "If true, the file is not moved or
deleted in any way. This option is good for readonly data, or for ETL type
requirements. If noop=true, Camel will set idempotent=true as well, to avoid
consuming the same files over and o [...]
"preMove": { "index": 16, "kind": "parameter", "displayName": "Pre Move",
"group": "consumer", "label": "consumer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Expression (such as File Language) used to
dynamically set the filename when moving it before processing. For example to
move in-progress files into the order directory set this value to order." },
- "preSort": { "index": 17, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You may want to do this in case you need to
operate on the files in a sorte [...]
+ "preSort": { "index": 17, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "enum",
"javaType": "java.lang.String", "enum": [ "true", "false", "name", "-name",
"modified", "-modified", "size", "-size" ], "deprecated": false, "autowired":
false, "secret": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You [...]
"recursive": { "index": 18, "kind": "parameter", "displayName":
"Recursive", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "If a directory,
will look for files in all the sub-directories as well." },
"sendEmptyMessageWhenIdle": { "index": 19, "kind": "parameter",
"displayName": "Send Empty Message When Idle", "group": "consumer", "label":
"consumer", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
false, "description": "If the polling consumer did not poll any files, you can
enable this option to send an empty message (no body) instead." },
"streamDownload": { "index": 20, "kind": "parameter", "displayName":
"Stream Download", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.file.remote.SftpConfiguration",
"configurationField": "configuration", "description": "Sets the download method
to use when not using a local working directory. If se [...]
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/smb.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/smb.json
index f37e49479359..8884ee25f5db 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/smb.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/smb.json
@@ -63,7 +63,7 @@
"moveFailed": { "index": 10, "kind": "parameter", "displayName": "Move
Failed", "group": "consumer", "label": "consumer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "description": "Sets the move failure expression based
on Simple language. For example, to move files into a .error subdirectory use:
.error. Note: When moving the files to the fail location Camel will handle the
error and will not pick up [...]
"noop": { "index": 11, "kind": "parameter", "displayName": "Noop",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "If true, the file is not moved or
deleted in any way. This option is good for readonly data, or for ETL type
requirements. If noop=true, Camel will set idempotent=true as well, to avoid
consuming the same files over and o [...]
"preMove": { "index": 12, "kind": "parameter", "displayName": "Pre Move",
"group": "consumer", "label": "consumer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Expression (such as File Language) used to
dynamically set the filename when moving it before processing. For example to
move in-progress files into the order directory set this value to order." },
- "preSort": { "index": 13, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You may want to do this in case you need to
operate on the files in a sorte [...]
+ "preSort": { "index": 13, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "enum",
"javaType": "java.lang.String", "enum": [ "true", "false", "name", "-name",
"modified", "-modified", "size", "-size" ], "deprecated": false, "autowired":
false, "secret": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You [...]
"recursive": { "index": 14, "kind": "parameter", "displayName":
"Recursive", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "If a directory,
will look for files in all the sub-directories as well." },
"searchPattern": { "index": 15, "kind": "parameter", "displayName":
"Search Pattern", "group": "consumer", "label": "consumer", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.smb.SmbConfiguration", "configurationField":
"configuration", "description": "The search pattern used to list the files
(server side on SMB). This parameter can contain the name of a [...]
"sendEmptyMessageWhenIdle": { "index": 16, "kind": "parameter",
"displayName": "Send Empty Message When Idle", "group": "consumer", "label":
"consumer", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
false, "description": "If the polling consumer did not poll any files, you can
enable this option to send an empty message (no body) instead." },
diff --git
a/components/camel-azure/camel-azure-files/src/generated/java/org/apache/camel/component/file/azure/FilesEndpointConfigurer.java
b/components/camel-azure/camel-azure-files/src/generated/java/org/apache/camel/component/file/azure/FilesEndpointConfigurer.java
index 32221926ccda..c3236f143d9e 100644
---
a/components/camel-azure/camel-azure-files/src/generated/java/org/apache/camel/component/file/azure/FilesEndpointConfigurer.java
+++
b/components/camel-azure/camel-azure-files/src/generated/java/org/apache/camel/component/file/azure/FilesEndpointConfigurer.java
@@ -126,7 +126,7 @@ public class FilesEndpointConfigurer extends
PropertyConfigurerSupport implement
case "premove":
case "preMove": target.setPreMove(property(camelContext,
java.lang.String.class, value)); return true;
case "presort":
- case "preSort": target.setPreSort(property(camelContext,
boolean.class, value)); return true;
+ case "preSort": target.setPreSort(property(camelContext,
java.lang.String.class, value)); return true;
case "processstrategy":
case "processStrategy":
target.setProcessStrategy(property(camelContext,
org.apache.camel.component.file.GenericFileProcessStrategy.class, value));
return true;
case "readlock":
@@ -308,7 +308,7 @@ public class FilesEndpointConfigurer extends
PropertyConfigurerSupport implement
case "premove":
case "preMove": return java.lang.String.class;
case "presort":
- case "preSort": return boolean.class;
+ case "preSort": return java.lang.String.class;
case "processstrategy":
case "processStrategy": return
org.apache.camel.component.file.GenericFileProcessStrategy.class;
case "readlock":
@@ -491,7 +491,7 @@ public class FilesEndpointConfigurer extends
PropertyConfigurerSupport implement
case "premove":
case "preMove": return target.getPreMove();
case "presort":
- case "preSort": return target.isPreSort();
+ case "preSort": return target.getPreSort();
case "processstrategy":
case "processStrategy": return target.getProcessStrategy();
case "readlock":
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 0ce6003fcb1c..ff1037a93927 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
@@ -62,7 +62,7 @@
"moveFailed": { "index": 11, "kind": "parameter", "displayName": "Move
Failed", "group": "consumer", "label": "consumer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "description": "Sets the move failure expression based
on Simple language. For example, to move files into a .error subdirectory use:
.error. Note: When moving the files to the fail location Camel will handle the
error and will not pick up [...]
"noop": { "index": 12, "kind": "parameter", "displayName": "Noop",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "If true, the file is not moved or
deleted in any way. This option is good for readonly data, or for ETL type
requirements. If noop=true, Camel will set idempotent=true as well, to avoid
consuming the same files over and o [...]
"preMove": { "index": 13, "kind": "parameter", "displayName": "Pre Move",
"group": "consumer", "label": "consumer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Expression (such as File Language) used to
dynamically set the filename when moving it before processing. For example to
move in-progress files into the order directory set this value to order." },
- "preSort": { "index": 14, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You may want to do this in case you need to
operate on the files in a sorte [...]
+ "preSort": { "index": 14, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "enum",
"javaType": "java.lang.String", "enum": [ "true", "false", "name", "-name",
"modified", "-modified", "size", "-size" ], "deprecated": false, "autowired":
false, "secret": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You [...]
"recursive": { "index": 15, "kind": "parameter", "displayName":
"Recursive", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "If a directory,
will look for files in all the sub-directories as well." },
"resumeDownload": { "index": 16, "kind": "parameter", "displayName":
"Resume Download", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "Configures
whether resume download is enabled. In addition the options localWorkDirectory
must be configured so downloaded files are stored in a local directory, which
is required to support resuming [...]
"sendEmptyMessageWhenIdle": { "index": 17, "kind": "parameter",
"displayName": "Send Empty Message When Idle", "group": "consumer", "label":
"consumer", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
false, "description": "If the polling consumer did not poll any files, you can
enable this option to send an empty message (no body) instead." },
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 d3936771729f..68097227d061 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
@@ -118,7 +118,7 @@ public class FilesConsumer extends
RemoteFileConsumer<ShareFileItem> {
LOG.trace("Found {} files in directory: {}", listedFileItems.length,
path);
if (getEndpoint().isPreSort()) {
- Arrays.sort(listedFileItems,
Comparator.comparing(ShareFileItem::getName));
+ Arrays.sort(listedFileItems,
preSortComparator(getEndpoint().getPreSort()));
}
for (var fileItem : listedFileItems) {
@@ -270,9 +270,26 @@ public class FilesConsumer extends
RemoteFileConsumer<ShareFileItem> {
private static long lastModified(ShareFileItem file) {
var raw = file.getProperties().getLastModified();
if (raw == null) {
- // if ls without metadata
return 0;
}
return raw.toInstant().toEpochMilli();
}
+
+ private static Comparator<ShareFileItem> preSortComparator(String preSort)
{
+ boolean reverse = preSort.startsWith("-");
+ String field = reverse ? preSort.substring(1) : preSort;
+ Comparator<ShareFileItem> cmp;
+ switch (field) {
+ case "modified":
+ cmp = Comparator.comparingLong(FilesConsumer::lastModified);
+ break;
+ case "size":
+ cmp = Comparator.comparingLong(ShareFileItem::getFileSize);
+ break;
+ default:
+ cmp = Comparator.comparing(ShareFileItem::getName);
+ break;
+ }
+ return reverse ? cmp.reversed() : cmp;
+ }
}
diff --git
a/components/camel-file/src/generated/java/org/apache/camel/component/file/FileEndpointConfigurer.java
b/components/camel-file/src/generated/java/org/apache/camel/component/file/FileEndpointConfigurer.java
index ee8e5565741b..4a4e654e036f 100644
---
a/components/camel-file/src/generated/java/org/apache/camel/component/file/FileEndpointConfigurer.java
+++
b/components/camel-file/src/generated/java/org/apache/camel/component/file/FileEndpointConfigurer.java
@@ -140,7 +140,7 @@ public class FileEndpointConfigurer extends
PropertyConfigurerSupport implements
case "premove":
case "preMove": target.setPreMove(property(camelContext,
java.lang.String.class, value)); return true;
case "presort":
- case "preSort": target.setPreSort(property(camelContext,
boolean.class, value)); return true;
+ case "preSort": target.setPreSort(property(camelContext,
java.lang.String.class, value)); return true;
case "probecontenttype":
case "probeContentType":
target.setProbeContentType(property(camelContext, boolean.class, value));
return true;
case "processstrategy":
@@ -330,7 +330,7 @@ public class FileEndpointConfigurer extends
PropertyConfigurerSupport implements
case "premove":
case "preMove": return java.lang.String.class;
case "presort":
- case "preSort": return boolean.class;
+ case "preSort": return java.lang.String.class;
case "probecontenttype":
case "probeContentType": return boolean.class;
case "processstrategy":
@@ -521,7 +521,7 @@ public class FileEndpointConfigurer extends
PropertyConfigurerSupport implements
case "premove":
case "preMove": return target.getPreMove();
case "presort":
- case "preSort": return target.isPreSort();
+ case "preSort": return target.getPreSort();
case "probecontenttype":
case "probeContentType": return target.isProbeContentType();
case "processstrategy":
diff --git
a/components/camel-file/src/generated/resources/META-INF/org/apache/camel/component/file/file.json
b/components/camel-file/src/generated/resources/META-INF/org/apache/camel/component/file/file.json
index 2972afac9dc5..942c55647425 100644
---
a/components/camel-file/src/generated/resources/META-INF/org/apache/camel/component/file/file.json
+++
b/components/camel-file/src/generated/resources/META-INF/org/apache/camel/component/file/file.json
@@ -59,7 +59,7 @@
"moveFailed": { "index": 6, "kind": "parameter", "displayName": "Move
Failed", "group": "consumer", "label": "consumer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "description": "Sets the move failure expression based
on Simple language. For example, to move files into a .error subdirectory use:
.error. Note: When moving the files to the fail location Camel will handle the
error and will not pick up [...]
"noop": { "index": 7, "kind": "parameter", "displayName": "Noop", "group":
"consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "If true, the file is not moved or
deleted in any way. This option is good for readonly data, or for ETL type
requirements. If noop=true, Camel will set idempotent=true as well, to avoid
consuming the same files over and ov [...]
"preMove": { "index": 8, "kind": "parameter", "displayName": "Pre Move",
"group": "consumer", "label": "consumer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Expression (such as File Language) used to
dynamically set the filename when moving it before processing. For example to
move in-progress files into the order directory set this value to order." },
- "preSort": { "index": 9, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You may want to do this in case you need to
operate on the files in a sorted [...]
+ "preSort": { "index": 9, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "enum",
"javaType": "java.lang.String", "enum": [ "true", "false", "name", "-name",
"modified", "-modified", "size", "-size" ], "deprecated": false, "autowired":
false, "secret": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You m [...]
"recursive": { "index": 10, "kind": "parameter", "displayName":
"Recursive", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "If a directory,
will look for files in all the sub-directories as well." },
"sendEmptyMessageWhenIdle": { "index": 11, "kind": "parameter",
"displayName": "Send Empty Message When Idle", "group": "consumer", "label":
"consumer", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
false, "description": "If the polling consumer did not poll any files, you can
enable this option to send an empty message (no body) instead." },
"bridgeErrorHandler": { "index": 12, "kind": "parameter", "displayName":
"Bridge Error Handler", "group": "consumer (advanced)", "label":
"consumer,advanced", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Allows for bridging the consumer to the
Camel routing Error Handler, which mean any exceptions (if possible) occurred
while the Camel consumer is trying to pickup incoming [...]
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 2554dcdbfd21..3b4505720fcf 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
@@ -87,7 +87,7 @@ public class FileConsumer extends GenericFileConsumer<File>
implements ResumeAwa
}
if (getEndpoint().isPreSort()) {
- Arrays.sort(files, Comparator.comparing(File::getAbsoluteFile));
+ Arrays.sort(files, preSortComparator(getEndpoint().getPreSort()));
}
if (processPolledFiles(dynamic, fileList, depth, files)) {
@@ -473,4 +473,22 @@ public class FileConsumer extends
GenericFileConsumer<File> implements ResumeAwa
public String adapterFactoryService() {
return "file-adapter-factory";
}
+
+ private static Comparator<File> preSortComparator(String preSort) {
+ boolean reverse = preSort.startsWith("-");
+ String field = reverse ? preSort.substring(1) : preSort;
+ Comparator<File> cmp;
+ switch (field) {
+ case "modified":
+ cmp = Comparator.comparingLong(File::lastModified);
+ break;
+ case "size":
+ cmp = Comparator.comparingLong(File::length);
+ break;
+ default:
+ cmp = Comparator.comparing(File::getName);
+ break;
+ }
+ return reverse ? cmp.reversed() : cmp;
+ }
}
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 a4b8d69bd9e8..a3e6f77e3890 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
@@ -205,11 +205,15 @@ public abstract class GenericFileEndpoint<T> extends
ScheduledPollEndpoint imple
protected boolean recursive;
@UriParam(label = "consumer", description = "If true, the file will be
deleted after it is processed successfully.")
protected boolean delete;
- @UriParam(label = "consumer", description = "When pre-sort is enabled then
the consumer will sort the file and "
- + "directory names during
polling, that was retrieved from the file system. You may want to do this in "
- + "case you need to operate on
the files in a sorted order. The pre-sort is executed before the consumer "
- + "starts to filter, and
accept files to process by Camel. This option is default=false meaning
disabled.")
- protected boolean preSort;
+ @UriParam(label = "consumer", enums =
"true,false,name,-name,modified,-modified,size,-size",
+ description = "When pre-sort is enabled then the consumer will
sort the file and "
+ + "directory names during polling, that was
retrieved from the file system. You may want to do this in "
+ + "case you need to operate on the files in a
sorted order. The pre-sort is executed before the consumer "
+ + "starts to filter, and accept files to process
by Camel. This option is default=false meaning disabled. "
+ + "The following values are supported: name (sort
by file name), modified (sort by last-modified timestamp), "
+ + "size (sort by file size). To sort in descending
(reverse) order, prefix the value with a minus sign "
+ + "(e.g., -modified to sort newest first). The
value true is an alias for name (backward compatible).")
+ protected String preSort;
@UriParam(label = "consumer,filter", description = "To define a maximum
messages to gather per poll. By default "
+ "no maximum is set.
Can be used to set a limit of e.g. 1000 to avoid when starting up the server
that "
+ "there are thousands
of files. Set a value of 0 or negative to disabled it. Notice: If this option
is "
@@ -715,17 +719,24 @@ public abstract class GenericFileEndpoint<T> extends
ScheduledPollEndpoint imple
this.excludeExt = excludeExt;
}
- public boolean isPreSort() {
+ public String getPreSort() {
return preSort;
}
+ public boolean isPreSort() {
+ return preSort != null && !preSort.isBlank() &&
!"false".equalsIgnoreCase(preSort);
+ }
+
/**
* When pre-sort is enabled then the consumer will sort the file and
directory names during polling, that was
* retrieved from the file system. You may want to do this in case you
need to operate on the files in a sorted
* order. The pre-sort is executed before the consumer starts to filter,
and accept files to process by Camel. This
- * option is default=false meaning disabled.
+ * option is default=false meaning disabled. The following values are
supported: name (sort by file name), modified
+ * (sort by last-modified timestamp), size (sort by file size). To sort in
descending (reverse) order, prefix the
+ * value with a minus sign (e.g., -modified to sort newest first). The
value true is an alias for name (backward
+ * compatible).
*/
- public void setPreSort(boolean preSort) {
+ public void setPreSort(String preSort) {
this.preSort = preSort;
}
diff --git
a/components/camel-ftp-common/src/main/java/org/apache/camel/component/file/remote/AbstractSftpConsumer.java
b/components/camel-ftp-common/src/main/java/org/apache/camel/component/file/remote/AbstractSftpConsumer.java
index f6914118c72b..90b955fa3522 100644
---
a/components/camel-ftp-common/src/main/java/org/apache/camel/component/file/remote/AbstractSftpConsumer.java
+++
b/components/camel-ftp-common/src/main/java/org/apache/camel/component/file/remote/AbstractSftpConsumer.java
@@ -140,7 +140,7 @@ public abstract class AbstractSftpConsumer extends
RemoteFileConsumer<SftpRemote
}
if (getEndpoint().isPreSort()) {
- Arrays.sort(files,
Comparator.comparing(SftpRemoteFile::getFilename));
+ Arrays.sort(files, preSortComparator(getEndpoint().getPreSort()));
}
for (SftpRemoteFile file : files) {
@@ -295,4 +295,23 @@ public abstract class AbstractSftpConsumer extends
RemoteFileConsumer<SftpRemote
RemoteFileConfiguration config = (RemoteFileConfiguration)
endpoint.getConfiguration();
return config.isUseList();
}
+
+ @SuppressWarnings("unchecked")
+ private static Comparator<SftpRemoteFile> preSortComparator(String
preSort) {
+ boolean reverse = preSort.startsWith("-");
+ String field = reverse ? preSort.substring(1) : preSort;
+ Comparator<SftpRemoteFile> cmp;
+ switch (field) {
+ case "modified":
+ cmp =
Comparator.comparingLong(SftpRemoteFile::getLastModified);
+ break;
+ case "size":
+ cmp = Comparator.comparingLong(SftpRemoteFile::getFileLength);
+ break;
+ default:
+ cmp = Comparator.comparing(SftpRemoteFile::getFilename);
+ break;
+ }
+ return reverse ? cmp.reversed() : cmp;
+ }
}
diff --git
a/components/camel-ftp/src/generated/java/org/apache/camel/component/file/remote/FtpEndpointConfigurer.java
b/components/camel-ftp/src/generated/java/org/apache/camel/component/file/remote/FtpEndpointConfigurer.java
index 41557de1bb6d..83aebc401f22 100644
---
a/components/camel-ftp/src/generated/java/org/apache/camel/component/file/remote/FtpEndpointConfigurer.java
+++
b/components/camel-ftp/src/generated/java/org/apache/camel/component/file/remote/FtpEndpointConfigurer.java
@@ -151,7 +151,7 @@ public class FtpEndpointConfigurer extends
PropertyConfigurerSupport implements
case "premove":
case "preMove": target.setPreMove(property(camelContext,
java.lang.String.class, value)); return true;
case "presort":
- case "preSort": target.setPreSort(property(camelContext,
boolean.class, value)); return true;
+ case "preSort": target.setPreSort(property(camelContext,
java.lang.String.class, value)); return true;
case "processstrategy":
case "processStrategy":
target.setProcessStrategy(property(camelContext,
org.apache.camel.component.file.GenericFileProcessStrategy.class, value));
return true;
case "readlock":
@@ -361,7 +361,7 @@ public class FtpEndpointConfigurer extends
PropertyConfigurerSupport implements
case "premove":
case "preMove": return java.lang.String.class;
case "presort":
- case "preSort": return boolean.class;
+ case "preSort": return java.lang.String.class;
case "processstrategy":
case "processStrategy": return
org.apache.camel.component.file.GenericFileProcessStrategy.class;
case "readlock":
@@ -572,7 +572,7 @@ public class FtpEndpointConfigurer extends
PropertyConfigurerSupport implements
case "premove":
case "preMove": return target.getPreMove();
case "presort":
- case "preSort": return target.isPreSort();
+ case "preSort": return target.getPreSort();
case "processstrategy":
case "processStrategy": return target.getProcessStrategy();
case "readlock":
diff --git
a/components/camel-ftp/src/generated/java/org/apache/camel/component/file/remote/SftpEndpointConfigurer.java
b/components/camel-ftp/src/generated/java/org/apache/camel/component/file/remote/SftpEndpointConfigurer.java
index ac599bcf8f9f..17277d9167a0 100644
---
a/components/camel-ftp/src/generated/java/org/apache/camel/component/file/remote/SftpEndpointConfigurer.java
+++
b/components/camel-ftp/src/generated/java/org/apache/camel/component/file/remote/SftpEndpointConfigurer.java
@@ -170,7 +170,7 @@ public class SftpEndpointConfigurer extends
PropertyConfigurerSupport implements
case "premove":
case "preMove": target.setPreMove(property(camelContext,
java.lang.String.class, value)); return true;
case "presort":
- case "preSort": target.setPreSort(property(camelContext,
boolean.class, value)); return true;
+ case "preSort": target.setPreSort(property(camelContext,
java.lang.String.class, value)); return true;
case "preferredauthentications":
case "preferredAuthentications":
target.getConfiguration().setPreferredAuthentications(property(camelContext,
java.lang.String.class, value)); return true;
case "privatekey":
@@ -422,7 +422,7 @@ public class SftpEndpointConfigurer extends
PropertyConfigurerSupport implements
case "premove":
case "preMove": return java.lang.String.class;
case "presort":
- case "preSort": return boolean.class;
+ case "preSort": return java.lang.String.class;
case "preferredauthentications":
case "preferredAuthentications": return java.lang.String.class;
case "privatekey":
@@ -675,7 +675,7 @@ public class SftpEndpointConfigurer extends
PropertyConfigurerSupport implements
case "premove":
case "preMove": return target.getPreMove();
case "presort":
- case "preSort": return target.isPreSort();
+ case "preSort": return target.getPreSort();
case "preferredauthentications":
case "preferredAuthentications": return
target.getConfiguration().getPreferredAuthentications();
case "privatekey":
diff --git
a/components/camel-ftp/src/generated/resources/META-INF/org/apache/camel/component/file/remote/ftp.json
b/components/camel-ftp/src/generated/resources/META-INF/org/apache/camel/component/file/remote/ftp.json
index 7ab2d6b4192d..966143f968c1 100644
---
a/components/camel-ftp/src/generated/resources/META-INF/org/apache/camel/component/file/remote/ftp.json
+++
b/components/camel-ftp/src/generated/resources/META-INF/org/apache/camel/component/file/remote/ftp.json
@@ -70,7 +70,7 @@
"moveFailed": { "index": 16, "kind": "parameter", "displayName": "Move
Failed", "group": "consumer", "label": "consumer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "description": "Sets the move failure expression based
on Simple language. For example, to move files into a .error subdirectory use:
.error. Note: When moving the files to the fail location Camel will handle the
error and will not pick up [...]
"noop": { "index": 17, "kind": "parameter", "displayName": "Noop",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "If true, the file is not moved or
deleted in any way. This option is good for readonly data, or for ETL type
requirements. If noop=true, Camel will set idempotent=true as well, to avoid
consuming the same files over and o [...]
"preMove": { "index": 18, "kind": "parameter", "displayName": "Pre Move",
"group": "consumer", "label": "consumer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Expression (such as File Language) used to
dynamically set the filename when moving it before processing. For example to
move in-progress files into the order directory set this value to order." },
- "preSort": { "index": 19, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You may want to do this in case you need to
operate on the files in a sorte [...]
+ "preSort": { "index": 19, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "enum",
"javaType": "java.lang.String", "enum": [ "true", "false", "name", "-name",
"modified", "-modified", "size", "-size" ], "deprecated": false, "autowired":
false, "secret": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You [...]
"recursive": { "index": 20, "kind": "parameter", "displayName":
"Recursive", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "If a directory,
will look for files in all the sub-directories as well." },
"resumeDownload": { "index": 21, "kind": "parameter", "displayName":
"Resume Download", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "Configures
whether resume download is enabled. This must be supported by the FTP server
(almost all FTP servers support it). In addition, the options
localWorkDirectory must be configured so downloade [...]
"sendEmptyMessageWhenIdle": { "index": 22, "kind": "parameter",
"displayName": "Send Empty Message When Idle", "group": "consumer", "label":
"consumer", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
false, "description": "If the polling consumer did not poll any files, you can
enable this option to send an empty message (no body) instead." },
diff --git
a/components/camel-ftp/src/generated/resources/META-INF/org/apache/camel/component/file/remote/ftps.json
b/components/camel-ftp/src/generated/resources/META-INF/org/apache/camel/component/file/remote/ftps.json
index 741f62beb210..9d38913f4853 100644
---
a/components/camel-ftp/src/generated/resources/META-INF/org/apache/camel/component/file/remote/ftps.json
+++
b/components/camel-ftp/src/generated/resources/META-INF/org/apache/camel/component/file/remote/ftps.json
@@ -71,7 +71,7 @@
"moveFailed": { "index": 16, "kind": "parameter", "displayName": "Move
Failed", "group": "consumer", "label": "consumer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "description": "Sets the move failure expression based
on Simple language. For example, to move files into a .error subdirectory use:
.error. Note: When moving the files to the fail location Camel will handle the
error and will not pick up [...]
"noop": { "index": 17, "kind": "parameter", "displayName": "Noop",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "If true, the file is not moved or
deleted in any way. This option is good for readonly data, or for ETL type
requirements. If noop=true, Camel will set idempotent=true as well, to avoid
consuming the same files over and o [...]
"preMove": { "index": 18, "kind": "parameter", "displayName": "Pre Move",
"group": "consumer", "label": "consumer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Expression (such as File Language) used to
dynamically set the filename when moving it before processing. For example to
move in-progress files into the order directory set this value to order." },
- "preSort": { "index": 19, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You may want to do this in case you need to
operate on the files in a sorte [...]
+ "preSort": { "index": 19, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "enum",
"javaType": "java.lang.String", "enum": [ "true", "false", "name", "-name",
"modified", "-modified", "size", "-size" ], "deprecated": false, "autowired":
false, "secret": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You [...]
"recursive": { "index": 20, "kind": "parameter", "displayName":
"Recursive", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "If a directory,
will look for files in all the sub-directories as well." },
"resumeDownload": { "index": 21, "kind": "parameter", "displayName":
"Resume Download", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "Configures
whether resume download is enabled. This must be supported by the FTP server
(almost all FTP servers support it). In addition, the options
localWorkDirectory must be configured so downloade [...]
"sendEmptyMessageWhenIdle": { "index": 22, "kind": "parameter",
"displayName": "Send Empty Message When Idle", "group": "consumer", "label":
"consumer", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
false, "description": "If the polling consumer did not poll any files, you can
enable this option to send an empty message (no body) instead." },
diff --git
a/components/camel-ftp/src/generated/resources/META-INF/org/apache/camel/component/file/remote/sftp.json
b/components/camel-ftp/src/generated/resources/META-INF/org/apache/camel/component/file/remote/sftp.json
index 9d255f2c4537..1a191263db0f 100644
---
a/components/camel-ftp/src/generated/resources/META-INF/org/apache/camel/component/file/remote/sftp.json
+++
b/components/camel-ftp/src/generated/resources/META-INF/org/apache/camel/component/file/remote/sftp.json
@@ -73,7 +73,7 @@
"moveFailed": { "index": 14, "kind": "parameter", "displayName": "Move
Failed", "group": "consumer", "label": "consumer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "description": "Sets the move failure expression based
on Simple language. For example, to move files into a .error subdirectory use:
.error. Note: When moving the files to the fail location Camel will handle the
error and will not pick up [...]
"noop": { "index": 15, "kind": "parameter", "displayName": "Noop",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "If true, the file is not moved or
deleted in any way. This option is good for readonly data, or for ETL type
requirements. If noop=true, Camel will set idempotent=true as well, to avoid
consuming the same files over and o [...]
"preMove": { "index": 16, "kind": "parameter", "displayName": "Pre Move",
"group": "consumer", "label": "consumer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Expression (such as File Language) used to
dynamically set the filename when moving it before processing. For example to
move in-progress files into the order directory set this value to order." },
- "preSort": { "index": 17, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You may want to do this in case you need to
operate on the files in a sorte [...]
+ "preSort": { "index": 17, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "enum",
"javaType": "java.lang.String", "enum": [ "true", "false", "name", "-name",
"modified", "-modified", "size", "-size" ], "deprecated": false, "autowired":
false, "secret": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You [...]
"recursive": { "index": 18, "kind": "parameter", "displayName":
"Recursive", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "If a directory,
will look for files in all the sub-directories as well." },
"sendEmptyMessageWhenIdle": { "index": 19, "kind": "parameter",
"displayName": "Send Empty Message When Idle", "group": "consumer", "label":
"consumer", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
false, "description": "If the polling consumer did not poll any files, you can
enable this option to send an empty message (no body) instead." },
"streamDownload": { "index": 20, "kind": "parameter", "displayName":
"Stream Download", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.file.remote.SftpConfiguration",
"configurationField": "configuration", "description": "Sets the download method
to use when not using a local working directory. If se [...]
diff --git
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java
index d5a340d02bc0..1985a707f117 100644
---
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java
+++
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java
@@ -148,7 +148,7 @@ public class FtpConsumer extends
RemoteFileConsumer<FTPFile> {
LOG.trace("Found {} files in directory: {}", files.length, dir);
if (getEndpoint().isPreSort()) {
- Arrays.sort(files, Comparator.comparing(FTPFile::getName));
+ Arrays.sort(files, preSortComparator(getEndpoint().getPreSort()));
}
for (FTPFile file : files) {
@@ -438,4 +438,22 @@ public class FtpConsumer extends
RemoteFileConsumer<FTPFile> {
}
return ftpConsumerToString;
}
+
+ private static Comparator<FTPFile> preSortComparator(String preSort) {
+ boolean reverse = preSort.startsWith("-");
+ String field = reverse ? preSort.substring(1) : preSort;
+ Comparator<FTPFile> cmp;
+ switch (field) {
+ case "modified":
+ cmp = Comparator.comparingLong(f -> f.getTimestamp() != null ?
f.getTimestamp().getTimeInMillis() : 0);
+ break;
+ case "size":
+ cmp = Comparator.comparingLong(FTPFile::getSize);
+ break;
+ default:
+ cmp = Comparator.comparing(FTPFile::getName);
+ break;
+ }
+ return reverse ? cmp.reversed() : cmp;
+ }
}
diff --git
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/SftpPreSortTest.java
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/SftpPreSortTest.java
new file mode 100644
index 000000000000..ee8f810717b2
--- /dev/null
+++
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/SftpPreSortTest.java
@@ -0,0 +1,102 @@
+/*
+ * 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.remote;
+
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class SftpPreSortTest extends CamelTestSupport {
+
+ @Test
+ public void testPreSortDefault() {
+ SftpEndpoint endpoint = context.getEndpoint("sftp://hostname/dir",
SftpEndpoint.class);
+ assertNull(endpoint.getPreSort());
+ assertFalse(endpoint.isPreSort());
+ }
+
+ @Test
+ public void testPreSortTrue() {
+ SftpEndpoint endpoint =
context.getEndpoint("sftp://hostname/dir?preSort=true", SftpEndpoint.class);
+ assertEquals("true", endpoint.getPreSort());
+ assertTrue(endpoint.isPreSort());
+ }
+
+ @Test
+ public void testPreSortFalse() {
+ SftpEndpoint endpoint =
context.getEndpoint("sftp://hostname/dir?preSort=false", SftpEndpoint.class);
+ assertEquals("false", endpoint.getPreSort());
+ assertFalse(endpoint.isPreSort());
+ }
+
+ @Test
+ public void testPreSortName() {
+ SftpEndpoint endpoint =
context.getEndpoint("sftp://hostname/dir?preSort=name", SftpEndpoint.class);
+ assertEquals("name", endpoint.getPreSort());
+ assertTrue(endpoint.isPreSort());
+ }
+
+ @Test
+ public void testPreSortReverseName() {
+ SftpEndpoint endpoint =
context.getEndpoint("sftp://hostname/dir?preSort=-name", SftpEndpoint.class);
+ assertEquals("-name", endpoint.getPreSort());
+ assertTrue(endpoint.isPreSort());
+ }
+
+ @Test
+ public void testPreSortModified() {
+ SftpEndpoint endpoint =
context.getEndpoint("sftp://hostname/dir?preSort=modified", SftpEndpoint.class);
+ assertEquals("modified", endpoint.getPreSort());
+ assertTrue(endpoint.isPreSort());
+ }
+
+ @Test
+ public void testPreSortReverseModified() {
+ SftpEndpoint endpoint =
context.getEndpoint("sftp://hostname/dir?preSort=-modified",
SftpEndpoint.class);
+ assertEquals("-modified", endpoint.getPreSort());
+ assertTrue(endpoint.isPreSort());
+ }
+
+ @Test
+ public void testPreSortSize() {
+ SftpEndpoint endpoint =
context.getEndpoint("sftp://hostname/dir?preSort=size", SftpEndpoint.class);
+ assertEquals("size", endpoint.getPreSort());
+ assertTrue(endpoint.isPreSort());
+ }
+
+ @Test
+ public void testPreSortReverseSize() {
+ SftpEndpoint endpoint =
context.getEndpoint("sftp://hostname/dir?preSort=-size", SftpEndpoint.class);
+ assertEquals("-size", endpoint.getPreSort());
+ assertTrue(endpoint.isPreSort());
+ }
+
+ @Test
+ public void testPreSortWithMaxMessagesPerPoll() {
+ SftpEndpoint endpoint = context.getEndpoint(
+
"sftp://hostname/dir?preSort=modified&maxMessagesPerPoll=10&eagerMaxMessagesPerPoll=true",
+ SftpEndpoint.class);
+ assertEquals("modified", endpoint.getPreSort());
+ assertTrue(endpoint.isPreSort());
+ assertEquals(10, endpoint.getMaxMessagesPerPoll());
+ assertTrue(endpoint.isEagerMaxMessagesPerPoll());
+ }
+}
diff --git
a/components/camel-mina-sftp/src/generated/java/org/apache/camel/component/file/remote/mina/MinaSftpEndpointConfigurer.java
b/components/camel-mina-sftp/src/generated/java/org/apache/camel/component/file/remote/mina/MinaSftpEndpointConfigurer.java
index 85e4a5331687..e5d63d18ab36 100644
---
a/components/camel-mina-sftp/src/generated/java/org/apache/camel/component/file/remote/mina/MinaSftpEndpointConfigurer.java
+++
b/components/camel-mina-sftp/src/generated/java/org/apache/camel/component/file/remote/mina/MinaSftpEndpointConfigurer.java
@@ -168,7 +168,7 @@ public class MinaSftpEndpointConfigurer extends
PropertyConfigurerSupport implem
case "premove":
case "preMove": target.setPreMove(property(camelContext,
java.lang.String.class, value)); return true;
case "presort":
- case "preSort": target.setPreSort(property(camelContext,
boolean.class, value)); return true;
+ case "preSort": target.setPreSort(property(camelContext,
java.lang.String.class, value)); return true;
case "preferredauthentications":
case "preferredAuthentications":
target.getConfiguration().setPreferredAuthentications(property(camelContext,
java.lang.String.class, value)); return true;
case "privatekey":
@@ -423,7 +423,7 @@ public class MinaSftpEndpointConfigurer extends
PropertyConfigurerSupport implem
case "premove":
case "preMove": return java.lang.String.class;
case "presort":
- case "preSort": return boolean.class;
+ case "preSort": return java.lang.String.class;
case "preferredauthentications":
case "preferredAuthentications": return java.lang.String.class;
case "privatekey":
@@ -679,7 +679,7 @@ public class MinaSftpEndpointConfigurer extends
PropertyConfigurerSupport implem
case "premove":
case "preMove": return target.getPreMove();
case "presort":
- case "preSort": return target.isPreSort();
+ case "preSort": return target.getPreSort();
case "preferredauthentications":
case "preferredAuthentications": return
target.getConfiguration().getPreferredAuthentications();
case "privatekey":
diff --git
a/components/camel-mina-sftp/src/generated/resources/META-INF/org/apache/camel/component/file/remote/mina/mina-sftp.json
b/components/camel-mina-sftp/src/generated/resources/META-INF/org/apache/camel/component/file/remote/mina/mina-sftp.json
index 850194684f3f..fdbdf04dd450 100644
---
a/components/camel-mina-sftp/src/generated/resources/META-INF/org/apache/camel/component/file/remote/mina/mina-sftp.json
+++
b/components/camel-mina-sftp/src/generated/resources/META-INF/org/apache/camel/component/file/remote/mina/mina-sftp.json
@@ -66,7 +66,7 @@
"moveFailed": { "index": 13, "kind": "parameter", "displayName": "Move
Failed", "group": "consumer", "label": "consumer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "description": "Sets the move failure expression based
on Simple language. For example, to move files into a .error subdirectory use:
.error. Note: When moving the files to the fail location Camel will handle the
error and will not pick up [...]
"noop": { "index": 14, "kind": "parameter", "displayName": "Noop",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "If true, the file is not moved or
deleted in any way. This option is good for readonly data, or for ETL type
requirements. If noop=true, Camel will set idempotent=true as well, to avoid
consuming the same files over and o [...]
"preMove": { "index": 15, "kind": "parameter", "displayName": "Pre Move",
"group": "consumer", "label": "consumer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Expression (such as File Language) used to
dynamically set the filename when moving it before processing. For example to
move in-progress files into the order directory set this value to order." },
- "preSort": { "index": 16, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You may want to do this in case you need to
operate on the files in a sorte [...]
+ "preSort": { "index": 16, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "enum",
"javaType": "java.lang.String", "enum": [ "true", "false", "name", "-name",
"modified", "-modified", "size", "-size" ], "deprecated": false, "autowired":
false, "secret": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You [...]
"recursive": { "index": 17, "kind": "parameter", "displayName":
"Recursive", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "If a directory,
will look for files in all the sub-directories as well." },
"sendEmptyMessageWhenIdle": { "index": 18, "kind": "parameter",
"displayName": "Send Empty Message When Idle", "group": "consumer", "label":
"consumer", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
false, "description": "If the polling consumer did not poll any files, you can
enable this option to send an empty message (no body) instead." },
"streamDownload": { "index": 19, "kind": "parameter", "displayName":
"Stream Download", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.file.remote.mina.MinaSftpConfiguration",
"configurationField": "configuration", "description": "Sets the download method
to use when not using a local working directo [...]
diff --git
a/components/camel-smb/src/generated/java/org/apache/camel/component/smb/SmbEndpointConfigurer.java
b/components/camel-smb/src/generated/java/org/apache/camel/component/smb/SmbEndpointConfigurer.java
index a375ec77c6f1..72171500936b 100644
---
a/components/camel-smb/src/generated/java/org/apache/camel/component/smb/SmbEndpointConfigurer.java
+++
b/components/camel-smb/src/generated/java/org/apache/camel/component/smb/SmbEndpointConfigurer.java
@@ -129,7 +129,7 @@ public class SmbEndpointConfigurer extends
PropertyConfigurerSupport implements
case "premove":
case "preMove": target.setPreMove(property(camelContext,
java.lang.String.class, value)); return true;
case "presort":
- case "preSort": target.setPreSort(property(camelContext,
boolean.class, value)); return true;
+ case "preSort": target.setPreSort(property(camelContext,
java.lang.String.class, value)); return true;
case "processstrategy":
case "processStrategy":
target.setProcessStrategy(property(camelContext,
org.apache.camel.component.file.GenericFileProcessStrategy.class, value));
return true;
case "readlock":
@@ -309,7 +309,7 @@ public class SmbEndpointConfigurer extends
PropertyConfigurerSupport implements
case "premove":
case "preMove": return java.lang.String.class;
case "presort":
- case "preSort": return boolean.class;
+ case "preSort": return java.lang.String.class;
case "processstrategy":
case "processStrategy": return
org.apache.camel.component.file.GenericFileProcessStrategy.class;
case "readlock":
@@ -485,7 +485,7 @@ public class SmbEndpointConfigurer extends
PropertyConfigurerSupport implements
case "premove":
case "preMove": return target.getPreMove();
case "presort":
- case "preSort": return target.isPreSort();
+ case "preSort": return target.getPreSort();
case "processstrategy":
case "processStrategy": return target.getProcessStrategy();
case "readlock":
diff --git
a/components/camel-smb/src/generated/resources/META-INF/org/apache/camel/component/smb/smb.json
b/components/camel-smb/src/generated/resources/META-INF/org/apache/camel/component/smb/smb.json
index f37e49479359..8884ee25f5db 100644
---
a/components/camel-smb/src/generated/resources/META-INF/org/apache/camel/component/smb/smb.json
+++
b/components/camel-smb/src/generated/resources/META-INF/org/apache/camel/component/smb/smb.json
@@ -63,7 +63,7 @@
"moveFailed": { "index": 10, "kind": "parameter", "displayName": "Move
Failed", "group": "consumer", "label": "consumer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "description": "Sets the move failure expression based
on Simple language. For example, to move files into a .error subdirectory use:
.error. Note: When moving the files to the fail location Camel will handle the
error and will not pick up [...]
"noop": { "index": 11, "kind": "parameter", "displayName": "Noop",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "If true, the file is not moved or
deleted in any way. This option is good for readonly data, or for ETL type
requirements. If noop=true, Camel will set idempotent=true as well, to avoid
consuming the same files over and o [...]
"preMove": { "index": 12, "kind": "parameter", "displayName": "Pre Move",
"group": "consumer", "label": "consumer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Expression (such as File Language) used to
dynamically set the filename when moving it before processing. For example to
move in-progress files into the order directory set this value to order." },
- "preSort": { "index": 13, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You may want to do this in case you need to
operate on the files in a sorte [...]
+ "preSort": { "index": 13, "kind": "parameter", "displayName": "Pre Sort",
"group": "consumer", "label": "consumer", "required": false, "type": "enum",
"javaType": "java.lang.String", "enum": [ "true", "false", "name", "-name",
"modified", "-modified", "size", "-size" ], "deprecated": false, "autowired":
false, "secret": false, "description": "When pre-sort is enabled then the
consumer will sort the file and directory names during polling, that was
retrieved from the file system. You [...]
"recursive": { "index": 14, "kind": "parameter", "displayName":
"Recursive", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "If a directory,
will look for files in all the sub-directories as well." },
"searchPattern": { "index": 15, "kind": "parameter", "displayName":
"Search Pattern", "group": "consumer", "label": "consumer", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.smb.SmbConfiguration", "configurationField":
"configuration", "description": "The search pattern used to list the files
(server side on SMB). This parameter can contain the name of a [...]
"sendEmptyMessageWhenIdle": { "index": 16, "kind": "parameter",
"displayName": "Send Empty Message When Idle", "group": "consumer", "label":
"consumer", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
false, "description": "If the polling consumer did not poll any files, you can
enable this option to send an empty message (no body) instead." },
diff --git
a/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbConsumer.java
b/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbConsumer.java
index 6cb966ac2500..4ffa70057271 100644
---
a/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbConsumer.java
+++
b/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbConsumer.java
@@ -84,7 +84,7 @@ public class SmbConsumer extends
GenericFileConsumer<FileIdBothDirectoryInformat
}
if (getEndpoint().isPreSort()) {
- Arrays.sort(files,
Comparator.comparing(FileIdBothDirectoryInformation::getFileName));
+ Arrays.sort(files, preSortComparator(getEndpoint().getPreSort()));
}
for (FileIdBothDirectoryInformation file : files) {
@@ -427,4 +427,22 @@ public class SmbConsumer extends
GenericFileConsumer<FileIdBothDirectoryInformat
private boolean isDirectory(FileIdBothDirectoryInformation file) {
return EnumWithValue.EnumUtils.isSet(file.getFileAttributes(),
FileAttributes.FILE_ATTRIBUTE_DIRECTORY);
}
+
+ private static Comparator<FileIdBothDirectoryInformation>
preSortComparator(String preSort) {
+ boolean reverse = preSort.startsWith("-");
+ String field = reverse ? preSort.substring(1) : preSort;
+ Comparator<FileIdBothDirectoryInformation> cmp;
+ switch (field) {
+ case "modified":
+ cmp = Comparator.comparingLong(f ->
f.getLastWriteTime().toEpochMillis());
+ break;
+ case "size":
+ cmp =
Comparator.comparingLong(FileIdBothDirectoryInformation::getEndOfFile);
+ break;
+ default:
+ cmp =
Comparator.comparing(FileIdBothDirectoryInformation::getFileName);
+ break;
+ }
+ return reverse ? cmp.reversed() : cmp;
+ }
}
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_22.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_22.adoc
index 13cd6ce04a09..e1866df7e647 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_22.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_22.adoc
@@ -103,6 +103,22 @@ payloads, enable stream caching on the route.
* The `bufferSize` option has been removed. It only configured the previous
streaming implementation and no longer has
any effect with authenticated encryption.
+=== camel-file / camel-ftp / camel-azure-files / camel-smb - preSort option
enhanced
+
+The `preSort` option on the File, FTP, FTPS, SFTP, Azure Files, and SMB
consumers has changed from a `boolean`
+to a `String`. Previously, `preSort=true` sorted files by name only. The
option now supports the following values:
+
+* `name` — sort by file name ascending (same behavior as old `preSort=true`)
+* `modified` — sort by last-modified timestamp ascending (oldest first)
+* `size` — sort by file size ascending (smallest first)
+* `-name`, `-modified`, `-size` — descending (reverse) order
+* `true` — backward compatible alias for `name`
+* `false` or not set — disabled (default, unchanged)
+
+The pre-sort is applied on the raw file listing before any filtering or eager
limiting, which makes it possible
+to combine `preSort=modified` with `eagerMaxMessagesPerPoll=true` and
`maxMessagesPerPoll=10` to efficiently
+consume the 10 oldest files without creating Exchange objects for every file
on the server.
+
=== camel-mail - MimeMultipartDataFormat inbound header filtering
When unmarshalling a MIME message with `headersInline=true`, the
`mime-multipart` data format now applies a
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/FileEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/FileEndpointBuilderFactory.java
index 0f7f1f54de13..08c182c729fb 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/FileEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/FileEndpointBuilderFactory.java
@@ -267,31 +267,15 @@ public interface FileEndpointBuilderFactory {
* system. You may want to do this in case you need to operate on the
* files in a sorted order. The pre-sort is executed before the
consumer
* starts to filter, and accept files to process by Camel. This option
- * is default=false meaning disabled.
+ * is default=false meaning disabled. The following values are
+ * supported: name (sort by file name), modified (sort by last-modified
+ * timestamp), size (sort by file size). To sort in descending
(reverse)
+ * order, prefix the value with a minus sign (e.g., -modified to sort
+ * newest first). The value true is an alias for name (backward
+ * compatible).
*
- * The option is a: <code>boolean</code> type.
- *
- * Default: false
- * Group: consumer
- *
- * @param preSort the value to set
- * @return the dsl builder
- */
- default FileEndpointConsumerBuilder preSort(boolean preSort) {
- doSetProperty("preSort", preSort);
- return this;
- }
- /**
- * When pre-sort is enabled then the consumer will sort the file and
- * directory names during polling, that was retrieved from the file
- * system. You may want to do this in case you need to operate on the
- * files in a sorted order. The pre-sort is executed before the
consumer
- * starts to filter, and accept files to process by Camel. This option
- * is default=false meaning disabled.
- *
- * The option will be converted to a <code>boolean</code> type.
+ * The option is a: <code>java.lang.String</code> type.
*
- * Default: false
* Group: consumer
*
* @param preSort the value to set
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 ade43f0cc8d1..99e1de5ad63c 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
@@ -329,31 +329,15 @@ public interface FilesEndpointBuilderFactory {
* system. You may want to do this in case you need to operate on the
* files in a sorted order. The pre-sort is executed before the
consumer
* starts to filter, and accept files to process by Camel. This option
- * is default=false meaning disabled.
+ * is default=false meaning disabled. The following values are
+ * supported: name (sort by file name), modified (sort by last-modified
+ * timestamp), size (sort by file size). To sort in descending
(reverse)
+ * order, prefix the value with a minus sign (e.g., -modified to sort
+ * newest first). The value true is an alias for name (backward
+ * compatible).
*
- * The option is a: <code>boolean</code> type.
- *
- * Default: false
- * Group: consumer
- *
- * @param preSort the value to set
- * @return the dsl builder
- */
- default FilesEndpointConsumerBuilder preSort(boolean preSort) {
- doSetProperty("preSort", preSort);
- return this;
- }
- /**
- * When pre-sort is enabled then the consumer will sort the file and
- * directory names during polling, that was retrieved from the file
- * system. You may want to do this in case you need to operate on the
- * files in a sorted order. The pre-sort is executed before the
consumer
- * starts to filter, and accept files to process by Camel. This option
- * is default=false meaning disabled.
- *
- * The option will be converted to a <code>boolean</code> type.
+ * The option is a: <code>java.lang.String</code> type.
*
- * Default: false
* Group: consumer
*
* @param preSort the value to set
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/FtpEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/FtpEndpointBuilderFactory.java
index 8d6e7d3ee87f..4995501af1f9 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/FtpEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/FtpEndpointBuilderFactory.java
@@ -500,31 +500,15 @@ public interface FtpEndpointBuilderFactory {
* system. You may want to do this in case you need to operate on the
* files in a sorted order. The pre-sort is executed before the
consumer
* starts to filter, and accept files to process by Camel. This option
- * is default=false meaning disabled.
+ * is default=false meaning disabled. The following values are
+ * supported: name (sort by file name), modified (sort by last-modified
+ * timestamp), size (sort by file size). To sort in descending
(reverse)
+ * order, prefix the value with a minus sign (e.g., -modified to sort
+ * newest first). The value true is an alias for name (backward
+ * compatible).
*
- * The option is a: <code>boolean</code> type.
- *
- * Default: false
- * Group: consumer
- *
- * @param preSort the value to set
- * @return the dsl builder
- */
- default FtpEndpointConsumerBuilder preSort(boolean preSort) {
- doSetProperty("preSort", preSort);
- return this;
- }
- /**
- * When pre-sort is enabled then the consumer will sort the file and
- * directory names during polling, that was retrieved from the file
- * system. You may want to do this in case you need to operate on the
- * files in a sorted order. The pre-sort is executed before the
consumer
- * starts to filter, and accept files to process by Camel. This option
- * is default=false meaning disabled.
- *
- * The option will be converted to a <code>boolean</code> type.
+ * The option is a: <code>java.lang.String</code> type.
*
- * Default: false
* Group: consumer
*
* @param preSort the value to set
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/FtpsEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/FtpsEndpointBuilderFactory.java
index 0e7077a4d23f..8087dfb3c145 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/FtpsEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/FtpsEndpointBuilderFactory.java
@@ -500,31 +500,15 @@ public interface FtpsEndpointBuilderFactory {
* system. You may want to do this in case you need to operate on the
* files in a sorted order. The pre-sort is executed before the
consumer
* starts to filter, and accept files to process by Camel. This option
- * is default=false meaning disabled.
+ * is default=false meaning disabled. The following values are
+ * supported: name (sort by file name), modified (sort by last-modified
+ * timestamp), size (sort by file size). To sort in descending
(reverse)
+ * order, prefix the value with a minus sign (e.g., -modified to sort
+ * newest first). The value true is an alias for name (backward
+ * compatible).
*
- * The option is a: <code>boolean</code> type.
- *
- * Default: false
- * Group: consumer
- *
- * @param preSort the value to set
- * @return the dsl builder
- */
- default FtpsEndpointConsumerBuilder preSort(boolean preSort) {
- doSetProperty("preSort", preSort);
- return this;
- }
- /**
- * When pre-sort is enabled then the consumer will sort the file and
- * directory names during polling, that was retrieved from the file
- * system. You may want to do this in case you need to operate on the
- * files in a sorted order. The pre-sort is executed before the
consumer
- * starts to filter, and accept files to process by Camel. This option
- * is default=false meaning disabled.
- *
- * The option will be converted to a <code>boolean</code> type.
+ * The option is a: <code>java.lang.String</code> type.
*
- * Default: false
* Group: consumer
*
* @param preSort the value to set
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MinaSftpEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MinaSftpEndpointBuilderFactory.java
index f9c6e18f55b7..a64efd8bd6b9 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MinaSftpEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MinaSftpEndpointBuilderFactory.java
@@ -401,31 +401,15 @@ public interface MinaSftpEndpointBuilderFactory {
* system. You may want to do this in case you need to operate on the
* files in a sorted order. The pre-sort is executed before the
consumer
* starts to filter, and accept files to process by Camel. This option
- * is default=false meaning disabled.
+ * is default=false meaning disabled. The following values are
+ * supported: name (sort by file name), modified (sort by last-modified
+ * timestamp), size (sort by file size). To sort in descending
(reverse)
+ * order, prefix the value with a minus sign (e.g., -modified to sort
+ * newest first). The value true is an alias for name (backward
+ * compatible).
*
- * The option is a: <code>boolean</code> type.
- *
- * Default: false
- * Group: consumer
- *
- * @param preSort the value to set
- * @return the dsl builder
- */
- default MinaSftpEndpointConsumerBuilder preSort(boolean preSort) {
- doSetProperty("preSort", preSort);
- return this;
- }
- /**
- * When pre-sort is enabled then the consumer will sort the file and
- * directory names during polling, that was retrieved from the file
- * system. You may want to do this in case you need to operate on the
- * files in a sorted order. The pre-sort is executed before the
consumer
- * starts to filter, and accept files to process by Camel. This option
- * is default=false meaning disabled.
- *
- * The option will be converted to a <code>boolean</code> type.
+ * The option is a: <code>java.lang.String</code> type.
*
- * Default: false
* Group: consumer
*
* @param preSort the value to set
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SftpEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SftpEndpointBuilderFactory.java
index c4f64b3654f1..83d82318978f 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SftpEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SftpEndpointBuilderFactory.java
@@ -434,31 +434,15 @@ public interface SftpEndpointBuilderFactory {
* system. You may want to do this in case you need to operate on the
* files in a sorted order. The pre-sort is executed before the
consumer
* starts to filter, and accept files to process by Camel. This option
- * is default=false meaning disabled.
+ * is default=false meaning disabled. The following values are
+ * supported: name (sort by file name), modified (sort by last-modified
+ * timestamp), size (sort by file size). To sort in descending
(reverse)
+ * order, prefix the value with a minus sign (e.g., -modified to sort
+ * newest first). The value true is an alias for name (backward
+ * compatible).
*
- * The option is a: <code>boolean</code> type.
- *
- * Default: false
- * Group: consumer
- *
- * @param preSort the value to set
- * @return the dsl builder
- */
- default SftpEndpointConsumerBuilder preSort(boolean preSort) {
- doSetProperty("preSort", preSort);
- return this;
- }
- /**
- * When pre-sort is enabled then the consumer will sort the file and
- * directory names during polling, that was retrieved from the file
- * system. You may want to do this in case you need to operate on the
- * files in a sorted order. The pre-sort is executed before the
consumer
- * starts to filter, and accept files to process by Camel. This option
- * is default=false meaning disabled.
- *
- * The option will be converted to a <code>boolean</code> type.
+ * The option is a: <code>java.lang.String</code> type.
*
- * Default: false
* Group: consumer
*
* @param preSort the value to set
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SmbEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SmbEndpointBuilderFactory.java
index 7f6dba3638f3..e37521490e4a 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SmbEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SmbEndpointBuilderFactory.java
@@ -303,31 +303,15 @@ public interface SmbEndpointBuilderFactory {
* system. You may want to do this in case you need to operate on the
* files in a sorted order. The pre-sort is executed before the
consumer
* starts to filter, and accept files to process by Camel. This option
- * is default=false meaning disabled.
+ * is default=false meaning disabled. The following values are
+ * supported: name (sort by file name), modified (sort by last-modified
+ * timestamp), size (sort by file size). To sort in descending
(reverse)
+ * order, prefix the value with a minus sign (e.g., -modified to sort
+ * newest first). The value true is an alias for name (backward
+ * compatible).
*
- * The option is a: <code>boolean</code> type.
- *
- * Default: false
- * Group: consumer
- *
- * @param preSort the value to set
- * @return the dsl builder
- */
- default SmbEndpointConsumerBuilder preSort(boolean preSort) {
- doSetProperty("preSort", preSort);
- return this;
- }
- /**
- * When pre-sort is enabled then the consumer will sort the file and
- * directory names during polling, that was retrieved from the file
- * system. You may want to do this in case you need to operate on the
- * files in a sorted order. The pre-sort is executed before the
consumer
- * starts to filter, and accept files to process by Camel. This option
- * is default=false meaning disabled.
- *
- * The option will be converted to a <code>boolean</code> type.
+ * The option is a: <code>java.lang.String</code> type.
*
- * Default: false
* Group: consumer
*
* @param preSort the value to set