You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/09/30 20:41:49 UTC
[camel] branch main updated: CAMEL-18568: Extend handleDuplicateAttachmentNames handling to suffix filename with UUID (#8448)
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 3666e8b139a CAMEL-18568: Extend handleDuplicateAttachmentNames handling to suffix filename with UUID (#8448)
3666e8b139a is described below
commit 3666e8b139a811c0adcf49a24cf43b25f4d3057b
Author: Manuel <48...@users.noreply.github.com>
AuthorDate: Fri Sep 30 22:41:43 2022 +0200
CAMEL-18568: Extend handleDuplicateAttachmentNames handling to suffix filename with UUID (#8448)
---
.../org/apache/camel/component/mail/imap.json | 4 +-
.../org/apache/camel/component/mail/imaps.json | 4 +-
.../org/apache/camel/component/mail/pop3.json | 4 +-
.../org/apache/camel/component/mail/pop3s.json | 4 +-
.../org/apache/camel/component/mail/smtp.json | 4 +-
.../org/apache/camel/component/mail/smtps.json | 4 +-
.../apache/camel/component/mail/MailBinding.java | 39 +++++++++++-
.../camel/component/mail/MailConfiguration.java | 7 ++-
.../apache/camel/component/mail/MailConstants.java | 1 +
.../component/mail/MailAttachmentNamesTest.java | 72 +++++++++++++++++++++-
.../resources/filename_duplicate_multiple_dots.txt | 62 +++++++++++++++++++
.../resources/filename_duplicate_no_extension.txt | 62 +++++++++++++++++++
.../filename_duplicate_single_dot_at_beginning.txt | 62 +++++++++++++++++++
13 files changed, 308 insertions(+), 21 deletions(-)
diff --git a/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/imap.json b/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/imap.json
index 5a7d5031ba1..32c3965d271 100644
--- a/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/imap.json
+++ b/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/imap.json
@@ -40,7 +40,7 @@
"fetchSize": { "kind": "property", "displayName": "Fetch Size", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": -1, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the maximum number of messages to consume during a poll. This can be [...]
"folderName": { "kind": "property", "displayName": "Folder Name", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "INBOX", "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "The folder to poll." },
"generateMissingAttachmentNames": { "kind": "property", "displayName": "Generate Missing Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set this to 'uuid' to set a UUID for the filename of the atta [...]
- "handleDuplicateAttachmentNames": { "kind": "property", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachments [...]
+ "handleDuplicateAttachmentNames": { "kind": "property", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachments [...]
"mapMailMessage": { "kind": "property", "displayName": "Map Mail Message", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Specifies whether Camel should map the received mail message to Camel body\/head [...]
"bcc": { "kind": "property", "displayName": "Bcc", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the BCC email address. Separate multiple email addresses with comma." },
"cc": { "kind": "property", "displayName": "Cc", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the CC email address. Separate multiple email addresses with comma." },
@@ -107,7 +107,7 @@
"fetchSize": { "kind": "parameter", "displayName": "Fetch Size", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": -1, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the maximum number of messages to consume during a poll. This can be [...]
"folderName": { "kind": "parameter", "displayName": "Folder Name", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "INBOX", "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "The folder to poll." },
"generateMissingAttachmentNames": { "kind": "parameter", "displayName": "Generate Missing Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set this to 'uuid' to set a UUID for the filename of the att [...]
- "handleDuplicateAttachmentNames": { "kind": "parameter", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachment [...]
+ "handleDuplicateAttachmentNames": { "kind": "parameter", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachment [...]
"mailUidGenerator": { "kind": "parameter", "displayName": "Mail Uid Generator", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.mail.MailUidGenerator", "deprecated": false, "autowired": false, "secret": false, "description": "A pluggable MailUidGenerator that allows to use custom logic to generate UUID of the mail message." },
"mapMailMessage": { "kind": "parameter", "displayName": "Map Mail Message", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Specifies whether Camel should map the received mail message to Camel body\/hea [...]
"pollStrategy": { "kind": "parameter", "displayName": "Poll Strategy", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.PollingConsumerPollStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the poll operation [...]
diff --git a/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/imaps.json b/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/imaps.json
index 8ee770b7143..244801a2b16 100644
--- a/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/imaps.json
+++ b/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/imaps.json
@@ -40,7 +40,7 @@
"fetchSize": { "kind": "property", "displayName": "Fetch Size", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": -1, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the maximum number of messages to consume during a poll. This can be [...]
"folderName": { "kind": "property", "displayName": "Folder Name", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "INBOX", "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "The folder to poll." },
"generateMissingAttachmentNames": { "kind": "property", "displayName": "Generate Missing Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set this to 'uuid' to set a UUID for the filename of the atta [...]
- "handleDuplicateAttachmentNames": { "kind": "property", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachments [...]
+ "handleDuplicateAttachmentNames": { "kind": "property", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachments [...]
"mapMailMessage": { "kind": "property", "displayName": "Map Mail Message", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Specifies whether Camel should map the received mail message to Camel body\/head [...]
"bcc": { "kind": "property", "displayName": "Bcc", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the BCC email address. Separate multiple email addresses with comma." },
"cc": { "kind": "property", "displayName": "Cc", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the CC email address. Separate multiple email addresses with comma." },
@@ -107,7 +107,7 @@
"fetchSize": { "kind": "parameter", "displayName": "Fetch Size", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": -1, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the maximum number of messages to consume during a poll. This can be [...]
"folderName": { "kind": "parameter", "displayName": "Folder Name", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "INBOX", "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "The folder to poll." },
"generateMissingAttachmentNames": { "kind": "parameter", "displayName": "Generate Missing Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set this to 'uuid' to set a UUID for the filename of the att [...]
- "handleDuplicateAttachmentNames": { "kind": "parameter", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachment [...]
+ "handleDuplicateAttachmentNames": { "kind": "parameter", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachment [...]
"mailUidGenerator": { "kind": "parameter", "displayName": "Mail Uid Generator", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.mail.MailUidGenerator", "deprecated": false, "autowired": false, "secret": false, "description": "A pluggable MailUidGenerator that allows to use custom logic to generate UUID of the mail message." },
"mapMailMessage": { "kind": "parameter", "displayName": "Map Mail Message", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Specifies whether Camel should map the received mail message to Camel body\/hea [...]
"pollStrategy": { "kind": "parameter", "displayName": "Poll Strategy", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.PollingConsumerPollStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the poll operation [...]
diff --git a/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/pop3.json b/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/pop3.json
index dad611b573b..b2f72d1b446 100644
--- a/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/pop3.json
+++ b/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/pop3.json
@@ -40,7 +40,7 @@
"fetchSize": { "kind": "property", "displayName": "Fetch Size", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": -1, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the maximum number of messages to consume during a poll. This can be [...]
"folderName": { "kind": "property", "displayName": "Folder Name", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "INBOX", "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "The folder to poll." },
"generateMissingAttachmentNames": { "kind": "property", "displayName": "Generate Missing Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set this to 'uuid' to set a UUID for the filename of the atta [...]
- "handleDuplicateAttachmentNames": { "kind": "property", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachments [...]
+ "handleDuplicateAttachmentNames": { "kind": "property", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachments [...]
"mapMailMessage": { "kind": "property", "displayName": "Map Mail Message", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Specifies whether Camel should map the received mail message to Camel body\/head [...]
"bcc": { "kind": "property", "displayName": "Bcc", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the BCC email address. Separate multiple email addresses with comma." },
"cc": { "kind": "property", "displayName": "Cc", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the CC email address. Separate multiple email addresses with comma." },
@@ -107,7 +107,7 @@
"fetchSize": { "kind": "parameter", "displayName": "Fetch Size", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": -1, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the maximum number of messages to consume during a poll. This can be [...]
"folderName": { "kind": "parameter", "displayName": "Folder Name", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "INBOX", "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "The folder to poll." },
"generateMissingAttachmentNames": { "kind": "parameter", "displayName": "Generate Missing Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set this to 'uuid' to set a UUID for the filename of the att [...]
- "handleDuplicateAttachmentNames": { "kind": "parameter", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachment [...]
+ "handleDuplicateAttachmentNames": { "kind": "parameter", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachment [...]
"mailUidGenerator": { "kind": "parameter", "displayName": "Mail Uid Generator", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.mail.MailUidGenerator", "deprecated": false, "autowired": false, "secret": false, "description": "A pluggable MailUidGenerator that allows to use custom logic to generate UUID of the mail message." },
"mapMailMessage": { "kind": "parameter", "displayName": "Map Mail Message", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Specifies whether Camel should map the received mail message to Camel body\/hea [...]
"pollStrategy": { "kind": "parameter", "displayName": "Poll Strategy", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.PollingConsumerPollStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the poll operation [...]
diff --git a/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/pop3s.json b/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/pop3s.json
index e0d45861b63..97fd38edfd9 100644
--- a/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/pop3s.json
+++ b/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/pop3s.json
@@ -40,7 +40,7 @@
"fetchSize": { "kind": "property", "displayName": "Fetch Size", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": -1, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the maximum number of messages to consume during a poll. This can be [...]
"folderName": { "kind": "property", "displayName": "Folder Name", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "INBOX", "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "The folder to poll." },
"generateMissingAttachmentNames": { "kind": "property", "displayName": "Generate Missing Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set this to 'uuid' to set a UUID for the filename of the atta [...]
- "handleDuplicateAttachmentNames": { "kind": "property", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachments [...]
+ "handleDuplicateAttachmentNames": { "kind": "property", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachments [...]
"mapMailMessage": { "kind": "property", "displayName": "Map Mail Message", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Specifies whether Camel should map the received mail message to Camel body\/head [...]
"bcc": { "kind": "property", "displayName": "Bcc", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the BCC email address. Separate multiple email addresses with comma." },
"cc": { "kind": "property", "displayName": "Cc", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the CC email address. Separate multiple email addresses with comma." },
@@ -107,7 +107,7 @@
"fetchSize": { "kind": "parameter", "displayName": "Fetch Size", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": -1, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the maximum number of messages to consume during a poll. This can be [...]
"folderName": { "kind": "parameter", "displayName": "Folder Name", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "INBOX", "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "The folder to poll." },
"generateMissingAttachmentNames": { "kind": "parameter", "displayName": "Generate Missing Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set this to 'uuid' to set a UUID for the filename of the att [...]
- "handleDuplicateAttachmentNames": { "kind": "parameter", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachment [...]
+ "handleDuplicateAttachmentNames": { "kind": "parameter", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachment [...]
"mailUidGenerator": { "kind": "parameter", "displayName": "Mail Uid Generator", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.mail.MailUidGenerator", "deprecated": false, "autowired": false, "secret": false, "description": "A pluggable MailUidGenerator that allows to use custom logic to generate UUID of the mail message." },
"mapMailMessage": { "kind": "parameter", "displayName": "Map Mail Message", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Specifies whether Camel should map the received mail message to Camel body\/hea [...]
"pollStrategy": { "kind": "parameter", "displayName": "Poll Strategy", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.PollingConsumerPollStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the poll operation [...]
diff --git a/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/smtp.json b/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/smtp.json
index 50fbcb20b19..1f806565d48 100644
--- a/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/smtp.json
+++ b/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/smtp.json
@@ -40,7 +40,7 @@
"fetchSize": { "kind": "property", "displayName": "Fetch Size", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": -1, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the maximum number of messages to consume during a poll. This can be [...]
"folderName": { "kind": "property", "displayName": "Folder Name", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "INBOX", "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "The folder to poll." },
"generateMissingAttachmentNames": { "kind": "property", "displayName": "Generate Missing Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set this to 'uuid' to set a UUID for the filename of the atta [...]
- "handleDuplicateAttachmentNames": { "kind": "property", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachments [...]
+ "handleDuplicateAttachmentNames": { "kind": "property", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachments [...]
"mapMailMessage": { "kind": "property", "displayName": "Map Mail Message", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Specifies whether Camel should map the received mail message to Camel body\/head [...]
"bcc": { "kind": "property", "displayName": "Bcc", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the BCC email address. Separate multiple email addresses with comma." },
"cc": { "kind": "property", "displayName": "Cc", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the CC email address. Separate multiple email addresses with comma." },
@@ -107,7 +107,7 @@
"fetchSize": { "kind": "parameter", "displayName": "Fetch Size", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": -1, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the maximum number of messages to consume during a poll. This can be [...]
"folderName": { "kind": "parameter", "displayName": "Folder Name", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "INBOX", "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "The folder to poll." },
"generateMissingAttachmentNames": { "kind": "parameter", "displayName": "Generate Missing Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set this to 'uuid' to set a UUID for the filename of the att [...]
- "handleDuplicateAttachmentNames": { "kind": "parameter", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachment [...]
+ "handleDuplicateAttachmentNames": { "kind": "parameter", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachment [...]
"mailUidGenerator": { "kind": "parameter", "displayName": "Mail Uid Generator", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.mail.MailUidGenerator", "deprecated": false, "autowired": false, "secret": false, "description": "A pluggable MailUidGenerator that allows to use custom logic to generate UUID of the mail message." },
"mapMailMessage": { "kind": "parameter", "displayName": "Map Mail Message", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Specifies whether Camel should map the received mail message to Camel body\/hea [...]
"pollStrategy": { "kind": "parameter", "displayName": "Poll Strategy", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.PollingConsumerPollStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the poll operation [...]
diff --git a/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/smtps.json b/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/smtps.json
index d0b0cc9a23b..ac31f77e34d 100644
--- a/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/smtps.json
+++ b/components/camel-mail/src/generated/resources/org/apache/camel/component/mail/smtps.json
@@ -40,7 +40,7 @@
"fetchSize": { "kind": "property", "displayName": "Fetch Size", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": -1, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the maximum number of messages to consume during a poll. This can be [...]
"folderName": { "kind": "property", "displayName": "Folder Name", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "INBOX", "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "The folder to poll." },
"generateMissingAttachmentNames": { "kind": "property", "displayName": "Generate Missing Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set this to 'uuid' to set a UUID for the filename of the atta [...]
- "handleDuplicateAttachmentNames": { "kind": "property", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachments [...]
+ "handleDuplicateAttachmentNames": { "kind": "property", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachments [...]
"mapMailMessage": { "kind": "property", "displayName": "Map Mail Message", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Specifies whether Camel should map the received mail message to Camel body\/head [...]
"bcc": { "kind": "property", "displayName": "Bcc", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the BCC email address. Separate multiple email addresses with comma." },
"cc": { "kind": "property", "displayName": "Cc", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the CC email address. Separate multiple email addresses with comma." },
@@ -107,7 +107,7 @@
"fetchSize": { "kind": "parameter", "displayName": "Fetch Size", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": -1, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Sets the maximum number of messages to consume during a poll. This can be [...]
"folderName": { "kind": "parameter", "displayName": "Folder Name", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "INBOX", "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "The folder to poll." },
"generateMissingAttachmentNames": { "kind": "parameter", "displayName": "Generate Missing Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set this to 'uuid' to set a UUID for the filename of the att [...]
- "handleDuplicateAttachmentNames": { "kind": "parameter", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachment [...]
+ "handleDuplicateAttachmentNames": { "kind": "parameter", "displayName": "Handle Duplicate Attachment Names", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Set the strategy to handle duplicate filenames of attachment [...]
"mailUidGenerator": { "kind": "parameter", "displayName": "Mail Uid Generator", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.mail.MailUidGenerator", "deprecated": false, "autowired": false, "secret": false, "description": "A pluggable MailUidGenerator that allows to use custom logic to generate UUID of the mail message." },
"mapMailMessage": { "kind": "parameter", "displayName": "Map Mail Message", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.mail.MailConfiguration", "configurationField": "configuration", "description": "Specifies whether Camel should map the received mail message to Camel body\/hea [...]
"pollStrategy": { "kind": "parameter", "displayName": "Poll Strategy", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.PollingConsumerPollStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the poll operation [...]
diff --git a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
index fa50312ada8..c812fce011c 100644
--- a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
+++ b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
@@ -386,9 +386,14 @@ public class MailBinding {
if (validDisposition(disposition, fileName)) {
LOG.debug("Mail contains file attachment: {}", fileName);
- if (handleDuplicateAttachmentNames != null && handleDuplicateAttachmentNames
+ if(handleDuplicateAttachmentNames != null){
+ if (handleDuplicateAttachmentNames
.equalsIgnoreCase(MailConstants.MAIL_HANDLE_DUPLICATE_ATTACHMENT_NAMES_UUID_PREFIX)) {
- fileName = handleDuplicateFilenames(map, fileName);
+ fileName = prefixDuplicateFilenames(map, fileName);
+ } else if(handleDuplicateAttachmentNames
+ .equalsIgnoreCase(MailConstants.MAIL_HANDLE_DUPLICATE_ATTACHMENT_NAMES_UUID_SUFFIX)){
+ fileName = suffixDuplicateFilenames(map, fileName);
+ }
}
if (!map.containsKey(fileName)) {
// Parts marked with a disposition of Part.ATTACHMENT are clearly attachments
@@ -434,7 +439,7 @@ public class MailBinding {
* @param fileName
* @return
*/
- private String handleDuplicateFilenames(Map<String, Attachment> map, String fileName) {
+ private String prefixDuplicateFilenames(Map<String, Attachment> map, String fileName) {
if (map.containsKey(fileName)) {
Attachment obj = map.remove(fileName);
map.put(prefixWithUUID(fileName), obj);
@@ -443,10 +448,38 @@ public class MailBinding {
return fileName;
}
+ /**
+ * Updates already existing filenames in the map and suffixes the current filename
+ * Filename will be suffixed, the file extension will remain
+ * If the string starts with a dot and no further dots are contained in the string,
+ * this is considered as a filename without file extension
+ *
+ * @param map
+ * @param fileName
+ * @return
+ */
+ private String suffixDuplicateFilenames(Map<String, Attachment> map, String fileName) {
+ if (map.containsKey(fileName)) {
+ Attachment obj = map.remove(fileName);
+ map.put(suffixWithUUID(fileName), obj);
+ return suffixWithUUID(fileName);
+ }
+ return fileName;
+ }
+
private String prefixWithUUID(String string) {
return UUID.randomUUID() + "_" + string;
}
+ private String suffixWithUUID(String string) {
+ if (string.lastIndexOf(".") > 0) {
+ string = new StringBuilder(string).insert(string.lastIndexOf("."), "_" + UUID.randomUUID()).toString();
+ } else {
+ string = string + "_" + UUID.randomUUID();
+ }
+ return string;
+ }
+
private boolean validDisposition(String disposition, String fileName) {
if (fileName == null || fileName.isEmpty()) {
return false;
diff --git a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
index ffe46c667cd..d1ec32b80f3 100644
--- a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
+++ b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
@@ -870,9 +870,10 @@ public class MailConfiguration implements Cloneable {
/**
* Set the strategy to handle duplicate filenames of attachments never: attachments that have a filename which is
- * already present in the attachments will be ignored unless failOnDuplicateFileAttachment is set to true
- * uuidPrefix: this will prefix the duplicate attachment filenames each with a uuid and underscore (uuid_)
- *
+ * already present in the attachments will be ignored unless failOnDuplicateFileAttachment is set to true.
+ * uuidPrefix: this will prefix the duplicate attachment filenames each with a uuid and underscore (uuid_filename.fileextension).
+ * uuidSuffix: this will suffix the duplicate attachment filenames each with a underscore and uuid (filename_uuid.fileextension).
+ *
* @param handleDuplicateAttachmentNames
*/
public void setHandleDuplicateAttachmentNames(String handleDuplicateAttachmentNames) {
diff --git a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConstants.java b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConstants.java
index ab995206085..8a8847ff03e 100644
--- a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConstants.java
+++ b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConstants.java
@@ -54,6 +54,7 @@ public final class MailConstants {
public static final String MAIL_GENERATE_MISSING_ATTACHMENT_NAMES_UUID = "uuid";
public static final String MAIL_HANDLE_DUPLICATE_ATTACHMENT_NAMES_NEVER = "never";
public static final String MAIL_HANDLE_DUPLICATE_ATTACHMENT_NAMES_UUID_PREFIX = "uuidPrefix";
+ public static final String MAIL_HANDLE_DUPLICATE_ATTACHMENT_NAMES_UUID_SUFFIX = "uuidSuffix";
private MailConstants() {
// utility class
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentNamesTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentNamesTest.java
index 7a40f9115c5..4e08ca8440b 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentNamesTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentNamesTest.java
@@ -44,6 +44,7 @@ import org.jvnet.mock_javamail.Mailbox;
public class MailAttachmentNamesTest extends CamelTestSupport {
+ public static final String UUID_EXPRESSION = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
MockEndpoint resultEndpoint;
MockEndpoint resultDefaultEndpoint;
Session session;
@@ -70,7 +71,12 @@ public class MailAttachmentNamesTest extends CamelTestSupport {
return new RoutesBuilder[] { new RouteBuilder() {
public void configure() {
from("pop3://james@localhost?password=foo&initialDelay=100&delay=100&generateMissingAttachmentNames=uuid&handleDuplicateAttachmentNames=uuidPrefix")
- .to("mock:result");
+ .to("mock:result");
+ }
+ }, new RouteBuilder() {
+ public void configure() {
+ from("pop3://suffix@localhost?password=foo&initialDelay=100&delay=100&generateMissingAttachmentNames=uuid&handleDuplicateAttachmentNames=uuidSuffix")
+ .to("mock:result");
}
}, new RouteBuilder() {
public void configure() {
@@ -172,6 +178,66 @@ public class MailAttachmentNamesTest extends CamelTestSupport {
Assert.assertNull(exchange.getIn(AttachmentMessage.class).getAttachmentObjects());
}
+ @Test
+ public void testAttachmentWithDuplicateFilenameSuffix() throws Exception {
+ sendTestMessage("filename_duplicate.txt", "suffix@localhost");
+
+ resultEndpoint.assertIsSatisfied();
+ Exchange exchange = resultEndpoint.getReceivedExchanges().get(0);
+ Assert.assertEquals(2, exchange.getIn(AttachmentMessage.class).getAttachmentObjects().entrySet().size());
+
+ Map<String, Attachment> attachments = exchange.getIn(AttachmentMessage.class).getAttachmentObjects();
+ for (Map.Entry<String, Attachment> entry : attachments.entrySet()) {
+ Pattern guidPattern = Pattern.compile("^Capture\\_" + UUID_EXPRESSION + "\\.PNG$");
+ Assert.assertTrue(guidPattern.matcher(entry.getKey()).matches());
+ }
+ }
+
+ @Test
+ public void testAttachmentWithDuplicateFilenameSuffixMultipleDots() throws Exception {
+ sendTestMessage("filename_duplicate_multiple_dots.txt", "suffix@localhost");
+
+ resultEndpoint.assertIsSatisfied();
+ Exchange exchange = resultEndpoint.getReceivedExchanges().get(0);
+ Assert.assertEquals(2, exchange.getIn(AttachmentMessage.class).getAttachmentObjects().entrySet().size());
+
+ Map<String, Attachment> attachments = exchange.getIn(AttachmentMessage.class).getAttachmentObjects();
+ for (Map.Entry<String, Attachment> entry : attachments.entrySet()) {
+ Pattern guidPattern = Pattern.compile("^\\.file.name\\_" + UUID_EXPRESSION + "\\.PNG$");
+ Assert.assertTrue(guidPattern.matcher(entry.getKey()).matches());
+ }
+ }
+
+ @Test
+ public void testAttachmentWithDuplicateFilenameSuffixNoExtension() throws Exception {
+ sendTestMessage("filename_duplicate_no_extension.txt", "suffix@localhost");
+
+ resultEndpoint.assertIsSatisfied();
+ Exchange exchange = resultEndpoint.getReceivedExchanges().get(0);
+ Assert.assertEquals(2, exchange.getIn(AttachmentMessage.class).getAttachmentObjects().entrySet().size());
+
+ Map<String, Attachment> attachments = exchange.getIn(AttachmentMessage.class).getAttachmentObjects();
+ for (Map.Entry<String, Attachment> entry : attachments.entrySet()) {
+ Pattern guidPattern = Pattern.compile("^Capture\\_" + UUID_EXPRESSION + "$");
+ Assert.assertTrue(guidPattern.matcher(entry.getKey()).matches());
+ }
+ }
+
+ @Test
+ public void testAttachmentWithDuplicateFilenameSuffixStartsWithDot() throws Exception {
+ sendTestMessage("filename_duplicate_single_dot_at_beginning.txt", "suffix@localhost");
+
+ resultEndpoint.assertIsSatisfied();
+ Exchange exchange = resultEndpoint.getReceivedExchanges().get(0);
+ Assert.assertEquals(2, exchange.getIn(AttachmentMessage.class).getAttachmentObjects().entrySet().size());
+
+ Map<String, Attachment> attachments = exchange.getIn(AttachmentMessage.class).getAttachmentObjects();
+ for (Map.Entry<String, Attachment> entry : attachments.entrySet()) {
+ Pattern guidPattern = Pattern.compile("^\\.fileName\\_" + UUID_EXPRESSION + "$");
+ Assert.assertTrue(guidPattern.matcher(entry.getKey()).matches());
+ }
+ }
+
private void sendTestMessage(String filename, String recipient) throws MessagingException, FileNotFoundException {
MimeMessage message = populateMimeMessage(session, filename);
message.setRecipients(Message.RecipientType.TO, recipient);
@@ -187,12 +253,12 @@ public class MailAttachmentNamesTest extends CamelTestSupport {
}
private boolean isUUID(String id) {
- Pattern guidPattern = Pattern.compile("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$");
+ Pattern guidPattern = Pattern.compile("^" + UUID_EXPRESSION + "$");
return guidPattern.matcher(id).matches();
}
private boolean startsWithUUID(String id) {
- Pattern guidPattern = Pattern.compile("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\_.*$");
+ Pattern guidPattern = Pattern.compile("^" + UUID_EXPRESSION + "\\_.*$");
return guidPattern.matcher(id).matches();
}
diff --git a/components/camel-mail/src/test/resources/filename_duplicate_multiple_dots.txt b/components/camel-mail/src/test/resources/filename_duplicate_multiple_dots.txt
new file mode 100644
index 00000000000..ad1dd62e6a7
--- /dev/null
+++ b/components/camel-mail/src/test/resources/filename_duplicate_multiple_dots.txt
@@ -0,0 +1,62 @@
+From: "Lastname, Firstname" <fi...@company.com>
+To: "receiver@company.com" <re...@company.com>
+Subject: Duplicate attachment names
+Date: Tue, 6 Sep 2022 18:19:49 +0000
+Accept-Language: en-DE, de-DE, en-US
+Content-Language: en-US
+Content-Type: multipart/mixed;
+ boundary="_005_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_"
+MIME-Version: 1.0
+
+--_005_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_
+Content-Type: multipart/alternative;
+ boundary="_000_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_"
+
+--_000_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_
+Content-Type: text/plain; charset="us-ascii"
+Content-Transfer-Encoding: quoted-printable
+
+
+
+--_000_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_
+Content-Type: text/html; charset="us-ascii"
+Content-Transfer-Encoding: quoted-printable
+
+<html>
+<body>
+</body>
+</html>
+
+--_000_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_--
+
+--_005_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_
+Content-Type: image/png; name=".file.name.PNG"
+Content-Description: .file.name.PNG
+Content-Disposition: attachment; filename=".file.name.PNG"; size=300;
+ creation-date="Tue, 06 Sep 2022 18:19:00 GMT";
+ modification-date="Tue, 06 Sep 2022 18:19:48 GMT"
+Content-Transfer-Encoding: base64
+
+iVBORw0KGgoAAAANSUhEUgAAACoAAAAfCAYAAACRdF9FAAAAAXNSR0IArs4c6QAAAARnQU1BAACx
+jwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADBSURBVFhH7dRLEoIwEIRhb8IjgNdA8f5XgvQi
+1ixanEwCStUsvg2E9L/i1g6P9ZMmzPQ5dOPzVB5a226oxD4+k4fW5qG1eWht1wkNA38BTQyU2vgs
+B7sTsLm3m/TT8qYOZSHfsDvBFMoOJCWRwO7MoQ5l49DFD4G9k+RQqezQFPm3oTJQiw1aqUJZhAYb
+tDo0NNxfRdShbDyHHCrlocAGrTwU2KCVhwIbtLpuKDt0FPaTl+RZD9VgcZI8+9NQvWXdAIrhycI/
+5FwqAAAAAElFTkSuQmCC
+
+--_005_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_
+Content-Type: image/png; name=".file.name.PNG"
+Content-Description: .file.name.PNG
+Content-Disposition: attachment; filename=".file.name.PNG"; size=300;
+ creation-date="Tue, 06 Sep 2022 18:19:00 GMT";
+ modification-date="Tue, 06 Sep 2022 18:19:48 GMT"
+Content-Transfer-Encoding: base64
+
+iVBORw0KGgoAAAANSUhEUgAAACoAAAAfCAYAAACRdF9FAAAAAXNSR0IArs4c6QAAAARnQU1BAACx
+jwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADBSURBVFhH7dRLEoIwEIRhb8IjgNdA8f5XgvQi
+1ixanEwCStUsvg2E9L/i1g6P9ZMmzPQ5dOPzVB5a226oxD4+k4fW5qG1eWht1wkNA38BTQyU2vgs
+B7sTsLm3m/TT8qYOZSHfsDvBFMoOJCWRwO7MoQ5l49DFD4G9k+RQqezQFPm3oTJQiw1aqUJZhAYb
+tDo0NNxfRdShbDyHHCrlocAGrTwU2KCVhwIbtLpuKDt0FPaTl+RZD9VgcZI8+9NQvWXdAIrhycI/
+5FwqAAAAAElFTkSuQmCC
+
+--_005_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_--
diff --git a/components/camel-mail/src/test/resources/filename_duplicate_no_extension.txt b/components/camel-mail/src/test/resources/filename_duplicate_no_extension.txt
new file mode 100644
index 00000000000..7c774bef88b
--- /dev/null
+++ b/components/camel-mail/src/test/resources/filename_duplicate_no_extension.txt
@@ -0,0 +1,62 @@
+From: "Lastname, Firstname" <fi...@company.com>
+To: "receiver@company.com" <re...@company.com>
+Subject: Duplicate attachment names
+Date: Tue, 6 Sep 2022 18:19:49 +0000
+Accept-Language: en-DE, de-DE, en-US
+Content-Language: en-US
+Content-Type: multipart/mixed;
+ boundary="_005_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_"
+MIME-Version: 1.0
+
+--_005_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_
+Content-Type: multipart/alternative;
+ boundary="_000_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_"
+
+--_000_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_
+Content-Type: text/plain; charset="us-ascii"
+Content-Transfer-Encoding: quoted-printable
+
+
+
+--_000_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_
+Content-Type: text/html; charset="us-ascii"
+Content-Transfer-Encoding: quoted-printable
+
+<html>
+<body>
+</body>
+</html>
+
+--_000_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_--
+
+--_005_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_
+Content-Type: image/png; name="Capture"
+Content-Description: Capture
+Content-Disposition: attachment; filename="Capture"; size=300;
+ creation-date="Tue, 06 Sep 2022 18:19:00 GMT";
+ modification-date="Tue, 06 Sep 2022 18:19:48 GMT"
+Content-Transfer-Encoding: base64
+
+iVBORw0KGgoAAAANSUhEUgAAACoAAAAfCAYAAACRdF9FAAAAAXNSR0IArs4c6QAAAARnQU1BAACx
+jwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADBSURBVFhH7dRLEoIwEIRhb8IjgNdA8f5XgvQi
+1ixanEwCStUsvg2E9L/i1g6P9ZMmzPQ5dOPzVB5a226oxD4+k4fW5qG1eWht1wkNA38BTQyU2vgs
+B7sTsLm3m/TT8qYOZSHfsDvBFMoOJCWRwO7MoQ5l49DFD4G9k+RQqezQFPm3oTJQiw1aqUJZhAYb
+tDo0NNxfRdShbDyHHCrlocAGrTwU2KCVhwIbtLpuKDt0FPaTl+RZD9VgcZI8+9NQvWXdAIrhycI/
+5FwqAAAAAElFTkSuQmCC
+
+--_005_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_
+Content-Type: image/png; name="Capture"
+Content-Description: Capture
+Content-Disposition: attachment; filename="Capture"; size=300;
+ creation-date="Tue, 06 Sep 2022 18:19:00 GMT";
+ modification-date="Tue, 06 Sep 2022 18:19:48 GMT"
+Content-Transfer-Encoding: base64
+
+iVBORw0KGgoAAAANSUhEUgAAACoAAAAfCAYAAACRdF9FAAAAAXNSR0IArs4c6QAAAARnQU1BAACx
+jwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADBSURBVFhH7dRLEoIwEIRhb8IjgNdA8f5XgvQi
+1ixanEwCStUsvg2E9L/i1g6P9ZMmzPQ5dOPzVB5a226oxD4+k4fW5qG1eWht1wkNA38BTQyU2vgs
+B7sTsLm3m/TT8qYOZSHfsDvBFMoOJCWRwO7MoQ5l49DFD4G9k+RQqezQFPm3oTJQiw1aqUJZhAYb
+tDo0NNxfRdShbDyHHCrlocAGrTwU2KCVhwIbtLpuKDt0FPaTl+RZD9VgcZI8+9NQvWXdAIrhycI/
+5FwqAAAAAElFTkSuQmCC
+
+--_005_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_--
diff --git a/components/camel-mail/src/test/resources/filename_duplicate_single_dot_at_beginning.txt b/components/camel-mail/src/test/resources/filename_duplicate_single_dot_at_beginning.txt
new file mode 100644
index 00000000000..4e331fdeee5
--- /dev/null
+++ b/components/camel-mail/src/test/resources/filename_duplicate_single_dot_at_beginning.txt
@@ -0,0 +1,62 @@
+From: "Lastname, Firstname" <fi...@company.com>
+To: "receiver@company.com" <re...@company.com>
+Subject: Duplicate attachment names
+Date: Tue, 6 Sep 2022 18:19:49 +0000
+Accept-Language: en-DE, de-DE, en-US
+Content-Language: en-US
+Content-Type: multipart/mixed;
+ boundary="_005_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_"
+MIME-Version: 1.0
+
+--_005_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_
+Content-Type: multipart/alternative;
+ boundary="_000_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_"
+
+--_000_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_
+Content-Type: text/plain; charset="us-ascii"
+Content-Transfer-Encoding: quoted-printable
+
+
+
+--_000_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_
+Content-Type: text/html; charset="us-ascii"
+Content-Transfer-Encoding: quoted-printable
+
+<html>
+<body>
+</body>
+</html>
+
+--_000_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_--
+
+--_005_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_
+Content-Type: image/png; name=".fileName"
+Content-Description: .fileName
+Content-Disposition: attachment; filename=".fileName"; size=300;
+ creation-date="Tue, 06 Sep 2022 18:19:00 GMT";
+ modification-date="Tue, 06 Sep 2022 18:19:48 GMT"
+Content-Transfer-Encoding: base64
+
+iVBORw0KGgoAAAANSUhEUgAAACoAAAAfCAYAAACRdF9FAAAAAXNSR0IArs4c6QAAAARnQU1BAACx
+jwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADBSURBVFhH7dRLEoIwEIRhb8IjgNdA8f5XgvQi
+1ixanEwCStUsvg2E9L/i1g6P9ZMmzPQ5dOPzVB5a226oxD4+k4fW5qG1eWht1wkNA38BTQyU2vgs
+B7sTsLm3m/TT8qYOZSHfsDvBFMoOJCWRwO7MoQ5l49DFD4G9k+RQqezQFPm3oTJQiw1aqUJZhAYb
+tDo0NNxfRdShbDyHHCrlocAGrTwU2KCVhwIbtLpuKDt0FPaTl+RZD9VgcZI8+9NQvWXdAIrhycI/
+5FwqAAAAAElFTkSuQmCC
+
+--_005_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_
+Content-Type: image/png; name=".fileName"
+Content-Description: .fileName
+Content-Disposition: attachment; filename=".fileName"; size=300;
+ creation-date="Tue, 06 Sep 2022 18:19:00 GMT";
+ modification-date="Tue, 06 Sep 2022 18:19:48 GMT"
+Content-Transfer-Encoding: base64
+
+iVBORw0KGgoAAAANSUhEUgAAACoAAAAfCAYAAACRdF9FAAAAAXNSR0IArs4c6QAAAARnQU1BAACx
+jwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADBSURBVFhH7dRLEoIwEIRhb8IjgNdA8f5XgvQi
+1ixanEwCStUsvg2E9L/i1g6P9ZMmzPQ5dOPzVB5a226oxD4+k4fW5qG1eWht1wkNA38BTQyU2vgs
+B7sTsLm3m/TT8qYOZSHfsDvBFMoOJCWRwO7MoQ5l49DFD4G9k+RQqezQFPm3oTJQiw1aqUJZhAYb
+tDo0NNxfRdShbDyHHCrlocAGrTwU2KCVhwIbtLpuKDt0FPaTl+RZD9VgcZI8+9NQvWXdAIrhycI/
+5FwqAAAAAElFTkSuQmCC
+
+--_005_AM9PR02MB741019D4290F345E6F3C4370E87E9AM9PR02MB7410eurp_--