use of org.folio.okapi.bean.TenantModuleDescriptor in project okapi by folio-org.
the class InternalModule method getModuleForTenant.
private void getModuleForTenant(String id, String mod, Handler<ExtendedAsyncResult<String>> fut) {
tenantManager.get(id, res -> {
if (res.failed()) {
fut.handle(new Failure<>(res.getType(), res.cause()));
return;
}
Tenant t = res.result();
// Convert the list of module names
Set<String> ml = t.listModules();
if (!ml.contains(mod)) {
fut.handle(new Failure<>(NOT_FOUND, mod));
return;
}
TenantModuleDescriptor tmd = new TenantModuleDescriptor();
tmd.setId(mod);
String s = Json.encodePrettily(tmd);
fut.handle(new Success<>(s));
});
}
use of org.folio.okapi.bean.TenantModuleDescriptor in project okapi by folio-org.
the class InternalModule method listModulesForTenant.
private void listModulesForTenant(String id, Handler<ExtendedAsyncResult<String>> fut) {
tenantManager.listModules(id, res -> {
if (res.failed()) {
fut.handle(new Failure<>(res.getType(), res.cause()));
return;
}
List<String> ml = res.result();
// into a list of objects
Iterator<String> mli = ml.iterator();
ArrayList<TenantModuleDescriptor> ta = new ArrayList<>();
while (mli.hasNext()) {
TenantModuleDescriptor tmd = new TenantModuleDescriptor();
tmd.setId(mli.next());
ta.add(tmd);
}
String s = Json.encodePrettily(ta);
fut.handle(new Success<>(s));
});
}
use of org.folio.okapi.bean.TenantModuleDescriptor in project okapi by folio-org.
the class InternalModule method listModulesFromInterface.
private void listModulesFromInterface(ProxyContext pc, String id, String intId, Handler<ExtendedAsyncResult<String>> fut) {
final String type = pc.getCtx().request().getParam("type");
tenantManager.listModulesFromInterface(id, intId, type, res -> {
if (res.failed()) {
fut.handle(new Failure<>(res.getType(), res.cause()));
return;
}
List<ModuleDescriptor> mdL = res.result();
ArrayList<TenantModuleDescriptor> ta = new ArrayList<>();
for (ModuleDescriptor md : mdL) {
TenantModuleDescriptor tmd = new TenantModuleDescriptor();
tmd.setId(md.getId());
ta.add(tmd);
}
String s = Json.encodePrettily(ta);
fut.handle(new Success<>(s));
});
}
use of org.folio.okapi.bean.TenantModuleDescriptor 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.bean.TenantModuleDescriptor in project okapi by folio-org.
the class TenantManager method installCommit2.
/* phase 2 enable modules for tenant */
private void installCommit2(Tenant tenant, ProxyContext pc, TenantInstallOptions options, Map<String, ModuleDescriptor> modsAvailable, List<TenantModuleDescriptor> tml, Iterator<TenantModuleDescriptor> it, Handler<ExtendedAsyncResult<Void>> fut) {
if (it.hasNext()) {
TenantModuleDescriptor tm = it.next();
ModuleDescriptor mdFrom = null;
ModuleDescriptor mdTo = null;
if ("enable".equals(tm.getAction())) {
if (tm.getFrom() != null) {
mdFrom = modsAvailable.get(tm.getFrom());
}
mdTo = modsAvailable.get(tm.getId());
} else if ("disable".equals(tm.getAction())) {
mdFrom = modsAvailable.get(tm.getId());
}
if (mdFrom == null && mdTo == null) {
installCommit2(tenant, pc, options, modsAvailable, tml, it, fut);
} else {
ead1TenantInterface(tenant, mdFrom, mdTo, pc, res -> {
if (res.failed()) {
fut.handle(new Failure<>(res.getType(), res.cause()));
} else {
installCommit2(tenant, pc, options, modsAvailable, tml, it, fut);
}
});
}
} else {
installCommit3(tenant, pc, options, modsAvailable, tml, tml.iterator(), fut);
}
}
Aggregations