From 1da36ace8395caaabd91be247d69cbf0eaee2583 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Sun, 12 Feb 2017 08:47:57 -0800 Subject: [PATCH] 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. --- .../threerings/getdown/data/Application.java | 25 ++++++++++++++++--- .../com/threerings/getdown/data/SysProps.java | 7 +++++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/threerings/getdown/data/Application.java b/src/main/java/com/threerings/getdown/data/Application.java index a79193f..32212ee 100644 --- a/src/main/java/com/threerings/getdown/data/Application.java +++ b/src/main/java/com/threerings/getdown/data/Application.java @@ -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) { - latest = replaceDomain(latest); + 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. */ diff --git a/src/main/java/com/threerings/getdown/data/SysProps.java b/src/main/java/com/threerings/getdown/data/SysProps.java index f983c4d..de620c9 100644 --- a/src/main/java/com/threerings/getdown/data/SysProps.java +++ b/src/main/java/com/threerings/getdown/data/SysProps.java @@ -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}. */