use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.
the class MarketplaceCatalog method setUpdatesAvailable.
private boolean setUpdatesAvailable(Map<String, IInstallableUnit> installedIUs, MarketplaceNodeCatalogItem item) {
boolean needOnlineCheck = false;
List<MarketplaceNodeInstallableUnitItem> installableUnitItems = item.getInstallableUnitItems();
for (MarketplaceNodeInstallableUnitItem iuItem : installableUnitItems) {
String key = createRepositoryIuKey(item.getSiteUrl(), iuItem.getId());
Version availableVersion = repositoryIuVersionById.get(key);
iuItem.setUpdateAvailable(false);
iuItem.setAvailable(false);
if (availableVersion != null) {
iuItem.setAvailable(true);
IInstallableUnit installedIu = installedIUs.get(iuItem.getId());
if (installedIu != null && installedIu.getVersion().compareTo(availableVersion) < 0) {
iuItem.setUpdateAvailable(true);
}
} else if (!repositoryIuVersionById.containsKey(key)) {
needOnlineCheck = true;
}
}
return needOnlineCheck;
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.
the class MarketplaceInfoTest method computeInstalledCatalogNodeIdsNoMarketplaceInfo.
@Test
public void computeInstalledCatalogNodeIdsNoMarketplaceInfo() {
assertTrue(item.getInstallableUnits().size() > 1);
assertEquals(0, catalogRegistry.getNodeKeyToIU().size());
Map<String, IInstallableUnit> installedIus = new HashMap<String, IInstallableUnit>();
InstallableUnit mainIu = addIU(installedIus, item.getInstallableUnits().get(0));
Set<? extends INode> installedCatalogNodeIds = catalogRegistry.computeInstalledNodes(item.getMarketplaceUrl(), installedIus);
assertNotNull(installedCatalogNodeIds);
assertEquals(0, installedCatalogNodeIds.size());
for (String iu : item.getInstallableUnits()) {
addIU(installedIus, iu);
}
mainIu.setProperty(MarketplaceInfo.MPC_NODE_IU_PROPERTY, item.getData().getUrl());
installedCatalogNodeIds = catalogRegistry.computeInstalledNodes(item.getMarketplaceUrl(), installedIus);
assertNotNull(installedCatalogNodeIds);
assertEquals(1, installedCatalogNodeIds.size());
assertEquals(item.getData().getUrl(), installedCatalogNodeIds.iterator().next().getUrl());
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.
the class MarketplaceInfoTest method addIU.
private InstallableUnit addIU(Map<String, IInstallableUnit> installedIus, String id) {
InstallableUnit installableUnit = (InstallableUnit) installedIus.get(id);
if (installableUnit == null) {
installableUnit = new InstallableUnit();
installableUnit.setId(id);
IInstallableUnit iu = installableUnit;
installedIus.put(iu.getId(), iu);
}
return installableUnit;
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.
the class CompositeProfileChangeOperation method updateRequest.
private void updateRequest(ProfileChangeRequest request, ProfileChangeOperation operation, MultiStatus status, IProgressMonitor monitor) {
// TODO we do too much here - this already does the plan resolution, which is expensive...
IStatus result = operation.resolveModal(monitor);
status.merge(result);
if (status.getSeverity() != IStatus.ERROR) {
IProfileChangeRequest operationChangeRequest = operation.getProfileChangeRequest();
Collection<IInstallableUnit> additions = operationChangeRequest.getAdditions();
Collection<IInstallableUnit> removals = operationChangeRequest.getRemovals();
Collection<IRequirement> extraRequirements = operationChangeRequest.getExtraRequirements();
request.removeAll(removals);
request.addAll(additions);
if (extraRequirements != null) {
request.addExtraRequirements(extraRequirements);
}
if (operationChangeRequest instanceof ProfileChangeRequest) {
ProfileChangeRequest internalRequest = (ProfileChangeRequest) operationChangeRequest;
Map<IInstallableUnit, List<String>> installableUnitProfilePropertiesToRemove = internalRequest.getInstallableUnitProfilePropertiesToRemove();
for (Entry<IInstallableUnit, List<String>> entry : installableUnitProfilePropertiesToRemove.entrySet()) {
List<String> properties = entry.getValue();
if (properties != null && !properties.isEmpty()) {
IInstallableUnit iu = entry.getKey();
for (String property : properties) {
request.removeInstallableUnitProfileProperty(iu, property);
}
}
}
Map<IInstallableUnit, Map<String, String>> installableUnitProfilePropertiesToAdd = internalRequest.getInstallableUnitProfilePropertiesToAdd();
for (Entry<IInstallableUnit, Map<String, String>> entry : installableUnitProfilePropertiesToAdd.entrySet()) {
Map<String, String> properties = entry.getValue();
if (properties != null && !properties.isEmpty()) {
IInstallableUnit iu = entry.getKey();
for (Entry<String, String> property : properties.entrySet()) {
request.setInstallableUnitProfileProperty(iu, property.getKey(), property.getValue());
}
}
}
String[] propertiesToRemove = internalRequest.getPropertiesToRemove();
for (String property : propertiesToRemove) {
request.removeProfileProperty(property);
}
Map<String, String> propertiesToAdd = internalRequest.getPropertiesToAdd();
for (Entry<String, String> property : propertiesToAdd.entrySet()) {
request.setProfileProperty(property.getKey(), property.getValue());
}
}
}
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.
the class ResolveFeatureNamesOperation method run.
public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
try {
SubMonitor monitor = SubMonitor.convert(progressMonitor, Messages.ResolveFeatureNamesOperation_resolvingFeatures, 100);
try {
List<IMetadataRepository> repositories = addRepositories(monitor.newChild(50));
List<IInstallableUnit> installableUnits = queryInstallableUnits(monitor.newChild(50), repositories);
Set<String> resolvedFeatureIds = new HashSet<String>();
for (IInstallableUnit iu : installableUnits) {
FeatureDescriptor descriptor = new FeatureDescriptor(iu);
resolvedFeatureIds.add(descriptor.getId());
resolvedFeatureIds.add(descriptor.getSimpleId());
featureDescriptors.add(descriptor);
}
for (CatalogItem catalogItem : items) {
for (String iu : catalogItem.getInstallableUnits()) {
if (!resolvedFeatureIds.contains(iu)) {
FeatureDescriptor descriptor = new FeatureDescriptor(iu);
unresolvedFeatureDescriptors.add(descriptor);
}
}
}
} finally {
// SECURITY: resolving feature names should never add repositories
removeAddedRepositoryLocations();
monitor.done();
}
} catch (OperationCanceledException e) {
throw new InterruptedException();
} catch (Exception e) {
throw new InvocationTargetException(e);
}
}
Aggregations