use of org.eclipse.amalgam.discovery.InstallableComponent in project gemoc-studio by eclipse.
the class PrepareInstallProfileJob method checkForUnavailable.
/**
* Verifies that we found what we were looking for: it's possible that we
* have connector descriptors that are no longer available on their
* respective sites. In that case we must inform the user. Unfortunately
* this is the earliest point at which we can know.
*/
private void checkForUnavailable(final List<IInstallableUnit> installableUnits) throws CoreException {
// at least one selected connector could not be found in a repository
Set<String> foundIds = new HashSet<String>();
for (IInstallableUnit unit : installableUnits) {
String id = unit.getId();
if (id.endsWith(P2_FEATURE_GROUP_SUFFIX)) {
id = id.substring(0, id.indexOf(P2_FEATURE_GROUP_SUFFIX));
}
foundIds.add(id);
}
// $NON-NLS-1$
String message = "";
// $NON-NLS-1$
String detailedMessage = "";
for (InstallableComponent descriptor : installableConnectors) {
StringBuilder unavailableIds = null;
for (String id : descriptor.getId()) {
if (!foundIds.contains(id)) {
if (unavailableIds == null) {
unavailableIds = new StringBuilder();
} else {
unavailableIds.append(Messages.InstallConnectorsJob_commaSeparator);
}
unavailableIds.append(id);
}
}
if (unavailableIds != null) {
if (message.length() > 0) {
message += Messages.InstallConnectorsJob_commaSeparator;
}
message += descriptor.getName();
if (detailedMessage.length() > 0) {
detailedMessage += Messages.InstallConnectorsJob_commaSeparator;
}
detailedMessage += NLS.bind(Messages.PrepareInstallProfileJob_notFoundDescriptorDetail, new Object[] { descriptor.getName(), unavailableIds.toString(), descriptor.getSitesURLS() });
}
}
if (message.length() > 0) {
// instead of aborting here we ask the user if they wish to proceed
// anyways
final boolean[] okayToProceed = new boolean[1];
final String finalMessage = message;
if (headless) {
throw new RuntimeException(detailedMessage);
} else {
Display.getDefault().syncExec(new Runnable() {
public void run() {
okayToProceed[0] = MessageDialog.openQuestion(DiscoveryUiUtil.getShell(), Messages.InstallConnectorsJob_questionProceed, NLS.bind(Messages.InstallConnectorsJob_questionProceed_long, new Object[] { finalMessage }));
}
});
if (!okayToProceed[0]) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(Messages.InstallConnectorsJob_connectorsNotAvailable, detailedMessage), null));
}
}
}
}
use of org.eclipse.amalgam.discovery.InstallableComponent in project gemoc-studio by eclipse.
the class PrepareInstallProfileJob method addRepositories.
private List<IMetadataRepository> addRepositories(SubMonitor monitor) throws MalformedURLException, URISyntaxException, ProvisionException {
// tell p2 that it's okay to use these repositories
ProvisioningSession session = ProvisioningUI.getDefaultUI().getSession();
RepositoryTracker repositoryTracker = ProvisioningUI.getDefaultUI().getRepositoryTracker();
repositoryLocations = new HashSet<URI>();
monitor.setWorkRemaining(installableConnectors.size() * 5);
for (InstallableComponent descriptor : installableConnectors) {
for (String url : descriptor.getSitesURLS()) {
addASiteURL(monitor, session, repositoryTracker, url);
}
}
// fetch meta-data for these repositories
ArrayList<IMetadataRepository> repositories = new ArrayList<IMetadataRepository>();
monitor.setWorkRemaining(repositories.size());
IMetadataRepositoryManager manager = (IMetadataRepositoryManager) session.getProvisioningAgent().getService(IMetadataRepositoryManager.SERVICE_NAME);
for (URI uri : repositoryLocations) {
checkCancelled(monitor);
IMetadataRepository repository = manager.loadRepository(uri, monitor.newChild(1));
repositories.add(repository);
}
return repositories;
}
Aggregations