You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2013/09/30 17:15:35 UTC
svn commit: r1527609 -
/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java
Author: adrianc
Date: Mon Sep 30 15:15:35 2013
New Revision: 1527609
URL: http://svn.apache.org/r1527609
Log:
Small change to GenericDelegator.findOne method - moved the primary key validation check to the beginning of the method.
I believe the original intention was to perform the validation check after the EV_VALIDATE ECAs were run, but the primary key was being used in three method calls before that happened - so those methods could have been passed an invalid primary key.
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java?rev=1527609&r1=1527608&r2=1527609&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java Mon Sep 30 15:15:35 2013
@@ -1574,6 +1574,9 @@ public class GenericDelegator implements
*/
public GenericValue findOne(String entityName, Map<String, ? extends Object> fields, boolean useCache) throws GenericEntityException {
GenericPK primaryKey = this.makePK(entityName, fields);
+ if (!primaryKey.isPrimaryKey()) {
+ throw new GenericModelException("[GenericDelegator.findOne] Passed primary key is not a valid primary key: " + primaryKey);
+ }
EntityEcaRuleRunner<?> ecaRunner = this.getEcaRuleRunner(entityName);
if (useCache) {
ecaRunner.evalRules(EntityEcaHandler.EV_CACHE_CHECK, EntityEcaHandler.OP_FIND, primaryKey, false);
@@ -1595,9 +1598,6 @@ public class GenericDelegator implements
GenericHelper helper = getEntityHelper(entityName);
GenericValue value = null;
- if (!primaryKey.isPrimaryKey()) {
- throw new GenericModelException("[GenericDelegator.findOne] Passed primary key is not a valid primary key: " + primaryKey);
- }
ecaRunner.evalRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_FIND, primaryKey, false);
try {
value = helper.findByPrimaryKey(primaryKey);