svn commit: r537329 - in /ofbiz/trunk: ./ applications/accounting/webapp/accounting/payment/ applications/accounting/widget/ applications/content/servicedef/ applications/content/src/org/ofbiz/content/email/ applications/party/src/org/ofbiz/party/commu...

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

svn commit: r537329 - in /ofbiz/trunk: ./ applications/accounting/webapp/accounting/payment/ applications/accounting/widget/ applications/content/servicedef/ applications/content/src/org/ofbiz/content/email/ applications/party/src/org/ofbiz/party/commu...

hansbak-2
Author: hansbak
Date: Fri May 11 20:49:45 2007
New Revision: 537329

URL: http://svn.apache.org/viewvc?view=rev&rev=537329
Log:
run only update balances if party found in partyAcctgPreference

Modified:
    ofbiz/trunk/.classpath
    ofbiz/trunk/applications/accounting/webapp/accounting/payment/PaymentForms.xml
    ofbiz/trunk/applications/accounting/widget/InvoiceScreens.xml
    ofbiz/trunk/applications/content/servicedef/services_email.xml
    ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java
    ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java
    ofbiz/trunk/framework/base/config/ofbiz-containers.xml
    ofbiz/trunk/framework/common/config/general.properties

Modified: ofbiz/trunk/.classpath
URL: http://svn.apache.org/viewvc/ofbiz/trunk/.classpath?view=diff&rev=537329&r1=537328&r2=537329
==============================================================================
--- ofbiz/trunk/.classpath (original)
+++ ofbiz/trunk/.classpath Fri May 11 20:49:45 2007
@@ -2,6 +2,7 @@
 <classpath>
  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
  <classpathentry kind="src" path="framework/testtools/src"/>
+ <classpathentry kind="src" path="hot-deploy/sharedofbiz/src"/>
  <classpathentry kind="src" path="specialpurpose/hhfacility/src"/>
  <classpathentry kind="src" path="specialpurpose/assetmaint/src"/>
  <classpathentry kind="src" path="specialpurpose/pos/src"/>

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/payment/PaymentForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/payment/PaymentForms.xml?view=diff&rev=537329&r1=537328&r2=537329
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/payment/PaymentForms.xml (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/payment/PaymentForms.xml Fri May 11 20:49:45 2007
@@ -55,7 +55,7 @@
             </service>
         </actions>
         <row-actions>
-            <set field="amountToApply" value="${bsh:
+            <set field="balanceamountToApply" value="${bsh:
                 import java.text.NumberFormat;
                 return(NumberFormat.getNumberInstance(context.get(&quot;locale&quot;)).format(org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(delegator,paymentId)));}"/>
         </row-actions>
@@ -70,7 +70,7 @@
         <field name="effectiveDate"><display/></field>
         <field name="currencyUomId"><hidden/></field>
         <field name="amount"><display also-hidden="false" type="currency" currency="${currencyUomId}"/></field>
-        <field name="amountToApply"><display also-hidden="false" type="currency" currency="${currencyUomId}"/></field>
+        <field name="balance"><display also-hidden="false" type="currency" currency="${currencyUomId}"/></field>
     </form>
 
     <form name="EditPayment" type="single" target="updatePayment" default-map-name="payment">

Modified: ofbiz/trunk/applications/accounting/widget/InvoiceScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/InvoiceScreens.xml?view=diff&rev=537329&r1=537328&r2=537329
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/InvoiceScreens.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/InvoiceScreens.xml Fri May 11 20:49:45 2007
@@ -47,7 +47,6 @@
             <actions>
                 <set field="title" value="New Invoice"/>
                 <set field="titleProperty" value="PageTitleEditInvoice"/>
-                <entity-one entity-name="Invoice" value-name="invoice"/>
             </actions>
             <widgets>
                 <decorator-screen name="CommonInvoiceDecorator" location="${parameters.mainDecoratorLocation}">

Modified: ofbiz/trunk/applications/content/servicedef/services_email.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/servicedef/services_email.xml?view=diff&rev=537329&r1=537328&r2=537329
==============================================================================
--- ofbiz/trunk/applications/content/servicedef/services_email.xml (original)
+++ ofbiz/trunk/applications/content/servicedef/services_email.xml Fri May 11 20:49:45 2007
@@ -46,6 +46,7 @@
             but are passed down to storeEmailAsCommunication during the SECA chain.  See sednMailInterface for more comments.</description>
         <implements service="sendMailInterface"/>
         <attribute name="body" type="String" mode="INOUT" optional="false"/>
