use of org.folio.rest.tools.utils.OutStream in project raml-module-builder by folio-org.
the class AdminAPI method postAdminPostgresMaintenance.
@Validate
@Override
public void postAdminPostgresMaintenance(String table, Command command, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(ClientGenerator.OKAPI_HEADER_TENANT));
String module = PomReader.INSTANCE.getModuleName();
String querySuffix = tenantId + "_" + module + "." + table + ";";
String query = null;
if (Command.ANALYZE == command) {
query = "analyze " + querySuffix;
} else if (Command.VACUUM == command) {
query = "vacuum " + querySuffix;
} else if (Command.VACUUM_ANALYZE == command) {
query = "vacuum analyze " + querySuffix;
} else if (Command.VACUUM_VERBOSE == command) {
query = "vacuum verbose " + querySuffix;
}
try {
PostgresClient.getInstance(vertxContext.owner()).select(query, reply -> {
if (reply.succeeded()) {
OutStream stream = new OutStream();
stream.setData(reply.result().getRows());
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostAdminPostgresMaintenanceResponse.withJsonCreated(stream)));
} else {
log.error(reply.cause().getMessage(), reply.cause());
asyncResultHandler.handle(io.vertx.core.Future.failedFuture(reply.cause().getMessage()));
}
});
} catch (Exception e) {
log.error(e.getMessage());
asyncResultHandler.handle(io.vertx.core.Future.failedFuture(e.getMessage()));
}
}
use of org.folio.rest.tools.utils.OutStream in project raml-module-builder by folio-org.
the class AdminAPI method getAdminLoglevel.
@Validate
@Override
public void getAdminLoglevel(java.util.Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
try {
JsonObject loggers = LogUtil.getLogConfiguration();
OutStream os = new OutStream();
os.setData(loggers);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PutAdminLoglevelResponse.withJsonOK(os)));
} catch (Exception e) {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PutAdminLoglevelResponse.withPlainInternalServerError("ERROR" + e.getMessage())));
log.error(e.getMessage(), e);
}
}
use of org.folio.rest.tools.utils.OutStream in project raml-module-builder by folio-org.
the class BooksDemoAPI method postRmbtestsBooks.
@Validate
@Override
public void postRmbtestsBooks(Book entity, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
OutStream stream = new OutStream();
stream.setData(entity);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostRmbtestsBooksResponse.withJsonCreated("/dummy/location", stream)));
}
use of org.folio.rest.tools.utils.OutStream in project raml-module-builder by folio-org.
the class JobAPI method postJobsJobconfsByJobconfsIdJobs.
@Validate
@Override
public void postJobsJobconfsByJobconfsIdJobs(String jobconfsId, String lang, Job entity, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
System.out.println("sending... postJobsJobconfsByJobconfsIdJobs");
entity.setJobConfId(jobconfsId);
try {
vertxContext.runOnContext(v -> {
try {
PostgresClient.getInstance(vertxContext.owner()).save(RTFConsts.JOBS_COLLECTION, entity, reply -> {
try {
OutStream stream = new OutStream();
stream.setData(entity);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostJobsJobconfsByJobconfsIdJobsResponse.withJsonCreated(reply.result(), stream)));
} catch (Exception e) {
log.error(e);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostJobsJobconfsByJobconfsIdJobsResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
}
});
} catch (Exception e) {
log.error(e.getMessage(), e);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostJobsJobconfsByJobconfsIdJobsResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
}
});
} catch (Exception e) {
log.error(e.getMessage(), e);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostJobsJobconfsByJobconfsIdJobsResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
}
}
use of org.folio.rest.tools.utils.OutStream in project raml-module-builder by folio-org.
the class JobAPI method postJobsJobconfs.
@Validate
@Override
public void postJobsJobconfs(String lang, JobConf entity, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
System.out.println("sending... postJobsJobconfs");
try {
vertxContext.runOnContext(v -> {
try {
PostgresClient.getInstance(vertxContext.owner()).save(RTFConsts.JOB_CONF_COLLECTION, entity, reply -> {
OutStream stream = new OutStream();
stream.setData(entity);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostJobsJobconfsResponse.withJsonCreated(reply.result(), stream)));
});
} catch (Exception e) {
log.error(e);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostJobsJobconfsResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
}
});
} catch (Exception e) {
log.error(e);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostJobsJobconfsResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
}
}
Aggregations