use of org.codice.ddf.catalog.ui.query.cql.CqlQueryResponse in project ddf by codice.
the class QueryApplication method init.
@Override
public void init() {
post("/cql", APPLICATION_JSON, (req, res) -> {
CqlRequest cqlRequest = mapper.readValue(req.body(), CqlRequest.class);
CqlQueryResponse cqlQueryResponse = executeCqlQuery(cqlRequest);
String result = mapper.toJson(cqlQueryResponse);
return result;
});
after("/cql", (req, res) -> {
res.type(APPLICATION_JSON);
res.header("Content-Encoding", "gzip");
});
exception(UnsupportedQueryException.class, (e, request, response) -> {
response.status(400);
response.body("Unsupported query request.");
LOGGER.error("Query endpoint failed", e);
});
exception(Exception.class, (e, request, response) -> {
response.status(500);
response.body("Error while processing query request.");
LOGGER.error("Query endpoint failed", e);
});
enableRouteOverview();
}
use of org.codice.ddf.catalog.ui.query.cql.CqlQueryResponse in project ddf by codice.
the class QueryApplication method executeCqlQuery.
private CqlQueryResponse executeCqlQuery(CqlRequest cqlRequest) throws UnsupportedQueryException, SourceUnavailableException, FederationException {
QueryRequest request = cqlRequest.createQueryRequest(catalogFramework.getId(), filterBuilder);
Stopwatch stopwatch = Stopwatch.createStarted();
QueryResponse response = catalogFramework.query(request);
stopwatch.stop();
return new CqlQueryResponse(cqlRequest.getId(), request, response, cqlRequest.getSource(), stopwatch.elapsed(TimeUnit.MILLISECONDS), cqlRequest.isNormalize(), filterAdapter, actionRegistry);
}
Aggregations