Search in sources :

Example 1 with CqlRequest

use of org.codice.ddf.catalog.ui.query.cql.CqlRequest 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();
}
Also used : CqlRequest(org.codice.ddf.catalog.ui.query.cql.CqlRequest) CqlQueryResponse(org.codice.ddf.catalog.ui.query.cql.CqlQueryResponse)

Aggregations

CqlQueryResponse (org.codice.ddf.catalog.ui.query.cql.CqlQueryResponse)1 CqlRequest (org.codice.ddf.catalog.ui.query.cql.CqlRequest)1