use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.
the class ProfileChangeOperationComputer method computeInstalledIus.
private IInstallableUnit[] computeInstalledIus(IInstallableUnit[] ius) {
List<IInstallableUnit> installedIus = new ArrayList<IInstallableUnit>(ius.length);
Map<String, IInstallableUnit> iUsById = MarketplaceClientUi.computeInstalledIUsById(new NullProgressMonitor());
for (IInstallableUnit iu : ius) {
IInstallableUnit installedIu = iUsById.get(iu.getId());
installedIus.add(installedIu);
}
return installedIus.toArray(new IInstallableUnit[installedIus.size()]);
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.
the class ProfileChangeOperationComputer method run.
public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
try {
boolean hasInstall = hasInstall();
boolean hasUninstall = hasUninstall();
SubMonitor monitor = SubMonitor.convert(progressMonitor, Messages.ProvisioningOperation_configuringProvisioningOperation, 1000 + (hasInstall ? 500 : 0) + (hasUninstall ? 100 : 0));
try {
IInstallableUnit[] uninstallIUs = null;
if (hasInstall) {
ius = computeInstallableUnits(monitor.newChild(500));
} else {
ius = new IInstallableUnit[0];
}
if (hasUninstall) {
uninstallIUs = computeUninstallUnits(monitor.newChild(100));
}
checkCancelled(monitor);
URI[] repositories = repositoryLocations == null ? new URI[0] : repositoryLocations.toArray(new URI[0]);
switch(operationType) {
case INSTALL:
operation = resolveInstall(monitor.newChild(500), ius, repositories);
break;
case UPDATE:
operation = resolveUpdate(monitor.newChild(500), computeInstalledIus(ius), repositories);
break;
case UNINSTALL:
operation = resolveUninstall(monitor.newChild(500), uninstallIUs, repositories);
break;
case CHANGE:
operation = resolveChange(monitor.newChild(500), ius, uninstallIUs, repositories);
break;
default:
throw new UnsupportedOperationException(operationType.name());
}
if (withRemediation && operation != null && operation.getResolutionResult().getSeverity() == IStatus.ERROR) {
RemediationOperation remediationOperation = new RemediationOperation(ProvisioningUI.getDefaultUI().getSession(), operation.getProfileChangeRequest());
remediationOperation.resolveModal(monitor.newChild(500));
if (remediationOperation.getResolutionResult() == Status.OK_STATUS) {
errorMessage = operation.getResolutionDetails();
operation = remediationOperation;
}
}
checkCancelled(monitor);
} finally {
monitor.done();
}
} catch (OperationCanceledException e) {
throw new InterruptedException();
} catch (Exception e) {
throw new InvocationTargetException(e);
}
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.
the class ProfileChangeOperationComputer method pruneNonInstall.
private void pruneNonInstall(List<IInstallableUnit> installableUnits) {
Set<String> installableFeatureIds = new HashSet<String>();
for (FeatureEntry featureEntry : featureEntries) {
Operation operation = featureEntry.computeChangeOperation();
if (operation == Operation.INSTALL || operation == Operation.UPDATE) {
installableFeatureIds.add(featureEntry.getFeatureDescriptor().getId());
}
}
Iterator<IInstallableUnit> it = installableUnits.iterator();
while (it.hasNext()) {
IInstallableUnit iu = it.next();
if (!installableFeatureIds.contains(iu.getId())) {
it.remove();
}
}
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.
the class ProfileChangeOperationComputer method computeInstallableUnits.
public IInstallableUnit[] computeInstallableUnits(IProgressMonitor monitor) throws CoreException {
try {
SubMonitor progress = SubMonitor.convert(monitor, 100);
// add repository urls and load meta data
List<IMetadataRepository> repositories = addRepositories(progress.newChild(50));
List<IInstallableUnit> installableUnits = queryInstallableUnits(progress.newChild(50), repositories);
checkForUnavailable(installableUnits);
pruneNonInstall(installableUnits);
// bug 306446 we never want to downgrade the installed version
pruneOlderVersions(installableUnits);
return installableUnits.toArray(new IInstallableUnit[installableUnits.size()]);
} catch (URISyntaxException e) {
// should never happen, since we already validated URLs.
throw new CoreException(new Status(IStatus.ERROR, MarketplaceClientUi.BUNDLE_ID, Messages.ProvisioningOperation_unexpectedErrorUrl, e));
} finally {
monitor.done();
}
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.
the class ProfileChangeOperationComputer method pruneNonUninstall.
private void pruneNonUninstall(List<IInstallableUnit> installableUnits) {
Set<String> installableFeatureIds = new HashSet<String>();
for (FeatureEntry featureEntry : featureEntries) {
if (featureEntry.computeChangeOperation() == Operation.UNINSTALL) {
installableFeatureIds.add(featureEntry.getFeatureDescriptor().getId());
}
}
Iterator<IInstallableUnit> it = installableUnits.iterator();
while (it.hasNext()) {
IInstallableUnit iu = it.next();
if (!installableFeatureIds.contains(iu.getId())) {
it.remove();
}
}
}
Aggregations