Changed hostname to apiBaseUrl.

This commit is contained in:
Winston Li 2014-12-06 01:27:08 +00:00
parent 3e544f9e7c
commit f8c311688d
4 changed files with 11 additions and 11 deletions

View file

@ -2,7 +2,7 @@
"port": 80, "port": 80,
"rootGitDirectory": "/var/wlgb/git", "rootGitDirectory": "/var/wlgb/git",
"apiKey": "", "apiKey": "",
"hostname": "https://radiant-wind-3058.herokuapp.com/", "apiBaseUrl": "https://radiant-wind-3058.herokuapp.com/api/v0",
"username": "staging", "username": "staging",
"password": "6kUfbv0R", "password": "6kUfbv0R",
"serviceName": "WriteLatex" "serviceName": "WriteLatex"

View file

@ -20,7 +20,7 @@ public class Config implements JSONSource {
private String apiKey; private String apiKey;
private String username; private String username;
private String password; private String password;
private String hostname; private String apiBaseURL;
private String serviceName; private String serviceName;
public Config(String configFilePath) throws InvalidConfigFileException, IOException { public Config(String configFilePath) throws InvalidConfigFileException, IOException {
@ -39,11 +39,11 @@ public class Config implements JSONSource {
apiKey = getElement(configObject, "apiKey").getAsString(); apiKey = getElement(configObject, "apiKey").getAsString();
username = getOptionalString(configObject, "username"); username = getOptionalString(configObject, "username");
password = getOptionalString(configObject, "password"); password = getOptionalString(configObject, "password");
String hostname = getElement(configObject, "hostname").getAsString(); String apiBaseURL = getElement(configObject, "apiBaseUrl").getAsString();
if (!hostname.endsWith("/")) { if (!apiBaseURL.endsWith("/")) {
hostname += "/"; apiBaseURL += "/";
} }
this.hostname = hostname; this.apiBaseURL = apiBaseURL;
serviceName = getElement(configObject, "serviceName").getAsString(); serviceName = getElement(configObject, "serviceName").getAsString();
} }
@ -67,8 +67,8 @@ public class Config implements JSONSource {
return password; return password;
} }
public String getHostname() { public String getAPIBaseURL() {
return hostname; return apiBaseURL;
} }
private JsonElement getElement(JsonObject configObject, String name) { private JsonElement getElement(JsonObject configObject, String name) {

View file

@ -52,7 +52,7 @@ public class WLGitBridgeServer {
public WLGitBridgeServer(Config config) throws ServletException, InvalidRootDirectoryPathException { public WLGitBridgeServer(Config config) throws ServletException, InvalidRootDirectoryPathException {
this(config.getPort(), config.getRootGitDirectory(), config.getAPIKey()); this(config.getPort(), config.getRootGitDirectory(), config.getAPIKey());
SnapshotAPIRequest.setBasicAuth(config.getUsername(), config.getPassword()); SnapshotAPIRequest.setBasicAuth(config.getUsername(), config.getPassword());
writeLatexHostname = config.getHostname(); writeLatexHostname = config.getAPIBaseURL();
SnapshotAPIRequest.setBaseURL(writeLatexHostname); SnapshotAPIRequest.setBaseURL(writeLatexHostname);
Util.setServiceName(config.getServiceName()); Util.setServiceName(config.getServiceName());
} }

View file

@ -10,7 +10,6 @@ public abstract class SnapshotAPIRequest<T extends Result> extends Request<T> {
private static String USERNAME; private static String USERNAME;
private static String PASSWORD; private static String PASSWORD;
/* Must end with / */
private static String BASE_URL; private static String BASE_URL;
public SnapshotAPIRequest(String projectName, String apiCall) { public SnapshotAPIRequest(String projectName, String apiCall) {
@ -31,8 +30,9 @@ public abstract class SnapshotAPIRequest<T extends Result> extends Request<T> {
PASSWORD = password; PASSWORD = password;
} }
/* baseURL ends with / */
public static void setBaseURL(String baseURL) { public static void setBaseURL(String baseURL) {
BASE_URL = baseURL; BASE_URL = baseURL + "/docs/";
} }
} }