Permalink
Browse files

A patch from Chatree Srichart for "The createDataResourceRole service…

… does not check if partyId exists" https://issues.apache.org/jira/browse/OFBIZ-5133

The createDataResourceRole service has a partyId attribute as optional but its implementation method does not check if the partyId exists before creating a DataResourceRole value.
The ensurePartyRole service also has a partyId attribute as optional but its implementation method does not check if the partyId exists before creating a PartyRole value.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1446876 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 47ac9b1 commit f9320845f416addb1de3407329b97ac82afa26c2 @JacquesLeRoux JacquesLeRoux committed Feb 16, 2013
@@ -180,16 +180,16 @@ under the License.
<!-- Methods for DataResourceRole -->
<simple-method method-name="createDataResourceRole" short-description="Create Data Resource Role">
- <make-value entity-name="DataResourceRole" 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="nowTimestamp"/>
- <set field="newEntity.fromDate" from-field="nowTimestamp"/>
- </if-empty>
-
- <create-value value-field="newEntity"/>
+ <if-not-empty field="parameters.partyId">
+ <make-value entity-name="DataResourceRole" 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="nowTimestamp"/>
+ <set field="newEntity.fromDate" from-field="nowTimestamp"/>
+ </if-empty>
+ <create-value value-field="newEntity"/>
+ </if-not-empty>
</simple-method>
<simple-method method-name="updateDataResourceRole" short-description="Update Data Resource Role">
<make-value entity-name="DataResourceRole" value-field="lookupKeyValue"/>
@@ -65,11 +65,14 @@ under the License.
<set from-field="parameters.roleTypeId" field="lookupPKMap.roleTypeId"/>
</else>
</if-empty>
- <find-by-primary-key entity-name="PartyRole" map="lookupPKMap" value-field="lookedUpValue"/>
- <if-empty field="lookedUpValue">
- <make-value value-field="newValue" entity-name="PartyRole" map="lookupPKMap"/>
- <create-value value-field="newValue"/>
- </if-empty>
+ <if-not-empty field="lookupPKMap.partyId">
+ <find-by-primary-key entity-name="PartyRole" map="lookupPKMap" value-field="lookedUpValue"/>
+ <if-empty field="lookedUpValue">
+ <make-value value-field="newValue" entity-name="PartyRole" map="lookupPKMap"/>
+ <create-value value-field="newValue"/>
+ </if-empty>
+ </if-not-empty>
+
</simple-method>
<simple-method method-name="createPersonAndUserLogin" short-description="Creates a person and userlogin" login-required="false">

0 comments on commit f932084

Please sign in to comment.