Search in sources :

Example 1 with AutoProxRule

use of org.commonjava.indy.autoprox.data.AutoProxRule in project indy by Commonjava.

the class ScriptRuleParser method parseRule.

public RuleMapping parseRule(final String spec, final String scriptName) throws AutoProxRuleException {
    if (spec == null) {
        return null;
    }
    AutoProxRule rule;
    try {
        rule = scriptEngine.parseScriptInstance(spec, AutoProxRule.class);
    } catch (final IndyGroovyException e) {
        throw new AutoProxRuleException("[AUTOPROX] Cannot load autoprox factory from: {} as an instance of: {}. Reason: {}", e, scriptName, AutoProxRule.class.getSimpleName(), e.getMessage());
    }
    if (rule != null) {
        return new RuleMapping(FilenameUtils.removeExtension(scriptName), spec, rule);
    }
    logger.warn("Rule named: {} parsed to null AutoProxRule instance. Spec was:\n\n{}\n\n", scriptName, spec);
    return null;
}
Also used : AutoProxRule(org.commonjava.indy.autoprox.data.AutoProxRule) IndyGroovyException(org.commonjava.indy.subsys.template.IndyGroovyException) RuleMapping(org.commonjava.indy.autoprox.data.RuleMapping) AutoProxRuleException(org.commonjava.indy.autoprox.data.AutoProxRuleException)

Aggregations

AutoProxRule (org.commonjava.indy.autoprox.data.AutoProxRule)1 AutoProxRuleException (org.commonjava.indy.autoprox.data.AutoProxRuleException)1 RuleMapping (org.commonjava.indy.autoprox.data.RuleMapping)1 IndyGroovyException (org.commonjava.indy.subsys.template.IndyGroovyException)1