Author: jacopoc
Date: Mon Sep 5 16:56:04 2016 New Revision: 1759332 URL: http://svn.apache.org/viewvc?rev=1759332&view=rev Log: OFBIZ-8142 A series of cleanups related to OFBiz servlet filters: * removed an unused filter (UrlRegexpContextFilter) * moved a series of methods from ContextFilter to WebAppUtil, where they make more sense; changed one of them to be a static method * made private some methods of ContextFilter and WebAppUtil because they were not used outside of their classes Removed: ofbiz/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/UrlRegexpContextFilter.java Modified: ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentUrlFilter.java ofbiz/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlFilter.java ofbiz/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContextFilter.java ofbiz/trunk/framework/common/src/main/java/org/apache/ofbiz/common/UrlServletHelper.java ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/WebAppUtil.java ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ContextFilter.java ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java Modified: ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentUrlFilter.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentUrlFilter.java?rev=1759332&r1=1759331&r2=1759332&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentUrlFilter.java (original) +++ ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentUrlFilter.java Mon Sep 5 16:56:04 2016 @@ -38,6 +38,7 @@ import org.apache.ofbiz.common.UrlServle import org.apache.ofbiz.entity.Delegator; import org.apache.ofbiz.entity.GenericValue; import org.apache.ofbiz.entity.util.EntityQuery; +import org.apache.ofbiz.webapp.WebAppUtil; import org.apache.ofbiz.webapp.control.ContextFilter; public class ContentUrlFilter extends ContextFilter { @@ -57,7 +58,7 @@ public class ContentUrlFilter extends Co //Get ServletContext ServletContext servletContext = config.getServletContext(); - ContextFilter.setCharacterEncoding(request); + WebAppUtil.setCharacterEncoding(request); //Set request attribute and session UrlServletHelper.setRequestAttributes(request, delegator, servletContext); @@ -88,7 +89,7 @@ public class ContentUrlFilter extends Co urlBuilder.append("/" + CONTROL_MOUNT_POINT); urlBuilder.append("/" + config.getInitParameter("viewRequest") + "?contentId=" + urlContentId); - ContextFilter.setAttributesFromRequestBody(request); + WebAppUtil.setAttributesFromRequestBody(request); //Set view query parameters UrlServletHelper.setViewQueryParameters(request, urlBuilder); Debug.logInfo("[Filtered request]: " + pathInfo + " (" + urlBuilder + ")", module); Modified: ofbiz/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlFilter.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlFilter.java?rev=1759332&r1=1759331&r2=1759332&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlFilter.java (original) +++ ofbiz/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlFilter.java Mon Sep 5 16:56:04 2016 @@ -44,6 +44,7 @@ import org.apache.ofbiz.entity.condition import org.apache.ofbiz.entity.util.EntityQuery; import org.apache.ofbiz.entity.util.EntityUtil; import org.apache.ofbiz.product.product.ProductContentWrapper; +import org.apache.ofbiz.webapp.WebAppUtil; import org.apache.ofbiz.webapp.control.ContextFilter; public class CatalogUrlFilter extends ContextFilter { @@ -66,7 +67,7 @@ public class CatalogUrlFilter extends Co //Get ServletContext ServletContext servletContext = config.getServletContext(); - ContextFilter.setCharacterEncoding(request); + WebAppUtil.setCharacterEncoding(request); //Set request attribute and session UrlServletHelper.setRequestAttributes(request, delegator, servletContext); @@ -324,7 +325,7 @@ public class CatalogUrlFilter extends Co UrlServletHelper.setViewQueryParameters(request, urlBuilder); if (UtilValidate.isNotEmpty(productId) || UtilValidate.isNotEmpty(productCategoryId) || UtilValidate.isNotEmpty(urlContentId)) { Debug.logInfo("[Filtered request]: " + pathInfo + " (" + urlBuilder + ")", module); - ContextFilter.setAttributesFromRequestBody(request); + WebAppUtil.setAttributesFromRequestBody(request); RequestDispatcher dispatch = request.getRequestDispatcher(urlBuilder.toString()); dispatch.forward(request, response); return; Modified: ofbiz/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContextFilter.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContextFilter.java?rev=1759332&r1=1759331&r2=1759332&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContextFilter.java (original) +++ ofbiz/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContextFilter.java Mon Sep 5 16:56:04 2016 @@ -39,6 +39,7 @@ import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.ofbiz.webapp.WebAppUtil; import org.apache.oro.text.regex.Pattern; import org.apache.oro.text.regex.Perl5Matcher; import org.apache.ofbiz.base.util.Debug; @@ -296,7 +297,7 @@ public class SeoContextFilter extends Co String serverName = httpRequest.getServerName(); try { // if tenant was specified, replace delegator with the new per-tenant delegator and set tenantId to session attribute - Delegator delegator = getDelegator(config.getServletContext()); + Delegator delegator = WebAppUtil.getDelegator(config.getServletContext()); // to access entity "tenant" we need the default delegator Delegator defaultdelegator = DelegatorFactory.getDelegator("default"); @@ -330,9 +331,9 @@ public class SeoContextFilter extends Co config.getServletContext().setAttribute("dispatcher", null); // initialize security - Security security = getSecurity(); + Security security = WebAppUtil.getSecurity(config.getServletContext()); // initialize the services dispatcher - LocalDispatcher dispatcher = getDispatcher(config.getServletContext()); + LocalDispatcher dispatcher = WebAppUtil.getDispatcher(config.getServletContext()); // set web context objects request.setAttribute("dispatcher", dispatcher); Modified: ofbiz/trunk/framework/common/src/main/java/org/apache/ofbiz/common/UrlServletHelper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/main/java/org/apache/ofbiz/common/UrlServletHelper.java?rev=1759332&r1=1759331&r2=1759332&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/main/java/org/apache/ofbiz/common/UrlServletHelper.java (original) +++ ofbiz/trunk/framework/common/src/main/java/org/apache/ofbiz/common/UrlServletHelper.java Mon Sep 5 16:56:04 2016 @@ -38,6 +38,7 @@ import org.apache.ofbiz.entity.GenericEn import org.apache.ofbiz.entity.GenericValue; import org.apache.ofbiz.entity.util.EntityQuery; import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.webapp.WebAppUtil; import org.apache.ofbiz.webapp.control.ContextFilter; import org.apache.ofbiz.webapp.website.WebSiteWorker; @@ -56,7 +57,7 @@ public final class UrlServletHelper exte String serverName = request.getServerName(); try { // if tenant was specified, replace delegator with the new per-tenant delegator and set tenantId to session attribute - delegator = getDelegator(servletContext); + delegator = WebAppUtil.getDelegator(servletContext); //Use base delegator for fetching data from entity of entityGroup org.apache.ofbiz.tenant Delegator baseDelegator = DelegatorFactory.getDelegator(delegator.getDelegatorBaseName()); Modified: ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/WebAppUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/WebAppUtil.java?rev=1759332&r1=1759331&r2=1759332&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/WebAppUtil.java (original) +++ ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/WebAppUtil.java Mon Sep 5 16:56:04 2016 @@ -22,13 +22,22 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.util.Map; import java.util.Map.Entry; - -import org.apache.tomcat.util.digester.Digester; -import org.apache.tomcat.util.descriptor.DigesterFactory; -import org.apache.tomcat.util.descriptor.web.ServletDef; -import org.apache.tomcat.util.descriptor.web.WebRuleSet; -import org.apache.tomcat.util.descriptor.web.WebXml; +import java.util.Set; +import javax.servlet.ServletContext; +import javax.servlet.ServletRequest; + +import org.apache.ofbiz.base.util.UtilValidate; +import org.apache.ofbiz.entity.Delegator; +import org.apache.ofbiz.entity.DelegatorFactory; +import org.apache.ofbiz.security.Security; +import org.apache.ofbiz.security.SecurityConfigurationException; +import org.apache.ofbiz.security.SecurityFactory; +import org.apache.ofbiz.service.LocalDispatcher; +import org.apache.ofbiz.service.ServiceContainer; +import org.apache.ofbiz.webapp.event.RequestBodyMapHandlerFactory; import org.apache.ofbiz.base.component.ComponentConfig; import org.apache.ofbiz.base.component.ComponentConfig.WebappInfo; import org.apache.ofbiz.base.util.Assert; @@ -36,6 +45,12 @@ import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.UtilXml.LocalErrorHandler; import org.apache.ofbiz.base.util.UtilXml.LocalResolver; import org.apache.ofbiz.base.util.cache.UtilCache; + +import org.apache.tomcat.util.digester.Digester; +import org.apache.tomcat.util.descriptor.DigesterFactory; +import org.apache.tomcat.util.descriptor.web.ServletDef; +import org.apache.tomcat.util.descriptor.web.WebRuleSet; +import org.apache.tomcat.util.descriptor.web.WebXml; import org.xml.sax.ErrorHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -118,6 +133,103 @@ public final class WebAppUtil { return webXml.getContextParams().get("webSiteId"); } + public static LocalDispatcher getDispatcher(ServletContext servletContext) { + LocalDispatcher dispatcher = (LocalDispatcher) servletContext.getAttribute("dispatcher"); + if (dispatcher == null) { + Delegator delegator = getDelegator(servletContext); + dispatcher = makeWebappDispatcher(servletContext, delegator); + servletContext.setAttribute("dispatcher", dispatcher); + } + return dispatcher; + } + + public static void setCharacterEncoding(ServletRequest request) throws UnsupportedEncodingException { + String charset = request.getServletContext().getInitParameter("charset"); + if (UtilValidate.isEmpty(charset)) charset = request.getCharacterEncoding(); + if (UtilValidate.isEmpty(charset)) charset = "UTF-8"; + if (Debug.verboseOn()) Debug.logVerbose("The character encoding of the request is: [" + request.getCharacterEncoding() + "]. The character encoding we will use for the request is: [" + charset + "]", module); + + if (!"none".equals(charset)) { + request.setCharacterEncoding(charset); + } + } + + public static void setAttributesFromRequestBody(ServletRequest request) { + // read the body (for JSON requests) and set the parameters as attributes: + Map<String, Object> requestBodyMap = null; + try { + requestBodyMap = RequestBodyMapHandlerFactory.extractMapFromRequestBody(request); + } catch (IOException ioe) { + Debug.logWarning(ioe, module); + } + if (requestBodyMap != null) { + Set<String> parameterNames = requestBodyMap.keySet(); + for (String parameterName: parameterNames) { + request.setAttribute(parameterName, requestBodyMap.get(parameterName)); + } + } + } + + /** This method only sets up a dispatcher for the current webapp and passed in delegator, it does not save it to the ServletContext or anywhere else, just returns it */ + public static LocalDispatcher makeWebappDispatcher(ServletContext servletContext, Delegator delegator) { + if (delegator == null) { + Debug.logError("[ContextFilter.init] ERROR: delegator not defined.", module); + return null; + } + // get the unique name of this dispatcher + String dispatcherName = servletContext.getInitParameter("localDispatcherName"); + + if (dispatcherName == null) { + Debug.logError("No localDispatcherName specified in the web.xml file", module); + dispatcherName = delegator.getDelegatorName(); + } + + LocalDispatcher dispatcher = ServiceContainer.getLocalDispatcher(dispatcherName, delegator); + if (dispatcher == null) { + Debug.logError("[ContextFilter.init] ERROR: dispatcher could not be initialized.", module); + } + + return dispatcher; + } + + public static Delegator getDelegator(ServletContext servletContext) { + Delegator delegator = (Delegator) servletContext.getAttribute("delegator"); + if (delegator == null) { + String delegatorName = servletContext.getInitParameter("entityDelegatorName"); + + if (UtilValidate.isEmpty(delegatorName)) { + delegatorName = "default"; + } + if (Debug.verboseOn()) Debug.logVerbose("Setup Entity Engine Delegator with name " + delegatorName, module); + delegator = DelegatorFactory.getDelegator(delegatorName); + servletContext.setAttribute("delegator", delegator); + if (delegator == null) { + Debug.logError("[ContextFilter.init] ERROR: delegator factory returned null for delegatorName \"" + delegatorName + "\"", module); + } + } + return delegator; + } + + public static Security getSecurity(ServletContext servletContext) { + Security security = (Security) servletContext.getAttribute("security"); + if (security == null) { + Delegator delegator = (Delegator) servletContext.getAttribute("delegator"); + + if (delegator != null) { + try { + security = SecurityFactory.getInstance(delegator); + } catch (SecurityConfigurationException e) { + Debug.logError(e, "Unable to obtain an instance of the security object.", module); + } + } + servletContext.setAttribute("security", security); + if (security == null) { + Debug.logError("An invalid (null) Security object has been set in the servlet context.", module); + } + } + return security; + } + /** * Returns a <code>WebXml</code> instance that models the web application's <code>web.xml</code> file. * @@ -125,7 +237,7 @@ public final class WebAppUtil { * @throws IOException * @throws SAXException */ - public static WebXml getWebXml(WebappInfo webAppInfo) throws IOException, SAXException { + private static WebXml getWebXml(WebappInfo webAppInfo) throws IOException, SAXException { Assert.notNull("webAppInfo", webAppInfo); String webXmlFileLocation = webAppInfo.getLocation().concat(webAppFileName); return parseWebXmlFile(webXmlFileLocation, true); @@ -139,7 +251,7 @@ public final class WebAppUtil { * @throws IOException * @throws SAXException */ - public static WebXml parseWebXmlFile(String webXmlFileLocation, boolean validate) throws IOException, SAXException { + private static WebXml parseWebXmlFile(String webXmlFileLocation, boolean validate) throws IOException, SAXException { Assert.notEmpty("webXmlFileLocation", webXmlFileLocation); WebXml result = webXmlCache.get(webXmlFileLocation); if (result == null) { Modified: ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ContextFilter.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ContextFilter.java?rev=1759332&r1=1759331&r2=1759332&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ContextFilter.java (original) +++ ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ContextFilter.java Mon Sep 5 16:56:04 2016 @@ -54,6 +54,7 @@ import org.apache.ofbiz.security.Securit import org.apache.ofbiz.security.SecurityFactory; import org.apache.ofbiz.service.LocalDispatcher; import org.apache.ofbiz.service.ServiceContainer; +import org.apache.ofbiz.webapp.WebAppUtil; import org.apache.ofbiz.webapp.event.RequestBodyMapHandlerFactory; import org.apache.ofbiz.webapp.website.WebSiteWorker; @@ -74,7 +75,7 @@ public class ContextFilter implements Fi public void init(FilterConfig config) throws ServletException { this.config = config; - // puts all init-parameters in ServletContext attributes for easier parameterization without code changes + // puts all init-parameters in ServletContext attributes for easier parametrization without code changes this.putAllInitParametersInAttributes(); // set debug @@ -86,11 +87,11 @@ public class ContextFilter implements Fi // check the serverId getServerId(); // initialize the delegator - getDelegator(config.getServletContext()); + WebAppUtil.getDelegator(config.getServletContext()); // initialize security - getSecurity(); + WebAppUtil.getSecurity(config.getServletContext()); // initialize the services dispatcher - getDispatcher(config.getServletContext()); + WebAppUtil.getDispatcher(config.getServletContext()); // this will speed up the initial sessionId generation new java.security.SecureRandom().nextLong(); @@ -251,14 +252,14 @@ public class ContextFilter implements Fi // check if multi tenant is enabled boolean useMultitenant = EntityUtil.isMultiTenantEnabled(); - setCharacterEncoding(request); - setAttributesFromRequestBody(request); + WebAppUtil.setCharacterEncoding(request); + WebAppUtil.setAttributesFromRequestBody(request); if (useMultitenant) { // 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 - Delegator delegator = getDelegator(config.getServletContext()); + Delegator delegator = WebAppUtil.getDelegator(config.getServletContext()); //Use base delegator for fetching data from entity of entityGroup org.apache.ofbiz.tenant Delegator baseDelegator = DelegatorFactory.getDelegator(delegator.getDelegatorBaseName()); @@ -298,9 +299,9 @@ public class ContextFilter implements Fi config.getServletContext().setAttribute("dispatcher", null); // initialize security - Security security = getSecurity(); + Security security = WebAppUtil.getSecurity(config.getServletContext()); // initialize the services dispatcher - LocalDispatcher dispatcher = getDispatcher(config.getServletContext()); + LocalDispatcher dispatcher = WebAppUtil.getDispatcher(config.getServletContext()); // set web context objects request.setAttribute("dispatcher", dispatcher); @@ -327,108 +328,11 @@ public class ContextFilter implements Fi * @see javax.servlet.Filter#destroy() */ public void destroy() { - getDispatcher(config.getServletContext()).deregister(); + WebAppUtil.getDispatcher(config.getServletContext()).deregister(); config = null; } - protected static LocalDispatcher getDispatcher(ServletContext servletContext) { - LocalDispatcher dispatcher = (LocalDispatcher) servletContext.getAttribute("dispatcher"); - if (dispatcher == null) { - Delegator delegator = getDelegator(servletContext); - dispatcher = makeWebappDispatcher(servletContext, delegator); - servletContext.setAttribute("dispatcher", dispatcher); - } - return dispatcher; - } - - public static void setCharacterEncoding(ServletRequest request) throws UnsupportedEncodingException { - String charset = request.getServletContext().getInitParameter("charset"); - if (UtilValidate.isEmpty(charset)) charset = request.getCharacterEncoding(); - if (UtilValidate.isEmpty(charset)) charset = "UTF-8"; - if (Debug.verboseOn()) Debug.logVerbose("The character encoding of the request is: [" + request.getCharacterEncoding() + "]. The character encoding we will use for the request is: [" + charset + "]", module); - - if (!"none".equals(charset)) { - request.setCharacterEncoding(charset); - } - } - - public static void setAttributesFromRequestBody(ServletRequest request) { - // read the body (for JSON requests) and set the parameters as attributes: - Map<String, Object> requestBodyMap = null; - try { - requestBodyMap = RequestBodyMapHandlerFactory.extractMapFromRequestBody(request); - } catch (IOException ioe) { - Debug.logWarning(ioe, module); - } - if (requestBodyMap != null) { - Set<String> parameterNames = requestBodyMap.keySet(); - for (String parameterName: parameterNames) { - request.setAttribute(parameterName, requestBodyMap.get(parameterName)); - } - } - } - - /** This method only sets up a dispatcher for the current webapp and passed in delegator, it does not save it to the ServletContext or anywhere else, just returns it */ - public static LocalDispatcher makeWebappDispatcher(ServletContext servletContext, Delegator delegator) { - if (delegator == null) { - Debug.logError("[ContextFilter.init] ERROR: delegator not defined.", module); - return null; - } - // get the unique name of this dispatcher - String dispatcherName = servletContext.getInitParameter("localDispatcherName"); - - if (dispatcherName == null) { - Debug.logError("No localDispatcherName specified in the web.xml file", module); - dispatcherName = delegator.getDelegatorName(); - } - - LocalDispatcher dispatcher = ServiceContainer.getLocalDispatcher(dispatcherName, delegator); - if (dispatcher == null) { - Debug.logError("[ContextFilter.init] ERROR: dispatcher could not be initialized.", module); - } - - return dispatcher; - } - - protected static Delegator getDelegator(ServletContext servletContext) { - Delegator delegator = (Delegator) servletContext.getAttribute("delegator"); - if (delegator == null) { - String delegatorName = servletContext.getInitParameter("entityDelegatorName"); - - if (UtilValidate.isEmpty(delegatorName)) { - delegatorName = "default"; - } - if (Debug.verboseOn()) Debug.logVerbose("Setup Entity Engine Delegator with name " + delegatorName, module); - delegator = DelegatorFactory.getDelegator(delegatorName); - servletContext.setAttribute("delegator", delegator); - if (delegator == null) { - Debug.logError("[ContextFilter.init] ERROR: delegator factory returned null for delegatorName \"" + delegatorName + "\"", module); - } - } - return delegator; - } - - protected Security getSecurity() { - Security security = (Security) config.getServletContext().getAttribute("security"); - if (security == null) { - Delegator delegator = (Delegator) config.getServletContext().getAttribute("delegator"); - - if (delegator != null) { - try { - security = SecurityFactory.getInstance(delegator); - } catch (SecurityConfigurationException e) { - Debug.logError(e, "Unable to obtain an instance of the security object.", module); - } - } - config.getServletContext().setAttribute("security", security); - if (security == null) { - Debug.logError("An invalid (null) Security object has been set in the servlet context.", module); - } - } - return security; - } - - protected void putAllInitParametersInAttributes() { + private void putAllInitParametersInAttributes() { Enumeration<String> initParamEnum = UtilGenerics.cast(config.getServletContext().getInitParameterNames()); while (initParamEnum.hasMoreElements()) { String initParamName = initParamEnum.nextElement(); @@ -438,7 +342,7 @@ public class ContextFilter implements Fi } } - protected String getServerId() { + private String getServerId() { String serverId = (String) config.getServletContext().getAttribute("_serverId"); if (serverId == null) { serverId = config.getServletContext().getInitParameter("ofbizServerName"); Modified: ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java?rev=1759332&r1=1759331&r2=1759332&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java (original) +++ ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java Mon Sep 5 16:56:04 2016 @@ -79,6 +79,7 @@ import org.apache.ofbiz.service.GenericS import org.apache.ofbiz.service.LocalDispatcher; import org.apache.ofbiz.service.ModelService; import org.apache.ofbiz.service.ServiceUtil; +import org.apache.ofbiz.webapp.WebAppUtil; import org.apache.ofbiz.webapp.stats.VisitHandler; /** @@ -475,7 +476,7 @@ public class LoginWorker { try { // after this line the delegator is replaced with the new per-tenant delegator delegator = DelegatorFactory.getDelegator(delegatorName); - dispatcher = ContextFilter.makeWebappDispatcher(servletContext, delegator); + dispatcher = WebAppUtil.makeWebappDispatcher(servletContext, delegator); } catch (NullPointerException e) { Debug.logError(e, "Error getting tenant delegator", module); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", "Tenant [" + tenantId + "] not found..."); @@ -494,7 +495,7 @@ public class LoginWorker { try { // after this line the delegator is replaced with default delegator delegator = DelegatorFactory.getDelegator(delegatorName); - dispatcher = ContextFilter.makeWebappDispatcher(servletContext, delegator); + dispatcher = WebAppUtil.makeWebappDispatcher(servletContext, delegator); } catch (NullPointerException e) { Debug.logError(e, "Error getting default delegator", module); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", "Error getting default delegator"); @@ -748,7 +749,7 @@ public class LoginWorker { session.setAttribute("delegatorName", delegatorName); delegator = DelegatorFactory.getDelegator(delegatorName); - LocalDispatcher dispatcher = ContextFilter.makeWebappDispatcher(session.getServletContext(), delegator); + LocalDispatcher dispatcher = WebAppUtil.makeWebappDispatcher(session.getServletContext(), delegator); setWebContextObjects(request, response, delegator, dispatcher); } @@ -1064,7 +1065,7 @@ public class LoginWorker { ServletContext servletContext = session.getServletContext(); if (!oldDelegatorName.equals(userLogin.getDelegator().getDelegatorName())) { delegator = DelegatorFactory.getDelegator(userLogin.getDelegator().getDelegatorName()); - dispatcher = ContextFilter.makeWebappDispatcher(servletContext, delegator); + dispatcher = WebAppUtil.makeWebappDispatcher(servletContext, delegator); setWebContextObjects(request, response, delegator, dispatcher); } // found userLogin, do the external login... |
Free forum by Nabble | Edit this page |