Search in sources :

Example 71 with Feature

use of org.apache.karaf.features.Feature in project ddf by codice.

the class SystemStateManager method captureSystemState.

private void captureSystemState() {
    LOGGER.info("Capturing system state");
    try {
        baseFeatures = Arrays.stream(features.listInstalledFeatures()).map(Feature::getName).collect(Collectors.toList());
        Configuration[] configs = adminConfig.listConfigurations(CONFIGURATION_FILTER);
        for (Configuration config : configs) {
            baseConfigurations.put(config.getPid(), config);
        }
        console.runCommand("catalog:export --provider --force --skip-signature-verification --delete=false --output \"./itest-catalog-entries.zip\" --cql \"\\\"metacard-tags\\\" not like 'geonames'\"");
        LOGGER.info("Feature Count: {}", baseFeatures.size());
        LOGGER.info("Configuration Count: {}", baseConfigurations.size());
    } catch (Exception e) {
        LOGGER.error("Error capturing system configuration.", e);
    }
}
Also used : Configuration(org.osgi.service.cm.Configuration) Feature(org.apache.karaf.features.Feature)

Example 72 with Feature

use of org.apache.karaf.features.Feature in project camel by apache.

the class CamelKarafTestSupport method assertFeatureInstalled.

public void assertFeatureInstalled(String featureName, String featureVersion) {
    Feature[] features = featuresService.listInstalledFeatures();
    for (Feature feature : features) {
        if (featureName.equals(feature.getName()) && featureVersion.equals(feature.getVersion())) {
            return;
        }
    }
    fail("Feature " + featureName + "/" + featureVersion + " should be installed but is not");
}
Also used : Feature(org.apache.karaf.features.Feature)

Example 73 with Feature

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

the class FeaturesServiceImpl method getFeatures.

@Override
public Feature[] getFeatures(String name, String version) throws Exception {
    List<Feature> features = new ArrayList<>();
    Pattern pattern = Pattern.compile(name);
    Map<String, Map<String, Feature>> allFeatures = getFeatures();
    for (String featureName : allFeatures.keySet()) {
        Matcher matcher = pattern.matcher(featureName);
        if (matcher.matches()) {
            Map<String, Feature> versions = allFeatures.get(featureName);
            Feature matchingFeature = getFeatureMatching(versions, version);
            if (matchingFeature != null) {
                features.add(matchingFeature);
            }
        }
    }
    return features.toArray(new Feature[features.size()]);
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList) Feature(org.apache.karaf.features.Feature) StateStorage.toStringStringSetMap(org.apache.karaf.features.internal.service.StateStorage.toStringStringSetMap) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

Example 74 with Feature

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

the class FeaturesServiceImpl method getFeatureMatching.

private Feature getFeatureMatching(Map<String, Feature> versions, String version) {
    if (version != null) {
        version = version.trim();
        if (version.equals(org.apache.karaf.features.internal.model.Feature.DEFAULT_VERSION)) {
            version = "";
        }
    } else {
        version = "";
    }
    if (versions == null || versions.isEmpty()) {
        return null;
    } else {
        Feature feature = version.isEmpty() ? null : versions.get(version);
        if (feature == null) {
            // Compute version range. If an version has been given, assume exact range
            VersionRange versionRange = version.isEmpty() ? new VersionRange(Version.emptyVersion) : new VersionRange(version, true, true);
            Version latest = Version.emptyVersion;
            for (String available : versions.keySet()) {
                Version availableVersion = VersionTable.getVersion(available);
                if (availableVersion.compareTo(latest) >= 0 && versionRange.contains(availableVersion)) {
                    feature = versions.get(available);
                    latest = availableVersion;
                }
            }
        }
        return feature;
    }
}
Also used : Version(org.osgi.framework.Version) VersionRange(org.apache.felix.utils.version.VersionRange) Feature(org.apache.karaf.features.Feature)

Example 75 with Feature

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

the class FeaturesServiceImplTest method testRemoveRepo2.

@Test
public void testRemoveRepo2() throws Exception {
    final FeaturesService featureService = createTestFeatureService();
    URI repoA = URI.create("custom:remove/a.xml");
    URI repoB = URI.create("custom:remove/b.xml");
    featureService.addRepository(repoA);
    featureService.addRepository(repoB);
    Feature a1Feature = featureService.getFeature("a1");
    installFeature(featureService, a1Feature);
    Feature b1Feature = featureService.getFeature("b1");
    installFeature(featureService, b1Feature);
    featureService.removeRepository(repoA);
    assertNotInstalled(featureService, a1Feature);
    assertInstalled(featureService, b1Feature);
}
Also used : FeaturesService(org.apache.karaf.features.FeaturesService) Feature(org.apache.karaf.features.Feature) Test(org.junit.Test)

Aggregations

Feature (org.apache.karaf.features.Feature)127 Test (org.junit.Test)56 FeaturesService (org.apache.karaf.features.FeaturesService)43 HashSet (java.util.HashSet)41 Repository (org.apache.karaf.features.Repository)39 ApplicationService (org.codice.ddf.admin.application.service.ApplicationService)18 Bundle (org.osgi.framework.Bundle)18 HashMap (java.util.HashMap)17 ArrayList (java.util.ArrayList)16 Map (java.util.Map)16 Dependency (org.apache.karaf.features.Dependency)15 BundleInfo (org.apache.karaf.features.BundleInfo)14 Application (org.codice.ddf.admin.application.service.Application)14 URI (java.net.URI)13 IOException (java.io.IOException)12 VersionRange (org.apache.felix.utils.version.VersionRange)12 LinkedHashSet (java.util.LinkedHashSet)11 Version (org.osgi.framework.Version)11 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)10 EnumSet (java.util.EnumSet)9