Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a property for api url #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions WEB-INF/classes/ApplicationResources.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
30 changes: 30 additions & 0 deletions src/org/calacademy/antweb/util/AntwebProps.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -365,6 +366,35 @@ public static String getSecureDomainApp() {
return domainApp;
}

/**
* Get the url for the API.
* <p>
* 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";
Expand Down
5 changes: 3 additions & 2 deletions web/documentation/api/apiV3_1-body.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down