You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2013/12/08 11:48:19 UTC
svn commit: r1549015 - in /ofbiz/trunk/framework:
base/src/org/ofbiz/base/container/ClassLoaderContainer.java
webapp/src/org/ofbiz/webapp/control/RequestHandler.java
webapp/src/org/ofbiz/webapp/website/WebSiteProperties.java
Author: jleroux
Date: Sun Dec 8 10:48:18 2013
New Revision: 1549015
URL: http://svn.apache.org/r1549015
Log:
In r1533839 (related to https://issues.apache.org/jira/browse/OFBIZ-4794 "Set different ports for testing in a CI environment (e.g. Jenkins)"
Which will mostly be used to simultaneously run official demos without having to create patches, I forgot the portOffset for websites and url.properties ports values.
This fixes this point. I also did in it RequestHandler class though the getDefaultServerRootUrl() method is now deprecated.
To be consistent with r1547186 I will backport in R13.07
People should be aware that this will change the ports values of websites and url.properties ports values which in some cases could be an unwanted side effect.
Anyway the portOffset feature is not destined to be used in production environments where websites and url.properties ports values are often changed purposely
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ClassLoaderContainer.java
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/website/WebSiteProperties.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ClassLoaderContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ClassLoaderContainer.java?rev=1549015&r1=1549014&r2=1549015&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ClassLoaderContainer.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ClassLoaderContainer.java Sun Dec 8 10:48:18 2013
@@ -68,7 +68,7 @@ public class ClassLoaderContainer implem
try {
ClassLoaderContainer.portOffset = Integer.valueOf(argumentVal);
} catch (NumberFormatException e) {
- e.printStackTrace();
+ Debug.logError(e, module);
}
}
}
@@ -82,6 +82,7 @@ public class ClassLoaderContainer implem
/**
* @see org.ofbiz.base.container.Container#start()
*/
+ @Override
public boolean start() throws ContainerException {
return true;
}
@@ -89,9 +90,11 @@ public class ClassLoaderContainer implem
/**
* @see org.ofbiz.base.container.Container#stop()
*/
+ @Override
public void stop() throws ContainerException {
}
+ @Override
public String getName() {
return name;
}
Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java?rev=1549015&r1=1549014&r2=1549015&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java Sun Dec 8 10:48:18 2013
@@ -37,6 +37,7 @@ import javax.servlet.http.HttpSession;
import javolution.util.FastMap;
+import org.ofbiz.base.container.ClassLoaderContainer;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.SSLUtil;
import org.ofbiz.base.util.StringUtil;
@@ -58,8 +59,8 @@ import org.ofbiz.webapp.stats.ServerHitB
import org.ofbiz.webapp.view.ViewFactory;
import org.ofbiz.webapp.view.ViewHandler;
import org.ofbiz.webapp.view.ViewHandlerException;
-import org.ofbiz.webapp.website.WebSiteWorker;
import org.ofbiz.webapp.website.WebSiteProperties;
+import org.ofbiz.webapp.website.WebSiteWorker;
import org.owasp.esapi.errors.EncodingException;
/**
@@ -1028,6 +1029,15 @@ public class RequestHandler {
String httpServer = UtilProperties.getPropertyValue("url.properties", "force.http.host");
boolean useHttps = UtilProperties.propertyValueEqualsIgnoreCase("url.properties", "port.https.enabled", "Y");
+ if (ClassLoaderContainer.portOffset != 0) {
+ Integer httpPortValue = Integer.valueOf(httpPort);
+ httpPortValue += ClassLoaderContainer.portOffset;
+ httpPort = httpPortValue.toString();
+ Integer httpsPortValue = Integer.valueOf(httpsPort);
+ httpsPortValue += ClassLoaderContainer.portOffset;
+ httpsPort = httpsPortValue.toString();
+ }
+
StringBuilder newURL = new StringBuilder();
if (secure && useHttps) {
Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/website/WebSiteProperties.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/website/WebSiteProperties.java?rev=1549015&r1=1549014&r2=1549015&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/website/WebSiteProperties.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/website/WebSiteProperties.java Sun Dec 8 10:48:18 2013
@@ -20,6 +20,7 @@ package org.ofbiz.webapp.website;
import javax.servlet.http.HttpServletRequest;
+import org.ofbiz.base.container.ClassLoaderContainer;
import org.ofbiz.base.lang.ThreadSafe;
import org.ofbiz.base.util.Assert;
import org.ofbiz.base.util.UtilMisc;
@@ -98,6 +99,16 @@ public final class WebSiteProperties {
if (httpsHost.isEmpty()) {
httpsHost = request.getServerName();
}
+
+ if (ClassLoaderContainer.portOffset != 0) {
+ Integer httpPortValue = Integer.valueOf(httpPort);
+ httpPortValue += ClassLoaderContainer.portOffset;
+ httpPort = httpPortValue.toString();
+ Integer httpsPortValue = Integer.valueOf(httpsPort);
+ httpsPortValue += ClassLoaderContainer.portOffset;
+ httpsPort = httpsPortValue.toString();
+ }
+
webSiteProps = new WebSiteProperties(httpPort, httpHost, httpsPort, httpsHost, enableHttps);
request.setAttribute("_WEBSITE_PROPS_", webSiteProps);
}
@@ -121,6 +132,16 @@ public final class WebSiteProperties {
String httpsPort = (webSiteValue.get("httpsPort") != null) ? webSiteValue.getString("httpsPort") : defaults.getHttpsPort();
String httpsHost = (webSiteValue.get("httpsHost") != null) ? webSiteValue.getString("httpsHost") : defaults.getHttpsHost();
boolean enableHttps = (webSiteValue.get("enableHttps") != null) ? webSiteValue.getBoolean("enableHttps") : defaults.getEnableHttps();
+
+ if (ClassLoaderContainer.portOffset != 0) {
+ Integer httpPortValue = Integer.valueOf(httpPort);
+ httpPortValue += ClassLoaderContainer.portOffset;
+ httpPort = httpPortValue.toString();
+ Integer httpsPortValue = Integer.valueOf(httpsPort);
+ httpsPortValue += ClassLoaderContainer.portOffset;
+ httpsPort = httpsPortValue.toString();
+ }
+
return new WebSiteProperties(httpPort, httpHost, httpsPort, httpsHost, enableHttps);
}