*/
protected void validate(EnunciateFreemarkerModel model) throws ModelValidationException {
debug("Validating the model...");
Messager messager = getMessager();
ValidatorChain validator = new ValidatorChain();
EnunciateConfiguration config = this.enunciate.getConfig();
Set<String> disabledRules = new TreeSet<String>(config.getDisabledRules());
if (this.enunciate.isModuleEnabled("rest")) {
//if the REST module is enabled, disable the validation rule that
//fails if the module is not enabled.
disabledRules.add("disabled.rest.module");
}
Validator coreValidator = config.getValidator();
if (coreValidator instanceof ConfigurableRules) {
((ConfigurableRules) coreValidator).disableRules(disabledRules);
}
validator.addValidator("core", coreValidator);
debug("Default validator added to the chain.");
for (DeploymentModule module : config.getEnabledModules()) {
Validator moduleValidator = module.getValidator();
if (moduleValidator != null) {
if (moduleValidator instanceof ConfigurableRules) {
((ConfigurableRules)moduleValidator).disableRules(disabledRules);
}
validator.addValidator(module.getName(), moduleValidator);
debug("Validator for module %s added to the chain.", module.getName());
}
}
if (!config.isAllowEmptyNamespace()) {
validator.addValidator("emptyns", new EmptyNamespaceValidator());
}
ValidationResult validationResult = validate(model, validator);