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 2018/08/07 11:14:40 UTC
[camel] branch master updated: CAMEL-12590: Fixed Type converter
confusion when camel-cxf and camel-mail are in same classpath. SortTerm
should not be a type converter there is no such need,
just call it directly from the mail component like we do for search term.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 129f9ab CAMEL-12590: Fixed Type converter confusion when camel-cxf and camel-mail are in same classpath. SortTerm should not be a type converter there is no such need, just call it directly from the mail component like we do for search term.
129f9ab is described below
commit 129f9abf911b081743cf33f5d2fff227c2f03b97
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Aug 7 13:14:23 2018 +0200
CAMEL-12590: Fixed Type converter confusion when camel-cxf and camel-mail are in same classpath. SortTerm should not be a type converter there is no such need, just call it directly from the mail component like we do for search term.
---
.../org/apache/camel/component/mail/MailComponent.java | 16 ++++++++++++++++
.../org/apache/camel/component/mail/MailConverters.java | 9 +++++++--
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java
index 2a51481..21b28d0 100644
--- a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java
+++ b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java
@@ -22,6 +22,7 @@ import java.util.Map;
import java.util.Set;
import javax.mail.search.SearchTerm;
+import com.sun.mail.imap.SortTerm;
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
import org.apache.camel.SSLContextParametersAware;
@@ -83,6 +84,21 @@ public class MailComponent extends UriEndpointComponent implements SSLContextPar
endpoint.setSearchTerm(st);
}
+ // special for sort term
+ Object sortTerm = getAndRemoveOrResolveReferenceParameter(parameters, "sortTerm", Object.class);
+ if (sortTerm != null) {
+ SortTerm[] st;
+ if (sortTerm instanceof String) {
+ // okay its a String then lets convert that to SortTerm
+ st = MailConverters.toSortTerm((String) sortTerm);
+ } else if (sortTerm instanceof SortTerm[]) {
+ st = (SortTerm[]) sortTerm;
+ } else {
+ throw new IllegalArgumentException("SortTerm must either be SortTerm[] or a String value");
+ }
+ endpoint.setSortTerm(st);
+ }
+
endpoint.setContentTypeResolver(contentTypeResolver);
setProperties(endpoint.getConfiguration(), parameters);
setProperties(endpoint, parameters);
diff --git a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConverters.java b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConverters.java
index de1a56f..33c28fd 100644
--- a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConverters.java
+++ b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConverters.java
@@ -141,6 +141,11 @@ public final class MailConverters {
return null;
}
+ /**
+ * Converters the simple search term builder to search term.
+ *
+ * This should not be a @Converter method
+ */
public static SearchTerm toSearchTerm(SimpleSearchTerm simple, TypeConverter typeConverter) throws ParseException, NoTypeConversionAvailableException {
SearchTermBuilder builder = new SearchTermBuilder();
if (simple.isUnseen()) {
@@ -214,9 +219,9 @@ public final class MailConverters {
}
/*
- * Converts from comma separated list of sort terms to SortTerm obj array
+ * Converts from comma separated list of sort terms to SortTerm obj array.
+ * This should not be a @Converter method
*/
- @Converter
public static SortTerm[] toSortTerm(String sortTerm) {
ArrayList<SortTerm> result = new ArrayList<>();