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> 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; }
/** * Creates and returns a new {@link VersionedId} from the given string specification. * The specification must be of the form "id/version", or just "id" if the version is absent * <p> * This factory method can be used to reconstruct a {@link VersionedId} * instance from the string representation produced by a previous invocation of * {@link #toString()}. * * @param spec the specification for the versioned id to create * @return the parsed versioned id * @throws IllegalArgumentException If <code>spec</code> is improperly * formatted. */ public static IVersionedId parse(String spec) { String[] segments = StringHelper.getArrayFromString(spec, '/'); return new VersionedId(segments[0], segments.length == 1 ? null : segments[1]); }
/** * Returns a list<VersionedName> of fragments that constitute this product. */ public List<IVersionedId> getFragments() { List<IVersionedId> result = new LinkedList<IVersionedId>(); for (FeatureEntry fragment : fragments) { result.add(new VersionedId(fragment.getId(), fragment.getVersion())); } return result; }
/** * Returns a List<VersionedName> of features that constitute this product. */ public List<IVersionedId> getFeatures() { List<IVersionedId> result = new LinkedList<IVersionedId>(); for (FeatureEntry feature : features) { result.add(new VersionedId(feature.getId(), feature.getVersion())); } return result; }
/** * Returns a list<VersionedName> of fragments that constitute this product. */ public List<IVersionedId> getFragments() { List<IVersionedId> result = new LinkedList<IVersionedId>(); for (FeatureEntry fragment : fragments) { result.add(new VersionedId(fragment.getId(), fragment.getVersion())); } return result; }
/** * Returns a list<VersionedName> of fragments that constitute this product. */ @Override public List<IVersionedId> getFragments() { List<IVersionedId> result = new LinkedList<>(); for (FeatureEntry fragment : fragments) { result.add(new VersionedId(fragment.getId(), fragment.getVersion())); } return result; }
public List<IVersionedId> getFeatures(int options) { List<IVersionedId> result = new LinkedList<IVersionedId>(); if ((options & INCLUDED_FEATURES) != 0) { for (FeatureEntry feature : features) { result.add(new VersionedId(feature.getId(), feature.getVersion())); } } if ((options & ROOT_FEATURES) != 0) { for (FeatureEntry feature : rootFeatures) { result.add(new VersionedId(feature.getId(), feature.getVersion())); } } return result; }
private static void put(Map<VersionedId, IInstallableUnit> units, IInstallableUnit unit) { units.put(new VersionedId(unit.getId(), unit.getVersion()), unit); }
@Override public List<IVersionedId> getFeatures(int options) { List<IVersionedId> result = new LinkedList<>(); if ((options & INCLUDED_FEATURES) != 0) { for (FeatureEntry feature : features) { result.add(new VersionedId(feature.getId(), feature.getVersion())); } } if ((options & ROOT_FEATURES) != 0) { for (FeatureEntry feature : rootFeatures) { result.add(new VersionedId(feature.getId(), feature.getVersion())); } } return result; }
/** * Returns a List<VersionedName> for each bundle that makes up this product. * @param includeFragments Indicates whether or not fragments should * be included in the list */ public List<IVersionedId> getBundles(boolean includeFragments) { List<IVersionedId> result = new LinkedList<IVersionedId>(); for (FeatureEntry plugin : plugins) { result.add(new VersionedId(plugin.getId(), plugin.getVersion())); } if (includeFragments) { for (FeatureEntry fragment : fragments) { result.add(new VersionedId(fragment.getId(), fragment.getVersion())); } } return result; }
/** * Returns a List<VersionedName> for each bundle that makes up this product. * @param includeFragments Indicates whether or not fragments should * be included in the list */ public List<IVersionedId> getBundles(boolean includeFragments) { List<IVersionedId> result = new LinkedList<IVersionedId>(); for (FeatureEntry plugin : plugins) { result.add(new VersionedId(plugin.getId(), plugin.getVersion())); } if (includeFragments) { for (FeatureEntry fragment : fragments) { result.add(new VersionedId(fragment.getId(), fragment.getVersion())); } } return result; }
/** * Returns a List<VersionedName> for each bundle that makes up this product. * @param includeFragments Indicates whether or not fragments should * be included in the list */ @Override public List<IVersionedId> getBundles(boolean includeFragments) { List<IVersionedId> result = new LinkedList<>(); for (FeatureEntry plugin : plugins) { result.add(new VersionedId(plugin.getId(), plugin.getVersion())); } if (includeFragments) { for (FeatureEntry fragment : fragments) { result.add(new VersionedId(fragment.getId(), fragment.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 (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; }
public InstallableUnitDAG toInstallableUnitDAG( Iterator<IInstallableUnit> iter ) { Map<IVersionedId, InstallableUnitInfo> nodes = new LinkedHashMap<IVersionedId, InstallableUnitInfo>(); while ( iter.hasNext() ) { IInstallableUnit iu = iter.next(); nodes.put( new VersionedId( iu.getId(), iu.getVersion() ), new InstallableUnitInfo( iu ) ); } for ( InstallableUnitInfo node : nodes.values() ) { for ( InstallableUnitInfo otherNode : getIncludedInstallableUnit( nodes, node.getInstallableUnit() ) ) { node.addChild( otherNode ); } } Map<IInstallableUnit, InstallableUnitInfo> units = new LinkedHashMap<IInstallableUnit, InstallableUnitInfo>(); for ( InstallableUnitInfo info : nodes.values() ) { units.put( info.getInstallableUnit(), info ); } // break cycles for ( InstallableUnitInfo unit : units.values() ) { breakCycles( unit, new LinkedList<InstallableUnitInfo>() ); } return new InstallableUnitDAG( units ); }
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<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 static Collection<InstallableUnitInfo> getIncludedInstallableUnit( Map<IVersionedId, InstallableUnitInfo> nodes, IInstallableUnit parent ) { Set<InstallableUnitInfo> result = new LinkedHashSet<InstallableUnitInfo>(); for ( IRequirement r : parent.getRequirements() ) { if ( r instanceof IRequiredCapability ) { IRequiredCapability rc = (IRequiredCapability) r; if ( isSingleVersion( rc.getRange() ) ) { InstallableUnitInfo otherNode = nodes.get( new VersionedId( rc.getName(), rc.getRange().getMinimum() ) ); if ( otherNode != null ) { result.add( otherNode ); } } } } return result; }
public void addMavenArtifact(IArtifactFacade artifact, Set<IInstallableUnit> units) { for (IInstallableUnit unit : units) { String classifier = unit.getProperty(RepositoryLayoutHelper.PROP_CLASSIFIER); if (classifier == null ? artifact.getClassifier() == null : classifier.equals(artifact.getClassifier())) { mavenInstallableUnits.put(unit, artifact); if (logger.isDebugEnabled()) { logger.debug("P2Resolver: artifact " + new GAV(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()) .toString() + " at location " + artifact.getLocation() + " resolves installable unit " + new VersionedId(unit.getId(), unit.getVersion())); } } } }