public void setId(String s) { this.id = new ModuleId(s); if (!this.id.hasSemVer()) { throw new IllegalArgumentException("Missing semantic version for: " + s); } }
public void setReplaces(String[] replaces) { if (replaces == null || replaces.length == 0) { this.replaces = null; } else { this.replaces = new LinkedList<>(); for (String p : replaces) { ModuleId id = new ModuleId(p); if (id.hasSemVer()) { throw new IllegalArgumentException("No semantic version for: " + p); } this.replaces.add(id); } } }
public String getLatest(Collection<String> l) { ModuleId bModule = null; String bId = null; for (String cId : l) { ModuleId cModule = new ModuleId(cId); if (product.equals(cModule.getProduct()) && (bModule == null || cModule.compareTo(bModule) > 0)) { bId = cId; bModule = cModule; } } return bId != null ? bId : id; }
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(Action.enable); tmd.setId(uId); logger.info("upgrade.. enable " + uId); tmd.setFrom(fId); tml2.add(tmd); } } return tml2; } else { return tml; } }
public void getModulesWithFilter(boolean preRelease, boolean npmSnapshot, 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 ((npmSnapshot || !idThis.hasNpmSnapshot()) && (preRelease || !idThis.hasPreRelease())) { mdl.add(md); } } fut.handle(new Success<>(mdl)); } }); }
for (TenantModuleDescriptor tm : tml) { String id = tm.getId(); ModuleId moduleId = new ModuleId(id); if (tm.getAction() == TenantModuleDescriptor.Action.enable) { if (!moduleId.hasSemVer()) {
public void getLatest(String id, Handler<ExtendedAsyncResult<ModuleDescriptor>> fut) { ModuleId moduleId = new ModuleId(id); if (moduleId.hasSemVer()) { get(id, fut); } else { modules.getKeys(res -> { if (res.failed()) { fut.handle(new Failure<>(res.getType(), res.cause())); } else { String latest = moduleId.getLatest(res.result()); get(latest, fut); } }); } }