manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1779015 - in /manifoldcf/trunk: ./ connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/email/
Date Mon, 16 Jan 2017 11:38:12 GMT
Author: kwright
Date: Mon Jan 16 11:38:12 2017
New Revision: 1779015

URL: http://svn.apache.org/viewvc?rev=1779015&view=rev
Log:
Fix for CONNECTORS-1368. Committed on behalf on Cihad Guzel.

Modified:
    manifoldcf/trunk/CHANGES.txt
    manifoldcf/trunk/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/email/EmailConfig.java
    manifoldcf/trunk/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/email/EmailConnector.java

Modified: manifoldcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/CHANGES.txt?rev=1779015&r1=1779014&r2=1779015&view=diff
==============================================================================
--- manifoldcf/trunk/CHANGES.txt (original)
+++ manifoldcf/trunk/CHANGES.txt Mon Jan 16 11:38:12 2017
@@ -3,6 +3,9 @@ $Id$
 
 ======================= 2.7-dev =====================
 
+CONNECTORS-1368: Add date range support to email connector.
+(Cihad Guzel)
+
 CONNECTORS-1366: Wrong report code in email connector when mime
 type is rejected.
 (Furkan KAMACI)

Modified: manifoldcf/trunk/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/email/EmailConfig.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/email/EmailConfig.java?rev=1779015&r1=1779014&r2=1779015&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/email/EmailConfig.java
(original)
+++ manifoldcf/trunk/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/email/EmailConfig.java
Mon Jan 16 11:38:12 2017
@@ -72,7 +72,7 @@ public class EmailConfig {
   public static final String PROTOCOL_DEFAULT_VALUE = "IMAP";
   public static final String PORT_DEFAULT_VALUE = "";
   public static final String[] BASIC_METADATA = {"To","From","Subject","Body","Date","Encoding
of Attachment","MIME type of attachment"};
-  public static final String[] BASIC_SEARCHABLE_ATTRIBUTES = {"To","From","Subject","Body","Date"};
+  public static final String[] BASIC_SEARCHABLE_ATTRIBUTES = {"To","From","Subject","Body","Start
Date", "End Date"};
 
   // Specification nodes
   
@@ -94,7 +94,12 @@ public class EmailConfig {
   public static final String EMAIL_ATTACHMENT_ENCODING = "encoding of attachment";
   public static final String EMAIL_ATTACHMENT_MIMETYPE = "mime type of attachment";
   public static final String EMAIL_VERSION = "1.0";
-  
+
+  // Date field names for filtering
+  public static final String EMAIL_FILTERING_DATE_FORMAT = "dd/MM/yy";
+  public static final String EMAIL_START_DATE = "start date";
+  public static final String EMAIL_END_DATE = "end date";
+
   // Mime types
   
   public static final String MIMETYPE_TEXT_PLAIN = "text/plain";

Modified: manifoldcf/trunk/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/email/EmailConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/email/EmailConnector.java?rev=1779015&r1=1779014&r2=1779015&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/email/EmailConnector.java
(original)
+++ manifoldcf/trunk/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/email/EmailConnector.java
Mon Jan 16 11:38:12 2017
@@ -28,6 +28,8 @@ import org.apache.manifoldcf.crawler.int
 import org.apache.manifoldcf.crawler.system.Logging;
 
 import java.io.*;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import javax.mail.*;
 import javax.mail.internet.MimeBodyPart;
@@ -345,6 +347,7 @@ public class EmailConnector extends org.
         Logging.connectors.debug("Email: Finding emails where '" + findParameterName +
             "' = '" + findParameterValue + "'");
       SearchTerm searchClause = null;
+      Integer comparisonTerm = null;
       if (findParameterName.equals(EmailConfig.EMAIL_SUBJECT)) {
         searchClause = new SubjectTerm(findParameterValue);
       } else if (findParameterName.equals(EmailConfig.EMAIL_FROM)) {
@@ -353,8 +356,22 @@ public class EmailConnector extends org.
         searchClause = new RecipientStringTerm(Message.RecipientType.TO, findParameterValue);
       } else if (findParameterName.equals(EmailConfig.EMAIL_BODY)) {
         searchClause = new BodyTerm(findParameterValue);
+      } else if (findParameterName.equals(EmailConfig.EMAIL_START_DATE)) {
+        comparisonTerm = ComparisonTerm.LT;
+      } else if (findParameterName.equals(EmailConfig.EMAIL_END_DATE)) {
+        comparisonTerm = ComparisonTerm.GT;
       }
-      
+
+      if (comparisonTerm != null) {
+        SimpleDateFormat date = new SimpleDateFormat(EmailConfig.EMAIL_FILTERING_DATE_FORMAT);
+        try {
+          searchClause = new ReceivedDateTerm(comparisonTerm, date.parse(findParameterValue));
+        } catch (ParseException e) {
+          Logging.connectors.warn("Email: Unknown date format: '" + findParameterValue +
"'for filter parameter name: '" + findParameterName + "'");
+        }
+      }
+
+
       if (searchClause != null)
       {
         if (searchTerm == null)



Mime
View raw message