+        <attribute name="bodyParts" type="java.util.List" mode="INOUT" optional="true"/>
         <attribute name="communicationEventId" type="String" mode="INOUT" optional="true"/>
         <override name="contentType" mode="INOUT"/>
         <override name="subject" mode="INOUT" optional="false"/>

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=537329&r1=537328&r2=537329
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java Fri May 11 20:49:45 2007
@@ -22,7 +22,14 @@
 import org.apache.fop.apps.Fop;
 import org.apache.fop.apps.FopFactory;
 import org.apache.fop.apps.MimeConstants;
-import org.ofbiz.base.util.*;
+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.collections.MapStack;
 import org.ofbiz.base.util.string.FlexibleStringExpander;
 import org.ofbiz.entity.GenericDelegator;
@@ -49,7 +56,14 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.sql.Timestamp;
-import java.util.*;
+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 javax.activation.DataHandler;
 import javax.activation.DataSource;
@@ -611,7 +625,7 @@
                     emailAddress = (InternetAddress)addr;
                     
                     if (!UtilValidate.isEmpty(emailAddress)) {
-                        result = dispatcher.runSync("findPartyFromEmailAddress",
+                        result = dispatcher.runSync("findPartyFromEmailAddressCompany",
                                 UtilMisc.toMap("address", emailAddress.getAddress(), "userLogin", userLogin));
                         if (result.get("partyId") != null) {
                             tempResults.add(result);
@@ -725,7 +739,6 @@
         MimeMessageWrapper wrapper = (MimeMessageWrapper) context.get("messageWrapper");
         MimeMessage message = wrapper.getMessage();
         Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
-        GenericValue userLogin = (GenericValue) context.get("userLogin");
         String partyIdTo = null;
         String partyIdFrom = null;
         String contentType = null;
@@ -735,6 +748,8 @@
         
         Map result = null;
         try {
+         // run as system Id
+            GenericValue userLogin = (GenericValue) delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "system"));
             String contentTypeRaw = message.getContentType();
             int idx = contentTypeRaw.indexOf(";");
             if (idx == -1) idx = contentTypeRaw.length();
@@ -744,6 +759,13 @@
             Address [] addressesTo = message.getRecipients(MimeMessage.RecipientType.TO);
             Address [] addressesCC = message.getRecipients(MimeMessage.RecipientType.CC);
             Address [] addressesBCC = message.getRecipients(MimeMessage.RecipientType.BCC);
+
+            // if no 'from' addresses specified ignore the message
+            if (addressesFrom == null) {
+                Debug.logInfo("Incoming Email message ignored, had not 'from' email address", module);
+                return ServiceUtil.returnSuccess(" Message Ignored: no 'From' address specified");
+            }
+
             Debug.logInfo("Processing Incoming Email message from: " +
                     (addressesFrom[0] == null? "not found" : addressesFrom[0].toString()) + " to: " +
                             (addressesTo[0] == null? "not found" : addressesTo[0].toString()), module);
@@ -760,26 +782,29 @@
                 }
             }
 
-            // if no 'from' addresses specified ignore the message
-            if (addressesFrom == null) {
-                Debug.logInfo("Incoming Email message ignored, had not 'from' email address", module);
-                return ServiceUtil.returnSuccess(" Message Ignored: no 'From' address specified");
-            }
-
-            // get the 'To' partyId
+            // get the 'To' partyId (should be in the partyAcctgPreference table
             List allResults = getListOfParyInfoFromEmailAddresses(addressesTo, addressesCC, addressesBCC, userLogin, dispatcher);
-            Iterator itr = allResults.iterator();
             //Get the first address from the list - this is the partyIdTo field of the CommunicationEvent
+            Iterator itr = allResults.iterator();
+            Debug.logInfo("====before userloginId: " + userLogin.get("userLoginId") + " party: " + userLogin.get("partyId"), module);
+            if (userLogin.get("userLoginId").equals("system")) userLogin.remove("partyId"); // make sure to search all users
+            Debug.logInfo("====after userloginId: " + userLogin.get("userLoginId") + " party: " + userLogin.get("partyId"), module);
             if ((allResults != null) && (allResults.size() > 0)) {
-                Map firstAddressTo = (Map) itr.next();
-                partyIdTo = (String)firstAddressTo.get("partyId");
-                contactMechIdTo = (String)firstAddressTo.get("contactMechId");
+             while (itr.hasNext()) {
+                    Map addressTo = (Map) itr.next();
+                    partyIdTo = (String)addressTo.get("partyId");
+                    contactMechIdTo = (String)addressTo.get("contactMechId");
+                    Debug.logInfo("====try to find:" + partyIdTo, module);
+                    if (delegator.findByPrimaryKey("PartyAcctgPreference", UtilMisc.toMap("partyId", partyIdTo)) != null)
+                     break;
+             }
             }
             
             
             String deliveredTo = null;
