use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.
the class DiscoveryManager method addAndDeploy2.
private void addAndDeploy2(DeploymentDescriptor dd, ProxyContext pc, Handler<ExtendedAsyncResult<DeploymentDescriptor>> fut, final String nodeId) {
if (moduleManager == null) {
fut.handle(new Failure<>(INTERNAL, "no module manager (should not happen)"));
return;
}
String modId = dd.getSrvcId();
moduleManager.get(modId, gres -> {
if (gres.failed()) {
if (gres.getType() == NOT_FOUND) {
fut.handle(new Failure<>(NOT_FOUND, "Module " + modId + " not found"));
} else {
fut.handle(new Failure<>(gres.getType(), gres.cause()));
}
return;
}
ModuleDescriptor md = gres.result();
LaunchDescriptor modLaunchDesc = md.getLaunchDescriptor();
if (modLaunchDesc == null) {
fut.handle(new Failure<>(USER, "Module " + modId + " has no launchDescriptor"));
return;
}
dd.setDescriptor(modLaunchDesc);
callDeploy(nodeId, pc, dd, fut);
});
}
use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.
the class PullManager method merge.
private void merge(String urlBase, List<ModuleDescriptor> mlLocal, ModuleDescriptor[] mlRemote, Handler<ExtendedAsyncResult<List<ModuleDescriptor>>> fut) {
TreeMap<String, Boolean> enabled = new TreeMap<>();
for (ModuleDescriptor md : mlLocal) {
enabled.put(md.getId(), false);
}
List<ModuleDescriptor> mlAdd = new LinkedList<>();
for (ModuleDescriptor md : mlRemote) {
if (!"okapi".equals(md.getProduct()) && enabled.get(md.getId()) == null) {
mlAdd.add(md);
}
}
logger.info("pull: " + mlAdd.size() + " MDs to fetch");
List<ModuleDescriptor> mlList = new LinkedList<>();
concurrentRuns = 0;
concurrentComplete = false;
getFull(urlBase, mlAdd.iterator(), mlList, res -> {
if (res.failed()) {
fut.handle(new Failure<>(res.getType(), res.cause()));
} else {
logger.info("pull: local insert");
moduleManager.createList(mlList, true, res1 -> {
if (res1.failed()) {
fut.handle(new Failure<>(res1.getType(), res1.cause()));
} else {
fut.handle(new Success<>(mlAdd));
}
});
}
});
}
use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.
the class TenantManager method enableAndDisableModule.
private void enableAndDisableModule(Tenant tenant, String moduleFrom, String moduleTo, ProxyContext pc, Handler<ExtendedAsyncResult<String>> fut) {
moduleManager.getLatest(moduleTo, resTo -> {
if (resTo.failed()) {
fut.handle(new Failure<>(resTo.getType(), resTo.cause()));
} else {
ModuleDescriptor mdTo = resTo.result();
moduleManager.get(moduleFrom, resFrom -> {
if (resFrom.failed()) {
fut.handle(new Failure<>(resFrom.getType(), resFrom.cause()));
} else {
ModuleDescriptor mdFrom = resFrom.result();
enableAndDisableModule2(tenant, mdFrom, mdTo, pc, fut);
}
});
}
});
}
use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.
the class TenantManager method ead3RealoadPerms.
/**
* enableAndDisable helper 3: Reload permissions. When we enable a module that
* provides the tenantPermissions interface, we may have other modules already
* enabled, who have not got their permissions pushed. Now that we have a
* place to push those permissions to, we do it recursively for all enabled
* modules.
*
* @param tenant
* @param moduleFrom
* @param mdTo
* @param permsModule
* @param pc
* @param fut
*/
private void ead3RealoadPerms(Tenant tenant, Iterator<String> modit, String moduleFrom, ModuleDescriptor mdTo, ModuleDescriptor permsModule, ProxyContext pc, Handler<ExtendedAsyncResult<Void>> fut) {
if (!modit.hasNext()) {
pc.debug("ead3RealoadPerms: No more modules to reload");
ead4Permissions(tenant, moduleFrom, mdTo, permsModule, pc, fut);
return;
}
String mdid = modit.next();
moduleManager.get(mdid, res -> {
if (res.failed()) {
// not likely to happen
pc.responseError(res.getType(), res.cause());
return;
}
ModuleDescriptor md = res.result();
pc.debug("ead3RealoadPerms: Should reload perms for " + md.getName());
tenantPerms(tenant, md, permsModule, pc, pres -> {
if (pres.failed()) {
// not likely to happen
pc.responseError(res.getType(), res.cause());
return;
}
ead3RealoadPerms(tenant, modit, moduleFrom, mdTo, permsModule, pc, fut);
});
});
}
use of org.folio.okapi.bean.ModuleDescriptor 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