svn commit: r477480 - in /incubator/ofbiz/trunk: applications/content/src/org/ofbiz/content/email/ applications/party/servicedef/ framework/common/config/

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

svn commit: r477480 - in /incubator/ofbiz/trunk: applications/content/src/org/ofbiz/content/email/ applications/party/servicedef/ framework/common/config/

hansbak-2
Author: hansbak
Date: Mon Nov 20 18:54:01 2006
New Revision: 477480

URL: http://svn.apache.org/viewvc?view=rev&rev=477480
Log:
various improvements for processing incoming email to avoid NPE at bad content of emails.

Modified:
    incubator/ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java
    incubator/ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailWorker.java
    incubator/ofbiz/trunk/applications/party/servicedef/services.xml
    incubator/ofbiz/trunk/framework/common/config/general.properties

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=477480&r1=477479&r2=477480
==============================================================================
--- 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 Mon Nov 20 18:54:01 2006
@@ -612,17 +612,15 @@
                     emailAddress = (InternetAddress)addr;
                     
                     if (!UtilValidate.isEmpty(emailAddress)) {
-                        map = new HashMap();
-                        map.put("address", emailAddress.getAddress());
-                        map.put("userLogin", userLogin);
-                        result = dispatcher.runSync("findPartyFromEmailAddress", map);
-                        
-                        tempResults.add(result);
+                        result = dispatcher.runSync("findPartyFromEmailAddress",
+                         UtilMisc.toMap("address", emailAddress.getAddress(), "userLogin", userLogin));
+                        if (result.get("partyId") != null) {
+                         tempResults.add(result);
+                        }
                     }
                 }    
             }
         }
-        
         return tempResults;
     }  
     
@@ -707,7 +705,7 @@
             String spamHeaderName = UtilProperties.getPropertyValue("general.properties", "mail.spam.name", "N");
             String configHeaderValue = UtilProperties.getPropertyValue("general.properties", "mail.spam.value");
             //          only execute when config file has been set && header variable found
-            if (!spamHeaderName.equals("N") && message.getHeader(spamHeaderName) != null) {
+            if (!spamHeaderName.equals("N") && message.getHeader(spamHeaderName) != null && message.getHeader(spamHeaderName).length > 0) {
                 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);

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=477480&r1=477479&r2=477480
==============================================================================
--- 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 Mon Nov 20 18:54:01 2006
@@ -52,7 +52,9 @@
  commEventMap.put("mimeTypeId", "text/html");
  commEventMap.put("userLogin", userLogin);
  String subject = message.getSubject();
-     Map result = null;
+ if (subject != null && subject.length() > 80) {
+ subject = subject.substring(0,80); // make sure not too big for database field. (20 characters for filename)
+ }
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
     
  Multipart multipart = (Multipart)message.getContent();
@@ -71,7 +73,11 @@
  && (disposition.equals(Part.ATTACHMENT) || disposition.equals(Part.INLINE))
      && (i != bodyContentIndex)) )
     {
- commEventMap.put("contentName", subject + "-" + i + " " + part.getFileName());
+ String attFileName = part.getFileName();
+ if (attFileName != null && attFileName.length() > 17) {
+ attFileName = attFileName.substring(0,17);
+ }
+ commEventMap.put("contentName", subject + "-" + i + " " + attFileName);
          commEventMap.put("drMimeTypeId", thisContentType);
          if (thisContentType.startsWith("text")) {
          String content = (String)part.getContent();
@@ -93,7 +99,7 @@
      commEventMap.put("drDataResourceTypeId", "IMAGE_OBJECT");
              commEventMap.put("_imageData_contentType", thisContentType);
          }
-         result = dispatcher.runSync("createCommContentDataResource", commEventMap);
+         dispatcher.runSync("createCommContentDataResource", commEventMap);
      attachmentCount++;
     }
  }

Modified: incubator/ofbiz/trunk/applications/party/servicedef/services.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/party/servicedef/services.xml?view=diff&rev=477480&r1=477479&r2=477480
==============================================================================
--- incubator/ofbiz/trunk/applications/party/servicedef/services.xml (original)
+++ incubator/ofbiz/trunk/applications/party/servicedef/services.xml Mon Nov 20 18:54:01 2006
@@ -343,9 +343,9 @@
     <!-- Party ContachMech reverse find -->
     <service name="findPartyFromEmailAddress" engine="simple"
             location="org/ofbiz/party/contact/PartyContactMechServices.xml" invoke="findPartyFromEmailAddress" auth="true">
-        <description>Create a Postal Address</description>
+        <description>Find the partyId/contactMechId for a specific email address, if not found do not return a value</description>
         <attribute name="address" type="String" mode="IN" optional="false"/>
-        <attribute name="personal" type="String" mode="IN" optional="true"/>
+        <attribute name="personal" type="String" mode="IN" optional="true"/><!-- field not used -->
         <attribute name="fromDate" type="Timestamp" mode="IN" optional="true"/>
         <attribute name="partyId" type="String" mode="OUT" optional="true"/>
         <attribute name="contactMechId" type="String" mode="OUT" optional="true"/>

Modified: incubator/ofbiz/trunk/framework/common/config/general.properties
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/common/config/general.properties?view=diff&rev=477480&r1=477479&r2=477480
==============================================================================
--- incubator/ofbiz/trunk/framework/common/config/general.properties (original)
+++ incubator/ofbiz/trunk/framework/common/config/general.properties Mon Nov 20 18:54:01 2006
@@ -52,5 +52,5 @@
 http.upload.max.size=-1
 
 # -- spam header name and value to block incoming spam detected by external spam checker, configured for spam assin
-mail.spam.name = X-Spam-Flag
-mail.spam.value = YES
\ No newline at end of file
+mail.spam.name=X-Spam-Flag
+mail.spam.value=YES