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()]);
}
Aggregations