You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2021/12/09 13:18:34 UTC
[camel] 01/06: CAMEL-17291 - Camel-AWS2-SES: Don't set the replyTo/to addresses as List
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 96c6b568eaf84be80d4833f6a7f4a73f33dc63d1
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Dec 9 13:45:09 2021 +0100
CAMEL-17291 - Camel-AWS2-SES: Don't set the replyTo/to addresses as List
---
.../component/aws2/ses/Ses2Configuration.java | 29 +++++++---------------
.../camel/component/aws2/ses/Ses2Producer.java | 23 +++++++++++------
2 files changed, 24 insertions(+), 28 deletions(-)
diff --git a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Configuration.java b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Configuration.java
index a5519d7..376e702 100644
--- a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Configuration.java
+++ b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Configuration.java
@@ -16,7 +16,6 @@
*/
package org.apache.camel.component.aws2.ses;
-import java.util.Arrays;
import java.util.List;
import org.apache.camel.RuntimeCamelException;
@@ -43,11 +42,11 @@ public class Ses2Configuration implements Cloneable {
@UriParam
private String subject;
@UriParam
- private List<String> to;
+ private String to;
@UriParam
private String returnPath;
@UriParam
- private List<String> replyToAddresses;
+ private String replyToAddresses;
@UriParam(enums = "HTTP,HTTPS", defaultValue = "HTTPS")
private Protocol proxyProtocol = Protocol.HTTPS;
@UriParam
@@ -98,22 +97,15 @@ public class Ses2Configuration implements Cloneable {
this.from = from;
}
- public List<String> getTo() {
+ public String getTo() {
return to;
}
/**
- * List of destination email address. Can be overriden with 'CamelAwsSesTo' header.
- */
- public void setTo(List<String> to) {
- this.to = to;
- }
-
- /**
- * List of destination email address. Can be overriden with 'CamelAwsSesTo' header.
+ * List of comma separated destination email address. Can be overriden with 'CamelAwsSesTo' header.
*/
public void setTo(String to) {
- this.to = Arrays.asList(to.split(","));
+ this.to = to;
}
public String getSecretKey() {
@@ -150,19 +142,16 @@ public class Ses2Configuration implements Cloneable {
this.returnPath = returnPath;
}
- public List<String> getReplyToAddresses() {
+ public String getReplyToAddresses() {
return replyToAddresses;
}
/**
- * List of reply-to email address(es) for the message, override it using 'CamelAwsSesReplyToAddresses' header.
+ * List of comma separated reply-to email address(es) for the message, override it using
+ * 'CamelAwsSesReplyToAddresses' header.
*/
- public void setReplyToAddresses(List<String> replyToAddresses) {
- this.replyToAddresses = replyToAddresses;
- }
-
public void setReplyToAddresses(String replyToAddresses) {
- this.replyToAddresses = Arrays.asList(replyToAddresses.split(","));
+ this.replyToAddresses = replyToAddresses;
}
public Protocol getProxyProtocol() {
diff --git a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Producer.java b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Producer.java
index de68af4..aedf021 100644
--- a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Producer.java
+++ b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Producer.java
@@ -21,6 +21,8 @@ import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
@@ -122,11 +124,13 @@ public class Ses2Producer extends DefaultProducer {
@SuppressWarnings("unchecked")
private Collection<String> determineReplyToAddresses(Exchange exchange) {
- List<String> replyToAddresses = exchange.getIn().getHeader(Ses2Constants.REPLY_TO_ADDRESSES, List.class);
+ String replyToAddresses = exchange.getIn().getHeader(Ses2Constants.REPLY_TO_ADDRESSES, String.class);
if (replyToAddresses == null) {
replyToAddresses = getConfiguration().getReplyToAddresses();
}
- return replyToAddresses;
+ return Stream.of(replyToAddresses.split(","))
+ .map(String::trim)
+ .collect(Collectors.toList());
}
private String determineReturnPath(Exchange exchange) {
@@ -137,22 +141,25 @@ public class Ses2Producer extends DefaultProducer {
return returnPath;
}
- @SuppressWarnings("unchecked")
private Destination determineTo(Exchange exchange) {
- List<String> to = exchange.getIn().getHeader(Ses2Constants.TO, List.class);
+ String to = exchange.getIn().getHeader(Ses2Constants.TO, String.class);
if (to == null) {
to = getConfiguration().getTo();
}
- return Destination.builder().toAddresses(to).build();
+ List<String> destinations = Stream.of(to.split(","))
+ .map(String::trim)
+ .collect(Collectors.toList());
+ return Destination.builder().toAddresses(destinations).build();
}
- @SuppressWarnings("unchecked")
private List<String> determineRawTo(Exchange exchange) {
- List<String> to = exchange.getIn().getHeader(Ses2Constants.TO, List.class);
+ String to = exchange.getIn().getHeader(Ses2Constants.TO, String.class);
if (to == null) {
to = getConfiguration().getTo();
}
- return to;
+ return Stream.of(to.split(","))
+ .map(String::trim)
+ .collect(Collectors.toList());
}
private String determineFrom(Exchange exchange) {