use of org.neo4j.kernel.configuration.Connector.ConnectorType.HTTP in project neo4j by neo4j.
the class ServerConfigurationValidator method validate.
/**
* Verifies that at least one http connector is specified and enabled.
*/
@Override
@Nonnull
public Map<String, String> validate(@Nonnull Collection<SettingValidator> settingValidators, @Nonnull Map<String, String> rawConfig, @Nonnull Log log, boolean parsingFile) throws InvalidSettingException {
Pattern pattern = Pattern.compile(Pattern.quote("dbms.connector.") + "([^\\.]+)\\.(.+)");
List<Connector> connectors = rawConfig.keySet().stream().map(pattern::matcher).filter(Matcher::matches).map(match -> match.group(1)).distinct().map(Connector::new).collect(Collectors.toList());
Map<String, String> validSettings = new HashMap<>(rawConfig);
// Add missing type info -- validation has succeeded so we can do this with confidence
connectors.stream().filter(connector -> connector.type.apply(rawConfig::get) == null).forEach(connector -> {
if ("http".equalsIgnoreCase(connector.group.groupKey) || "https".equalsIgnoreCase(connector.group.groupKey)) {
validSettings.put(connector.type.name(), HTTP.name());
} else {
validSettings.put(connector.type.name(), BOLT.name());
}
});
if (connectors.stream().filter(connector -> connector.type.apply(validSettings::get).equals(HTTP)).noneMatch(connector -> connector.enabled.apply(validSettings::get))) {
throw new InvalidSettingException(String.format("Missing mandatory enabled connector of type '%s'", HTTP));
}
return validSettings;
}
Aggregations