use of io.fabric8.internal.ProfileDependencyConfig in project fabric8 by jboss-fuse.
the class FabricServiceImpl method validateProfileDependencies.
protected void validateProfileDependencies(CreateContainerOptions options) {
Map<String, Map<String, String>> profileDependencies = Profiles.getOverlayFactoryConfigurations(this, options.getProfiles(), options.getVersion(), ProfileDependencyConfig.PROFILE_DEPENDENCY_CONFIG_PID);
Set<Map.Entry<String, Map<String, String>>> entries = profileDependencies.entrySet();
for (Map.Entry<String, Map<String, String>> entry : entries) {
String configName = entry.getKey();
Map<String, String> exportConfig = entry.getValue();
if (exportConfig != null && !exportConfig.isEmpty()) {
ProfileDependencyConfig config = new ProfileDependencyConfig();
try {
configurer.configure(exportConfig, config);
} catch (Exception e) {
throw new FabricException("Failed to load configuration for " + configName + " of " + config + " due to: " + e, e);
}
// Ensure dependent container exists
if (ProfileDependencyKind.ZOOKEEPER_SERVICE.equals(config.getKind())) {
try {
List<String> children = getChildren(this.curator.get(), config.getZookeeperPath());
if (children == null || children.isEmpty()) {
throw new ProfileDependencyException(options.getProfiles(), config.getProfileWildcards(), config.getProfileTags(), config.getSummary());
}
boolean dependencyFound = false;
Iterator<String> childIterator = children.iterator();
while (!dependencyFound && childIterator.hasNext()) {
String containerName = childIterator.next();
Container container = this.getContainer(containerName);
Profile[] profiles = container.getProfiles();
int profileCount = 0;
while (!dependencyFound && profileCount < profiles.length) {
Profile profile = profiles[profileCount];
if (config.getProfileWildcards() != null) {
for (String profileWildcard : config.getProfileWildcards()) {
if (profile.getId().contains(profileWildcard)) {
dependencyFound = true;
break;
}
}
}
if (!dependencyFound && config.getProfileTags() != null) {
List<String> profileTags = profile.getTags();
int foundTags = 0;
for (String configProfileTag : config.getProfileTags()) {
if (profileTags.contains(configProfileTag)) {
foundTags++;
}
}
if (foundTags == config.getProfileTags().length) {
dependencyFound = true;
}
}
}
}
if (!dependencyFound) {
throw new ProfileDependencyException(options.getProfiles(), config.getProfileWildcards(), config.getProfileTags(), config.getSummary());
}
} catch (Exception e) {
throw new ProfileDependencyException(options.getProfiles(), config.getProfileWildcards(), config.getProfileTags(), config.getSummary(), e);
}
}
}
}
}
Aggregations