svn commit: r451194 - in /incubator/ofbiz/trunk/applications/content: servicedef/services_email.xml src/org/ofbiz/content/email/EmailServices.java src/org/ofbiz/content/email/EmailWorker.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r451194 - in /incubator/ofbiz/trunk/applications/content: servicedef/services_email.xml src/org/ofbiz/content/email/EmailServices.java src/org/ofbiz/content/email/EmailWorker.java

hansbak-2
Author: hansbak
Date: Fri Sep 29 02:26:50 2006
New Revision: 451194

URL: http://svn.apache.org/viewvc?view=rev&rev=451194
Log:
Some more fixes to the incomig email services

Modified:
    incubator/ofbiz/trunk/applications/content/servicedef/services_email.xml
    incubator/ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java
    incubator/ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailWorker.java

Modified: incubator/ofbiz/trunk/applications/content/servicedef/services_email.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/content/servicedef/services_email.xml?view=diff&rev=451194&r1=451193&r2=451194
==============================================================================
--- incubator/ofbiz/trunk/applications/content/servicedef/services_email.xml (original)
+++ incubator/ofbiz/trunk/applications/content/servicedef/services_email.xml Fri Sep 29 02:26:50 2006
@@ -103,10 +103,10 @@
     <service name="storeEmailAsCommunication" engine="java"
             location="org.ofbiz.content.email.EmailServices" invoke="storeEmailAsCommunication" auth="true">
         <description>Store email as a communication event with the status COM_COMPLETE and current timestamp as datetimeStarted and datetimeEnded.  
-                     The communication event will be from the party of the userLogin to the party of the partyId parameter.  It is meant to run a SECA after
-                     a sendMail to record outgoing emails.</description>
+                     The communication event will be from the party of the userLogin to the party of the partyId parameter.
+                     It is meant to run a SECA after a sendMail to record outgoing emails.</description>
         <attribute name="partyId" type="String" mode="IN" optional="true"/>
-        <attribute name="communicationEventId" type="String" mode="IN" optional="true"/>
+        <attribute name="communicationEventId" type="String" mode="IN" optional="false"/>
         <attribute name="subject" type="String" mode="IN" optional="false"/>
         <attribute name="body" type="String" mode="IN" optional="false"/>
         <attribute name="contentType" type="String" mode="IN" optional="true"/>
@@ -117,9 +117,10 @@
             Process incoming email. Try to determine partyIdFrom from the first SendFrom email address. datetimeStarted and datetimeEnded are the
             sent and received dates respectively, partyIdTo is from the first SendTo email address. If the parties are not found,
             the email addresses are stored in CommunicationEvent.note
+            If however it is detected as spam (external) or when the 'from' email address is missing, the service will not return a communicationEventId  
         </description>
         <attribute name="messageWrapper" type="org.ofbiz.service.mail.MimeMessageWrapper" mode="IN"/>
-        <attribute name="communicationEventId" type="String" mode="OUT" optional="false"/>
+        <attribute name="communicationEventId" type="String" mode="OUT" optional="true"/>
     </service>
     <service name="storeForwardedEmail" engine="java"
             location="org.ofbiz.content.email.EmailServices" invoke="storeForwardedEmail" auth="true">

Modified: incubator/ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java?view=diff&rev=451194&r1=451193&r2=451194
==============================================================================
--- incubator/ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java (original)
+++ incubator/ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java Fri Sep 29 02:26:50 2006
@@ -707,6 +707,7 @@
             Address [] addressesTo = message.getRecipients(MimeMessage.RecipientType.TO);
             Address [] addressesCC = message.getRecipients(MimeMessage.RecipientType.CC);
             Address [] addressesBCC = message.getRecipients(MimeMessage.RecipientType.BCC);
+            Debug.logInfo("Processing Incoming Email message from: " + addressesFrom[0].toString() + " to: " + addressesTo[0].toString(), module);
 
             // ignore the message when the spam status = yes
             String spamHeaderName = UtilProperties.getPropertyValue("general.properties", "mail.spam.name", "N");
