diff --git a/WEB-INF/classes/ApplicationResources.properties b/WEB-INF/classes/ApplicationResources.properties index 9cd433b0..0afca4c9 100755 --- a/WEB-INF/classes/ApplicationResources.properties +++ b/WEB-INF/classes/ApplicationResources.properties @@ -69,6 +69,10 @@ search.specimenlocality.madants=country='madagascar' site.plaziFilesURL=http://plazi.cs.umb.edu/exist/rest/db/taxonx_docs site.plaziDescriptionRoot=http://plazi.cs.umb.edu/exist/rest/db/taxonx_docs/getSPM.xq?render=xhtml&description=broad&associations=no&doc= +# can be be path relative to root (/v3.1), or entire url (http://api.antweb.org) +# If relative path is provided, it is appended to the domainApp +site.apiUrl=/v3.1 + #These relative should be in ApplicationResources.properties because they do not change # In site.docroot: maybe /usr/local/tomcat/webapps/antweb/ diff --git a/src/org/calacademy/antweb/util/AntwebProps.java b/src/org/calacademy/antweb/util/AntwebProps.java index 32f01f05..4c4647f7 100755 --- a/src/org/calacademy/antweb/util/AntwebProps.java +++ b/src/org/calacademy/antweb/util/AntwebProps.java @@ -275,6 +275,7 @@ public static String getDomain() { public static String s_domainApp = null; public static String s_secureDomainApp = null; + public static String s_apiUrl = null; public static String getInsecureDomainApp() { String domain = AntwebProps.getProp("site.domain"); @@ -365,6 +366,35 @@ public static String getSecureDomainApp() { return domainApp; } + /** + * Get the url for the API. + *
+ * Can either be a path from the domain, like: site.apiUrl=/v3.1 + * or a complete url, like: site.apiUrl=api.antweb.org + */ + public static String getApiUrl() { + + if (s_apiUrl != null) return s_apiUrl; + + String apiUrl = AntwebProps.getProp("site.apiUrl"); + + if (apiUrl == null) { + A.log("site.apiUrl was null!"); + s_apiUrl = "https://antweb.org/v3.1"; + return s_apiUrl; + } + + if (apiUrl.startsWith("/")) { + s_apiUrl = getDomainApp() + apiUrl; + } else if (apiUrl.startsWith("http")) { + s_apiUrl = apiUrl; + } + + A.log("getApiUrl() apiDomainApp:" + s_apiUrl); + + return s_apiUrl; + } + public static String getGoogleEarthURI() { if (true) return "googleEarth.do"; diff --git a/web/documentation/api/apiV3_1-body.jsp b/web/documentation/api/apiV3_1-body.jsp index eb6e9382..071ee7a4 100755 --- a/web/documentation/api/apiV3_1-body.jsp +++ b/web/documentation/api/apiV3_1-body.jsp @@ -5,8 +5,9 @@ <% //String apiDomainApp = "http://api.antweb.org/v3.1"; //String apiDomainApp = "https://10.2.22.30/v3.1"; - String apiDomainApp = "https://antweb.org/v3.1"; - +// String apiDomainApp = "https://antweb.org/v3.1"; + String apiDomainApp = AntwebProps.getApiUrl(); + if (AntwebProps.isDevMode()) { apiDomainApp = "http://localhost:5000"; }