use of org.folio.okapi.bean.TenantModuleDescriptor in project okapi by folio-org.
the class TenantManager method installCommit1.
/* phase 1 deploy modules if necessary */
private void installCommit1(Tenant t, ProxyContext pc, TenantInstallOptions options, Map<String, ModuleDescriptor> modsAvailable, List<TenantModuleDescriptor> tml, Iterator<TenantModuleDescriptor> it, Handler<ExtendedAsyncResult<Void>> fut) {
if (it.hasNext() && options.getDeploy()) {
TenantModuleDescriptor tm = it.next();
if ("enable".equals(tm.getAction()) || "uptodate".equals(tm.getAction())) {
ModuleDescriptor md = modsAvailable.get(tm.getId());
proxyService.autoDeploy(md, pc, res -> {
if (res.failed()) {
fut.handle(new Failure<>(res.getType(), res.cause()));
} else {
installCommit1(t, pc, options, modsAvailable, tml, it, fut);
}
});
} else {
installCommit1(t, pc, options, modsAvailable, tml, it, fut);
}
} else {
installCommit2(t, pc, options, modsAvailable, tml, tml.iterator(), fut);
}
}
use of org.folio.okapi.bean.TenantModuleDescriptor in project okapi by folio-org.
the class TenantManager method tmEnable.
private boolean tmEnable(String id, Map<String, ModuleDescriptor> modsAvailable, Map<String, ModuleDescriptor> modsEnabled, List<TenantModuleDescriptor> tml, Handler<ExtendedAsyncResult<Boolean>> fut) {
ModuleId moduleId = new ModuleId(id);
if (!moduleId.hasSemVer()) {
id = moduleId.getLatest(modsAvailable.keySet());
}
if (!modsAvailable.containsKey(id)) {
fut.handle(new Failure<>(NOT_FOUND, id));
return true;
}
if (modsEnabled.containsKey(id)) {
boolean alreadyEnabled = false;
for (TenantModuleDescriptor tm : tml) {
if (tm.getId().equals(id)) {
alreadyEnabled = true;
}
}
if (!alreadyEnabled) {
TenantModuleDescriptor tmu = new TenantModuleDescriptor();
tmu.setAction("uptodate");
tmu.setId(id);
tml.add(tmu);
}
} else {
moduleManager.addModuleDependencies(modsAvailable.get(id), modsAvailable, modsEnabled, tml);
}
return false;
}
use of org.folio.okapi.bean.TenantModuleDescriptor in project okapi by folio-org.
the class TenantManager method installCommit3.
/* phase 3 undeploy if no longer needed */
private void installCommit3(Tenant tenant, ProxyContext pc, TenantInstallOptions options, Map<String, ModuleDescriptor> modsAvailable, List<TenantModuleDescriptor> tml, Iterator<TenantModuleDescriptor> it, Handler<ExtendedAsyncResult<Void>> fut) {
if (it.hasNext() && options.getDeploy()) {
TenantModuleDescriptor tm = it.next();
ModuleDescriptor md = null;
if ("enable".equals(tm.getAction())) {
md = modsAvailable.get(tm.getFrom());
}
if ("disable".equals(tm.getAction())) {
md = modsAvailable.get(tm.getId());
}
if (md != null) {
final ModuleDescriptor mdF = md;
getModuleUser(md.getId(), ures -> {
if (ures.failed()) {
// in use or other error, so skip
installCommit3(tenant, pc, options, modsAvailable, tml, it, fut);
} else {
// success means : not in use, so we can undeploy it
proxyService.autoUndeploy(mdF, pc, res -> {
if (res.failed()) {
fut.handle(new Failure<>(res.getType(), res.cause()));
} else {
installCommit3(tenant, pc, options, modsAvailable, tml, it, fut);
}
});
}
});
} else {
installCommit3(tenant, pc, options, modsAvailable, tml, it, fut);
}
} else {
fut.handle(new Success<>());
}
}
use of org.folio.okapi.bean.TenantModuleDescriptor in project okapi by folio-org.
the class TenantManager method prepareTenantModuleList.
private List<TenantModuleDescriptor> prepareTenantModuleList(Map<String, ModuleDescriptor> modsAvailable, Map<String, ModuleDescriptor> modsEnabled, List<TenantModuleDescriptor> tml) {
if (tml == null) {
// upgrade case . Mark all newer modules for install
List<TenantModuleDescriptor> tml2 = new LinkedList<>();
for (String fId : modsEnabled.keySet()) {
ModuleId moduleId = new ModuleId(fId);
String uId = moduleId.getLatest(modsAvailable.keySet());
if (!uId.equals(fId)) {
TenantModuleDescriptor tmd = new TenantModuleDescriptor();
tmd.setAction("enable");
tmd.setId(uId);
logger.info("upgrade.. enable " + uId);
tmd.setFrom(fId);
tml2.add(tmd);
}
}
return tml2;
} else {
return tml;
}
}
use of org.folio.okapi.bean.TenantModuleDescriptor in project okapi by folio-org.
the class TenantManager method installCheckDependencies.
private void installCheckDependencies(Map<String, ModuleDescriptor> modsAvailable, Map<String, ModuleDescriptor> modsEnabled, List<TenantModuleDescriptor> tml, Handler<ExtendedAsyncResult<Boolean>> fut) {
List<TenantModuleDescriptor> tml2 = new LinkedList<>();
for (TenantModuleDescriptor tm : tml) {
if (tmAction(tm, modsAvailable, modsEnabled, tml2, fut)) {
return;
}
}
String s = moduleManager.checkAllDependencies(modsEnabled);
if (!s.isEmpty()) {
logger.warn("installModules.checkAllDependencies: " + s);
fut.handle(new Failure<>(USER, s));
return;
}
tml.clear();
for (TenantModuleDescriptor tm : tml2) {
tml.add(tm);
}
logger.info("installModules.returning OK");
fut.handle(new Success<>(Boolean.TRUE));
}
Aggregations