james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject svn commit: r1688135 - in /james/mailbox/trunk/elasticsearch/src: main/java/org/apache/james/mailbox/elasticsearch/json/ main/java/org/apache/james/mailbox/elasticsearch/query/ test/resources/documents/
Date Mon, 29 Jun 2015 08:37:10 GMT
Author: btellier
Date: Mon Jun 29 08:37:10 2015
New Revision: 1688135

URL: http://svn.apache.org/r1688135
Log:
MAILBOX-242 Implement a node provider in order to connect to ElasticSearch as a client node
- patch contributed by Antoine Duprat

Modified:
    james/mailbox/trunk/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessage.java
    james/mailbox/trunk/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/CriterionConverter.java
    james/mailbox/trunk/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/DateResolutionFormater.java
    james/mailbox/trunk/elasticsearch/src/test/resources/documents/htmlMail.json
    james/mailbox/trunk/elasticsearch/src/test/resources/documents/pgpSignedMail.json
    james/mailbox/trunk/elasticsearch/src/test/resources/documents/spamMail.json

Modified: james/mailbox/trunk/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessage.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessage.java?rev=1688135&r1=1688134&r2=1688135&view=diff
==============================================================================
--- james/mailbox/trunk/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessage.java
(original)
+++ james/mailbox/trunk/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessage.java
Mon Jun 29 08:37:10 2015
@@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.
 import com.google.common.base.Preconditions;
 import com.google.common.base.Throwables;
 import com.google.common.collect.Multimap;
+import org.apache.james.mailbox.elasticsearch.query.DateResolutionFormater;
 import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.mail.model.Message;
 import org.apache.james.mailbox.store.mail.model.Property;
@@ -33,7 +34,6 @@ import java.time.Instant;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
 
-import static java.time.format.DateTimeFormatter.ISO_OFFSET_DATE_TIME;
 import java.util.List;
 import java.util.Optional;
 import java.util.Set;
