svn commit: r1643499 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java

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

svn commit: r1643499 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java

jacopoc
Author: jacopoc
Date: Sat Dec  6 08:01:06 2014
New Revision: 1643499

URL: http://svn.apache.org/r1643499
Log:
Added a check to prevent client code holding a reference to a "tenant" delegator to access super/meta tenant tables. Thanks to Arun Patidar for spotting this and for discussing with me the proper solution.

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=1643499&r1=1643498&r2=1643499&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java Sat Dec  6 08:01:06 2014
@@ -478,9 +478,12 @@ public class GenericDelegator implements
         if (helperBaseName == null) {
             return null;
         }
-        GenericHelperInfo helperInfo = new GenericHelperInfo(entityGroupName, helperBaseName);
+        if (UtilValidate.isNotEmpty(this.delegatorTenantId) && "org.ofbiz.tenant".equals(entityGroupName)) {
+            Debug.logInfo("Can't access entity of entityGroup = " + entityGroupName + " using tenant delegator "+ this.getDelegatorName()+", use base delegator instead", module);
+            return null;
+        }
 
-        // to avoid infinite recursion, and to behave right for shared org.ofbiz.tenant entities, do nothing with the tenantId if the entityGroupName=org.ofbiz.tenant
+        GenericHelperInfo helperInfo = new GenericHelperInfo(entityGroupName, helperBaseName);
         if (UtilValidate.isNotEmpty(this.delegatorTenantId)) {
             // get the JDBC parameters from the DB for the entityGroupName and tenantId
             try {
@@ -500,7 +503,6 @@ public class GenericDelegator implements
                 // don't complain about this too much, just log the error if there is one
                 Debug.logInfo(e, "Error getting TenantDataSource info for tenantId=" + this.delegatorTenantId + ", entityGroupName=" + entityGroupName, module);
             }
-
         }
         return helperInfo;
     }