use of com.axibase.tsd.api.util.NotCheckedException in project atsd-api-test by axibase.
the class ReplacementTableMethod method replacementTableExist.
public static boolean replacementTableExist(String replacementTable) throws NotCheckedException {
replacementTable = replacementTable.replace(" ", "_").toLowerCase();
final Response response = ReplacementTableMethod.getReplacementTablesResponse();
if (response.getStatus() != OK.getStatusCode()) {
throw new NotCheckedException("Fail to execute replacement table query");
}
InputStream bodyStream = (InputStream) response.getEntity();
String body;
try {
body = IOUtils.toString(bodyStream, "UTF-8");
} catch (IOException ignored) {
throw new IllegalStateException("Error in decoding stream to string");
}
Document doc = Jsoup.parse(body);
Element table = doc.select("table").get(0);
Elements trs = table.select("tr");
for (Element tr : trs) {
Elements tds = tr.select("td");
for (Element td : tds) {
if (td.text().contains(replacementTable)) {
return true;
}
}
}
return false;
}
use of com.axibase.tsd.api.util.NotCheckedException in project atsd-api-test by axibase.
the class PropertyMethod method propertyTypeExist.
public static boolean propertyTypeExist(String propertyType) {
final PropertyQuery q = new PropertyQuery();
q.setEntity("*");
q.setType(propertyType);
q.setStartDate(MIN_STORABLE_DATE);
q.setEndDate(MAX_STORABLE_DATE);
q.setLimit(1);
final Response response = queryProperty(q);
if (response.getStatus() != OK.getStatusCode()) {
throw new NotCheckedException("Fail to execute property query");
}
String given = response.readEntity(String.class);
if ("[]".equals(given)) {
return false;
} else
return true;
}
Aggregations