private static String toBundleFilter(String bsn, String versionRangeStr) { final String filterStr; String bsnFilter = String.format("(%s=%s)", BundleNamespace.BUNDLE_NAMESPACE, bsn); if (versionRangeStr == null) { filterStr = bsnFilter; } else { VersionRange versionRange = new VersionRange(versionRangeStr); if (versionRange.isExact()) { String exactVersionFilter = String.format("(%s=%s)", BundleNamespace.CAPABILITY_BUNDLE_VERSION_ATTRIBUTE, versionRange.getLeft()); filterStr = String.format("(&%s%s)", bsnFilter, exactVersionFilter); } else if (versionRange.getRight() == null) { filterStr = String.format("(&%s%s)", bsnFilter, lowerVersionFilter(versionRange)); } else { filterStr = String.format("(&%s%s%s)", bsnFilter, lowerVersionFilter(versionRange), upperVersionFilter(versionRange)); } } return filterStr; }
public Requirement ( final VersionRange range, final boolean optional, final Boolean greedy, final String filter ) { this.range = range; this.optional = optional; this.greedy = greedy; this.filter = filter; }
private String makeString ( final VersionRange range ) { if ( range == null ) { return "0.0.0"; } else { return range.toString (); } }
public VersionRange makeVersionRange () { if ( this.version == null ) { return new VersionRange ( "0.0.0" ); } else { return new VersionRange ( VersionRange.LEFT_CLOSED, this.version, this.version, VersionRange.RIGHT_CLOSED ); } }
public BundleRequirement ( final String id, final VersionRange versionRange, final boolean optional, final boolean reexport ) { this.id = id; this.versionRange = versionRange; this.optional = optional; this.reexport = reexport; }
/** * Check if this resources matches the supplied product definition * * @param def The product definition to check against * @return A {@link MatchResult} that says whether the resource matches the product definition, and if * not the reason why the match failed. */ public MatchResult matches(ProductDefinition def) { Collection<AppliesToFilterInfo> atfiList = _asset.getWlpInformation().getAppliesToFilterInfo(); if (atfiList == null || atfiList.isEmpty()) { return MatchResult.NOT_APPLICABLE; } MatchResult matchResult = MatchResult.MATCHED; for (AppliesToFilterInfo atfi : atfiList) { if (!!!atfi.getProductId().equals(def.getId())) { // This one isn't applicable, maybe the next one is matchResult = MatchResult.NOT_APPLICABLE; continue; } else { if (def.getVersion() != null && !def.getVersion().isEmpty()) { Version checkVersion = new Version(def.getVersion()); VersionRange vr = FilterVersion.getFilterRange(atfi.getMinVersion(), atfi.getMaxVersion()); if (!vr.includes(checkVersion)) { return MatchResult.INVALID_VERSION; } } if (atfi.getRawEditions() != null && !!!atfi.getRawEditions().isEmpty() && !!!atfi.getRawEditions().contains(def.getEdition())) { return MatchResult.INVALID_EDITION; } if (atfi.getInstallType() != null && !!!atfi.getInstallType().equals(def.getInstallType())) { return MatchResult.INVALID_INSTALL_TYPE; } // Got here so this must have been a match, only need one of the array to match, not all return MatchResult.MATCHED; } } return matchResult; }
public VersionRange getProductVersions() { String versions = getProperty(PRODUCT_VERSIONS); return (versions == null) ? null : VersionRange.valueOf(versions); }
public boolean matchesProductVersion(String version) { VersionRange versions = getProductVersions(); return (versions == null) ? true : versions .includes(new Version(version)); }
public VersionRange getRange () { return this.range; }
@Override public VersionRange makeRange ( final Version version ) { return new VersionRange ( "0.0.0" ); }
@Override public VersionRange makeRange ( final Version version ) { final Version endVersion = new Version ( version.getMajor (), version.getMinor () + 1, 0 ); return new VersionRange ( VersionRange.LEFT_CLOSED, version, endVersion, VersionRange.RIGHT_OPEN ); }
@Override public VersionRange makeRange ( final Version version ) { final Version endVersion = new Version ( version.getMajor () + 1, 0, 0 ); return new VersionRange ( VersionRange.LEFT_CLOSED, version, endVersion, VersionRange.RIGHT_OPEN ); }
@Override public VersionRange makeRange ( final Version version ) { return new VersionRange ( VersionRange.LEFT_CLOSED, version, version, VersionRange.RIGHT_CLOSED ); }
@Override public VersionRange makeRange ( final Version version ) { return new VersionRange ( version.toString () ); }
public PackageImport ( final String name, final VersionRange versionRange, final boolean optional ) { this.name = name; this.versionRange = versionRange; this.optional = optional; }
public VersionRange getVersionRange () { return this.versionRange; }
public abstract VersionRange makeRange ( Version version );