-            if (message.getHeader("Delivered-To") != null) {
-                deliveredTo = message.getHeader("Delivered-To")[0];
+            if (message.getHeader("Delivered-To") != null && message.getHeader("Delivered-To").length > 0) {
+                if (message.getHeader("Delivered-To").length > 1) deliveredTo = message.getHeader("Delivered-To")[1];
+ else deliveredTo = message.getHeader("Delivered-To")[0];
                 // check if started with the domain name if yes remove including the dash.
                 String dn = deliveredTo.substring(deliveredTo.indexOf("@")+1, deliveredTo.length());
                 if (deliveredTo.startsWith(dn)) {
@@ -789,7 +814,7 @@
             
             // if partyIdTo not found try to find the "to" address using the delivered-to header
             if ((partyIdTo == null) && (deliveredTo != null)) {
-                result = dispatcher.runSync("findPartyFromEmailAddress", UtilMisc.toMap("address", deliveredTo, "userLogin", userLogin));          
+                result = dispatcher.runSync("findPartyFromEmailAddressCompany", UtilMisc.toMap("address", deliveredTo, "userLogin", userLogin));          
                 partyIdTo = (String)result.get("partyId");
                 contactMechIdTo = (String)result.get("contactMechId");
             }
@@ -825,6 +850,7 @@
                 commEventMap = addMessageBody(commEventMap, (Multipart) message.getContent());
             }                
             
+/*
             // Retrieve all the addresses from the email
             Set emailAddressesFrom = new TreeSet();
             Set emailAddressesTo = new TreeSet();
@@ -855,7 +881,7 @@
             if (UtilValidate.isNotEmpty(ccString)) commEventMap.put("ccString", ccString);
             if (UtilValidate.isNotEmpty(ccString)) commEventMap.put("fromString", fromString);
             if (UtilValidate.isNotEmpty(bccString)) commEventMap.put("bccString", bccString);
-
+*/
             // 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) {
@@ -869,12 +895,11 @@
             if (partyIdTo != null) {
                 commEventMap.put("partyIdTo", partyIdTo);              
                 commEventMap.put("contactMechIdTo", contactMechIdTo);
-            } else {
+            }
                 commNote += "Sent to: " + ((InternetAddress)addressesTo[0]).getAddress()  + "; ";
                 if (deliveredTo != null) {
                     commNote += "Delivered-To: " + deliveredTo + "; ";
                 }
-            }
             
             commNote += "Sent to: " + ((InternetAddress)addressesTo[0]).getAddress()  + "; ";
             commNote += "Delivered-To: " + deliveredTo + "; ";
@@ -890,16 +915,6 @@
             }
             
             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/src/org/ofbiz/party/communication/CommunicationEventServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java?view=diff&rev=537329&r1=537328&r2=537329
==============================================================================
--- ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java (original)
+++ ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java Fri May 11 20:49:45 2007
@@ -19,15 +19,21 @@
 
 package org.ofbiz.party.communication;
 
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
 import java.util.*;
 
+import javolution.util.FastList;
+
 import org.ofbiz.base.util.*;
+import org.ofbiz.content.data.DataResourceWorker;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.condition.EntityConditionList;
 import org.ofbiz.entity.condition.EntityExpr;
 import org.ofbiz.entity.condition.EntityOperator;
+import org.ofbiz.entity.util.ByteWrapper;
 import org.ofbiz.entity.util.EntityFindOptions;
 import org.ofbiz.entity.util.EntityUtil;
 import org.ofbiz.service.DispatchContext;
@@ -73,12 +79,39 @@
                         
             // prepare the email
             Map sendMailParams = new HashMap();
