manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1786203 - in /manifoldcf/trunk: CHANGES.txt connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/email/EmailConnector.java
Date Thu, 09 Mar 2017 16:59:19 GMT
Author: kwright
Date: Thu Mar  9 16:59:19 2017
New Revision: 1786203

URL: http://svn.apache.org/viewvc?rev=1786203&view=rev
Log:
Tentative fix for CONNECTORS-1396.

Modified:
    manifoldcf/trunk/CHANGES.txt
    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=1786203&r1=1786202&r2=1786203&view=diff
==============================================================================
--- manifoldcf/trunk/CHANGES.txt (original)
+++ manifoldcf/trunk/CHANGES.txt Thu Mar  9 16:59:19 2017
@@ -3,6 +3,9 @@ $Id$
 
 ======================= 2.7-dev =====================
 
+CONNECTORS-1396: Fix email connector class cast exception.
+(Cihad Guzel, Karl Wright)
+
 CONNECTORS-1394: Fix email connector ArrayIndexOutOfBounds
 exception.
 (Cihad Guzel, Karl Wright)

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=1786203&r1=1786202&r2=1786203&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 Mar  9 16:59:19 2017
@@ -628,39 +628,51 @@ public class EmailConnector extends org.
                 } else if (metadata.toLowerCase(Locale.ROOT).equals(EmailConfig.EMAIL_DATE))
{
                   rd.addField(EmailConfig.EMAIL_DATE, sentDate.toString());
                 } else if (metadata.toLowerCase(Locale.ROOT).equals(EmailConfig.EMAIL_ATTACHMENT_ENCODING))
{
-                  Multipart mp = (Multipart) msg.getContent();
-                  if (mp != null) {
-                    String[] encoding = 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)))))
{
-                        final String[] fileSplit = part.getFileName().split("\\?");
-                        if (fileSplit.length > 1) {
-                          encoding[k] = fileSplit[1];
-                        } else {
-                          encoding[k] = "";
+                  Object o = msg.getContent();
+                  if (o != null) {
+                    if (o instanceof Multipart) {
+                      Multipart mp = (Multipart) o;
+                      String[] encoding = 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)))))
{
+                          final String[] fileSplit = part.getFileName().split("\\?");
+                          if (fileSplit.length > 1) {
+                            encoding[k] = fileSplit[1];
+                          } else {
+                            encoding[k] = "";
+                          }
                         }
                       }
+                      rd.addField(EmailConfig.ENCODING_FIELD, encoding);
+                    } else if (o instanceof String) {
+                      rd.addField(EmailConfig.ENCODING_FIELD, "");
                     }
-                    rd.addField(EmailConfig.ENCODING_FIELD, encoding);
                   }
                 } else if (metadata.toLowerCase(Locale.ROOT).equals(EmailConfig.EMAIL_ATTACHMENT_MIMETYPE))
{
-                  Multipart mp = (Multipart) msg.getContent();
-                  String[] MIMEType = 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)))))
{
-                      MIMEType[k] = part.getContentType();
+                  Object o = msg.getContent();
+                  if (o != null) {
+                    if (o instanceof Multipart) {
+                      Multipart mp = (Multipart) o;
+                      String[] MIMEType = 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)))))
{
+                          MIMEType[k] = part.getContentType();
 
+                        }
+                      }
+                      rd.addField(EmailConfig.MIMETYPE_FIELD, MIMEType);
+                    } else if (o instanceof String) {
+                      rd.addField(EmailConfig.MIMETYPE_FIELD, "");
                     }
                   }
-                  rd.addField(EmailConfig.MIMETYPE_FIELD, MIMEType);
                 }
               }
                   



Mime
View raw message