use of org.folio.rest.annotations.Validate in project raml-module-builder by folio-org.
the class AdminAPI method putAdminLoglevel.
@Validate
@Override
public void putAdminLoglevel(Level level, String javaPackage, java.util.Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
try {
JsonObject updatedLoggers = LogUtil.updateLogConfiguration(javaPackage, level.name());
OutStream os = new OutStream();
os.setData(updatedLoggers);
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.annotations.Validate in project raml-module-builder by folio-org.
the class AdminAPI method getAdminPostgresTableAccessStats.
@Validate
@Override
public void getAdminPostgresTableAccessStats(Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
PostgresClient.getInstance(vertxContext.owner()).select("SELECT schemaname,relname,seq_scan,idx_scan,cast(idx_scan " + "AS numeric) / (idx_scan + seq_scan) AS idx_scan_pct " + "FROM pg_stat_user_tables WHERE (idx_scan + seq_scan)>0 " + "ORDER BY idx_scan_pct;", reply -> {
if (reply.succeeded()) {
OutStream stream = new OutStream();
stream.setData(reply.result().getRows());
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetAdminPostgresTableAccessStatsResponse.withJsonOK(stream)));
} else {
log.error(reply.cause().getMessage(), reply.cause());
asyncResultHandler.handle(io.vertx.core.Future.failedFuture(reply.cause().getMessage()));
}
});
}
use of org.folio.rest.annotations.Validate in project raml-module-builder by folio-org.
the class AdminAPI method getAdminPostgresActiveSessions.
@Validate
@Override
public void getAdminPostgresActiveSessions(String dbname, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
PostgresClient.getInstance(vertxContext.owner(), "public").select("SELECT pid , usename, " + "application_name, client_addr, client_hostname, " + "query, state from pg_stat_activity where datname='" + dbname + "'", reply -> {
if (reply.succeeded()) {
OutStream stream = new OutStream();
stream.setData(reply.result().getRows());
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetAdminPostgresActiveSessionsResponse.withJsonOK(stream)));
} else {
log.error(reply.cause().getMessage(), reply.cause());
asyncResultHandler.handle(io.vertx.core.Future.failedFuture(reply.cause().getMessage()));
}
});
}
use of org.folio.rest.annotations.Validate 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.annotations.Validate 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);
}
}
Aggregations