Search in sources :

Example 1 with Repository

use of org.apache.karaf.features.Repository in project karaf by apache.

the class FeaturesPlugin method getFeatures.

private List<ExtendedFeature> getFeatures(List<Repository> repositories) {
    List<ExtendedFeature> features = new ArrayList<>();
    if (featuresService == null) {
        this.log.error("Features service is not available");
        return features;
    }
    try {
        for (Repository r : repositories) {
            for (Feature f : r.getFeatures()) {
                ExtendedFeature.State state = featuresService.isInstalled(f) ? ExtendedFeature.State.INSTALLED : ExtendedFeature.State.UNINSTALLED;
                features.add(new ExtendedFeature(state, r.getName(), f));
            }
        }
    } catch (Exception e) {
        this.log.error(e.getMessage());
    }
    Collections.sort(features, new ExtendedFeatureComparator());
    return features;
}
Also used : Repository(org.apache.karaf.features.Repository) ArrayList(java.util.ArrayList) Feature(org.apache.karaf.features.Feature) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 2 with Repository

use of org.apache.karaf.features.Repository in project karaf by apache.

the class FeaturesServiceImpl method createFeatureCacheInternal.

private Map<String, Map<String, Feature>> createFeatureCacheInternal() throws Exception {
    Map<String, Map<String, Feature>> map = new HashMap<>();
    Repository[] repos = repositories.listRepositories();
    for (Repository repo : repos) {
        for (Feature f : repo.getFeatures()) {
            if (map.get(f.getName()) == null) {
                Map<String, Feature> versionMap = new HashMap<>();
                versionMap.put(f.getVersion(), f);
                map.put(f.getName(), versionMap);
            } else {
                map.get(f.getName()).put(f.getVersion(), f);
            }
        }
    }
    return map;
}
Also used : Repository(org.apache.karaf.features.Repository) HashMap(java.util.HashMap) StateStorage.toStringStringSetMap(org.apache.karaf.features.internal.service.StateStorage.toStringStringSetMap) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Feature(org.apache.karaf.features.Feature)

Example 3 with Repository

use of org.apache.karaf.features.Repository in project karaf by apache.

the class RepositoryCache method removeRepository.

public synchronized void removeRepository(URI repositoryUri) throws Exception {
    List<String> toRemove = new ArrayList<>();
    toRemove.add(repositoryUri.toString());
    while (!toRemove.isEmpty()) {
        Repository rep = repositoryCache.remove(toRemove.remove(0));
        if (rep != null) {
            for (URI u : rep.getRepositories()) {
                toRemove.add(u.toString());
            }
        }
    }
}
Also used : Repository(org.apache.karaf.features.Repository) ArrayList(java.util.ArrayList) URI(java.net.URI)

Example 4 with Repository

use of org.apache.karaf.features.Repository in project karaf by apache.

the class ListFeatureVersionsCommand method doExecute.

protected void doExecute(FeaturesService admin) throws Exception {
    ShellTable table = new ShellTable();
    table.column("Version");
    table.column("Repository");
    table.column("Repository URL");
    table.emptyTableText("No versions available for features '" + feature + "'");
    for (Repository r : Arrays.asList(admin.listRepositories())) {
        for (Feature f : r.getFeatures()) {
            if (f.getName().equals(feature)) {
                table.addRow().addContent(f.getVersion(), r.getName(), r.getURI());
            }
        }
    }
    table.print(System.out, !noFormat);
}
Also used : Repository(org.apache.karaf.features.Repository) ShellTable(org.apache.karaf.shell.support.table.ShellTable) Feature(org.apache.karaf.features.Feature)

Example 5 with Repository

use of org.apache.karaf.features.Repository in project karaf by apache.

the class RepoListCommand method reloadAllRepos.

private void reloadAllRepos(FeaturesService featuresService) throws Exception {
    System.out.println("Reloading all repositories from their urls");
    System.out.println();
    List<Exception> exceptions = new ArrayList<>();
    for (Repository repo : featuresService.listRepositories()) {
        try {
            featuresService.addRepository(repo.getURI());
        } catch (Exception e) {
            exceptions.add(e);
        }
    }
    MultiException.throwIf("Unable to reload repositories", exceptions);
}
Also used : Repository(org.apache.karaf.features.Repository) ArrayList(java.util.ArrayList) MultiException(org.apache.karaf.shell.support.MultiException)

Aggregations

Repository (org.apache.karaf.features.Repository)84 Test (org.junit.Test)52 HashSet (java.util.HashSet)51 FeaturesService (org.apache.karaf.features.FeaturesService)44 Feature (org.apache.karaf.features.Feature)38 ApplicationService (org.codice.ddf.admin.application.service.ApplicationService)37 URI (java.net.URI)20 Application (org.codice.ddf.admin.application.service.Application)20 LinkedHashSet (java.util.LinkedHashSet)9 ArrayList (java.util.ArrayList)8 ApplicationServiceException (org.codice.ddf.admin.application.service.ApplicationServiceException)8 Logger (org.slf4j.Logger)7 Appender (ch.qos.logback.core.Appender)6 IOException (java.io.IOException)6 HashMap (java.util.HashMap)6 ArgumentMatcher (org.mockito.ArgumentMatcher)6 Mockito.anyString (org.mockito.Mockito.anyString)6 EnumSet (java.util.EnumSet)5 Map (java.util.Map)5 TreeMap (java.util.TreeMap)4