use of org.folio.okapi.common.Failure 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 org.folio.okapi.common.Failure 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 org.folio.okapi.common.Failure 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 org.folio.okapi.common.Failure 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));
}
}
use of org.folio.okapi.common.Failure in project okapi by folio-org.
the class InternalModule method createTenant.
private void createTenant(ProxyContext pc, String body, Handler<ExtendedAsyncResult<String>> fut) {
try {
final TenantDescriptor td = Json.decodeValue(body, TenantDescriptor.class);
if (td.getId() == null || td.getId().isEmpty()) {
td.setId(UUID.randomUUID().toString());
}
final String id = td.getId();
if (!id.matches("^[a-z0-9_-]+$")) {
fut.handle(new Failure<>(USER, "Invalid tenant id '" + id + "'"));
return;
}
Tenant t = new Tenant(td);
tenantManager.insert(t, res -> {
if (res.failed()) {
fut.handle(new Failure<>(res.getType(), res.cause()));
return;
}
location(pc, id, null, Json.encodePrettily(t.getDescriptor()), fut);
});
} catch (DecodeException ex) {
fut.handle(new Failure<>(USER, ex));
}
}
Aggregations