use of org.folio.okapi.bean.TenantDescriptor in project okapi by folio-org.
the class InternalModule method getTenant.
private void getTenant(String id, Handler<ExtendedAsyncResult<String>> fut) {
tenantManager.get(id, res -> {
if (res.failed()) {
fut.handle(new Failure<>(res.getType(), res.cause()));
return;
}
Tenant te = res.result();
TenantDescriptor td = te.getDescriptor();
String s = Json.encodePrettily(td);
fut.handle(new Success<>(s));
});
}
use of org.folio.okapi.bean.TenantDescriptor in project okapi by folio-org.
the class InternalModule method updateTenant.
private void updateTenant(String id, String body, Handler<ExtendedAsyncResult<String>> fut) {
try {
final TenantDescriptor td = Json.decodeValue(body, TenantDescriptor.class);
if (!id.equals(td.getId())) {
fut.handle(new Failure<>(USER, "Tenant.id=" + td.getId() + " id=" + id));
return;
}
Tenant t = new Tenant(td);
tenantManager.updateDescriptor(td, res -> {
if (res.failed()) {
fut.handle(new Failure<>(res.getType(), res.cause()));
return;
}
final String s = Json.encodePrettily(t.getDescriptor());
fut.handle(new Success<>(s));
});
} catch (DecodeException ex) {
fut.handle(new Failure<>(USER, ex));
}
}
use of org.folio.okapi.bean.TenantDescriptor 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