use of org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager in project knime-core by knime.
the class InstallMissingNodesJob method findExtensions.
private IStatus findExtensions(final IProgressMonitor monitor, final List<NodeAndBundleInformation> missingNodes, final Set<IInstallableUnit> featuresToInstall) {
ProvisioningSession session = ProvisioningUI.getDefaultUI().getSession();
Bundle myself = FrameworkUtil.getBundle(getClass());
try {
IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) session.getProvisioningAgent().getService(IMetadataRepositoryManager.SERVICE_NAME);
for (URI uri : metadataManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL)) {
if (!missingNodes.isEmpty()) {
IMetadataRepository repo = metadataManager.loadRepository(uri, monitor);
for (Iterator<NodeAndBundleInformation> it = missingNodes.iterator(); it.hasNext(); ) {
NodeAndBundleInformation info = it.next();
if (searchInRepository(repo, info, metadataManager, monitor, featuresToInstall)) {
it.remove();
}
}
}
}
return Status.OK_STATUS;
} catch (ProvisionException ex) {
NodeLogger.getLogger(getClass()).error("Could not create provisioning agent: " + ex.getMessage(), ex);
return new Status(IStatus.ERROR, myself.getSymbolicName(), "Could not query updates site for missing extensions", ex);
}
}
use of org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager in project tycho by eclipse.
the class RemoteAgentMetadataRepositoryCacheTest method loadHttpRepository.
private IMetadataRepository loadHttpRepository(RemoteAgent agent) throws ProvisionException {
IMetadataRepositoryManager metadataRepositoryManager = agent.getService(IMetadataRepositoryManager.class);
IMetadataRepository repo = metadataRepositoryManager.loadRepository(localHttpRepo, null);
return repo;
}
use of org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager in project tycho by eclipse.
the class TargetPlatformFilterEvaluatorTest method loadTestUnits.
private static Set<IInstallableUnit> loadTestUnits() throws Exception {
IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) p2Context.getAgent().getService(IMetadataRepositoryManager.SERVICE_NAME);
File testDataFile = ResourceUtil.resourceFile("targetfiltering/content.xml");
IMetadataRepository testDataRepository = metadataManager.loadRepository(testDataFile.getParentFile().toURI(), null);
return testDataRepository.query(QueryUtil.ALL_UNITS, null).toUnmodifiableSet();
}
use of org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager in project azure-tools-for-java by Microsoft.
the class PluginUtil method forceInstallPluginUsingP2.
private static void forceInstallPluginUsingP2(String pluginGroupID) {
URI repoURI = getEclipseP2Repository();
ProvisioningUI provisioningUI = ProvisioningUI.getDefaultUI();
if (provisioningUI != null && repoURI != null) {
ProvisioningSession provisioningSession = provisioningUI.getSession();
IProvisioningAgent provisioningAgent = null;
if (provisioningSession != null && (provisioningAgent = provisioningSession.getProvisioningAgent()) != null) {
IMetadataRepositoryManager manager = (IMetadataRepositoryManager) provisioningAgent.getService(IMetadataRepositoryManager.SERVICE_NAME);
if (manager != null) {
try {
IMetadataRepository repository = manager.loadRepository(repoURI, null);
if (repository != null) {
IQueryResult<IInstallableUnit> iqr = repository.query(QueryUtil.createIUQuery(pluginGroupID), null);
if (iqr != null) {
Collection<IInstallableUnit> iuList = StreamSupport.stream(iqr.spliterator(), false).collect(Collectors.toList());
if (iuList.size() > 0) {
InstallOperation io = new InstallOperation(provisioningSession, iuList);
provisioningUI.openInstallWizard(iuList, io, null);
return;
}
}
}
} catch (Exception e) {
String errorMsg = "Error installing " + pluginGroupID + "! Please manually install using Eclipse P2 repository from: Help -> Install New Software.... Click OK to continue.";
PluginUtil.displayErrorDialogAndLog(getParentShell(), "Fail to install", errorMsg, e);
}
}
}
}
String errorMsg = "Error installing " + pluginGroupID + "! In the following installation wizard, please select the right repository and then filter by " + pluginGroupID + "! Click OK to continue.";
PluginUtil.displayErrorDialogAndLog(getParentShell(), "Fail to install", errorMsg, null);
provisioningUI.openInstallWizard(null, null, null);
}
use of org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager in project translationstudio8 by heartsome.
the class Activator method loadUpdateSite.
private void loadUpdateSite() throws InvocationTargetException {
// get the agent
final IProvisioningAgent agent = (IProvisioningAgent) ServiceHelper.getService(Activator.bundleContext, IProvisioningAgent.SERVICE_NAME);
// get the repository managers and define our repositories
IMetadataRepositoryManager manager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
if (manager == null) {
logger.error("When load repository,Metadata manager was null");
return;
}
// Load artifact manager
IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
if (artifactManager == null) {
logger.error("When load repository,Artifact manager was null");
return;
}
// Load repository
try {
String url = getUrlString();
if (url == null) {
return;
}
URI repoLocation = new URI(url);
URI[] ex = manager.getKnownRepositories(IMetadataRepositoryManager.REPOSITORIES_ALL);
for (URI e : ex) {
manager.removeRepository(e);
artifactManager.removeRepository(e);
}
manager.addRepository(repoLocation);
artifactManager.addRepository(repoLocation);
} catch (URISyntaxException e) {
logger.error("Caught URI syntax exception " + e.getMessage(), e);
throw new InvocationTargetException(e);
}
}
Aggregations