use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.
the class ModuleManager method createList2.
private void createList2(List<ModuleDescriptor> list, Handler<ExtendedAsyncResult<Void>> fut) {
CompList<Void> futures = new CompList<>(INTERNAL);
for (ModuleDescriptor md : list) {
Future<Void> f = Future.future();
createList3(md, f::handle);
futures.add(f);
}
futures.all(fut);
}
use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.
the class ModuleManager method addModuleDependencies.
public int addModuleDependencies(ModuleDescriptor md, Map<String, ModuleDescriptor> modsAvailable, Map<String, ModuleDescriptor> modsEnabled, List<TenantModuleDescriptor> tml) {
int sum = 0;
logger.info("addModuleDependencies " + md.getId());
for (InterfaceDescriptor req : md.getRequiresList()) {
int v = checkInterfaceDependency(req, modsAvailable, modsEnabled, tml);
if (v == -1) {
return v;
}
sum += v;
}
List<ModuleDescriptor> fromModule = new LinkedList<>();
sum += resolveModuleConflicts(md, modsEnabled, tml, fromModule);
logger.info("addModuleDependencies - add " + md.getId());
modsEnabled.put(md.getId(), md);
TenantModuleDescriptor tm = new TenantModuleDescriptor();
tm.setAction("enable");
if (!fromModule.isEmpty()) {
tm.setFrom(fromModule.get(0).getId());
}
tm.setId(md.getId());
tml.add(tm);
return sum + 1;
}
use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.
the class ModuleManager method createList.
/**
* Create a whole list of modules.
*
* @param list
* @param fut
*/
public void createList(List<ModuleDescriptor> list, boolean check, Handler<ExtendedAsyncResult<Void>> fut) {
modules.getAll(ares -> {
if (ares.failed()) {
fut.handle(new Failure<>(ares.getType(), ares.cause()));
return;
}
LinkedHashMap<String, ModuleDescriptor> tempList = ares.result();
LinkedList<ModuleDescriptor> nList = new LinkedList<>();
for (ModuleDescriptor md : list) {
final String id = md.getId();
if (tempList.containsKey(id)) {
ModuleDescriptor exMd = tempList.get(id);
String exJson = Json.encodePrettily(exMd);
String json = Json.encodePrettily(md);
if (!json.equals(exJson)) {
fut.handle(new Failure<>(USER, "create: module " + id + " exists already"));
return;
}
} else {
tempList.put(id, md);
nList.add(md);
}
}
if (check) {
String res = checkAllDependencies(tempList);
if (!res.isEmpty()) {
fut.handle(new Failure<>(USER, res));
return;
}
}
createList2(nList, fut);
});
}
use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.
the class ModuleManager method getModulesWithFilter.
public void getModulesWithFilter(ModuleId filter, boolean preRelease, Handler<ExtendedAsyncResult<List<ModuleDescriptor>>> fut) {
modules.getAll(kres -> {
if (kres.failed()) {
fut.handle(new Failure<>(kres.getType(), kres.cause()));
} else {
List<ModuleDescriptor> mdl = new LinkedList<>();
for (ModuleDescriptor md : kres.result().values()) {
String id = md.getId();
ModuleId idThis = new ModuleId(id);
if ((filter == null || idThis.hasPrefix(filter)) && (preRelease || !idThis.hasPreRelease())) {
mdl.add(md);
}
}
fut.handle(new Success<>(mdl));
}
});
}
use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.
the class ModuleManager method loadModules.
/**
* Load the modules from the database, if not already loaded.
*
* @param fut
*/
private void loadModules(Handler<ExtendedAsyncResult<Void>> fut) {
if (moduleStore == null) {
logger.debug("No ModuleStorage to load from, starting with empty");
fut.handle(new Success<>());
return;
}
modules.size(kres -> {
if (kres.failed()) {
fut.handle(new Failure<>(INTERNAL, kres.cause()));
return;
}
if (kres.result() > 0) {
logger.debug("Not loading modules, looks like someone already did");
fut.handle(new Success<>());
return;
}
moduleStore.getAll(mres -> {
if (mres.failed()) {
fut.handle(new Failure<>(mres.getType(), mres.cause()));
return;
}
CompList<Void> futures = new CompList<>(INTERNAL);
for (ModuleDescriptor md : mres.result()) {
Future<Void> f = Future.future();
modules.add(md.getId(), md, f::handle);
futures.add(f);
}
futures.all(fut);
});
});
}
Aggregations