svn commit: r1713778 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/category/SeoContextFilter.java

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

svn commit: r1713778 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/category/SeoContextFilter.java

jleroux@apache.org
Author: jleroux
Date: Wed Nov 11 09:04:18 2015
New Revision: 1713778

URL: http://svn.apache.org/viewvc?rev=1713778&view=rev
Log:
A patch from  Ingo Wolfmayr for "EcomSEO generates an error when used in multi-tenancy setup" https://issues.apache.org/jira/browse/OFBIZ-6525

When using the ecomseo application of the ecommerce component in a tenant the tenant entity can't be accessed, and an error is returned.

Modified:
    ofbiz/trunk/applications/product/src/org/ofbiz/product/category/SeoContextFilter.java

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/SeoContextFilter.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/SeoContextFilter.java?rev=1713778&r1=1713777&r2=1713778&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/category/SeoContextFilter.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/category/SeoContextFilter.java Wed Nov 11 09:04:18 2015
@@ -295,13 +295,19 @@ public class SeoContextFilter extends Co
             // get tenant delegator by domain name
             String serverName = httpRequest.getServerName();
             try {
-                // if tenant was specified, replace delegator with the new per-tenant delegator and set tenantId to session attribute
+                // if tenant was specified, replace delegator with the new per-tenant delegator and set tenantId to session attribute                
                 Delegator delegator = getDelegator(config.getServletContext());
-                List<GenericValue> tenants = delegator.findList("Tenant", EntityCondition.makeCondition("domainName", serverName), null, UtilMisc.toList("-createdStamp"), null, false);
+                
+                // to access entity "tenant" we need the default delegator
+                Delegator defaultdelegator = DelegatorFactory.getDelegator("default");
+                
+                // take the tenantId from the current delegator
+                String tenantId = delegator.getDelegatorTenantId();
+                
+                List<GenericValue> tenants = defaultdelegator.findList("Tenant", EntityCondition.makeCondition("tenantId", tenantId), null, UtilMisc.toList("-createdStamp"), null, false);
                 if (UtilValidate.isNotEmpty(tenants)) {
                     GenericValue tenant = EntityUtil.getFirst(tenants);
-                    String tenantId = tenant.getString("tenantId");
-
+                    
                     // if the request path is a root mount then redirect to the initial path
                     if (UtilValidate.isNotEmpty(requestPath) && requestPath.equals(contextUri)) {
                         String initialPath = tenant.getString("initialPath");