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.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1848444 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Brohl
2018-12-08 09:27:15 +00:00
parent ae18673c40
commit b5e8175fc0
2 changed files with 24 additions and 10 deletions
@@ -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>
@@ -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 -->