Search in sources :

Example 6 with IndyGroovyException

use of org.commonjava.indy.subsys.template.IndyGroovyException 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

IndyGroovyException (org.commonjava.indy.subsys.template.IndyGroovyException)6 HashMap (java.util.HashMap)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 IOException (java.io.IOException)2 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)2 InputStream (java.io.InputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 TreeMap (java.util.TreeMap)1 WebdavException (net.sf.webdav.exceptions.WebdavException)1 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)1 AutoProxRule (org.commonjava.indy.autoprox.data.AutoProxRule)1 AutoProxRuleException (org.commonjava.indy.autoprox.data.AutoProxRuleException)1 RuleMapping (org.commonjava.indy.autoprox.data.RuleMapping)1 StoreResource (org.commonjava.indy.content.StoreResource)1 StoreKey (org.commonjava.indy.model.core.StoreKey)1 StoreType (org.commonjava.indy.model.core.StoreType)1 DirectoryListingDTO (org.commonjava.indy.model.core.dto.DirectoryListingDTO)1