use of org.folio.rest.jaxrs.model.NatureOfContentTerms in project mod-inventory-storage by folio-org.
the class NatureOfContentTermAPI method getNatureOfContentTerms.
@Validate
@Override
public void getNatureOfContentTerms(String query, int offset, int limit, String lang, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
/**
* http://host:port/nature-of-content-terms
*/
vertxContext.runOnContext(v -> {
try {
String tenantId = TenantTool.tenantId(okapiHeaders);
CQLWrapper cql = getCQL(query, limit, offset);
PostgresClient.getInstance(vertxContext.owner(), tenantId).get(REFERENCE_TABLE, NatureOfContentTerm.class, new String[] { "*" }, cql, true, true, reply -> {
if (reply.succeeded()) {
NatureOfContentTerms records = new NatureOfContentTerms();
List<NatureOfContentTerm> record = reply.result().getResults();
records.setNatureOfContentTerms(record);
records.setTotalRecords(reply.result().getResultInfo().getTotalRecords());
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetNatureOfContentTermsResponse.respond200WithApplicationJson(records)));
} else {
log.error(reply.cause().getMessage(), reply.cause());
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetNatureOfContentTermsResponse.respond400WithTextPlain(reply.cause().getMessage())));
}
});
} catch (Exception e) {
log.error(e.getMessage(), e);
String message = messages.getMessage(lang, MessageConsts.InternalServerError);
if (e.getCause() instanceof CQLParseException) {
message = " CQL parse error " + e.getLocalizedMessage();
}
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetNatureOfContentTermsResponse.respond500WithTextPlain(message)));
}
});
}
Aggregations