manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kam...@apache.org
Subject svn commit: r1791239 - in /manifoldcf/trunk: ./ connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/email/
Date Thu, 13 Apr 2017 12:28:24 GMT
Author: kamaci
Date: Thu Apr 13 12:28:24 2017
New Revision: 1791239

URL: http://svn.apache.org/viewvc?rev=1791239&view=rev
Log:
Fix for CONNECTORS-1405

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=1791239&r1=1791238&r2=1791239&view=diff
==============================================================================
--- manifoldcf/trunk/CHANGES.txt (original)
+++ manifoldcf/trunk/CHANGES.txt Thu Apr 13 12:28:24 2017
@@ -3,6 +3,9 @@ $Id$
 
 ======================= 2.7-dev =====================
 
+CONNECTORS-1405: Add filename metadata information for email.
+(Furkan KAMACI)
+
 CONNECTORS-1402: Add metadata information for email attachments.
 (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=1791239&r1=1791238&r2=1791239&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
Thu Apr 13 12:28:24 2017
@@ -76,7 +76,8 @@ 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_METADATA = {"To","From","Subject","Body","Date","Encoding
of Attachment",
+      "MIME Type of attachment", "File Name of Attachment"};
   public static final String[] BASIC_SEARCHABLE_ATTRIBUTES = {"To","From","Subject","Body","Start
Date", "End Date"};
 
   // Specification nodes
@@ -98,6 +99,7 @@ public class EmailConfig {
   public static final String EMAIL_DATE = "date";
   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_ATTACHMENT_FILENAME = "file name of attachment";
   public static final String EMAIL_VERSION = "1.0";
 
   // Date field names for filtering
@@ -114,6 +116,7 @@ public class EmailConfig {
   
   public static final String ENCODING_FIELD = "encoding";
   public static final String MIMETYPE_FIELD = "mimetype";
+  public static final String FILENAME_FIELD = "filename";
   //public static final String TO = "To";
   
   // Activity names

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=1791239&r1=1791238&r2=1791239&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
Thu Apr 13 12:28:24 2017
@@ -672,6 +672,26 @@ public class EmailConnector extends org.
                       rd.addField(EmailConfig.MIMETYPE_FIELD, "");
                     }
                   }
+                } else if (metadata.toLowerCase(Locale.ROOT).equals(EmailConfig.EMAIL_ATTACHMENT_FILENAME))
{
+                  Object o = msg.getContent();
+                  if (o != null) {
+                    if (o instanceof Multipart) {
+                      Multipart mp = (Multipart) o;
+                      String[] fileNames = new String[mp.getCount()];
+                      for (int k = 0, n = mp.getCount(); k < n; k++) {
+                        Part part = mp.getBodyPart(k);
+                        String disposition = part.getDisposition();
+                        if ((disposition != null) &&
+                            ((disposition.toLowerCase(Locale.ROOT).equals(Part.ATTACHMENT)
||
+                                (disposition.toLowerCase(Locale.ROOT).equals(Part.INLINE)))))
{
+                          fileNames[k] = part.getFileName();
+                        }
+                      }
+                      rd.addField(EmailConfig.FILENAME_FIELD, fileNames);
+                    } else if (o instanceof String) {
+                      rd.addField(EmailConfig.FILENAME_FIELD, "");
+                    }
+                  }
                 }
               }
                   



Mime
View raw message