Added override_appbase system property.
This can be used to completely override the appbase via the installer in situations where you want to build a deployment once, but then potentially serve it from some other webserver.
This commit is contained in:
@@ -537,14 +537,15 @@ public class Application
|
||||
if (_appbase == null) {
|
||||
throw new RuntimeException("m.missing_appbase");
|
||||
}
|
||||
|
||||
// check if we're overriding the domain in the appbase
|
||||
_appbase = overrideAppbase(_appbase);
|
||||
|
||||
// make sure there's a trailing slash
|
||||
if (!_appbase.endsWith("/")) {
|
||||
_appbase = _appbase + "/";
|
||||
}
|
||||
|
||||
// check if we're overriding the domain in the appbase
|
||||
_appbase = replaceDomain(_appbase);
|
||||
|
||||
// extract our version information
|
||||
String vstr = (String)cdata.get("version");
|
||||
if (vstr != null) _version = parseLong(vstr, "m.invalid_version");
|
||||
@@ -560,7 +561,11 @@ public class Application
|
||||
// check for a latest config URL
|
||||
String latest = (String)cdata.get("latest");
|
||||
if (latest != null) {
|
||||
if (latest.startsWith(_appbase)) {
|
||||
latest = _appbase + latest.substring(_appbase.length());
|
||||
} else {
|
||||
latest = replaceDomain(latest);
|
||||
}
|
||||
try {
|
||||
_latest = new URL(latest);
|
||||
} catch (MalformedURLException mue) {
|
||||
@@ -1736,6 +1741,18 @@ public class Application
|
||||
return cookie.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies {@code appbase_override} or {@code appbase_domain} if they are set.
|
||||
*/
|
||||
protected String overrideAppbase (String appbase) {
|
||||
String appbaseOverride = SysProps.appbaseOverride();
|
||||
if (appbaseOverride != null) {
|
||||
return appbaseOverride;
|
||||
} else {
|
||||
return replaceDomain(appbase);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If appbase_domain property is set, replace the domain on the provided string.
|
||||
*/
|
||||
|
||||
@@ -27,7 +27,7 @@ public class SysProps
|
||||
}
|
||||
|
||||
/** Configures the appbase (in lieu of providing a skeleton getdown.txt, and as a last resort
|
||||
* fallback). Usage: {@code -Dappbase=someurl}. */
|
||||
* fallback). Usage: {@code -Dappbase=URL}. */
|
||||
public static String appBase () {
|
||||
return System.getProperty("appbase");
|
||||
}
|
||||
@@ -43,6 +43,11 @@ public class SysProps
|
||||
return System.getProperty("appbase_domain");
|
||||
}
|
||||
|
||||
/** Overrides enter {@code appbase}. Usage: {@code -Dappbase_override=URL}. */
|
||||
public static String appbaseOverride () {
|
||||
return System.getProperty("appbase_override");
|
||||
}
|
||||
|
||||
/** If true, Getdown installs the app without ever bringing up a UI, except in the event of an
|
||||
* error. NOTE: it does not launch the app. See {@link #launchInSilent}.
|
||||
* Usage: {@code -Dsilent}. */
|
||||
|
||||
Reference in New Issue
Block a user