@@ -716,14 +717,14 @@
                 String msgHeaderValue = message.getHeader(spamHeaderName)[0];
                 if(msgHeaderValue != null && msgHeaderValue.startsWith(configHeaderValue)) {
                     Debug.logInfo("Incoming Email message ignored, was detected by external spam checker", module);
-                    ServiceUtil.returnSuccess();
+                    return ServiceUtil.returnSuccess(" Message Ignored: detected by external spam checker");
                 }
             }
 
             // if no 'from' addresses specified ignore the message
             if (addressesFrom == null) {
                 Debug.logInfo("Incoming Email message ignored, had not 'from' email address", module);
-                ServiceUtil.returnSuccess();
+                return ServiceUtil.returnSuccess(" Message Ignored: no 'From' address specified");
             }
             
             result = getParyInfoFromEmailAddress(addressesFrom, userLogin, dispatcher);
@@ -736,7 +737,6 @@
             //Get the first address from the list - this is the partyIdTo field of the CommunicationEvent
             if ((allResults != null) && (allResults.size() > 0)) {
                 Map firstAddressTo = (Map) itr.next();
-                
                 partyIdTo = (String)firstAddressTo.get("partyId");
                 contactMechIdTo = (String)firstAddressTo.get("contactMechId");
             }          
@@ -744,7 +744,6 @@
             Map commEventMap = new HashMap();
         commEventMap.put("communicationEventTypeId", "AUTO_EMAIL_COMM");
         commEventMap.put("contactMechTypeId", "EMAIL_ADDRESS");
-        commEventMap.put("partyIdTo", partyIdTo);
         String subject = message.getSubject();
         commEventMap.put("subject", subject);
     
@@ -797,15 +796,22 @@
             String commNote = "";
             if (partyIdFrom != null) {
          commEventMap.put("partyIdFrom", partyIdFrom);        
-         commEventMap.put("contactMechIdFrom", contactMechIdFrom);
          commEventMap.put("contactMechIdTo", contactMechIdTo);
-         commEventMap.put("statusId", "COM_ENTERED");
             } else {
-                commEventMap.put("statusId", "COM_UNKNOWN_PARTY");
-                commNote += "Sent from: " + ((InternetAddress)addressesFrom[0]).getAddress();
+                commNote += "Sent from: " +  ((InternetAddress)addressesFrom[0]).getAddress() + "; ";
+            }
+
+            if (partyIdTo != null) {
+                commEventMap.put("partyIdTo", partyIdTo);              
+                commEventMap.put("contactMechIdTo", contactMechIdTo);
+            } else {
+                commNote += "Sent to: " + ((InternetAddress)addressesTo[0]).getAddress()  + "; ";
             }
-     if (partyIdTo == null) {
-                commNote += "Sent to: " + ((InternetAddress)addressesTo[0]).getAddress();
+
+            if (partyIdTo != null && partyIdFrom != null) {
+                commEventMap.put("statusId", "COM_ENTERED");
+            } else {
+                commEventMap.put("statusId", "COM_UNKNOWN_PARTY");
             }
             
             if (!("".equals(commNote))) {

Modified: incubator/ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailWorker.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailWorker.java?view=diff&rev=451194&r1=451193&r2=451194
==============================================================================
--- incubator/ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailWorker.java (original)
+++ incubator/ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailWorker.java Fri Sep 29 02:26:50 2006
@@ -79,7 +79,7 @@
  && (disposition.equals(Part.ATTACHMENT) || disposition.equals(Part.INLINE))
      && (i != bodyContentIndex)) )
     {
- commEventMap.put("contentName", subject + "-" + i);
+ commEventMap.put("contentName", subject + "-" + i + " " + part.getFileName());
          commEventMap.put("drMimeTypeId", thisContentType);
          if (thisContentType.startsWith("text")) {
          String content = (String)part.getContent();
@@ -96,6 +96,7 @@
      ByteWrapper imageData = new ByteWrapper(baos.toByteArray());
      int len = imageData.getLength();
      if (Debug.infoOn()) Debug.logInfo("imageData length: " + len, module);
+                    commEventMap.put("drDataResourceName", part.getFileName());
      commEventMap.put("imageData", imageData);
      commEventMap.put("drDataResourceTypeId", "IMAGE_OBJECT");
              commEventMap.put("_imageData_contentType", thisContentType);