use of org.folio.rest.annotations.Validate in project raml-module-builder by folio-org.
the class JobAPI method deleteJobsJobconfsByJobconfsIdJobsByJobId.
@Validate
@Override
public void deleteJobsJobconfsByJobconfsIdJobsByJobId(String jobId, String jobconfsId, String lang, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
Job query = new Job();
query.setId(jobId);
query.setJobConfId(jobconfsId);
System.out.println("sending... deleteJobsJobconfsByJobconfsIdJobsByJobId");
try {
vertxContext.runOnContext(v -> {
try {
PostgresClient.getInstance(vertxContext.owner()).delete(RTFConsts.JOBS_COLLECTION, query, reply -> {
if (reply.succeeded()) {
if (reply.result().getUpdated() == 1) {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(DeleteJobsJobconfsByJobconfsIdJobsByJobIdResponse.withNoContent()));
} else {
String message = messages.getMessage(lang, MessageConsts.DeletedCountError, 1, reply.result().getUpdated());
log.error(message);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(DeleteJobsJobconfsByJobconfsIdJobsByJobIdResponse.withPlainNotFound(message)));
}
} else {
log.error(reply.cause());
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(DeleteJobsJobconfsByJobconfsIdJobsByJobIdResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
}
});
} catch (Exception e) {
log.error(e.getMessage(), e);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(DeleteJobsJobconfsByJobconfsIdJobsByJobIdResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
}
});
} catch (Exception e) {
log.error(e.getMessage(), e);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(DeleteJobsJobconfsByJobconfsIdJobsByJobIdResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
}
}
use of org.folio.rest.annotations.Validate in project raml-module-builder by folio-org.
the class JobAPI method getJobsJobconfsByJobconfsId.
@Validate
@Override
public void getJobsJobconfsByJobconfsId(String jobconfsId, String lang, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
System.out.println("sending... getJobsJobconfsByJobconfsId");
try {
Criteria c = new Criteria();
c.addField("_id");
c.setOperation("=");
c.setValue(jobconfsId);
c.setJSONB(false);
vertxContext.runOnContext(v -> {
try {
PostgresClient.getInstance(vertxContext.owner()).get(RTFConsts.JOB_CONF_COLLECTION, JobConf.class, new Criterion(c), true, reply -> {
@SuppressWarnings("unchecked") List<JobConf> confs = (List<JobConf>) reply.result().getResults();
if (confs.isEmpty()) {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetJobsJobconfsByJobconfsIdResponse.withPlainNotFound("JobConf " + messages.getMessage(lang, "10008"))));
return;
}
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetJobsJobconfsByJobconfsIdResponse.withJsonOK(confs.get(0))));
});
} catch (Exception e) {
log.error(e);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetJobsJobconfsByJobconfsIdResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
}
});
} catch (Exception e) {
log.error(e);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetJobsJobconfsByJobconfsIdResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
}
}
use of org.folio.rest.annotations.Validate in project raml-module-builder by folio-org.
the class JobAPI method getJobsJobconfsByJobconfsIdJobsByJobId.
@Validate
@Override
public void getJobsJobconfsByJobconfsIdJobsByJobId(String jobId, String jobconfsId, String lang, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
Job query = new Job();
query.setId(jobId);
query.setJobConfId(jobconfsId);
System.out.println("sending... getJobsJobconfsByJobconfsIdJobsByJobId");
try {
vertxContext.runOnContext(v -> {
try {
PostgresClient.getInstance(vertxContext.owner()).get(RTFConsts.JOBS_COLLECTION, query, true, reply -> {
try {
@SuppressWarnings("unchecked") List<Job> job = (List<Job>) reply.result().getResults();
if (job.isEmpty()) {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetJobsJobconfsByJobconfsIdJobsByJobIdResponse.withPlainNotFound("Job " + messages.getMessage(lang, "10008"))));
return;
}
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetJobsJobconfsByJobconfsIdJobsByJobIdResponse.withJsonOK(job.get(0))));
} catch (Exception e) {
log.error(e.getMessage(), e);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetJobsJobconfsByJobconfsIdJobsByJobIdResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
}
});
} catch (Exception e) {
log.error(e.getMessage(), e);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetJobsJobconfsByJobconfsIdJobsByJobIdResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
}
});
} catch (Exception e) {
log.error(e.getMessage(), e);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetJobsJobconfsByJobconfsIdJobsByJobIdResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
}
}
use of org.folio.rest.annotations.Validate in project raml-module-builder by folio-org.
the class JobAPI method putJobsJobconfsByJobconfsId.
@Validate
@Override
public void putJobsJobconfsByJobconfsId(String jobconfsId, String lang, JobConf entity, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
JobConf query = new JobConf();
query.setId(jobconfsId);
System.out.println("sending... putJobsJobconfsByJobconfsId");
try {
vertxContext.runOnContext(v -> {
try {
PostgresClient.getInstance(vertxContext.owner()).update(RTFConsts.JOB_CONF_COLLECTION, entity, jobconfsId, reply -> {
if (reply.succeeded() && reply.result().getUpdated() == 0) {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PutJobsJobconfsByJobconfsIdResponse.withPlainNotFound(jobconfsId)));
} else {
try {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PutJobsJobconfsByJobconfsIdResponse.withNoContent()));
} catch (Exception e) {
log.error(e);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PutJobsJobconfsByJobconfsIdResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
}
}
});
} catch (Exception e) {
log.error(e.getMessage(), e);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PutJobsJobconfsByJobconfsIdResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
}
});
} catch (Exception e) {
log.error(e.getMessage(), e);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PutJobsJobconfsByJobconfsIdResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
}
}
use of org.folio.rest.annotations.Validate in project raml-module-builder by folio-org.
the class JobAPI method putJobsJobconfsByJobconfsIdJobsByJobId.
@Validate
@Override
public void putJobsJobconfsByJobconfsIdJobsByJobId(String jobId, String jobconfsId, String lang, Job entity, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
System.out.println("sending... putJobsJobconfsByJobconfsId");
try {
Criteria c = new Criteria();
c.addField("_id");
c.setOperation("=");
c.setValue(jobId);
c.setJSONB(false);
Criteria d = new Criteria();
d.addField("job_conf_id");
d.setOperation("=");
d.setValue(jobconfsId);
d.setJSONB(false);
vertxContext.runOnContext(v -> {
try {
PostgresClient.getInstance(vertxContext.owner()).update(RTFConsts.JOBS_COLLECTION, entity, new Criterion().addCriterion(c, "AND", d), true, reply -> {
if (reply.succeeded() && reply.result().getUpdated() == 0) {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PutJobsJobconfsByJobconfsIdJobsByJobIdResponse.withPlainNotFound(jobId)));
} else {
try {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PutJobsJobconfsByJobconfsIdJobsByJobIdResponse.withNoContent()));
} catch (Exception e) {
log.error(e);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PutJobsJobconfsByJobconfsIdJobsByJobIdResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
}
}
});
} catch (Exception e) {
log.error(e.getMessage(), e);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PutJobsJobconfsByJobconfsIdJobsByJobIdResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
}
});
} catch (Exception e) {
log.error(e.getMessage(), e);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PutJobsJobconfsByJobconfsIdJobsByJobIdResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
}
}
Aggregations