Login  Register

[jira] Commented: (OFBIZ-56) incoming email attachments buggy

Posted by Nicolas Malin (Jira) on Jul 28, 2006; 10:16pm
URL: http://ofbiz.116.s1.nabble.com/jira-Created-OFBIZ-56-incoming-email-attachments-buggy-tp168906p168923.html

    [ http://issues.apache.org/jira/browse/OFBIZ-56?page=comments#action_12424171 ]
           
BJ Freeman commented on OFBIZ-56:
---------------------------------

this has two fixes in it
1) fixes the contenttype test for emails that don'e have more than one contentype.
2) is the fix above.

this is  my first patch. Hope I did it correct.

IIndex: C:/projects/java/ofbiz_incubator_trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java
===================================================================
--- C:/projects/java/ofbiz_incubator_trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java (revision 426495)
+++ C:/projects/java/ofbiz_incubator_trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java (working copy)
@@ -686,9 +686,20 @@
         Map result = null;
         try {
             String contentTypeRaw = message.getContentType();
-            int idx = contentTypeRaw.indexOf(";");
-            contentType = contentTypeRaw.substring(0, idx);
-            Address [] addressesFrom = message.getFrom();
+          //  int idx = contentTypeRaw.indexOf(";");
+            //some emails do not use ;. if you use the above commented out code, it may be null;
+ //so the code below will throw an exception.
+            //  contentType = contentTypeRaw.substring(0, idx);
+            //following is the fix.
+     int idx = 0;
+ idx = contentTypeRaw.indexOf(";");
+ if (idx >= 1) {
+ contentType = contentTypeRaw.substring(0, idx);
+ } else {
+ contentType = contentTypeRaw;
+ }
+ //end of fix
+           Address [] addressesFrom = message.getFrom();
             Address [] addressesTo = message.getRecipients(MimeMessage.RecipientType.TO);
             Address [] addressesCC = message.getRecipients(MimeMessage.RecipientType.CC);
             Address [] addressesBCC = message.getRecipients(MimeMessage.RecipientType.BCC);            
@@ -763,16 +774,31 @@
             if (partyIdFrom != null) {
          commEventMap.put("partyIdFrom", partyIdFrom);        
          commEventMap.put("contactMechIdFrom", contactMechIdFrom);
-         commEventMap.put("contactMechIdTo", contactMechIdTo);
+//         commEventMap.put("contactMechIdTo", contactMechIdTo);
          commEventMap.put("statusId", "COM_ENTERED");
          } else {
                 // create a task to find party for email
          commEventMap.put("statusId", "COM_UNKNOWN_PARTY");
          commNote = "Sent from: " + UtilMisc.toListArray(addressesFrom);
          }
+            /*
      if (partyIdTo == null) {
                 commNote += "Sent to: " + UtilMisc.toListArray(addressesTo);
             }
+            */
+           // modifed 06/20/06 to match the partyIDfrom
+
+            if (partyIdTo != null) {
+            commEventMap.put("partyIdto", partyIdTo);
+//            moved from PartyIDfrom, since if PartyIDfrom is null won't get set.
+            commEventMap.put("contactMechIdTo", contactMechIdTo);
+     commEventMap.put("statusId", "COM_ENTERED");
+            }else {
+//             create a task to find party for email
+//            this will override the status already set
+            commEventMap.put("statusId", "COM_UNKNOWN_PARTY");
+            commNote += "Sent to: " + UtilMisc.toListArray(addressesTo);
+            }
             if (!("".equals(commNote))) {
                 commEventMap.put("note", commNote);
             }


> incoming email attachments buggy
> --------------------------------
>
>                 Key: OFBIZ-56
>                 URL: http://issues.apache.org/jira/browse/OFBIZ-56
>             Project: OFBiz (The Open for Business Project)
>          Issue Type: Bug
>          Components: content
>    Affects Versions: SVN trunk
>            Reporter: Si Chen
>             Fix For: SVN trunk
>
>
> storeIncomingEmail has problems with attachments.  If you send two images, the same image ends up being stored twice.  Some types of content are not stored correctly (such as word docs with images embedded).  Other times the /ViewSimpleContent request has problems retrieving content correctly.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira