private IMatchExpression<IInstallableUnit> getFilterAdvice(IVersionedId name) { if (info == null) return null; Collection<IFilterAdvice> filterAdvice = info.getAdvice(CONFIG_ANY, true, name.getId(), name.getVersion(), IFilterAdvice.class); for (IFilterAdvice advice : filterAdvice) { IMatchExpression<IInstallableUnit> result = advice.getFilter(name.getId(), name.getVersion(), false); if (result != null) return result; } return null; }
public boolean containsPlugin(String plugin) { List<IVersionedId> bundles = getBundles(true); for (IVersionedId versionedId : bundles) { if (versionedId.getId().equals(plugin)) { return true; } } return false; }
private IMatchExpression<IInstallableUnit> getFilterAdvice(IVersionedId name) { if (info == null) return null; Collection<IFilterAdvice> filterAdvice = info.getAdvice(CONFIG_ANY, true, name.getId(), name.getVersion(), IFilterAdvice.class); for (IFilterAdvice advice : filterAdvice) { IMatchExpression<IInstallableUnit> result = advice.getFilter(name.getId(), name.getVersion(), false); if (result != null) return result; } return null; }
/** * Creates a query that will match any {@link IInstallableUnit} with the given * id and version. * * @param versionedId The precise id/version combination that a matching unit must have * @return a query that matches IU's by id and version */ public static IQuery<IInstallableUnit> createIUQuery(IVersionedId versionedId) { return createIUQuery(versionedId.getId(), versionedId.getVersion()); }
private IMatchExpression<IInstallableUnit> getFilterAdvice(IVersionedId name) { if (info == null) return null; Collection<IFilterAdvice> filterAdvice = info.getAdvice(CONFIG_ANY, true, name.getId(), name.getVersion(), IFilterAdvice.class); for (IFilterAdvice advice : filterAdvice) { IMatchExpression<IInstallableUnit> result = advice.getFilter(name.getId(), name.getVersion(), false); if (result != null) return result; } return null; }
private IMatchExpression<IInstallableUnit> getFilterAdvice(IVersionedId name) { if (info == null) return null; Collection<IFilterAdvice> filterAdvice = info.getAdvice(CONFIG_ANY, true, name.getId(), name.getVersion(), IFilterAdvice.class); for (IFilterAdvice advice : filterAdvice) { IMatchExpression<IInstallableUnit> result = advice.getFilter(name.getId(), name.getVersion(), false); if (result != null) return result; } return null; }
private Collection<IVersionedId> listElements(List<IVersionedId> elements, String suffix) { if (suffix == null || suffix.length() == 0) return elements; ArrayList<IVersionedId> result = new ArrayList<>(elements.size()); for (IVersionedId elementName : elements) { result.add(new VersionedId(elementName.getId() + suffix, elementName.getVersion())); } return result; }
private Collection<IVersionedId> listElements(List<IVersionedId> elements, String suffix) { if (suffix == null || suffix.length() == 0) return elements; ArrayList<IVersionedId> result = new ArrayList<IVersionedId>(elements.size()); for (IVersionedId elementName : elements) { result.add(new VersionedId(elementName.getId() + suffix, elementName.getVersion())); } return result; }
private Collection<IVersionedId> listElements(List<IVersionedId> elements, String suffix) { if (suffix == null || suffix.length() == 0) return elements; ArrayList<IVersionedId> result = new ArrayList<IVersionedId>(elements.size()); for (IVersionedId elementName : elements) { result.add(new VersionedId(elementName.getId() + suffix, elementName.getVersion())); } return result; }
private Collection<IVersionedId> versionElements(Collection<IVersionedId> elements, String namespace) { Collection<IVersionAdvice> versionAdvice = info.getAdvice(null, true, null, null, IVersionAdvice.class); List<IVersionedId> result = new ArrayList<IVersionedId>(); for (IVersionedId element : elements) { Version elementVersion = element.getVersion(); if (elementVersion == null || Version.emptyVersion.equals(elementVersion)) { Iterator<IVersionAdvice> advice = versionAdvice.iterator(); while (advice.hasNext()) { elementVersion = advice.next().getVersion(namespace, element.getId()); break; } } // if advisedVersion is null, we get the highest version IInstallableUnit unit = queryForIU(publisherResults, element.getId(), elementVersion); if (unit != null) { result.add(unit); } else { // if the bundle is platform specific we will have broken metadata due to a missing filter finalStatus.add(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.message_cannotDetermineFilterOnInclusion, element.getId(), elementVersion))); // preserve legacy behaviour for callers who choose to ignore the error status: // include element without filter, but only if there was an IVersionAdvice with "no advice" for this bundle (see bug 398066) if (elementVersion != null) { result.add(new VersionedId(element.getId(), elementVersion)); } } } return result; }
private Collection<IVersionedId> versionElements(Collection<IVersionedId> elements, String namespace) { Collection<IVersionAdvice> versionAdvice = info.getAdvice(null, true, null, null, IVersionAdvice.class); List<IVersionedId> result = new ArrayList<IVersionedId>(); for (IVersionedId element : elements) { Version elementVersion = element.getVersion(); if (elementVersion == null || Version.emptyVersion.equals(elementVersion)) { Iterator<IVersionAdvice> advice = versionAdvice.iterator(); while (advice.hasNext()) { elementVersion = advice.next().getVersion(namespace, element.getId()); break; } } // if advisedVersion is null, we get the highest version IInstallableUnit unit = queryForIU(publisherResults, element.getId(), elementVersion); if (unit != null) { result.add(unit); } else if (elementVersion != null) { //best effort result.add(new VersionedId(element.getId(), elementVersion)); } //TODO we could still add a requirement on version 0.0.0 to get any version, but if the //bundle is platform specific we will have broken metadata due to a missing filter } return result; }
private Collection<IVersionedId> versionElements(Collection<IVersionedId> elements, String namespace) { Collection<IVersionAdvice> versionAdvice = info.getAdvice(null, true, null, null, IVersionAdvice.class); List<IVersionedId> result = new ArrayList<>(); for (IVersionedId element : elements) { Version elementVersion = element.getVersion(); if (elementVersion == null || Version.emptyVersion.equals(elementVersion)) { Iterator<IVersionAdvice> advice = versionAdvice.iterator(); while (advice.hasNext()) { elementVersion = advice.next().getVersion(namespace, element.getId()); break; } } // if advisedVersion is null, we get the highest version IInstallableUnit unit = queryForIU(publisherResults, element.getId(), elementVersion); if (unit != null) { result.add(unit); } else { // if the bundle is platform specific we will have broken metadata due to a missing filter finalStatus.add(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.message_cannotDetermineFilterOnInclusion, element.getId(), elementVersion))); // preserve legacy behaviour for callers who choose to ignore the error status: // include element without filter, but only if there was an IVersionAdvice with "no advice" for this bundle (see bug 398066) if (elementVersion != null) { result.add(new VersionedId(element.getId(), elementVersion)); } } } return result; }
private Collection<IInstallableUnit> gatherIUs(IQueryable<IInstallableUnit> searchContext, Collection<? extends IVersionedId> ius, boolean checkIUs, IProgressMonitor monitor) throws ProvisionException { Collection<IInstallableUnit> gatheredIUs = new ArrayList<IInstallableUnit>(ius.size()); for (IVersionedId versionedId : ius) { if (!checkIUs && versionedId instanceof IInstallableUnit) { gatheredIUs.add((IInstallableUnit) versionedId); continue; } IQuery<IInstallableUnit> installableUnits = QueryUtil.createIUQuery(versionedId.getId(), versionedId.getVersion()); IQueryResult<IInstallableUnit> matches = searchContext.query(installableUnits, monitor); if (matches.isEmpty()) throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.OperationFactory_noIUFound, versionedId))); //Add the first IU Iterator<IInstallableUnit> iuIt = matches.iterator(); gatheredIUs.add(iuIt.next()); } return gatheredIUs; }
private Collection<IInstallableUnit> gatherIUs(IQueryable<IInstallableUnit> searchContext, Collection<? extends IVersionedId> ius, boolean checkIUs, IProgressMonitor monitor) throws ProvisionException { Collection<IInstallableUnit> gatheredIUs = new ArrayList<IInstallableUnit>(ius.size()); for (IVersionedId versionedId : ius) { if (!checkIUs && versionedId instanceof IInstallableUnit) { gatheredIUs.add((IInstallableUnit) versionedId); continue; } IQuery<IInstallableUnit> installableUnits = QueryUtil.createIUQuery(versionedId.getId(), versionedId.getVersion()); IQueryResult<IInstallableUnit> matches = searchContext.query(installableUnits, monitor); if (matches.isEmpty()) throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.OperationFactory_noIUFound, versionedId))); //Add the first IU Iterator<IInstallableUnit> iuIt = matches.iterator(); gatheredIUs.add(iuIt.next()); } return gatheredIUs; }
private void addProductFileBundles(ConfigData data) { List<IVersionedId> bundles = product.getBundles(true); Set<BundleInfo> set = new HashSet<BundleInfo>(); set.addAll(Arrays.asList(data.getBundles())); for (IVersionedId vid : bundles) { BundleInfo bundleInfo = new BundleInfo(); bundleInfo.setSymbolicName(vid.getId()); bundleInfo.setVersion(vid.getVersion().toString()); if (!set.contains(bundleInfo)) data.addBundle(bundleInfo); } }
private void addProductFileBundles(ConfigData data) { List<IVersionedId> bundles = product.getBundles(true); Set<BundleInfo> set = new HashSet<>(); set.addAll(Arrays.asList(data.getBundles())); for (IVersionedId vid : bundles) { BundleInfo bundleInfo = new BundleInfo(); bundleInfo.setSymbolicName(vid.getId()); bundleInfo.setVersion(vid.getVersion().toString()); if (!set.contains(bundleInfo)) data.addBundle(bundleInfo); } }
private void addProductFileBundles(ConfigData data) { List<IVersionedId> bundles = product.getBundles(true); Set<BundleInfo> set = new HashSet<BundleInfo>(); set.addAll(Arrays.asList(data.getBundles())); for (IVersionedId vid : bundles) { BundleInfo bundleInfo = new BundleInfo(); bundleInfo.setSymbolicName(vid.getId()); bundleInfo.setVersion(vid.getVersion().toString()); if (!set.contains(bundleInfo)) data.addBundle(bundleInfo); } }
String id = versionedID.getId(); IVersionedId prev = greatestIUVersion.put(id, versionedID); if (prev == null) continue; if (prev.getVersion().compareTo(versionedID.getVersion()) > 0) greatestIUVersion.put(id, prev); String id = versionedID.getId(); continue; if (prev.getVersion().compareTo(versionedID.getVersion()) > 0) greatestIUVersion.put(id, prev);
/** * Creates and returns a collection of RequiredCapabilities for the IUs represented * by the given collection. The collection may include a mixture of IInstallableUnits * or VersionedNames. * @param children descriptions of the IUs on which requirements are to be made * @return a collection of RequiredCapabilities representing the given IUs */ protected Collection<IRequirement> createIURequirements(Collection<? extends IVersionedId> children) { ArrayList<IRequirement> result = new ArrayList<>(children.size()); for (IVersionedId next : children) { if (next instanceof IInstallableUnit) { IInstallableUnit iu = (IInstallableUnit) next; VersionRange range = new VersionRange(iu.getVersion(), true, iu.getVersion(), true); result.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, iu.getId(), range, iu.getFilter() == null ? null : iu.getFilter(), false, false)); } else { Version version = next.getVersion(); VersionRange range = (version == null || Version.emptyVersion.equals(version)) ? VersionRange.emptyRange : new VersionRange(version, true, version, true); IMatchExpression<IInstallableUnit> filter = getFilterAdvice(next); result.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, next.getId(), range, filter, false, false)); } } return result; }
/** * Creates and returns a collection of RequiredCapabilities for the IUs represented * by the given collection. The collection may include a mixture of IInstallableUnits * or VersionedNames. * @param children descriptions of the IUs on which requirements are to be made * @return a collection of RequiredCapabilities representing the given IUs */ protected Collection<IRequirement> createIURequirements(Collection<? extends IVersionedId> children) { ArrayList<IRequirement> result = new ArrayList<IRequirement>(children.size()); for (IVersionedId next : children) { if (next instanceof IInstallableUnit) { IInstallableUnit iu = (IInstallableUnit) next; VersionRange range = new VersionRange(iu.getVersion(), true, iu.getVersion(), true); result.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, iu.getId(), range, iu.getFilter() == null ? null : iu.getFilter(), false, false)); } else { Version version = next.getVersion(); VersionRange range = (version == null || Version.emptyVersion.equals(version)) ? VersionRange.emptyRange : new VersionRange(version, true, version, true); IMatchExpression<IInstallableUnit> filter = getFilterAdvice(next); result.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, next.getId(), range, filter, false, false)); } } return result; }