Does this effect the Tenant operation?
========================= BJ Freeman Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=52> Specialtymarket.com <http://www.specialtymarket.com/> Systems Integrator-- Glad to Assist Chat Y! messenger: bjfr33man [hidden email] sent the following on 11/9/2010 1:14 AM: > Author: hansbak > Date: Tue Nov 9 09:14:33 2010 > New Revision: 1032896 > > URL: http://svn.apache.org/viewvc?rev=1032896&view=rev > Log: > removing the tenant servlet because that gave a problem with the root mountpoint defined twice in systems which already use the root mount point > > Removed: > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/TenantServlet.java > Modified: > ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > > Modified: ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java?rev=1032896&r1=1032895&r2=1032896&view=diff > ============================================================================== > --- ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java (original) > +++ ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java Tue Nov 9 09:14:33 2010 > @@ -621,43 +621,6 @@ public class CatalinaContainer implement > return context; > } > > - protected Context createTenantContext() throws ContainerException { > - String server = "default-server"; > - Engine engine = engines.get(server); > - if (engine == null) { > - Debug.logWarning("Server with name [" + server + "] not found;", module); > - return null; > - } > - > - // create the web application context > - StandardContext context = (StandardContext) embedded.createContext("/", System.getProperty("ofbiz.home")); > - context.setJ2EEApplication(J2EE_APP); > - context.setJ2EEServer(J2EE_SERVER); > - context.setLoader(embedded.createLoader(ClassLoaderContainer.getClassLoader())); > - context.setReloadable(contextReloadable); > - context.setDistributable(distribute); > - context.setCrossContext(crossContext); > - > - > - // create the Default Servlet instance to mount > - StandardWrapper defaultServlet = new StandardWrapper(); > - defaultServlet.setServletClass("org.ofbiz.webapp.control.TenantServlet"); > - defaultServlet.setServletName("default"); > - defaultServlet.setLoadOnStartup(1); > - defaultServlet.addInitParameter("debug", "0"); > - defaultServlet.addInitParameter("listing", "true"); > - defaultServlet.addMapping("/"); > - context.addChild(defaultServlet); > - context.addServletMapping("/", "default"); > - > - Host host = hosts.get(engine.getName() + "._DEFAULT"); > - context.setRealm(host.getRealm()); > - host.addChild(context); > - context.getMapper().setDefaultHostName(host.getName()); > - > - return context; > - } > - > protected void loadComponents() throws ContainerException { > if (embedded == null) { > throw new ContainerException("Cannot load web applications without Embedded instance!"); > @@ -679,12 +642,6 @@ public class CatalinaContainer implement > } > } > } > - > - // if the multitenant is enabled then create the tenant context > - String useMultitenant = UtilProperties.getPropertyValue("general.properties", "multitenant"); > - if ("Y".equals(useMultitenant)&& UtilValidate.isEmpty(delegator.getDelegatorTenantId())) { > - createTenantContext(); > - } > } > > public void stop() throws ContainerException { > > Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java?rev=1032896&r1=1032895&r2=1032896&view=diff > ============================================================================== > --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java (original) > +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java Tue Nov 9 09:14:33 2010 > @@ -288,6 +288,12 @@ public class ContextFilter implements Fi > GenericValue tenant = EntityUtil.getFirst(tenants); > String tenantId = tenant.getString("tenantId"); > > + // if the request URI is "/control/main" then redirect to the initial path > + if (httpRequest.getRequestURI().startsWith("/control/main")) { > + String initialPath = tenant.getString("initialPath"); > + ((HttpServletResponse)response).sendRedirect(initialPath); > + } > + > // make that tenant active, setup a new delegator and a new dispatcher > String tenantDelegatorName = delegator.getDelegatorBaseName() + "#" + tenantId; > httpRequest.getSession().setAttribute("delegatorName", tenantDelegatorName); > > > |
On 9/11/2010, at 10:14 PM, [hidden email] wrote:
> Author: hansbak > Date: Tue Nov 9 09:14:33 2010 > New Revision: 1032896 > > URL: http://svn.apache.org/viewvc?rev=1032896&view=rev > Log: > removing the tenant servlet because that gave a problem with the root mountpoint defined twice in systems which already use the root mount point > > Removed: > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/TenantServlet.java > Modified: > ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > > > Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java?rev=1032896&r1=1032895&r2=1032896&view=diff > ============================================================================== > --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java (original) > +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java Tue Nov 9 09:14:33 2010 > @@ -288,6 +288,12 @@ public class ContextFilter implements Fi > GenericValue tenant = EntityUtil.getFirst(tenants); > String tenantId = tenant.getString("tenantId"); > > + // if the request URI is "/control/main" then redirect to the initial path > + if (httpRequest.getRequestURI().startsWith("/control/main")) { > + String initialPath = tenant.getString("initialPath"); > + ((HttpServletResponse)response).sendRedirect(initialPath); > + } > + > // make that tenant active, setup a new delegator and a new dispatcher > String tenantDelegatorName = delegator.getDelegatorBaseName() + "#" + tenantId; > httpRequest.getSession().setAttribute("delegatorName", tenantDelegatorName); You should always return after sending a redirect or otherwise the request continues to be processed. Also, I'm not sure what the /control/main redirect is for but keep in mind that the framework shouldn't really know anything about URIs like that and depending on them decreases flexibility. "control" is just a url pattern defined in each webapp's web.xml and can be changed to anything and there is no requirement for each application to have a "main" request. The only reason "main" is the default page is because each webapp's index.jsp redirects to it. Regards Scott smime.p7s (3K) Download Attachment |
In reply to this post by BJ Freeman
No, it doesn't. For the createTenantContext method, I created it for handle
the root mount point when an user enter only domain name. Unfortunately, it breaked the system that already has an existing webapp with root mount point. So, This changing I removed it back and handled the root mount point at the ContextFillter. Regards, Chatree Srichart On Wed, Nov 10, 2010 at 1:25 AM, BJ Freeman <[hidden email]> wrote: > Does this effect the Tenant operation? > > ========================= > BJ Freeman > Strategic Power Office with Supplier Automation < > http://www.businessesnetwork.com/automation/viewforum.php?f=52> > Specialtymarket.com <http://www.specialtymarket.com/> > Systems Integrator-- Glad to Assist > > Chat Y! messenger: bjfr33man > > > [hidden email] sent the following on 11/9/2010 1:14 AM: > >> Author: hansbak >> Date: Tue Nov 9 09:14:33 2010 >> New Revision: 1032896 >> >> URL: http://svn.apache.org/viewvc?rev=1032896&view=rev >> Log: >> removing the tenant servlet because that gave a problem with the root >> mountpoint defined twice in systems which already use the root mount point >> >> Removed: >> >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/TenantServlet.java >> Modified: >> >> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java >> >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >> >> Modified: >> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java?rev=1032896&r1=1032895&r2=1032896&view=diff >> >> ============================================================================== >> --- >> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java >> (original) >> +++ >> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java >> Tue Nov 9 09:14:33 2010 >> @@ -621,43 +621,6 @@ public class CatalinaContainer implement >> return context; >> } >> >> - protected Context createTenantContext() throws ContainerException { >> - String server = "default-server"; >> - Engine engine = engines.get(server); >> - if (engine == null) { >> - Debug.logWarning("Server with name [" + server + "] not >> found;", module); >> - return null; >> - } >> - >> - // create the web application context >> - StandardContext context = (StandardContext) >> embedded.createContext("/", System.getProperty("ofbiz.home")); >> - context.setJ2EEApplication(J2EE_APP); >> - context.setJ2EEServer(J2EE_SERVER); >> - >> context.setLoader(embedded.createLoader(ClassLoaderContainer.getClassLoader())); >> - context.setReloadable(contextReloadable); >> - context.setDistributable(distribute); >> - context.setCrossContext(crossContext); >> - >> - >> - // create the Default Servlet instance to mount >> - StandardWrapper defaultServlet = new StandardWrapper(); >> - >> defaultServlet.setServletClass("org.ofbiz.webapp.control.TenantServlet"); >> - defaultServlet.setServletName("default"); >> - defaultServlet.setLoadOnStartup(1); >> - defaultServlet.addInitParameter("debug", "0"); >> - defaultServlet.addInitParameter("listing", "true"); >> - defaultServlet.addMapping("/"); >> - context.addChild(defaultServlet); >> - context.addServletMapping("/", "default"); >> - >> - Host host = hosts.get(engine.getName() + "._DEFAULT"); >> - context.setRealm(host.getRealm()); >> - host.addChild(context); >> - context.getMapper().setDefaultHostName(host.getName()); >> - >> - return context; >> - } >> - >> protected void loadComponents() throws ContainerException { >> if (embedded == null) { >> throw new ContainerException("Cannot load web applications >> without Embedded instance!"); >> @@ -679,12 +642,6 @@ public class CatalinaContainer implement >> } >> } >> } >> - >> - // if the multitenant is enabled then create the tenant context >> - String useMultitenant = >> UtilProperties.getPropertyValue("general.properties", "multitenant"); >> - if ("Y".equals(useMultitenant)&& >> UtilValidate.isEmpty(delegator.getDelegatorTenantId())) { >> - createTenantContext(); >> - } >> } >> >> public void stop() throws ContainerException { >> >> Modified: >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java?rev=1032896&r1=1032895&r2=1032896&view=diff >> >> ============================================================================== >> --- >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >> (original) >> +++ >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >> Tue Nov 9 09:14:33 2010 >> @@ -288,6 +288,12 @@ public class ContextFilter implements Fi >> GenericValue tenant = EntityUtil.getFirst(tenants); >> String tenantId = tenant.getString("tenantId"); >> >> + // if the request URI is "/control/main" then >> redirect to the initial path >> + if >> (httpRequest.getRequestURI().startsWith("/control/main")) { >> + String initialPath = >> tenant.getString("initialPath"); >> + >> ((HttpServletResponse)response).sendRedirect(initialPath); >> + } >> + >> // make that tenant active, setup a new delegator and >> a new dispatcher >> String tenantDelegatorName = >> delegator.getDelegatorBaseName() + "#" + tenantId; >> >> httpRequest.getSession().setAttribute("delegatorName", >> tenantDelegatorName); >> >> >> >> > |
In reply to this post by Scott Gray-2
Hi Scott Gray,
May I ask you some suggestion? Is there anyway to handle the root mount point when an user enter only domain name in a web browser. The purpose of this code is I need to handle the first URI after an user enter only domain name on a web browser and redirect to the initial path that be specified in the Tenant entity. Regards, Chatree Srichart On Wed, Nov 10, 2010 at 3:00 AM, Scott Gray <[hidden email]>wrote: > On 9/11/2010, at 10:14 PM, [hidden email] wrote: > > > Author: hansbak > > Date: Tue Nov 9 09:14:33 2010 > > New Revision: 1032896 > > > > URL: http://svn.apache.org/viewvc?rev=1032896&view=rev > > Log: > > removing the tenant servlet because that gave a problem with the root > mountpoint defined twice in systems which already use the root mount point > > > > Removed: > > > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/TenantServlet.java > > Modified: > > > ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java > > > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > > > > > > Modified: > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > > URL: > http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java?rev=1032896&r1=1032895&r2=1032896&view=diff > > > ============================================================================== > > --- > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > (original) > > +++ > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > Tue Nov 9 09:14:33 2010 > > @@ -288,6 +288,12 @@ public class ContextFilter implements Fi > > GenericValue tenant = EntityUtil.getFirst(tenants); > > String tenantId = tenant.getString("tenantId"); > > > > + // if the request URI is "/control/main" then > redirect to the initial path > > + if > (httpRequest.getRequestURI().startsWith("/control/main")) { > > + String initialPath = > tenant.getString("initialPath"); > > + > ((HttpServletResponse)response).sendRedirect(initialPath); > > + } > > + > > // make that tenant active, setup a new delegator and > a new dispatcher > > String tenantDelegatorName = > delegator.getDelegatorBaseName() + "#" + tenantId; > > > httpRequest.getSession().setAttribute("delegatorName", tenantDelegatorName); > > Hi Hans, > > You should always return after sending a redirect or otherwise the request > continues to be processed. > > Also, I'm not sure what the /control/main redirect is for but keep in mind > that the framework shouldn't really know anything about URIs like that and > depending on them decreases flexibility. "control" is just a url pattern > defined in each webapp's web.xml and can be changed to anything and there is > no requirement for each application to have a "main" request. The only > reason "main" is the default page is because each webapp's index.jsp > redirects to it. > > Regards > Scott > > |
It's difficult to say what the best solution is without understanding the problem your trying to solve with this initialPath field. It seems like using the index.jsp to push the user in the right direction would be the most flexible option. That's what happens at the moment e.g. http://www.example.com would redirect to http://www.example.com/control/main so you could just add additional logic to figure out a tenant specific redirect.
Regards Scott HotWax Media http://www.hotwaxmedia.com On 10/11/2010, at 4:17 PM, Chatree Srichart wrote: > Hi Scott Gray, > May I ask you some suggestion? Is there anyway to handle the root mount > point when an user enter only domain name in a web browser. The purpose of > this code is I need to handle the first URI after an user enter only domain > name on a web browser and redirect to the initial path that be specified in > the Tenant entity. > > Regards, > Chatree Srichart > > On Wed, Nov 10, 2010 at 3:00 AM, Scott Gray <[hidden email]>wrote: > >> On 9/11/2010, at 10:14 PM, [hidden email] wrote: >> >>> Author: hansbak >>> Date: Tue Nov 9 09:14:33 2010 >>> New Revision: 1032896 >>> >>> URL: http://svn.apache.org/viewvc?rev=1032896&view=rev >>> Log: >>> removing the tenant servlet because that gave a problem with the root >> mountpoint defined twice in systems which already use the root mount point >>> >>> Removed: >>> >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/TenantServlet.java >>> Modified: >>> >> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java >>> >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >>> >>> >>> Modified: >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >>> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java?rev=1032896&r1=1032895&r2=1032896&view=diff >>> >> ============================================================================== >>> --- >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >> (original) >>> +++ >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >> Tue Nov 9 09:14:33 2010 >>> @@ -288,6 +288,12 @@ public class ContextFilter implements Fi >>> GenericValue tenant = EntityUtil.getFirst(tenants); >>> String tenantId = tenant.getString("tenantId"); >>> >>> + // if the request URI is "/control/main" then >> redirect to the initial path >>> + if >> (httpRequest.getRequestURI().startsWith("/control/main")) { >>> + String initialPath = >> tenant.getString("initialPath"); >>> + >> ((HttpServletResponse)response).sendRedirect(initialPath); >>> + } >>> + >>> // make that tenant active, setup a new delegator and >> a new dispatcher >>> String tenantDelegatorName = >> delegator.getDelegatorBaseName() + "#" + tenantId; >>> >> httpRequest.getSession().setAttribute("delegatorName", tenantDelegatorName); >> >> Hi Hans, >> >> You should always return after sending a redirect or otherwise the request >> continues to be processed. >> >> Also, I'm not sure what the /control/main redirect is for but keep in mind >> that the framework shouldn't really know anything about URIs like that and >> depending on them decreases flexibility. "control" is just a url pattern >> defined in each webapp's web.xml and can be changed to anything and there is >> no requirement for each application to have a "main" request. The only >> reason "main" is the default page is because each webapp's index.jsp >> redirects to it. >> >> Regards >> Scott >> >> smime.p7s (3K) Download Attachment |
In reply to this post by Chatree Srichart
Hi Scott Gray,
I found this solution: Index: framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java =================================================================== --- framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java (revision 1033345) +++ framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java (working copy) @@ -196,6 +196,8 @@ } // test to see if we have come through the control servlet already, if not do the processing + String requestPath = null; + String contextUri = null; if (request.getAttribute(ContextFilter.FORWARDED_FROM_SERVLET) == null) { // Debug.logInfo("In ContextFilter.doFilter, FORWARDED_FROM_SERVLET is NOT set", module); String allowedPath = config.getInitParameter("allowedPaths"); @@ -208,7 +210,7 @@ if (debug) Debug.log("[Request]: " + httpRequest.getRequestURI(), module); - String requestPath = httpRequest.getServletPath(); + requestPath = httpRequest.getServletPath(); if (requestPath == null) requestPath = ""; if (requestPath.lastIndexOf("/") > 0) { if (requestPath.indexOf("/") == 0) { @@ -234,7 +236,7 @@ if (httpRequest.getPathInfo() != null) { contextUriBuffer.append(httpRequest.getPathInfo()); } - String contextUri = contextUriBuffer.toString(); + contextUri = contextUriBuffer.toString(); // Verbose Debugging if (Debug.verboseOn()) { @@ -288,10 +290,11 @@ GenericValue tenant = EntityUtil.getFirst(tenants); String tenantId = tenant.getString("tenantId"); - // if the request URI is "/control/main" then redirect to the initial path - if (httpRequest.getRequestURI().startsWith("/control/main")) { + // 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"); ((HttpServletResponse)response).sendRedirect(initialPath); + return; } // make that tenant active, setup a new delegator and a new dispatcher Could you approve this solution, please? Regards, Chatree Srichart On Wed, Nov 10, 2010 at 10:17 AM, Chatree Srichart < [hidden email]> wrote: > Hi Scott Gray, > May I ask you some suggestion? Is there anyway to handle the root mount > point when an user enter only domain name in a web browser. The purpose of > this code is I need to handle the first URI after an user enter only domain > name on a web browser and redirect to the initial path that be specified in > the Tenant entity. > > Regards, > Chatree Srichart > > > On Wed, Nov 10, 2010 at 3:00 AM, Scott Gray <[hidden email]>wrote: > >> On 9/11/2010, at 10:14 PM, [hidden email] wrote: >> >> > Author: hansbak >> > Date: Tue Nov 9 09:14:33 2010 >> > New Revision: 1032896 >> > >> > URL: http://svn.apache.org/viewvc?rev=1032896&view=rev >> > Log: >> > removing the tenant servlet because that gave a problem with the root >> mountpoint defined twice in systems which already use the root mount point >> > >> > Removed: >> > >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/TenantServlet.java >> > Modified: >> > >> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java >> > >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >> > >> > >> > Modified: >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >> > URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java?rev=1032896&r1=1032895&r2=1032896&view=diff >> > >> ============================================================================== >> > --- >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >> (original) >> > +++ >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >> Tue Nov 9 09:14:33 2010 >> > @@ -288,6 +288,12 @@ public class ContextFilter implements Fi >> > GenericValue tenant = EntityUtil.getFirst(tenants); >> > String tenantId = tenant.getString("tenantId"); >> > >> > + // if the request URI is "/control/main" then >> redirect to the initial path >> > + if >> (httpRequest.getRequestURI().startsWith("/control/main")) { >> > + String initialPath = >> tenant.getString("initialPath"); >> > + >> ((HttpServletResponse)response).sendRedirect(initialPath); >> > + } >> > + >> > // make that tenant active, setup a new delegator >> and a new dispatcher >> > String tenantDelegatorName = >> delegator.getDelegatorBaseName() + "#" + tenantId; >> > >> httpRequest.getSession().setAttribute("delegatorName", tenantDelegatorName); >> >> Hi Hans, >> >> You should always return after sending a redirect or otherwise the request >> continues to be processed. >> >> Also, I'm not sure what the /control/main redirect is for but keep in mind >> that the framework shouldn't really know anything about URIs like that and >> depending on them decreases flexibility. "control" is just a url pattern >> defined in each webapp's web.xml and can be changed to anything and there is >> no requirement for each application to have a "main" request. The only >> reason "main" is the default page is because each webapp's index.jsp >> redirects to it. >> >> Regards >> Scott >> >> > |
Hi Chatree,
Perhaps if you could explain the purpose of the initialPath and a use case for it then I might be able to offer some suggestions but without that I don't really understand the problem you are trying to solve. How are you handling this problem for webapps that aren't mounted at root? Thanks Scott HotWax Media http://www.hotwaxmedia.com On 10/11/2010, at 5:35 PM, Chatree Srichart wrote: > Hi Scott Gray, > > I found this solution: > > Index: framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > =================================================================== > --- framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > (revision 1033345) > +++ framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > (working copy) > @@ -196,6 +196,8 @@ > } > > // test to see if we have come through the control servlet already, > if not do the processing > + String requestPath = null; > + String contextUri = null; > if (request.getAttribute(ContextFilter.FORWARDED_FROM_SERVLET) == > null) { > // Debug.logInfo("In ContextFilter.doFilter, > FORWARDED_FROM_SERVLET is NOT set", module); > String allowedPath = config.getInitParameter("allowedPaths"); > @@ -208,7 +210,7 @@ > > if (debug) Debug.log("[Request]: " + > httpRequest.getRequestURI(), module); > > - String requestPath = httpRequest.getServletPath(); > + requestPath = httpRequest.getServletPath(); > if (requestPath == null) requestPath = ""; > if (requestPath.lastIndexOf("/") > 0) { > if (requestPath.indexOf("/") == 0) { > @@ -234,7 +236,7 @@ > if (httpRequest.getPathInfo() != null) { > contextUriBuffer.append(httpRequest.getPathInfo()); > } > - String contextUri = contextUriBuffer.toString(); > + contextUri = contextUriBuffer.toString(); > > // Verbose Debugging > if (Debug.verboseOn()) { > @@ -288,10 +290,11 @@ > GenericValue tenant = EntityUtil.getFirst(tenants); > String tenantId = tenant.getString("tenantId"); > > - // if the request URI is "/control/main" then redirect > to the initial path > - if > (httpRequest.getRequestURI().startsWith("/control/main")) { > + // 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"); > > ((HttpServletResponse)response).sendRedirect(initialPath); > + return; > } > > // make that tenant active, setup a new delegator and a > new dispatcher > > Could you approve this solution, please? > > Regards, > Chatree Srichart > > On Wed, Nov 10, 2010 at 10:17 AM, Chatree Srichart < > [hidden email]> wrote: > >> Hi Scott Gray, >> May I ask you some suggestion? Is there anyway to handle the root mount >> point when an user enter only domain name in a web browser. The purpose of >> this code is I need to handle the first URI after an user enter only domain >> name on a web browser and redirect to the initial path that be specified in >> the Tenant entity. >> >> Regards, >> Chatree Srichart >> >> >> On Wed, Nov 10, 2010 at 3:00 AM, Scott Gray <[hidden email]>wrote: >> >>> On 9/11/2010, at 10:14 PM, [hidden email] wrote: >>> >>>> Author: hansbak >>>> Date: Tue Nov 9 09:14:33 2010 >>>> New Revision: 1032896 >>>> >>>> URL: http://svn.apache.org/viewvc?rev=1032896&view=rev >>>> Log: >>>> removing the tenant servlet because that gave a problem with the root >>> mountpoint defined twice in systems which already use the root mount point >>>> >>>> Removed: >>>> >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/TenantServlet.java >>>> Modified: >>>> >>> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java >>>> >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >>>> >>>> >>>> Modified: >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >>>> URL: >>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java?rev=1032896&r1=1032895&r2=1032896&view=diff >>>> >>> ============================================================================== >>>> --- >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >>> (original) >>>> +++ >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >>> Tue Nov 9 09:14:33 2010 >>>> @@ -288,6 +288,12 @@ public class ContextFilter implements Fi >>>> GenericValue tenant = EntityUtil.getFirst(tenants); >>>> String tenantId = tenant.getString("tenantId"); >>>> >>>> + // if the request URI is "/control/main" then >>> redirect to the initial path >>>> + if >>> (httpRequest.getRequestURI().startsWith("/control/main")) { >>>> + String initialPath = >>> tenant.getString("initialPath"); >>>> + >>> ((HttpServletResponse)response).sendRedirect(initialPath); >>>> + } >>>> + >>>> // make that tenant active, setup a new delegator >>> and a new dispatcher >>>> String tenantDelegatorName = >>> delegator.getDelegatorBaseName() + "#" + tenantId; >>>> >>> httpRequest.getSession().setAttribute("delegatorName", tenantDelegatorName); >>> >>> Hi Hans, >>> >>> You should always return after sending a redirect or otherwise the request >>> continues to be processed. >>> >>> Also, I'm not sure what the /control/main redirect is for but keep in mind >>> that the framework shouldn't really know anything about URIs like that and >>> depending on them decreases flexibility. "control" is just a url pattern >>> defined in each webapp's web.xml and can be changed to anything and there is >>> no requirement for each application to have a "main" request. The only >>> reason "main" is the default page is because each webapp's index.jsp >>> redirects to it. >>> >>> Regards >>> Scott >>> >>> >> smime.p7s (3K) Download Attachment |
I wrote the wiki for the intial path concept:
https://cwiki.apache.org/confluence/display/OFBIZ/Multitenancy+support You can see at the bottom of page called "Setting the initial path according to domain name". Regards, Chatree Srichart On Wed, Nov 10, 2010 at 11:55 AM, Scott Gray <[hidden email]>wrote: > Hi Chatree, > > Perhaps if you could explain the purpose of the initialPath and a use case > for it then I might be able to offer some suggestions but without that I > don't really understand the problem you are trying to solve. > > How are you handling this problem for webapps that aren't mounted at root? > > Thanks > Scott > > HotWax Media > http://www.hotwaxmedia.com > > On 10/11/2010, at 5:35 PM, Chatree Srichart wrote: > > > Hi Scott Gray, > > > > I found this solution: > > > > Index: framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > > =================================================================== > > --- framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > > (revision 1033345) > > +++ framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > > (working copy) > > @@ -196,6 +196,8 @@ > > } > > > > // test to see if we have come through the control servlet > already, > > if not do the processing > > + String requestPath = null; > > + String contextUri = null; > > if (request.getAttribute(ContextFilter.FORWARDED_FROM_SERVLET) == > > null) { > > // Debug.logInfo("In ContextFilter.doFilter, > > FORWARDED_FROM_SERVLET is NOT set", module); > > String allowedPath = config.getInitParameter("allowedPaths"); > > @@ -208,7 +210,7 @@ > > > > if (debug) Debug.log("[Request]: " + > > httpRequest.getRequestURI(), module); > > > > - String requestPath = httpRequest.getServletPath(); > > + requestPath = httpRequest.getServletPath(); > > if (requestPath == null) requestPath = ""; > > if (requestPath.lastIndexOf("/") > 0) { > > if (requestPath.indexOf("/") == 0) { > > @@ -234,7 +236,7 @@ > > if (httpRequest.getPathInfo() != null) { > > contextUriBuffer.append(httpRequest.getPathInfo()); > > } > > - String contextUri = contextUriBuffer.toString(); > > + contextUri = contextUriBuffer.toString(); > > > > // Verbose Debugging > > if (Debug.verboseOn()) { > > @@ -288,10 +290,11 @@ > > GenericValue tenant = EntityUtil.getFirst(tenants); > > String tenantId = tenant.getString("tenantId"); > > > > - // if the request URI is "/control/main" then > redirect > > to the initial path > > - if > > (httpRequest.getRequestURI().startsWith("/control/main")) { > > + // 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"); > > > > ((HttpServletResponse)response).sendRedirect(initialPath); > > + return; > > } > > > > // make that tenant active, setup a new delegator and > a > > new dispatcher > > > > Could you approve this solution, please? > > > > Regards, > > Chatree Srichart > > > > On Wed, Nov 10, 2010 at 10:17 AM, Chatree Srichart < > > [hidden email]> wrote: > > > >> Hi Scott Gray, > >> May I ask you some suggestion? Is there anyway to handle the root mount > >> point when an user enter only domain name in a web browser. The purpose > of > >> this code is I need to handle the first URI after an user enter only > domain > >> name on a web browser and redirect to the initial path that be specified > in > >> the Tenant entity. > >> > >> Regards, > >> Chatree Srichart > >> > >> > >> On Wed, Nov 10, 2010 at 3:00 AM, Scott Gray <[hidden email] > >wrote: > >> > >>> On 9/11/2010, at 10:14 PM, [hidden email] wrote: > >>> > >>>> Author: hansbak > >>>> Date: Tue Nov 9 09:14:33 2010 > >>>> New Revision: 1032896 > >>>> > >>>> URL: http://svn.apache.org/viewvc?rev=1032896&view=rev > >>>> Log: > >>>> removing the tenant servlet because that gave a problem with the root > >>> mountpoint defined twice in systems which already use the root mount > point > >>>> > >>>> Removed: > >>>> > >>> > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/TenantServlet.java > >>>> Modified: > >>>> > >>> > ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java > >>>> > >>> > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > >>>> > >>>> > >>>> Modified: > >>> > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > >>>> URL: > >>> > http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java?rev=1032896&r1=1032895&r2=1032896&view=diff > >>>> > >>> > ============================================================================== > >>>> --- > >>> > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > >>> (original) > >>>> +++ > >>> > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > >>> Tue Nov 9 09:14:33 2010 > >>>> @@ -288,6 +288,12 @@ public class ContextFilter implements Fi > >>>> GenericValue tenant = EntityUtil.getFirst(tenants); > >>>> String tenantId = tenant.getString("tenantId"); > >>>> > >>>> + // if the request URI is "/control/main" then > >>> redirect to the initial path > >>>> + if > >>> (httpRequest.getRequestURI().startsWith("/control/main")) { > >>>> + String initialPath = > >>> tenant.getString("initialPath"); > >>>> + > >>> ((HttpServletResponse)response).sendRedirect(initialPath); > >>>> + } > >>>> + > >>>> // make that tenant active, setup a new delegator > >>> and a new dispatcher > >>>> String tenantDelegatorName = > >>> delegator.getDelegatorBaseName() + "#" + tenantId; > >>>> > >>> httpRequest.getSession().setAttribute("delegatorName", > tenantDelegatorName); > >>> > >>> Hi Hans, > >>> > >>> You should always return after sending a redirect or otherwise the > request > >>> continues to be processed. > >>> > >>> Also, I'm not sure what the /control/main redirect is for but keep in > mind > >>> that the framework shouldn't really know anything about URIs like that > and > >>> depending on them decreases flexibility. "control" is just a url > pattern > >>> defined in each webapp's web.xml and can be changed to anything and > there is > >>> no requirement for each application to have a "main" request. The only > >>> reason "main" is the default page is because each webapp's index.jsp > >>> redirects to it. > >>> > >>> Regards > >>> Scott > >>> > >>> > >> > > |
Thanks Chatree, that document explains what it does but it doesn't explain why it is needed. The index.jsp file in each webapp currently does exactly what you've described so I guess I don't understand why we need something specifically for multi-tenant here?
Regards Scott On 10/11/2010, at 6:02 PM, Chatree Srichart wrote: > I wrote the wiki for the intial path concept: > https://cwiki.apache.org/confluence/display/OFBIZ/Multitenancy+support > You can see at the bottom of page called "Setting the initial path according > to domain name". > > Regards, > Chatree Srichart > > On Wed, Nov 10, 2010 at 11:55 AM, Scott Gray <[hidden email]>wrote: > >> Hi Chatree, >> >> Perhaps if you could explain the purpose of the initialPath and a use case >> for it then I might be able to offer some suggestions but without that I >> don't really understand the problem you are trying to solve. >> >> How are you handling this problem for webapps that aren't mounted at root? >> >> Thanks >> Scott >> >> HotWax Media >> http://www.hotwaxmedia.com >> >> On 10/11/2010, at 5:35 PM, Chatree Srichart wrote: >> >>> Hi Scott Gray, >>> >>> I found this solution: >>> >>> Index: framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >>> =================================================================== >>> --- framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >>> (revision 1033345) >>> +++ framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >>> (working copy) >>> @@ -196,6 +196,8 @@ >>> } >>> >>> // test to see if we have come through the control servlet >> already, >>> if not do the processing >>> + String requestPath = null; >>> + String contextUri = null; >>> if (request.getAttribute(ContextFilter.FORWARDED_FROM_SERVLET) == >>> null) { >>> // Debug.logInfo("In ContextFilter.doFilter, >>> FORWARDED_FROM_SERVLET is NOT set", module); >>> String allowedPath = config.getInitParameter("allowedPaths"); >>> @@ -208,7 +210,7 @@ >>> >>> if (debug) Debug.log("[Request]: " + >>> httpRequest.getRequestURI(), module); >>> >>> - String requestPath = httpRequest.getServletPath(); >>> + requestPath = httpRequest.getServletPath(); >>> if (requestPath == null) requestPath = ""; >>> if (requestPath.lastIndexOf("/") > 0) { >>> if (requestPath.indexOf("/") == 0) { >>> @@ -234,7 +236,7 @@ >>> if (httpRequest.getPathInfo() != null) { >>> contextUriBuffer.append(httpRequest.getPathInfo()); >>> } >>> - String contextUri = contextUriBuffer.toString(); >>> + contextUri = contextUriBuffer.toString(); >>> >>> // Verbose Debugging >>> if (Debug.verboseOn()) { >>> @@ -288,10 +290,11 @@ >>> GenericValue tenant = EntityUtil.getFirst(tenants); >>> String tenantId = tenant.getString("tenantId"); >>> >>> - // if the request URI is "/control/main" then >> redirect >>> to the initial path >>> - if >>> (httpRequest.getRequestURI().startsWith("/control/main")) { >>> + // 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"); >>> >>> ((HttpServletResponse)response).sendRedirect(initialPath); >>> + return; >>> } >>> >>> // make that tenant active, setup a new delegator and >> a >>> new dispatcher >>> >>> Could you approve this solution, please? >>> >>> Regards, >>> Chatree Srichart >>> >>> On Wed, Nov 10, 2010 at 10:17 AM, Chatree Srichart < >>> [hidden email]> wrote: >>> >>>> Hi Scott Gray, >>>> May I ask you some suggestion? Is there anyway to handle the root mount >>>> point when an user enter only domain name in a web browser. The purpose >> of >>>> this code is I need to handle the first URI after an user enter only >> domain >>>> name on a web browser and redirect to the initial path that be specified >> in >>>> the Tenant entity. >>>> >>>> Regards, >>>> Chatree Srichart >>>> >>>> >>>> On Wed, Nov 10, 2010 at 3:00 AM, Scott Gray <[hidden email] >>> wrote: >>>> >>>>> On 9/11/2010, at 10:14 PM, [hidden email] wrote: >>>>> >>>>>> Author: hansbak >>>>>> Date: Tue Nov 9 09:14:33 2010 >>>>>> New Revision: 1032896 >>>>>> >>>>>> URL: http://svn.apache.org/viewvc?rev=1032896&view=rev >>>>>> Log: >>>>>> removing the tenant servlet because that gave a problem with the root >>>>> mountpoint defined twice in systems which already use the root mount >> point >>>>>> >>>>>> Removed: >>>>>> >>>>> >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/TenantServlet.java >>>>>> Modified: >>>>>> >>>>> >> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java >>>>>> >>>>> >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >>>>>> >>>>>> >>>>>> Modified: >>>>> >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >>>>>> URL: >>>>> >> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java?rev=1032896&r1=1032895&r2=1032896&view=diff >>>>>> >>>>> >> ============================================================================== >>>>>> --- >>>>> >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >>>>> (original) >>>>>> +++ >>>>> >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >>>>> Tue Nov 9 09:14:33 2010 >>>>>> @@ -288,6 +288,12 @@ public class ContextFilter implements Fi >>>>>> GenericValue tenant = EntityUtil.getFirst(tenants); >>>>>> String tenantId = tenant.getString("tenantId"); >>>>>> >>>>>> + // if the request URI is "/control/main" then >>>>> redirect to the initial path >>>>>> + if >>>>> (httpRequest.getRequestURI().startsWith("/control/main")) { >>>>>> + String initialPath = >>>>> tenant.getString("initialPath"); >>>>>> + >>>>> ((HttpServletResponse)response).sendRedirect(initialPath); >>>>>> + } >>>>>> + >>>>>> // make that tenant active, setup a new delegator >>>>> and a new dispatcher >>>>>> String tenantDelegatorName = >>>>> delegator.getDelegatorBaseName() + "#" + tenantId; >>>>>> >>>>> httpRequest.getSession().setAttribute("delegatorName", >> tenantDelegatorName); >>>>> >>>>> Hi Hans, >>>>> >>>>> You should always return after sending a redirect or otherwise the >> request >>>>> continues to be processed. >>>>> >>>>> Also, I'm not sure what the /control/main redirect is for but keep in >> mind >>>>> that the framework shouldn't really know anything about URIs like that >> and >>>>> depending on them decreases flexibility. "control" is just a url >> pattern >>>>> defined in each webapp's web.xml and can be changed to anything and >> there is >>>>> no requirement for each application to have a "main" request. The only >>>>> reason "main" is the default page is because each webapp's index.jsp >>>>> redirects to it. >>>>> >>>>> Regards >>>>> Scott >>>>> >>>>> >>>> >> >> smime.p7s (3K) Download Attachment |
For example, I have a single OFBiz running for multiple users with different
domain names. I use the multi-tenant feature to separate domain name and database for the multiple users. I would like to separate the user sites with different webapps, also different mount points. I think instead of I have to write about 10 lines of code in the index.jsp file, I only just add the domain name and initial path into the database. I think it would be easier. Regards, Chatree Srichart On Wed, Nov 10, 2010 at 12:10 PM, Scott Gray <[hidden email]>wrote: > Thanks Chatree, that document explains what it does but it doesn't explain > why it is needed. The index.jsp file in each webapp currently does exactly > what you've described so I guess I don't understand why we need something > specifically for multi-tenant here? > > Regards > Scott > > On 10/11/2010, at 6:02 PM, Chatree Srichart wrote: > > > I wrote the wiki for the intial path concept: > > https://cwiki.apache.org/confluence/display/OFBIZ/Multitenancy+support > > You can see at the bottom of page called "Setting the initial path > according > > to domain name". > > > > Regards, > > Chatree Srichart > > > > On Wed, Nov 10, 2010 at 11:55 AM, Scott Gray <[hidden email] > >wrote: > > > >> Hi Chatree, > >> > >> Perhaps if you could explain the purpose of the initialPath and a use > case > >> for it then I might be able to offer some suggestions but without that I > >> don't really understand the problem you are trying to solve. > >> > >> How are you handling this problem for webapps that aren't mounted at > root? > >> > >> Thanks > >> Scott > >> > >> HotWax Media > >> http://www.hotwaxmedia.com > >> > >> On 10/11/2010, at 5:35 PM, Chatree Srichart wrote: > >> > >>> Hi Scott Gray, > >>> > >>> I found this solution: > >>> > >>> Index: framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > >>> =================================================================== > >>> --- framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > >>> (revision 1033345) > >>> +++ framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > >>> (working copy) > >>> @@ -196,6 +196,8 @@ > >>> } > >>> > >>> // test to see if we have come through the control servlet > >> already, > >>> if not do the processing > >>> + String requestPath = null; > >>> + String contextUri = null; > >>> if (request.getAttribute(ContextFilter.FORWARDED_FROM_SERVLET) > == > >>> null) { > >>> // Debug.logInfo("In ContextFilter.doFilter, > >>> FORWARDED_FROM_SERVLET is NOT set", module); > >>> String allowedPath = > config.getInitParameter("allowedPaths"); > >>> @@ -208,7 +210,7 @@ > >>> > >>> if (debug) Debug.log("[Request]: " + > >>> httpRequest.getRequestURI(), module); > >>> > >>> - String requestPath = httpRequest.getServletPath(); > >>> + requestPath = httpRequest.getServletPath(); > >>> if (requestPath == null) requestPath = ""; > >>> if (requestPath.lastIndexOf("/") > 0) { > >>> if (requestPath.indexOf("/") == 0) { > >>> @@ -234,7 +236,7 @@ > >>> if (httpRequest.getPathInfo() != null) { > >>> contextUriBuffer.append(httpRequest.getPathInfo()); > >>> } > >>> - String contextUri = contextUriBuffer.toString(); > >>> + contextUri = contextUriBuffer.toString(); > >>> > >>> // Verbose Debugging > >>> if (Debug.verboseOn()) { > >>> @@ -288,10 +290,11 @@ > >>> GenericValue tenant = EntityUtil.getFirst(tenants); > >>> String tenantId = tenant.getString("tenantId"); > >>> > >>> - // if the request URI is "/control/main" then > >> redirect > >>> to the initial path > >>> - if > >>> (httpRequest.getRequestURI().startsWith("/control/main")) { > >>> + // 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"); > >>> > >>> ((HttpServletResponse)response).sendRedirect(initialPath); > >>> + return; > >>> } > >>> > >>> // make that tenant active, setup a new delegator > and > >> a > >>> new dispatcher > >>> > >>> Could you approve this solution, please? > >>> > >>> Regards, > >>> Chatree Srichart > >>> > >>> On Wed, Nov 10, 2010 at 10:17 AM, Chatree Srichart < > >>> [hidden email]> wrote: > >>> > >>>> Hi Scott Gray, > >>>> May I ask you some suggestion? Is there anyway to handle the root > mount > >>>> point when an user enter only domain name in a web browser. The > purpose > >> of > >>>> this code is I need to handle the first URI after an user enter only > >> domain > >>>> name on a web browser and redirect to the initial path that be > specified > >> in > >>>> the Tenant entity. > >>>> > >>>> Regards, > >>>> Chatree Srichart > >>>> > >>>> > >>>> On Wed, Nov 10, 2010 at 3:00 AM, Scott Gray < > [hidden email] > >>> wrote: > >>>> > >>>>> On 9/11/2010, at 10:14 PM, [hidden email] wrote: > >>>>> > >>>>>> Author: hansbak > >>>>>> Date: Tue Nov 9 09:14:33 2010 > >>>>>> New Revision: 1032896 > >>>>>> > >>>>>> URL: http://svn.apache.org/viewvc?rev=1032896&view=rev > >>>>>> Log: > >>>>>> removing the tenant servlet because that gave a problem with the > root > >>>>> mountpoint defined twice in systems which already use the root mount > >> point > >>>>>> > >>>>>> Removed: > >>>>>> > >>>>> > >> > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/TenantServlet.java > >>>>>> Modified: > >>>>>> > >>>>> > >> > ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java > >>>>>> > >>>>> > >> > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > >>>>>> > >>>>>> > >>>>>> Modified: > >>>>> > >> > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > >>>>>> URL: > >>>>> > >> > http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java?rev=1032896&r1=1032895&r2=1032896&view=diff > >>>>>> > >>>>> > >> > ============================================================================== > >>>>>> --- > >>>>> > >> > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > >>>>> (original) > >>>>>> +++ > >>>>> > >> > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > >>>>> Tue Nov 9 09:14:33 2010 > >>>>>> @@ -288,6 +288,12 @@ public class ContextFilter implements Fi > >>>>>> GenericValue tenant = > EntityUtil.getFirst(tenants); > >>>>>> String tenantId = tenant.getString("tenantId"); > >>>>>> > >>>>>> + // if the request URI is "/control/main" then > >>>>> redirect to the initial path > >>>>>> + if > >>>>> (httpRequest.getRequestURI().startsWith("/control/main")) { > >>>>>> + String initialPath = > >>>>> tenant.getString("initialPath"); > >>>>>> + > >>>>> ((HttpServletResponse)response).sendRedirect(initialPath); > >>>>>> + } > >>>>>> + > >>>>>> // make that tenant active, setup a new delegator > >>>>> and a new dispatcher > >>>>>> String tenantDelegatorName = > >>>>> delegator.getDelegatorBaseName() + "#" + tenantId; > >>>>>> > >>>>> httpRequest.getSession().setAttribute("delegatorName", > >> tenantDelegatorName); > >>>>> > >>>>> Hi Hans, > >>>>> > >>>>> You should always return after sending a redirect or otherwise the > >> request > >>>>> continues to be processed. > >>>>> > >>>>> Also, I'm not sure what the /control/main redirect is for but keep in > >> mind > >>>>> that the framework shouldn't really know anything about URIs like > that > >> and > >>>>> depending on them decreases flexibility. "control" is just a url > >> pattern > >>>>> defined in each webapp's web.xml and can be changed to anything and > >> there is > >>>>> no requirement for each application to have a "main" request. The > only > >>>>> reason "main" is the default page is because each webapp's index.jsp > >>>>> redirects to it. > >>>>> > >>>>> Regards > >>>>> Scott > >>>>> > >>>>> > >>>> > >> > >> > > |
Free forum by Nabble | Edit this page |