Search in sources :

Example 1 with IndexProvider

use of aQute.bnd.service.IndexProvider in project bndtools by bndtools.

the class RepositoryTreeLabelProvider method isRemoteRepo.

private static boolean isRemoteRepo(RepositoryPlugin repository) {
    List<?> locations = Collections.emptyList();
    if (repository instanceof IndexProvider) {
        try {
            locations = ((IndexProvider) repository).getIndexLocations();
        } catch (Exception e) {
            logger.logError("Unable to get repository index list", e);
        }
    }
    for (Object locationObj : locations) {
        try {
            URI location;
            if (locationObj instanceof URI)
                location = (URI) locationObj;
            else if (locationObj instanceof URL)
                location = ((URL) locationObj).toURI();
            else
                return false;
            String protocol = location.getScheme();
            if ("http".equals(protocol) || "https".equals(protocol))
                return true;
        } catch (URISyntaxException e) {
            return false;
        }
    }
    return false;
}
Also used : IndexProvider(aQute.bnd.service.IndexProvider) StyledString(org.eclipse.jface.viewers.StyledString) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) URISyntaxException(java.net.URISyntaxException) URL(java.net.URL)

Example 2 with IndexProvider

use of aQute.bnd.service.IndexProvider in project bndtools by bndtools.

the class RepositoryTreeContentProvider method addRepositoryPlugins.

private void addRepositoryPlugins(Collection<Object> result, Workspace workspace) {
    workspace.getErrors().clear();
    List<RepositoryPlugin> repoPlugins = workspace.getPlugins(RepositoryPlugin.class);
    for (String error : workspace.getErrors()) {
        logger.logError(error, null);
    }
    for (RepositoryPlugin repoPlugin : repoPlugins) {
        if (CACHE_REPOSITORY.equals(repoPlugin.getName()))
            continue;
        if (repoPlugin instanceof IndexProvider) {
            IndexProvider indexProvider = (IndexProvider) repoPlugin;
            if (!supportsPhase(indexProvider))
                continue;
        }
        if (showRepos)
            result.add(repoPlugin);
        else
            result.addAll(Arrays.asList(getRepositoryBundles(repoPlugin)));
    }
}
Also used : IndexProvider(aQute.bnd.service.IndexProvider) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin)

Aggregations

IndexProvider (aQute.bnd.service.IndexProvider)2 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 StyledString (org.eclipse.jface.viewers.StyledString)1