use of org.eclipse.equinox.p2.metadata.IInstallableUnit 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.metadata.IInstallableUnit in project webtools.servertools by eclipse.
the class ExtensionWizard method addPages.
public void addPages() {
super.addPages();
ProvisioningUI ui = ProvisioningUI.getDefaultUI();
licensePage = new AcceptLicensesWizardPage(ui.getLicenseManager(), new IInstallableUnit[0], null);
licensePage.setWizard(this);
errorPage = new ErrorWizardPage();
errorPage.setWizard(this);
extensionPage = new ExtensionWizardPage(licensePage, errorPage);
extensionPage.setWizard(this);
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method installErrorReport.
public void installErrorReport(IProgressMonitor monitor, IStatus result, Set<CatalogItem> items, IInstallableUnit[] operationIUs, String resolutionDetails) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceDiscoveryStrategy_sendingErrorNotification, 100);
try {
Set<Node> nodes = new HashSet<Node>();
for (CatalogItem item : items) {
Object data = item.getData();
if (data instanceof INode) {
nodes.add((Node) data);
}
}
Set<String> iuIdsAndVersions = new HashSet<String>();
for (IInstallableUnit iu : operationIUs) {
String id = iu.getId();
String version = iu.getVersion() == null ? null : iu.getVersion().toString();
// $NON-NLS-1$
iuIdsAndVersions.add(id + "," + version);
}
marketplaceService.reportInstallError(result, nodes, iuIdsAndVersions, resolutionDetails, progress);
} finally {
progress.done();
}
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.
the class MarketplaceInfo method computeInstalledNodes.
/**
* Calculate the known catalog nodes that might be installed. Since no remote query should happen, this only checks
* if any one of the IUs for a node are installed.
*
* @param repositoryUrl
* the catalog url for which installed nodes should be computed
* @param installedIus
* all of the currently installed IUs
* @return a set of node ids, or an empty set if there are no known installed nodes
*/
public synchronized Set<INode> computeInstalledNodes(URL repositoryUrl, Map<String, IInstallableUnit> installedIus) {
Set<INode> nodes = new HashSet<INode>();
String keyPrefix = computeUrlKey(repositoryUrl) + '#';
for (Map.Entry<String, List<String>> entry : nodeKeyToIU.entrySet()) {
if (entry.getKey().startsWith(keyPrefix)) {
List<String> ius = nodeKeyToIU.get(entry.getKey());
if (computeInstalled(installedIus.keySet(), ius, false)) {
String nodeId = entry.getKey().substring(keyPrefix.length());
INode node = QueryHelper.nodeById(nodeId);
nodes.add(node);
}
}
}
for (IInstallableUnit iu : installedIus.values()) {
String nodeUrl = iu.getProperty(MPC_NODE_IU_PROPERTY);
if (nodeUrl != null && nodeUrl.startsWith(repositoryUrl.toString())) {
INode node = QueryHelper.nodeByUrl(nodeUrl);
nodes.add(node);
}
}
return nodes;
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.
the class AbstractProvisioningOperation method queryInstallableUnits.
/**
* Perform a query to get the installable units. This causes p2 to determine what features are available in each
* repository. We select installable units by matching both the feature id and the repository; it is possible though
* unlikely that the same feature id is available from more than one of the selected repositories, and we must
* ensure that the user gets the one that they asked for.
*/
protected List<IInstallableUnit> queryInstallableUnits(SubMonitor monitor, List<IMetadataRepository> repositories) throws URISyntaxException {
final List<IInstallableUnit> installableUnits = new ArrayList<IInstallableUnit>();
monitor.setWorkRemaining(repositories.size());
for (final IMetadataRepository repository : repositories) {
checkCancelled(monitor);
final Set<String> installableUnitIdsThisRepository = getDescriptorIds(repository);
IQuery<IInstallableUnit> query = QueryUtil.createLatestQuery(QueryUtil.createIUGroupQuery());
IQueryResult<IInstallableUnit> result = repository.query(query, monitor.newChild(1));
for (IInstallableUnit iu : result) {
String id = iu.getId();
if (installableUnitIdsThisRepository.contains(id)) {
installableUnits.add(iu);
}
}
}
return installableUnits;
}
Aggregations