You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by si...@apache.org on 2007/02/12 18:33:11 UTC

svn commit: r506544 - in /ofbiz/trunk/applications: content/src/org/ofbiz/content/email/EmailServices.java party/entitydef/entitymodel.xml

Author: sichen
Date: Mon Feb 12 09:33:09 2007
New Revision: 506544

URL: http://svn.apache.org/viewvc?view=rev&rev=506544
Log:
OFBIZ-704: Add CommunicationEvent.fromString, toString, ccString, headerString
Adding these four fields and logic to populate them from email headers in storeIncomingEmail service

Modified:
    ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java
    ofbiz/trunk/applications/party/entitydef/entitymodel.xml

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java?view=diff&rev=506544&r1=506543&r2=506544
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java Mon Feb 12 09:33:09 2007
@@ -22,14 +22,7 @@
 import org.apache.fop.apps.Fop;
 import org.apache.fop.apps.FopFactory;
 import org.apache.fop.apps.MimeConstants;
-import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.GeneralException;
-import org.ofbiz.base.util.HttpClient;
-import org.ofbiz.base.util.HttpClientException;
-import org.ofbiz.base.util.UtilDateTime;
-import org.ofbiz.base.util.UtilMisc;
-import org.ofbiz.base.util.UtilProperties;
-import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.base.util.*;
 import org.ofbiz.base.util.collections.MapStack;
 import org.ofbiz.base.util.string.FlexibleStringExpander;
 import org.ofbiz.entity.GenericDelegator;
@@ -56,14 +49,7 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Properties;
+import java.util.*;
 
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
@@ -831,6 +817,27 @@
                 commEventMap = addMessageBody(commEventMap, (Multipart) message.getContent());
             }                
             
+            // Retrieve all the addresses from the email
+            Set emailAddressesFrom = new TreeSet();
+            Set emailAddressesTo = new TreeSet();
+            Set emailAddressesCC = new TreeSet();
+            for (int x = 0 ; x < addressesFrom.length ; x++) {
+                emailAddressesFrom.add(((InternetAddress) addressesFrom[x]).getAddress());
+            }
+            for (int x = 0 ; x < addressesTo.length ; x++) {
+                emailAddressesTo.add(((InternetAddress) addressesTo[x]).getAddress());
+            }
+            for (int x = 0 ; x < addressesCC.length ; x++) {
+                emailAddressesCC.add(((InternetAddress) addressesCC[x]).getAddress());
+            }
+            String fromString = StringUtil.join(UtilMisc.toList(emailAddressesFrom), ",");
+            String toString = StringUtil.join(UtilMisc.toList(emailAddressesTo), ",");
+            String ccString = StringUtil.join(UtilMisc.toList(emailAddressesCC), ",");
+            
+            if (UtilValidate.isNotEmpty(toString)) commEventMap.put("toString", toString);
+            if (UtilValidate.isNotEmpty(ccString)) commEventMap.put("ccString", ccString);
+            if (UtilValidate.isNotEmpty(ccString)) commEventMap.put("fromString", fromString);
+
             // store from/to parties, but when not found make a note of the email to/from address in the workEffort Note Section.
             String commNote = "";
             if (partyIdFrom != null) {
@@ -865,6 +872,16 @@
             }
             
             commEventMap.put("userLogin", userLogin);
+            
+            // Populate the CommunicationEvent.headerString field with the email headers
+            String headerString = "";
+            Enumeration headerLines = message.getAllHeaderLines();
+            while (headerLines.hasMoreElements()) {
+                headerString += System.getProperty("line.separator");
+                headerString += headerLines.nextElement();
+            }
+            commEventMap.put("headerString", headerString);
+
             result = dispatcher.runSync("createCommunicationEvent", commEventMap);
             communicationEventId = (String)result.get("communicationEventId");
             

Modified: ofbiz/trunk/applications/party/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/entitydef/entitymodel.xml?view=diff&rev=506544&r1=506543&r2=506544
==============================================================================
--- ofbiz/trunk/applications/party/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/party/entitydef/entitymodel.xml Mon Feb 12 09:33:09 2007
@@ -509,6 +509,10 @@
       <field name="content" type="very-long"></field>
       <field name="note" type="comment"></field>
       <field name="contactListId" type="id"></field>
+      <field name="headerString" type="very-long"></field>
+      <field name="fromString" type="very-long"></field>
+      <field name="toString" type="very-long"></field>
+      <field name="ccString" type="very-long"></field>
       <prim-key field="communicationEventId"/>
       <relation type="one" fk-name="COM_EVNT_TYPE" rel-entity-name="CommunicationEventType">
         <key-map field-name="communicationEventTypeId"/>