You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mb...@apache.org on 2018/12/08 09:27:16 UTC

svn commit: r1848444 - in /ofbiz/ofbiz-framework/trunk/applications/marketing: config/MarketingUiLabels.xml minilang/marketing/contact/ContactListServices.xml

Author: mbrohl
Date: Sat Dec  8 09:27:15 2018
New Revision: 1848444

URL: http://svn.apache.org/viewvc?rev=1848444&view=rev
Log:
Fixed: Missing nullcheck in service createContactListParty.
(OFBIZ-10653)

This fix adds a nullcheck for the partyEmail and provides a better 
errorMessage for the in-request service call. In addition the failing 
partyID will be logged for the admin to see.

Thanks Dennis Balkir for reporting and providing the patch.

Modified:
    ofbiz/ofbiz-framework/trunk/applications/marketing/config/MarketingUiLabels.xml
    ofbiz/ofbiz-framework/trunk/applications/marketing/minilang/marketing/contact/ContactListServices.xml

Modified: ofbiz/ofbiz-framework/trunk/applications/marketing/config/MarketingUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/marketing/config/MarketingUiLabels.xml?rev=1848444&r1=1848443&r2=1848444&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/marketing/config/MarketingUiLabels.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/marketing/config/MarketingUiLabels.xml Sat Dec  8 09:27:15 2018
@@ -797,6 +797,10 @@
         <value xml:lang="zh">验证电子邮件站点标识</value>
         <value xml:lang="zh-TW">驗證電子郵件站台識別</value>
     </property>
+    <property key="MarketingContactMechNotExists">
+        <value xml:lang="de">Der bevorzugte Kontaktmechanismus für Party [${partyId}] konnte nicht gefunden werden</value>
+        <value xml:lang="en">Could not find the preferred contact mechanism for party [${parameters.partyId}]</value>
+    </property>
     <property key="MarketingContactMechNotRightForContactList">
         <value xml:lang="de">Der bevorzugte Kontaktmechanismus [${preferredContactMechType.description}] ist vom falschen Typ für die Liste [${listContactMechType.description}].</value>
         <value xml:lang="en">The preferred contact mechanism [${preferredContactMechType.description}] was not of the right type for the list [${listContactMechType.description}].</value>

Modified: ofbiz/ofbiz-framework/trunk/applications/marketing/minilang/marketing/contact/ContactListServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/marketing/minilang/marketing/contact/ContactListServices.xml?rev=1848444&r1=1848443&r2=1848444&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/marketing/minilang/marketing/contact/ContactListServices.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/marketing/minilang/marketing/contact/ContactListServices.xml Sat Dec  8 09:27:15 2018
@@ -85,18 +85,28 @@ under the License.
                     <result-to-field result-name="contactMechId" field="parameters.preferredContactMechId"/>
                 </call-service>        
             </if-empty>
-        </if-empty>    
+        </if-empty>
 
-        <make-value entity-name="ContactListParty" value-field="newEntity"/>
-        <set-nonpk-fields map="parameters" value-field="newEntity"/>
-        <set-pk-fields map="parameters" value-field="newEntity"/>
-        <if-empty field="newEntity.fromDate"><now-timestamp field="newEntity.fromDate"/></if-empty>
+        <if-not-empty field="parameters.preferredContactMechId">
+            <make-value entity-name="ContactListParty" value-field="newEntity"/>
+            <set-nonpk-fields map="parameters" value-field="newEntity"/>
+            <set-pk-fields map="parameters" value-field="newEntity"/>
+            <if-empty field="newEntity.fromDate"><now-timestamp field="newEntity.fromDate"/></if-empty>
+
+            <create-value value-field="newEntity"/>
+            <set-service-fields service-name="createContactListPartyStatus" map="newEntity" to-map="createContactListPartyStatusMap"/>
+            <set field="createContactListPartyStatusMap.baseLocation" from-field="parameters.baseLocation"/>
+            <call-service service-name="createContactListPartyStatus" in-map-name="createContactListPartyStatusMap"/>
+
+            <!-- Some parties happen to not have email addresses, this should be logged -->
+            <else>
+                <log level="info" message="Could not find the preferred contact mechanism for party [${parameters.partyId}]"/>
+                <set field="partyId" from-field="parameters.partyId"/>
+                <property-to-field resource="MarketingUiLabels.xml" property="MarketingContactMechNotExists" field="message"/>
+                <field-to-result field="message" result-name="errorMessage"></field-to-result>
+            </else>
+        </if-not-empty>
 
-        <create-value value-field="newEntity"/>
-        
-        <set-service-fields service-name="createContactListPartyStatus" map="newEntity" to-map="createContactListPartyStatusMap"/>
-        <set field="createContactListPartyStatusMap.baseLocation" from-field="parameters.baseLocation"/>
-        <call-service service-name="createContactListPartyStatus" in-map-name="createContactListPartyStatusMap"/>
     </simple-method>
     <simple-method method-name="updateContactListParty" short-description="Update Add Party To ContactList">
         <!-- allow if userLogin.partyId = parameters.partyId or has permission -->