use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager in project knime-core by knime.
the class RepositoryUpdater method updateArtifactRepositoryURLs.
/**
* Updates the URLs of all enabled artifact repository by adding the KNIME ID to them.
*/
public void updateArtifactRepositoryURLs() {
BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext();
ServiceReference<IProvisioningAgent> ref = context.getServiceReference(IProvisioningAgent.class);
if (ref != null) {
IProvisioningAgent agent = context.getService(ref);
try {
IArtifactRepositoryManager repoManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
if (repoManager != null) {
// is null if started from the SDK
for (URI uri : repoManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_NON_LOCAL)) {
updateArtifactRepositoryURL(repoManager, uri, true);
}
}
} finally {
context.ungetService(ref);
}
}
}
use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager in project knime-core by knime.
the class RepositoryUpdater method removeOutdatedArtifactRepository.
private void removeOutdatedArtifactRepository(final RepositoryEvent event) {
BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext();
ServiceReference<IProvisioningAgent> ref = context.getServiceReference(IProvisioningAgent.class);
if (ref != null) {
IProvisioningAgent agent = context.getService(ref);
try {
IArtifactRepositoryManager repoManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
if (repoManager != null) {
URI removedMetadatalocation = event.getRepositoryLocation();
String correspondingArtifactRepoPrefix = removedMetadatalocation.toString();
if (!correspondingArtifactRepoPrefix.endsWith("/")) {
correspondingArtifactRepoPrefix += "/";
}
correspondingArtifactRepoPrefix += "knid=";
for (URI uri : repoManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_NON_LOCAL)) {
if (urlContainsID(uri) && uri.toString().startsWith(correspondingArtifactRepoPrefix)) {
repoManager.removeRepository(uri);
}
}
for (URI uri : repoManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_DISABLED)) {
if (urlContainsID(uri) && uri.toString().startsWith(correspondingArtifactRepoPrefix)) {
repoManager.removeRepository(uri);
}
}
}
} finally {
context.ungetService(ref);
}
}
}
use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager 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);
}
}
use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager in project knime-core by knime.
the class RepositoryUpdater method updateArtifactRepository.
private void updateArtifactRepository(final RepositoryEvent event) {
BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext();
ServiceReference<IProvisioningAgent> ref = context.getServiceReference(IProvisioningAgent.class);
if (ref != null) {
IProvisioningAgent agent = context.getService(ref);
try {
IArtifactRepositoryManager repoManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
if (repoManager != null) {
updateArtifactRepositoryURL(repoManager, event.getRepositoryLocation(), event.isRepositoryEnabled());
}
} finally {
context.ungetService(ref);
}
}
}
use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager in project tycho by eclipse.
the class RemoteAgentMavenMirrorsTest method loadRepositories.
private Repositories loadRepositories(String id, URI specifiedUrl) throws Exception {
IRepositoryIdManager idManager = (IRepositoryIdManager) subject.getService(IRepositoryIdManager.SERVICE_NAME);
idManager.addMapping(id, specifiedUrl);
IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) subject.getService(IMetadataRepositoryManager.SERVICE_NAME);
IMetadataRepository metadataRepo = metadataManager.loadRepository(specifiedUrl, null);
IArtifactRepositoryManager artifactsManager = (IArtifactRepositoryManager) subject.getService(IArtifactRepositoryManager.SERVICE_NAME);
IArtifactRepository artifactsRepo = artifactsManager.loadRepository(specifiedUrl, null);
return new Repositories(metadataRepo, artifactsRepo);
}
Aggregations