use of io.vertx.core.json.DecodeException in project okapi by folio-org.
the class InternalModule method listModules.
private void listModules(ProxyContext pc, Handler<ExtendedAsyncResult<String>> fut) {
try {
ModuleId filter = null;
String filterStr = pc.getCtx().request().getParam("filter");
if (filterStr != null) {
filter = new ModuleId(filterStr);
}
final String orderByStr = pc.getCtx().request().getParam("orderBy");
final String orderStr = pc.getCtx().request().getParam("order");
final boolean preRelease = getParamBoolean(pc.getCtx().request(), "preRelease", true);
final boolean full = getParamBoolean(pc.getCtx().request(), "full", false);
moduleManager.getModulesWithFilter(filter, preRelease, res -> {
if (res.failed()) {
fut.handle(new Failure<>(res.getType(), res.cause()));
return;
}
List<ModuleDescriptor> mdl = res.result();
if (orderByStr != null) {
if (!"id".equals(orderByStr)) {
fut.handle(new Failure<>(USER, "unknown orderBy field: " + orderByStr));
return;
}
if (orderStr == null || "desc".equals(orderStr)) {
Collections.sort(mdl, Collections.reverseOrder());
} else if ("asc".equals(orderStr)) {
Collections.sort(mdl);
} else {
fut.handle(new Failure<>(USER, "invalid order value: " + orderStr));
return;
}
} else {
Collections.sort(mdl, Collections.reverseOrder());
}
List<ModuleDescriptor> ml = new ArrayList<>(mdl.size());
for (ModuleDescriptor md : mdl) {
ml.add(new ModuleDescriptor(md, full));
}
String s = Json.encodePrettily(ml);
fut.handle(new Success<>(s));
});
} catch (DecodeException ex) {
fut.handle(new Failure<>(USER, ex));
}
}
use of io.vertx.core.json.DecodeException in project okapi by folio-org.
the class InternalModule method upgradeModulesForTenant.
private void upgradeModulesForTenant(ProxyContext pc, String id, Handler<ExtendedAsyncResult<String>> fut) {
try {
TenantInstallOptions options = createTenantOptions(pc.getCtx());
tenantManager.installUpgradeModules(id, pc, options, null, res -> {
if (res.failed()) {
fut.handle(new Failure<>(res.getType(), res.cause()));
} else {
logger.info("installUpgradeModules returns:\n" + Json.encodePrettily(res.result()));
fut.handle(new Success<>(Json.encodePrettily(res.result())));
}
});
} catch (DecodeException ex) {
fut.handle(new Failure<>(USER, ex));
}
}
use of io.vertx.core.json.DecodeException in project okapi by folio-org.
the class InternalModule method enableModuleForTenant.
private void enableModuleForTenant(ProxyContext pc, String id, String body, Handler<ExtendedAsyncResult<String>> fut) {
try {
final TenantModuleDescriptor td = Json.decodeValue(body, TenantModuleDescriptor.class);
String moduleTo = td.getId();
tenantManager.enableAndDisableModule(id, null, moduleTo, pc, eres -> {
if (eres.failed()) {
fut.handle(new Failure<>(eres.getType(), eres.cause()));
return;
}
td.setId(eres.result());
location(pc, td.getId(), null, Json.encodePrettily(td), fut);
});
} catch (DecodeException ex) {
fut.handle(new Failure<>(USER, ex));
}
}
use of io.vertx.core.json.DecodeException in project okapi by folio-org.
the class InternalModule method createEnv.
private void createEnv(ProxyContext pc, String body, Handler<ExtendedAsyncResult<String>> fut) {
try {
final EnvEntry pmd = Json.decodeValue(body, EnvEntry.class);
envManager.add(pmd, res -> {
if (res.failed()) {
fut.handle(new Failure<>(res.getType(), res.cause()));
return;
}
final String js = Json.encodePrettily(pmd);
location(pc, pmd.getName(), null, js, fut);
});
} catch (DecodeException ex) {
fut.handle(new Failure<>(USER, ex));
}
}
use of io.vertx.core.json.DecodeException in project okapi by folio-org.
the class InternalModule method discoveryDeploy.
private void discoveryDeploy(ProxyContext pc, String body, Handler<ExtendedAsyncResult<String>> fut) {
try {
final DeploymentDescriptor pmd = Json.decodeValue(body, DeploymentDescriptor.class);
discoveryManager.addAndDeploy(pmd, pc, res -> {
if (res.failed()) {
fut.handle(new Failure<>(res.getType(), res.cause()));
return;
}
DeploymentDescriptor md = res.result();
final String s = Json.encodePrettily(md);
final String baseuri = pc.getCtx().request().uri() + "/" + md.getSrvcId();
location(pc, md.getInstId(), baseuri, s, fut);
});
} catch (DecodeException ex) {
fut.handle(new Failure<>(USER, ex));
}
}
Aggregations