Search in sources :

Example 76 with Repository

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

the class FeaturesValidationTest method testNs11.

@Test
public void testNs11() throws Exception {
    Repository features = unmarshalAndValidate("f04.xml");
    ;
    assertNotNull(features);
}
Also used : Repository(org.apache.karaf.features.Repository) Test(org.junit.Test)

Example 77 with Repository

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

the class FeaturesValidationTest method testNs13.

@Test
public void testNs13() throws Exception {
    Repository features = unmarshalAndValidate("f07.xml");
    assertNotNull(features);
    Feature f0 = features.getFeatures()[0];
    Feature f1 = features.getFeatures()[1];
    assertEquals("2.5.6.SEC02", f0.getVersion());
    assertTrue(f1.isHidden());
    assertNotNull(f1.getLibraries());
    assertEquals(1, f0.getLibraries().size());
    Library lib = f0.getLibraries().get(0);
    assertEquals("my-library", lib.getLocation());
    assertEquals(Library.TYPE_ENDORSED, lib.getType());
    assertFalse(lib.isExport());
    assertTrue(lib.isDelegate());
}
Also used : Repository(org.apache.karaf.features.Repository) Library(org.apache.karaf.features.Library) Feature(org.apache.karaf.features.Feature) Test(org.junit.Test)

Example 78 with Repository

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

the class RepositoryCacheImpl method removeRepository.

@Override
public void removeRepository(URI repositoryUri) {
    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 79 with Repository

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

the class RepositoryCacheImpl method getRepositoryClosure.

/**
 * Returns a set containing the given repository and all its dependencies recursively
 */
@Override
public Set<Repository> getRepositoryClosure(Repository repo) {
    Set<Repository> closure = new HashSet<>();
    Deque<Repository> remaining = new ArrayDeque<>(Collections.singleton(repo));
    while (!remaining.isEmpty()) {
        Repository rep = remaining.removeFirst();
        if (closure.add(rep)) {
            for (URI uri : rep.getRepositories()) {
                remaining.add(getRepository(uri.toString()));
            }
        }
    }
    return closure;
}
Also used : Repository(org.apache.karaf.features.Repository) URI(java.net.URI) ArrayDeque(java.util.ArrayDeque) HashSet(java.util.HashSet)

Example 80 with Repository

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

the class FeaturesCommandSupport method selectRepositories.

protected Set<URI> selectRepositories(String nameOrUrl, String version) throws Exception {
    Set<URI> uris = new LinkedHashSet<>();
    String effectiveVersion = (version == null) ? "LATEST" : version;
    URI uri = featuresService.getRepositoryUriFor(nameOrUrl, effectiveVersion);
    if (uri == null) {
        // add regex support on installed repositories
        Pattern pattern = Pattern.compile(nameOrUrl);
        for (Repository repository : featuresService.listRepositories()) {
            URI u = repository.getURI();
            String rname = repository.getName();
            if (pattern.matcher(u.toString()).matches() || rname != null && pattern.matcher(rname).matches()) {
                uris.add(u);
            }
        }
    } else {
        uris.add(uri);
    }
    return uris;
}
Also used : Pattern(java.util.regex.Pattern) Repository(org.apache.karaf.features.Repository) URI(java.net.URI)

Aggregations

Repository (org.apache.karaf.features.Repository)85 Test (org.junit.Test)53 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)21 Application (org.codice.ddf.admin.application.service.Application)20 ArrayList (java.util.ArrayList)8 LinkedHashSet (java.util.LinkedHashSet)8 ApplicationServiceException (org.codice.ddf.admin.application.service.ApplicationServiceException)8 Logger (org.slf4j.Logger)7 Appender (ch.qos.logback.core.Appender)6 HashMap (java.util.HashMap)6 ArgumentMatcher (org.mockito.ArgumentMatcher)6 Mockito.anyString (org.mockito.Mockito.anyString)6 IOException (java.io.IOException)5 EnumSet (java.util.EnumSet)5 Map (java.util.Map)5 TreeMap (java.util.TreeMap)4