use of org.commonjava.indy.promote.validate.model.ValidationRule in project indy by Commonjava.
the class ValidationRuleParser method parseRule.
public ValidationRuleMapping parseRule(final String spec, final String scriptName) throws PromotionValidationException {
if (spec == null) {
return null;
}
Logger logger = LoggerFactory.getLogger(getClass());
logger.debug("Parsing rule from: {} with content:\n{}\n", scriptName, spec);
ValidationRule rule = null;
try {
rule = scriptEngine.parseScriptInstance(spec, ValidationRule.class);
logger.debug("Parsed: {}", rule.getClass().getName());
} catch (final IndyGroovyException e) {
throw new PromotionValidationException("[PROMOTE] Cannot load validation rule from: {} as an instance of: {}. Reason: {}", e, scriptName, ValidationRule.class.getSimpleName(), e.getMessage());
}
if (rule != null) {
return new ValidationRuleMapping(scriptName, spec, rule);
}
return null;
}
Aggregations