Author: matthieu
Date: Fri Dec 11 12:34:37 2015
New Revision: 1719390

URL: http://svn.apache.org/viewvc?rev=1719390&view=rev
Log:
JAMES-1644 Handle Reply-To standard header

Modified:
    
james/project/trunk/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollection.java
    
james/project/trunk/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessage.java
    
james/project/trunk/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/JsonMessageConstants.java
    
james/project/trunk/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollectionTest.java
    
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/htmlMail.json
    
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/mail.json
    
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/nonTextual.json
    
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/pgpSignedMail.json
    
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/recursiveMail.json
    
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/spamMail.json

Modified: 
james/project/trunk/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollection.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollection.java?rev=1719390&r1=1719389&r2=1719390&view=diff
==============================================================================
--- 
james/project/trunk/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollection.java
 (original)
+++ 
james/project/trunk/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollection.java
 Fri Dec 11 12:34:37 2015
@@ -61,6 +61,7 @@ public class HeaderCollection {
         private final Set<EMailer> fromAddressSet;
         private final Set<EMailer> ccAddressSet;
         private final Set<EMailer> bccAddressSet;
+        private final Set<EMailer> replyToAddressSet;
         private final Set<String> subjectSet;
         private final Multimap<String, String> headers;
         private Optional<ZonedDateTime> sentDate;
@@ -70,6 +71,7 @@ public class HeaderCollection {
             fromAddressSet = new HashSet<>();
             ccAddressSet = new HashSet<>();
             bccAddressSet = new HashSet<>();
+            replyToAddressSet = new HashSet<>();
             subjectSet = new HashSet<>();
             headers = ArrayListMultimap.create();
             sentDate = Optional.empty();
@@ -90,6 +92,7 @@ public class HeaderCollection {
                 ImmutableSet.copyOf(fromAddressSet),
                 ImmutableSet.copyOf(ccAddressSet),
                 ImmutableSet.copyOf(bccAddressSet),
+                ImmutableSet.copyOf(replyToAddressSet),
                 ImmutableSet.copyOf(subjectSet),
                 ImmutableMultimap.copyOf(headers),
                 sentDate);
@@ -101,6 +104,7 @@ public class HeaderCollection {
                 case FROM:
                 case CC:
                 case BCC:
+                case REPLY_TO:
                     manageAddressField(headerName, headerValue);
                     break;
                 case SUBJECT:
@@ -140,6 +144,8 @@ public class HeaderCollection {
                     return ccAddressSet;
                 case BCC:
                     return bccAddressSet;
+                case REPLY_TO:
+                    return replyToAddressSet;
             }
             throw new RuntimeException(headerName + " is not a address header 
name");
         }
@@ -172,6 +178,7 @@ public class HeaderCollection {
     public static final String FROM = "from";
     public static final String CC = "cc";
     public static final String BCC = "bcc";
+    public static final String REPLY_TO = "reply-to";
     public static final String SUBJECT = "subject";
     public static final String DATE = "date";
 
@@ -185,17 +192,19 @@ public class HeaderCollection {
     private final ImmutableSet<EMailer> fromAddressSet;
     private final ImmutableSet<EMailer> ccAddressSet;
     private final ImmutableSet<EMailer> bccAddressSet;
+    private final ImmutableSet<EMailer> replyToAddressSet;
     private final ImmutableSet<String> subjectSet;
     private final ImmutableMultimap<String, String> headers;
     private Optional<ZonedDateTime> sentDate;
 
     private HeaderCollection(ImmutableSet<EMailer> toAddressSet, 
ImmutableSet<EMailer> fromAddressSet,
-        ImmutableSet<EMailer> ccAddressSet, ImmutableSet<EMailer> 
bccAddressSet, ImmutableSet<String> subjectSet,
+        ImmutableSet<EMailer> ccAddressSet, ImmutableSet<EMailer> 
bccAddressSet, ImmutableSet<EMailer> replyToAddressSet, ImmutableSet<String> 
subjectSet,
         ImmutableMultimap<String, String> headers, Optional<ZonedDateTime> 
sentDate) {
         this.toAddressSet = toAddressSet;
         this.fromAddressSet = fromAddressSet;
         this.ccAddressSet = ccAddressSet;
         this.bccAddressSet = bccAddressSet;
+        this.replyToAddressSet = replyToAddressSet;
         this.subjectSet = subjectSet;
         this.headers = headers;
         this.sentDate = sentDate;
@@ -217,6 +226,10 @@ public class HeaderCollection {
         return bccAddressSet;
     }
 
+    public Set<EMailer> getReplyToAddressSet() {
+        return replyToAddressSet;
+    }
+
     public Set<String> getSubjectSet() {
         return subjectSet;
     }

Modified: 
james/project/trunk/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessage.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessage.java?rev=1719390&r1=1719389&r2=1719390&view=diff
==============================================================================
--- 
james/project/trunk/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessage.java
 (original)
+++ 
james/project/trunk/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessage.java
 Fri Dec 11 12:34:37 2015
@@ -67,6 +67,7 @@ public class IndexableMessage {
         this.subjects = headerCollection.getSubjectSet();
         this.from = headerCollection.getFromAddressSet();
         this.to = headerCollection.getToAddressSet();
+        this.replyTo = headerCollection.getReplyToAddressSet();
         this.cc = headerCollection.getCcAddressSet();
         this.bcc = headerCollection.getBccAddressSet();
         this.sentDate = 
DateResolutionFormater.DATE_TIME_FOMATTER.format(headerCollection.getSentDate().orElse(internalDate));
@@ -118,6 +119,7 @@ public class IndexableMessage {
     private Set<EMailer> to;
     private Set<EMailer> cc;
     private Set<EMailer> bcc;
+    private Set<EMailer> replyTo;
     private Set<String> subjects;
     private String sentDate;
     private List<Property> properties;
@@ -224,6 +226,11 @@ public class IndexableMessage {
         return bcc;
     }
 
+    @JsonProperty(JsonMessageConstants.REPLY_TO)
+    public Set<EMailer> getReplyTo() {
+        return replyTo;
+    }
+
     @JsonProperty(JsonMessageConstants.SENT_DATE)
     public String getSentDate() {
         return sentDate;

Modified: 
james/project/trunk/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/JsonMessageConstants.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/JsonMessageConstants.java?rev=1719390&r1=1719389&r2=1719390&view=diff
==============================================================================
--- 
james/project/trunk/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/JsonMessageConstants.java
 (original)
+++ 
james/project/trunk/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/JsonMessageConstants.java
 Fri Dec 11 12:34:37 2015
@@ -35,6 +35,7 @@ public interface JsonMessageConstants {
     String TO = "to";
     String CC = "cc";
     String BCC = "bcc";
+    String REPLY_TO = "replyTo";
     String SUBJECT = "subject";
     String DATE = "date";
     String SIZE = "size";

Modified: 
james/project/trunk/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollectionTest.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollectionTest.java?rev=1719390&r1=1719389&r2=1719390&view=diff
==============================================================================
--- 
james/project/trunk/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollectionTest.java
 (original)
+++ 
james/project/trunk/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollectionTest.java
 Fri Dec 11 12:34:37 2015
@@ -86,6 +86,13 @@ public class HeaderCollectionTest {
     }
 
     @Test
+    public void displayNamesShouldBeRetreivedOnReplyTo() {
+        HeaderCollection headerCollection = HeaderCollection.builder().add(new 
FieldImpl("Reply-To", "Christophe Hamerling 
<[email protected]>")).build();
+        assertThat(headerCollection.getReplyToAddressSet())
+            .containsOnly(new EMailer("Christophe Hamerling", 
"[email protected]"));
+    }
+
+    @Test
     public void displayNamesShouldBeRetreivedOnBcc() {
         HeaderCollection headerCollection = HeaderCollection.builder().add(new 
FieldImpl("Bcc", "Christophe Hamerling <[email protected]>")).build();
         assertThat(headerCollection.getBccAddressSet())

Modified: 
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/htmlMail.json
URL: 
http://svn.apache.org/viewvc/james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/htmlMail.json?rev=1719390&r1=1719389&r2=1719390&view=diff
==============================================================================
--- 
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/htmlMail.json
 (original)
+++ 
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/htmlMail.json
 Fri Dec 11 12:34:37 2015
@@ -93,6 +93,7 @@
   ],
   "cc":[],
   "bcc":[],
+  "replyTo":[],
   "subject":[
     "Regardez les meilleures destinations depuis Paris"
   ],

Modified: 
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/mail.json
URL: 
http://svn.apache.org/viewvc/james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/mail.json?rev=1719390&r1=1719389&r2=1719390&view=diff
==============================================================================
--- 
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/mail.json
 (original)
+++ 
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/mail.json
 Fri Dec 11 12:34:37 2015
@@ -132,6 +132,7 @@
  ],
  "cc": [],
  "bcc": [],
+ "replyTo": [{"name":"General Discussion about Arch 
Linux","address":"[email protected]"}],
  "subject": [
   "[arch-general] Inkscape fails to open svg files"
  ],
@@ -162,4 +163,4 @@
  "isRecent": false,
  "hasAttachment": false,
  "isUnread": false
-}
\ No newline at end of file
+}

Modified: 
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/nonTextual.json
URL: 
http://svn.apache.org/viewvc/james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/nonTextual.json?rev=1719390&r1=1719389&r2=1719390&view=diff
==============================================================================
--- 
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/nonTextual.json
 (original)
+++ 
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/nonTextual.json
 Fri Dec 11 12:34:37 2015
@@ -56,6 +56,7 @@
   ],
   "cc":[],
   "bcc":[],
+  "replyTo":[],
   "subject":["Test message"],
   "sentDate":"2015-06-18T12:43:26+0200",
   "properties":[

Modified: 
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/pgpSignedMail.json
URL: 
http://svn.apache.org/viewvc/james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/pgpSignedMail.json?rev=1719390&r1=1719389&r2=1719390&view=diff
==============================================================================
--- 
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/pgpSignedMail.json
 (original)
+++ 
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/pgpSignedMail.json
 Fri Dec 11 12:34:37 2015
@@ -139,6 +139,7 @@
   ],
   "cc": [],
   "bcc": [],
+  "replyTo": 
[{"name":"[email protected]","address":"[email protected]"}],
   "subject": [
        "[SECURITY] [DSA 3278-1] libapache-mod-jk security update"
   ],
@@ -169,4 +170,4 @@
   "isRecent": false,
   "hasAttachment": false,
   "isUnread": false
-}
\ No newline at end of file
+}

Modified: 
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/recursiveMail.json
URL: 
http://svn.apache.org/viewvc/james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/recursiveMail.json?rev=1719390&r1=1719389&r2=1719390&view=diff
==============================================================================
--- 
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/recursiveMail.json
 (original)
+++ 
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/recursiveMail.json
 Fri Dec 11 12:34:37 2015
@@ -69,6 +69,7 @@
   ],
   "cc": [],
   "bcc": [],
+  "replyTo": [],
   "subject": [
     "Fwd: Courbe Sprint"
   ],
@@ -219,4 +220,4 @@
   "isDeleted": true,
   "hasAttachment": true,
   "isUnread": false
-}
\ No newline at end of file
+}

Modified: 
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/spamMail.json
URL: 
http://svn.apache.org/viewvc/james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/spamMail.json?rev=1719390&r1=1719389&r2=1719390&view=diff
==============================================================================
--- 
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/spamMail.json
 (original)
+++ 
james/project/trunk/mailbox/elasticsearch/src/test/resources/documents/spamMail.json
 Fri Dec 11 12:34:37 2015
@@ -100,6 +100,7 @@
   ],
   "cc": [],
   "bcc": [],
+  "replyTo": [],
   "subject": [
        "[root] UNCHECKED contents in mail FROM <[email protected]>"
   ],
@@ -197,4 +198,4 @@
   "isRecent": false,
   "hasAttachment": true,
   "isUnread": true
-}
\ No newline at end of file
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to