use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.
the class TenantManager method ead2PermMod.
/**
* enableAndDisable helper 2: Choose which permission module to invoke.
*
* @param tenant
* @param mdFrom
* @param mdTo
* @param pc
* @param fut
*/
private void ead2PermMod(Tenant tenant, ModuleDescriptor mdFrom, ModuleDescriptor mdTo, ProxyContext pc, Handler<ExtendedAsyncResult<Void>> fut) {
String moduleFrom = mdFrom != null ? mdFrom.getId() : null;
String moduleTo = mdTo.getId();
findSystemInterface(tenant, res -> {
if (res.failed()) {
if (res.getType() == NOT_FOUND) {
// no perms interface.
if (mdTo.getSystemInterface("_tenantPermissions") != null) {
pc.debug("ead2PermMod: Here we reload perms of all enabled modules");
Set<String> listModules = tenant.listModules();
pc.debug("Got a list of already-enabled moduled: " + Json.encode(listModules));
Iterator<String> modit = listModules.iterator();
ead3RealoadPerms(tenant, modit, moduleFrom, mdTo, mdTo, pc, fut);
return;
}
pc.debug("enablePermissions: No tenantPermissions interface found. " + "Carrying on without it.");
ead5commit(tenant, moduleFrom, moduleTo, pc, fut);
} else {
pc.responseError(res.getType(), res.cause());
}
} else {
ModuleDescriptor permsMod = res.result();
if (mdTo.getSystemInterface("_tenantPermissions") != null) {
pc.debug("Using the tenantPermissions of this module itself");
permsMod = mdTo;
}
ead4Permissions(tenant, moduleFrom, mdTo, permsMod, pc, fut);
}
});
}
use of org.folio.okapi.bean.ModuleDescriptor 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.ModuleDescriptor 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.ModuleDescriptor in project okapi by folio-org.
the class TenantManager method listModulesFromInterface.
public void listModulesFromInterface(String tenantId, String interfaceName, String interfaceType, Handler<ExtendedAsyncResult<List<ModuleDescriptor>>> fut) {
tenants.get(tenantId, tres -> {
if (tres.failed()) {
fut.handle(new Failure<>(tres.getType(), tres.cause()));
return;
}
Tenant tenant = tres.result();
List<ModuleDescriptor> mdList = new LinkedList<>();
moduleManager.getEnabledModules(tenant, mres -> {
if (mres.failed()) {
fut.handle(new Failure<>(mres.getType(), mres.cause()));
return;
}
List<ModuleDescriptor> modlist = mres.result();
for (ModuleDescriptor md : modlist) {
for (InterfaceDescriptor provide : md.getProvidesList()) {
if (interfaceName.equals(provide.getId()) && (interfaceType == null || provide.isType(interfaceType))) {
mdList.add(md);
break;
}
}
}
fut.handle(new Success<>(mdList));
});
// modlist
});
// tenant
}
use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.
the class TenantManager method listInterfaces.
private void listInterfaces(Tenant tenant, boolean full, String interfaceType, Handler<ExtendedAsyncResult<List<InterfaceDescriptor>>> fut) {
List<InterfaceDescriptor> intList = new LinkedList<>();
moduleManager.getEnabledModules(tenant, mres -> {
if (mres.failed()) {
fut.handle(new Failure<>(mres.getType(), mres.cause()));
return;
}
List<ModuleDescriptor> modlist = mres.result();
Set<String> ids = new HashSet<>();
for (ModuleDescriptor md : modlist) {
for (InterfaceDescriptor provide : md.getProvidesList()) {
if (interfaceType == null || provide.isType(interfaceType)) {
if (full) {
intList.add(provide);
} else {
if (ids.add(provide.getId())) {
InterfaceDescriptor tmp = new InterfaceDescriptor();
tmp.setId(provide.getId());
tmp.setVersion(provide.getVersion());
intList.add(tmp);
}
}
}
}
}
fut.handle(new Success<>(intList));
});
}
Aggregations