Search in sources :

Example 1 with InvalidComponentException

use of io.fabric8.api.InvalidComponentException in project fabric8 by jboss-fuse.

the class FabricFeaturesServiceImpl method listInstalledFeatures.

@Override
public Feature[] listInstalledFeatures() {
    assertValid();
    Set<Feature> installed = new HashSet<Feature>();
    try {
        Map<String, Map<String, Feature>> allFeatures = getFeatures(installedRepositories);
        Profile overlayProfile = fabricService.get().getCurrentContainer().getOverlayProfile();
        Profile effectiveProfile = Profiles.getEffectiveProfile(fabricService.get(), overlayProfile);
        for (String featureName : effectiveProfile.getFeatures()) {
            try {
                Feature f;
                if (featureName.contains("/")) {
                    String[] parts = featureName.split("/");
                    String name = parts[0];
                    String version = parts[1];
                    f = allFeatures.get(name).get(version);
                } else {
                    TreeMap<String, Feature> versionMap = (TreeMap<String, Feature>) allFeatures.get(featureName);
                    f = versionMap.lastEntry().getValue();
                }
                addFeatures(f, installed);
            } catch (Throwable ex) {
                // may also throw java.lang.NoClassDefFoundError when
                // bundle wiring is no longer active - ignoring
                LOGGER.debug("Error while adding {} to the features list");
            }
        }
    } catch (IllegalStateException e) {
        if ("Client is not started".equals(e.getMessage())) {
            LOGGER.warn("Zookeeper connection not available. It's not yet possible to compute features.");
        }
    } catch (InvalidComponentException e) {
        LOGGER.info("FeaturesService was deactivated");
    } catch (Exception e) {
        LOGGER.error("Error retrieving features.", e);
    }
    return installed.toArray(new Feature[installed.size()]);
}
Also used : Feature(org.apache.karaf.features.Feature) Profile(io.fabric8.api.Profile) InvalidComponentException(io.fabric8.api.InvalidComponentException) InvalidComponentException(io.fabric8.api.InvalidComponentException)

Aggregations

InvalidComponentException (io.fabric8.api.InvalidComponentException)1 Profile (io.fabric8.api.Profile)1 Feature (org.apache.karaf.features.Feature)1