in src/main/java/org/apache/sling/testing/clients/query/QueryClient.java [154:179]
protected JsonNode doQuery(final String query, final QueryType type, final boolean showResults, final boolean explain)
throws ClientException, InterruptedException {
List<NameValuePair> params = URLParameterBuilder.create()
.add("query", query)
.add("type", type.toString())
.add("showresults", Boolean.toString(showResults))
.add("explain", Boolean.toString(explain))
.getList();
try {
// try optimistically to execute the query
SlingHttpResponse response = this.doGet(QueryServlet.SERVLET_PATH, params, SC_OK);
return JsonUtils.getJsonNodeFromString(response.getContent());
} catch (ClientException e) {
if (e.getHttpStatusCode() == SC_NOT_FOUND) {
LOG.info("Could not find query servlet, will try to install it");
installServlet();
LOG.info("Retrying the query");
SlingHttpResponse response = this.doGet(QueryServlet.SERVLET_PATH, params, SC_OK);
return JsonUtils.getJsonNodeFromString(response.getContent());
} else {
throw e;
}
}
}