com.aceql.jdbc.commons.main.http.AceQLHealthCheckInfoApi Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aceql-http-client-jdbc-driver Show documentation
Show all versions of aceql-http-client-jdbc-driver Show documentation
The AceQL Java Client JDBC Driver allows to wrap the AceQL HTTP APIs and eliminates the tedious works of handling communications errors and parsing JSON results.
Android and Java Desktop application developers can access remote SQL databases and/or SQL databases in the cloud by simply including standard JDBC calls in their code, just like they would for a local database.
The newest version!
package com.aceql.jdbc.commons.main.http;
import com.aceql.jdbc.commons.AceQLException;
import com.aceql.jdbc.commons.main.metadata.dto.HealthCheckInfoDto;
import com.aceql.jdbc.commons.main.metadata.util.GsonWsUtil;
import com.aceql.jdbc.commons.main.util.framework.FrameworkDebug;
/**
* Dedicated HTTP and API operations for meta data API.
* @author Nicolas de Pomereu
*
*/
public class AceQLHealthCheckInfoApi {
public static boolean DEBUG = FrameworkDebug.isSet(AceQLHealthCheckInfoApi.class);
/* The HttpManager */
private HttpManager httpManager;
private String url;
public AceQLHealthCheckInfoApi(HttpManager httpManager, String url) {
super();
this.httpManager = httpManager;
this.url = url;
}
public HealthCheckInfoDto getHealthCheckInfoDto() throws AceQLException {
try {
String action = "health_check_info";
String result = httpManager.callWithGet(url + action);
ResultAnalyzer resultAnalyzer = new ResultAnalyzer(result, httpManager.getHttpStatusCode(),
httpManager.getHttpStatusMessage());
if (!resultAnalyzer.isStatusOk()) {
throw new AceQLException(resultAnalyzer.getErrorMessage(), resultAnalyzer.getErrorType(), null,
resultAnalyzer.getStackTrace(), httpManager.getHttpStatusCode());
}
debug("HealthCheckInfoDto url+action: " + url+action);
debug("HealthCheckInfoDto: ");
debug(result);
// If result is OK, it's a DTO
HealthCheckInfoDto healthCheckInfoDto = GsonWsUtil.fromJson(result,
HealthCheckInfoDto.class);
return healthCheckInfoDto;
}
catch (AceQLException e) {
throw e;
}
catch (Exception e) {
throw new AceQLException(e.getMessage(), 0, e, null, httpManager.getHttpStatusCode());
}
}
private void debug(String s) {
if (DEBUG) {
System.out.println(s);
}
}
}