use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.
the class PullManager method getList.
private void getList(String urlBase, Handler<ExtendedAsyncResult<ModuleDescriptor[]>> fut) {
String url = urlBase;
if (!url.endsWith("/")) {
url += "/";
}
url += "_/proxy/modules";
final Buffer body = Buffer.buffer();
HttpClientRequest req = httpClient.getAbs(url, res -> {
res.handler(body::appendBuffer);
res.endHandler(x -> {
if (res.statusCode() != 200) {
fut.handle(new Failure<>(ErrorType.USER, body.toString()));
} else {
ModuleDescriptor[] ml = Json.decodeValue(body.toString(), ModuleDescriptor[].class);
fut.handle(new Success<>(ml));
}
});
res.exceptionHandler(x -> fut.handle(new Failure<>(ErrorType.INTERNAL, x.getMessage())));
});
req.exceptionHandler(x -> fut.handle(new Failure<>(ErrorType.INTERNAL, x.getMessage())));
req.end();
}
use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.
the class PullManager method getFullReq.
private void getFullReq(String url, Handler<ExtendedAsyncResult<List<ModuleDescriptor>>> fut, List<ModuleDescriptor> ml, String urlBase, Iterator<ModuleDescriptor> it) {
final Buffer body = Buffer.buffer();
HttpClientRequest req = httpClient.getAbs(url, res -> {
res.handler(body::appendBuffer);
res.endHandler(x -> {
if (concurrentRuns > 0) {
concurrentRuns--;
}
if (res.statusCode() != 200) {
if (!concurrentComplete) {
concurrentComplete = true;
fut.handle(new Failure<>(ErrorType.USER, body.toString()));
}
} else {
ModuleDescriptor md = Json.decodeValue(body.toString(), ModuleDescriptor.class);
ml.add(md);
getFull(urlBase, it, ml, fut);
}
});
res.exceptionHandler(x -> {
if (concurrentRuns > 0) {
concurrentRuns--;
}
if (!concurrentComplete) {
concurrentComplete = true;
fut.handle(new Failure<>(ErrorType.INTERNAL, x.getMessage()));
}
});
});
req.exceptionHandler(x -> {
if (concurrentRuns > 0) {
concurrentRuns--;
}
if (!concurrentComplete) {
concurrentComplete = true;
fut.handle(new Failure<>(ErrorType.INTERNAL, x.getMessage()));
}
});
req.end();
}
use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.
the class TenantManager method checkDependencies.
/**
* Check module dependencies and conflicts.
*
* @param tenant to check for
* @param modFrom module to be removed. Ignored in the checks
* @param modTo module to be added
* @param fut Callback for error messages, or a simple Success
*/
private void checkDependencies(Tenant tenant, ModuleDescriptor modFrom, ModuleDescriptor modTo, Handler<ExtendedAsyncResult<Void>> fut) {
moduleManager.getEnabledModules(tenant, gres -> {
if (gres.failed()) {
fut.handle(new Failure<>(gres.getType(), gres.cause()));
return;
}
List<ModuleDescriptor> modlist = gres.result();
HashMap<String, ModuleDescriptor> mods = new HashMap<>(modlist.size());
for (ModuleDescriptor md : modlist) {
mods.put(md.getId(), md);
}
if (modFrom != null) {
mods.remove(modFrom.getId());
}
if (modTo != null) {
ModuleDescriptor already = mods.get(modTo.getId());
if (already != null) {
fut.handle(new Failure<>(USER, "Module " + modTo.getId() + " already provided"));
return;
}
mods.put(modTo.getId(), modTo);
}
String conflicts = moduleManager.checkAllConflicts(mods);
String deps = moduleManager.checkAllDependencies(mods);
if (conflicts.isEmpty() && deps.isEmpty()) {
fut.handle(new Success<>());
} else {
fut.handle(new Failure<>(USER, conflicts + " " + deps));
}
});
}
use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.
the class TenantManager method installUpgradeModules.
public void installUpgradeModules(String tenantId, ProxyContext pc, TenantInstallOptions options, List<TenantModuleDescriptor> tml, Handler<ExtendedAsyncResult<List<TenantModuleDescriptor>>> fut) {
tenants.get(tenantId, gres -> {
if (gres.failed()) {
fut.handle(new Failure<>(gres.getType(), gres.cause()));
return;
}
Tenant t = gres.result();
moduleManager.getModulesWithFilter(null, options.getPreRelease(), mres -> {
if (mres.failed()) {
fut.handle(new Failure<>(mres.getType(), mres.cause()));
return;
}
List<ModuleDescriptor> modResult = mres.result();
HashMap<String, ModuleDescriptor> modsAvailable = new HashMap<>(modResult.size());
HashMap<String, ModuleDescriptor> modsEnabled = new HashMap<>();
for (ModuleDescriptor md : modResult) {
modsAvailable.put(md.getId(), md);
logger.info("mod available: " + md.getId());
if (t.isEnabled(md.getId())) {
logger.info("mod enabled: " + md.getId());
modsEnabled.put(md.getId(), md);
}
}
List<TenantModuleDescriptor> tml2 = prepareTenantModuleList(modsAvailable, modsEnabled, tml);
installUpgradeModules2(t, pc, options, modsAvailable, modsEnabled, tml2, fut);
});
});
}
use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.
the class TenantManager method findSystemInterfaceR.
private void findSystemInterfaceR(Tenant tenant, String interfaceName, Iterator<String> it, Handler<ExtendedAsyncResult<ModuleDescriptor>> fut) {
if (!it.hasNext()) {
fut.handle(new Failure<>(NOT_FOUND, "No module provides " + interfaceName));
return;
}
String mid = it.next();
moduleManager.get(mid, gres -> {
if (gres.failed()) {
// should not happen
fut.handle(new Failure<>(gres.getType(), gres.cause()));
return;
}
ModuleDescriptor md = gres.result();
logger.debug("findSystemInterface: looking at " + mid + ": " + " si: " + md.getSystemInterface(interfaceName));
if (md.getSystemInterface(interfaceName) != null) {
logger.debug("findSystemInterface: found " + mid);
fut.handle(new Success<>(md));
return;
}
findSystemInterfaceR(tenant, interfaceName, it, fut);
});
}
Aggregations