+            //attachment
+            List bodyParts = FastList.newInstance();
+            List commEventContentAssocs = communicationEvent.getRelated("CommEventContentAssoc");
+            Iterator contentItr = commEventContentAssocs.iterator();
+            ByteWrapper byteWrapper = null;
+            while (contentItr.hasNext()) {
+            
+             GenericValue content = (GenericValue) contentItr.next();
+             GenericValue fromContent = content.getRelatedOne("FromContent");
+                GenericValue dataResources = fromContent.getRelatedOne("DataResource");
+                try {
+ byteWrapper = DataResourceWorker.getContentAsByteWrapper(delegator, dataResources.getString("dataResourceId"), null, null, locale, null);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (GeneralException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ bodyParts.add(UtilMisc.toMap("content", byteWrapper.getBytes(), "type", dataResources.getString("mimeTypeId"), "filename", dataResources.getString("dataResourceName")));
+
+
+            }
+            
             sendMailParams.put("sendFrom", communicationEvent.getRelatedOne("FromContactMech").getString("infoString"));
             sendMailParams.put("subject", communicationEvent.getString("subject"));
             sendMailParams.put("body", communicationEvent.getString("content"));
+            // check attachment
+            if(bodyParts != null)
+             sendMailParams.put("bodyParts",bodyParts);
             sendMailParams.put("contentType", communicationEvent.getString("contentMimeTypeId"));
             sendMailParams.put("userLogin", userLogin);
-            
+                        
             // if there is no contact list, then send look for a contactMechIdTo and partyId
             if ((communicationEvent.getString("contactListId") == null) ||
                 (communicationEvent.getString("contactListId").equals(""))) {

Modified: ofbiz/trunk/framework/base/config/ofbiz-containers.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/config/ofbiz-containers.xml?view=diff&rev=537329&r1=537328&r2=537329
==============================================================================
--- ofbiz/trunk/framework/base/config/ofbiz-containers.xml (original)
+++ ofbiz/trunk/framework/base/config/ofbiz-containers.xml Fri May 11 20:49:45 2007
@@ -55,23 +55,22 @@
     <!-- JavaMail Listener Container - Triggers MCA Rules -->
     <!-- if delete-mail is set to true, will delete messages after fetching them. otherwise, will try to mark them as seen
          mail.store.protocol supports both imap and pop3, but pop3 will not be able to mark messages as seen, so you would need to delete them -->
-    <!-- To use the mail listerner just uncomment and go...
-    <container name="javamail-container" class="org.ofbiz.service.mail.JavaMailContainer">
+    <!-- To use the mail listerner just uncomment and go... -->
+    <!--container name="javamail-container" class="org.ofbiz.service.mail.JavaMailContainer">
         <property name="delegator-name" value="default"/>
         <property name="dispatcher-name" value="JavaMailDispatcher"/>
         <property name="run-as-user" value="system"/>
         <property name="poll-delay" value="300000"/>
-        <property name="delete-mail" value="false"/>
+        <property name="delete-mail" value="true"/>
         <property name="maxSize" value="100000"/>
         <property name="default-listener" value="store-listener">
-            <property name="mail.store.protocol" value="imap"/>
-            <property name="mail.host" value="[host]"/>
-            <property name="mail.user" value="[user]"/>
-            <property name="mail.pass" value="[pass]"/>
-            <property name="mail.debug" value="false"/>
+            <property name="mail.store.protocol" value="pop3"/>
+            <property name="mail.host" value="mail.a-net.nl"/>
+            <property name="mail.user" value="[hidden email]"/>
+            <property name="mail.pass" value="test"/>
+            <property name="mail.debug" value="true"/>
         </property>
-    </container>
-    -->
+    </container-->
 
     <!-- load Shark Workflow Engine -->
     <!-- NOTE: before uncommenting this please see the instructions in the ofbiz/OPTIONAL_LIBRARIES file.

Modified: ofbiz/trunk/framework/common/config/general.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/config/general.properties?view=diff&rev=537329&r1=537328&r2=537329
==============================================================================
--- ofbiz/trunk/framework/common/config/general.properties (original)
+++ ofbiz/trunk/framework/common/config/general.properties Fri May 11 20:49:45 2007
@@ -39,20 +39,20 @@
 usps.address.match=(^.*?p[\\. ]*o[\\. ]*box.*$)|(^.*?post.*?office.*?box.*$)|((^|(^.*? ))r[\\. ]*r[\\. ]*(( +)|([0-9#]+)).*$)|(^.*?rural.*?route.*$)
 
 # -- mail notifications enabled (Y|N)
-mail.notifications.enabled=N
+mail.notifications.enabled=Y
 
 # -- redirect all mail notifications to this address for testing
 #mail.notifications.redirectTo=
 
 # -- the default mail server to use
-mail.smtp.relay.host=localhost
+mail.smtp.relay.host=mail.hansbakker.com
 
 # -- SMTP Auth settings
-#mail.smtp.auth.user=
-#mail.smtp.auth.password=
+mail.smtp.auth.user=[hidden email]
+mail.smtp.auth.password=annette
 
 # -- debug SMTP mail option enabled (Y|N)
-mail.debug.on=N
+mail.debug.on=Y
 
 # -- HTTP upload max size in bytes (-1 for unlimited)
 http.upload.max.size=-1