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; }
public String getId() { return id != null ? id.getId() : null; }
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); } }); } }
String filterStr = req.getParam("filter"); if (filterStr != null) { filter = new ModuleId(filterStr); ModuleDescriptor md = iterator.next(); String id = md.getId(); ModuleId idThis = new ModuleId(id); if ((filter != null && !idThis.hasPrefix(filter)) || (!npmSnapshot && idThis.hasNpmSnapshot()) || (!preRelease && idThis.hasPreRelease()) || !interfaceCheck(md.getRequires(), requireStr) || !interfaceCheck(md.getProvides(), provideStr)) {
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)); } }); }
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; } }
@JsonIgnore public String getProduct() { return id.getProduct(); } }
@Override public boolean equals(Object that) { if (this == that) { return true; } if (!(that instanceof ModuleId)) { return false; } return compareTo((ModuleId) that) == 0; }
+ "', not '" + okapiModule + "'"); if (ModuleId.compare(ev, okapiModule) >= 4) { logger.warn("checkSuperTenant: This Okapi is too old, " + okapiVersion + " we already have " + ev + " in the database. "
for (TenantModuleDescriptor tm : tml) { String id = tm.getId(); ModuleId moduleId = new ModuleId(id); if (tm.getAction() == TenantModuleDescriptor.Action.enable) { if (!moduleId.hasSemVer()) { id = moduleId.getLatest(modsAvailable.keySet()); tm.setId(id); if (!moduleId.hasSemVer()) { id = moduleId.getLatest(modsEnabled.keySet()); tm.setId(id);
public String[] getReplaces() { if (replaces == null || replaces.size() == 0) { return null; } String[] a = new String[replaces.size()]; int i = 0; for (ModuleId p : replaces) { a[i++] = p.getProduct(); } return a; }
@Override public int compareTo(ModuleDescriptor other) { return id.compareTo(other.id); }
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); } } }