use of org.eclipse.equinox.p2.operations.Update in project epp.mpc by eclipse.
the class MarketplaceWizard method updateProfileChangeOperation.
public void updateProfileChangeOperation() {
removeAddedRepositoryLocations();
addedRepositoryLocations = null;
profileChangeOperation = null;
operationIUs = null;
IWizardContainer wizardContainer = getContainer();
if (getSelectionModel().computeProvisioningOperationViable()) {
ProfileChangeOperationComputer provisioningOperation = null;
try {
final Map<CatalogItem, Operation> itemToOperation = getSelectionModel().getItemToSelectedOperation();
final Set<CatalogItem> selectedItems = getSelectionModel().getSelectedCatalogItems();
OperationType operationType = null;
for (Map.Entry<CatalogItem, Operation> entry : itemToOperation.entrySet()) {
if (!selectedItems.contains(entry.getKey())) {
continue;
}
OperationType entryOperationType = OperationType.map(entry.getValue());
if (entryOperationType != null) {
if (operationType == null || operationType == OperationType.UPDATE || entryOperationType == OperationType.CHANGE) {
operationType = entryOperationType;
}
}
}
Map<FeatureEntry, Operation> featureEntries = getSelectionModel().getFeatureEntryToOperation(false, false);
if (operationType == OperationType.CHANGE || operationType == OperationType.UPDATE) {
Set<OperationType> featureOperations = EnumSet.noneOf(OperationType.class);
for (Entry<FeatureEntry, Operation> entry : featureEntries.entrySet()) {
OperationType operation = OperationType.map(entry.getValue());
if (operation != null) {
featureOperations.add(operation);
}
}
if (featureOperations.contains(OperationType.INSTALL) && featureOperations.contains(OperationType.UPDATE)) {
// just perform install instead, which covers update
featureOperations.remove(OperationType.UPDATE);
}
if (featureOperations.size() == 1) {
operationType = featureOperations.iterator().next();
}
}
URI dependenciesRepository = null;
if (getConfiguration().getCatalogDescriptor().getDependenciesRepository() != null) {
try {
dependenciesRepository = getConfiguration().getCatalogDescriptor().getDependenciesRepository().toURI();
} catch (URISyntaxException e) {
throw new InvocationTargetException(e);
}
}
provisioningOperation = new ProfileChangeOperationComputer(operationType, selectedItems, featureEntries.keySet(), dependenciesRepository, getConfiguration().getCatalogDescriptor().isInstallFromAllRepositories() ? ProfileChangeOperationComputer.ResolutionStrategy.FALLBACK_STRATEGY : ProfileChangeOperationComputer.ResolutionStrategy.SELECTED_REPOSITORIES, withRemediation);
wizardContainer.run(true, true, provisioningOperation);
profileChangeOperation = provisioningOperation.getOperation();
operationIUs = provisioningOperation.getIus();
addedRepositoryLocations = provisioningOperation.getAddedRepositoryLocations();
operationNewInstallItems = computeNewInstallCatalogItems();
errorMessage = provisioningOperation.getErrorMessage();
final IStatus result = profileChangeOperation.getResolutionResult();
if (result != null && operationIUs != null && operationIUs.length > 0 && operationType == OperationType.INSTALL) {
switch(result.getSeverity()) {
case IStatus.ERROR:
Job job = new Job(Messages.MarketplaceWizard_errorNotificationJob) {
IStatus r = result;
Set<CatalogItem> items = new HashSet<CatalogItem>(itemToOperation.keySet());
IInstallableUnit[] ius = operationIUs;
String details = profileChangeOperation.getResolutionDetails();
{
setSystem(false);
setUser(false);
setPriority(LONG);
}
@Override
protected IStatus run(IProgressMonitor monitor) {
getCatalog().installErrorReport(monitor, r, items, ius, details);
return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
}
};
job.schedule();
}
}
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
IStatus status;
if (cause instanceof CoreException) {
status = ((CoreException) cause).getStatus();
} else {
status = new Status(IStatus.ERROR, MarketplaceClientUi.BUNDLE_ID, NLS.bind(Messages.MarketplaceWizard_problemsPerformingProvisioningOperation, new Object[] { cause.getMessage() }), cause);
}
MarketplaceClientUi.handle(status, StatusManager.SHOW | StatusManager.BLOCK | StatusManager.LOG);
} catch (InterruptedException e) {
// canceled
MarketplaceClientUi.log(IStatus.CANCEL, MarketplaceClientUi.BUNDLE_ID, Messages.MarketplaceWizard_ProvisioningOperationCancelled, e);
} finally {
if (provisioningOperation != null) {
addedRepositoryLocations = provisioningOperation.getAddedRepositoryLocations();
}
}
}
// re-get the container - in case the wizard was closed in the meantime, this will be null...
wizardContainer = getContainer();
if (wizardContainer != null && wizardContainer.getCurrentPage() == featureSelectionWizardPage) {
featureSelectionWizardPage.updateMessage();
}
}
use of org.eclipse.equinox.p2.operations.Update 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.operations.Update in project archi by archimatetool.
the class P2Handler method update.
public IStatus update(URI uri, IProgressMonitor monitor) throws ProvisionException {
loadRepository(uri, monitor);
UpdateOperation operation = new UpdateOperation(getProvisioningSession());
return performOperation(operation, monitor);
}
use of org.eclipse.equinox.p2.operations.Update in project tycho by eclipse.
the class RemoteMetadataRepositoryManager method failIfRepositoryContainsPartialIUs.
private void failIfRepositoryContainsPartialIUs(IMetadataRepository repository, URI effectiveLocation) throws ProvisionException {
IQueryResult<IInstallableUnit> allUnits = repository.query(QueryUtil.ALL_UNITS, null);
boolean hasPartialIUs = false;
for (IInstallableUnit unit : allUnits.toUnmodifiableSet()) {
if (Boolean.valueOf(unit.getProperty(IInstallableUnit.PROP_PARTIAL_IU))) {
hasPartialIUs = true;
logger.error("Partial IU: " + unit.getId());
}
}
if (hasPartialIUs) {
String message = "The p2 repository at " + effectiveLocation + " contains partial IUs (see above) from an old style update site which cannot be used for dependency resolution";
throw new ProvisionException(message);
}
}
Aggregations