@@ -68,9 +68,7 @@ public class IndexableMessage {
         this.to = headerCollection.getToAddressSet();
         this.cc = headerCollection.getCcAddressSet();
         this.bcc = headerCollection.getBccAddressSet();
-        this.sentDate = ISO_OFFSET_DATE_TIME.format(
-            headerCollection.getSentDate()
-                .orElse(internalDate));
+        this.sentDate = DateResolutionFormater.DATE_TIME_FOMATTER.format(headerCollection.getSentDate().orElse(internalDate));
     }
 
     private void copyMessageFields(Message<? extends MailboxId> message) {
@@ -78,7 +76,7 @@ public class IndexableMessage {
         this.mailboxId = message.getMailboxId().serialize();
         this.modSeq = message.getModSeq();
         this.size = message.getFullContentOctets();
-        this.date = ISO_OFFSET_DATE_TIME.format(getSanitizedInternalDate(message));
+        this.date = DateResolutionFormater.DATE_TIME_FOMATTER.format(getSanitizedInternalDate(message));
         this.mediaType = message.getMediaType();
         this.subType = message.getSubType();
         this.isAnswered = message.isAnswered();

Modified: james/mailbox/trunk/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/CriterionConverter.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/CriterionConverter.java?rev=1688135&r1=1688134&r2=1688135&view=diff
==============================================================================
--- james/mailbox/trunk/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/CriterionConverter.java
(original)
+++ james/mailbox/trunk/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/CriterionConverter.java
Mon Jun 29 08:37:10 2015
@@ -40,7 +40,6 @@ import static org.elasticsearch.index.qu
 import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
 import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
 import static org.elasticsearch.index.query.QueryBuilders.nestedQuery;
-import static java.time.format.DateTimeFormatter.ISO_OFFSET_DATE_TIME;
 
 public class CriterionConverter {
 
@@ -129,8 +128,8 @@ public class CriterionConverter {
 
     private FilteredQueryRepresentation dateRangeFilter(String field, SearchQuery.DateOperator
dateOperator) {
         SearchQuery.DateResolution dateResolution = dateOperator.getDateResultion();
-        String lowDateString = ISO_OFFSET_DATE_TIME.format(DateResolutionFormater.computeLowerDate(DateResolutionFormater.convertDateToZonedDateTime(dateOperator.getDate()),
dateResolution));
-        String upDateString = ISO_OFFSET_DATE_TIME.format(
+        String lowDateString = DateResolutionFormater.DATE_TIME_FOMATTER.format(DateResolutionFormater.computeLowerDate(DateResolutionFormater.convertDateToZonedDateTime(dateOperator.getDate()),
dateResolution));
+        String upDateString = DateResolutionFormater.DATE_TIME_FOMATTER.format(
             DateResolutionFormater.computeUpperDate(
                 DateResolutionFormater.convertDateToZonedDateTime(dateOperator.getDate()),
                 dateResolution));

Modified: james/mailbox/trunk/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/DateResolutionFormater.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/DateResolutionFormater.java?rev=1688135&r1=1688134&r2=1688135&view=diff
==============================================================================
--- james/mailbox/trunk/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/DateResolutionFormater.java
(original)
+++ james/mailbox/trunk/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/DateResolutionFormater.java
Mon Jun 29 08:37:10 2015
@@ -26,10 +26,13 @@ import java.time.ZoneId;
 import java.time.ZonedDateTime;
 import java.time.temporal.ChronoUnit;
 import java.time.temporal.TemporalUnit;
+import java.time.format.DateTimeFormatter;
 import java.util.Date;
 
 public class DateResolutionFormater {
 
+    public static DateTimeFormatter DATE_TIME_FOMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ");
+
     public static ZonedDateTime computeUpperDate(ZonedDateTime date, SearchQuery.DateResolution
resolution) {
         return date.truncatedTo(convertDateResolutionField(resolution)).plus(1,convertDateResolutionField(resolution));
     }

Modified: james/mailbox/trunk/elasticsearch/src/test/resources/documents/htmlMail.json
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/elasticsearch/src/test/resources/documents/htmlMail.json?rev=1688135&r1=1688134&r2=1688135&view=diff
==============================================================================
--- james/mailbox/trunk/elasticsearch/src/test/resources/documents/htmlMail.json (original)
+++ james/mailbox/trunk/elasticsearch/src/test/resources/documents/htmlMail.json Mon Jun 29
08:37:10 2015
@@ -3,7 +3,7 @@
   "mailboxId":"18",
   "modSeq":42,
   "size":25,
-  "date":"2015-06-07T00:00:00+02:00",
+  "date":"2015-06-07T00:00:00+0200",
   "mediaType":"plain",
   "subtype":"text",
   "userFlags":["social","pocket-money"],
@@ -96,7 +96,7 @@
   "subject":[
     "Regardez les meilleures destinations depuis Paris"
   ],
-  "sentDate":"2015-06-04T07:36:08Z",
+  "sentDate":"2015-06-04T07:36:08+0000",
   "properties":[
     {
       "namespace":"http://james.apache.org/rfc2045/Content-Type",

Modified: james/mailbox/trunk/elasticsearch/src/test/resources/documents/pgpSignedMail.json
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/elasticsearch/src/test/resources/documents/pgpSignedMail.json?rev=1688135&r1=1688134&r2=1688135&view=diff
==============================================================================
--- james/mailbox/trunk/elasticsearch/src/test/resources/documents/pgpSignedMail.json (original)
+++ james/mailbox/trunk/elasticsearch/src/test/resources/documents/pgpSignedMail.json Mon
Jun 29 08:37:10 2015
@@ -3,7 +3,7 @@
   "mailboxId": "18",
   "modSeq": 42,
   "size": 25,
-  "date": "2015-06-07T00:00:00+02:00",
+  "date": "2015-06-07T00:00:00+0200",
   "mediaType": "plain",
   "subtype": "text",
   "userFlags": [
@@ -142,7 +142,7 @@
   "subject": [
 	"[SECURITY] [DSA 3278-1] libapache-mod-jk security update"
   ],
-  "sentDate": "2015-06-03T19:14:32Z",
+  "sentDate": "2015-06-03T19:14:32+0000",
   "properties": [
 	{
 	  "namespace": "http://james.apache.org/rfc2045/Content-Type",

Modified: james/mailbox/trunk/elasticsearch/src/test/resources/documents/spamMail.json
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/elasticsearch/src/test/resources/documents/spamMail.json?rev=1688135&r1=1688134&r2=1688135&view=diff
==============================================================================
--- james/mailbox/trunk/elasticsearch/src/test/resources/documents/spamMail.json (original)
+++ james/mailbox/trunk/elasticsearch/src/test/resources/documents/spamMail.json Mon Jun 29
08:37:10 2015
@@ -3,7 +3,7 @@
   "mailboxId": "18",
   "modSeq": 42,
   "size": 25,
-  "date": "2015-06-07T00:00:00+02:00",
+  "date": "2015-06-07T00:00:00+0200",
   "mediaType": "plain",
   "subtype": "text",
   "userFlags": [],
@@ -103,7 +103,7 @@
   "subject": [
 	"[root] UNCHECKED contents in mail FROM <quentin.h@riseup.net>"
   ],
-  "sentDate": "2015-06-03T09:05:46+0000",
+  "sentDate": "2015-06-07T00:00:00+0200",
   "properties": [
 	{
 	  "namespace": "http://james.apache.org/rfc2045/Content-Type",



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message