if (this.scriptSourceUri == null)
{
Collection failedKeys = new ArrayList();
failedKeys.add(SCRIPT_SOURCE_PREF_KEY);
throw new ValidatorException("Configuration failed: " + SCRIPT_SOURCE_PREF_KEY + " should be set properly!", failedKeys);
}
else
{
try
{
if (this.scriptSourceUri.startsWith("file:"))
{
String decodedScriptSourceUri = this.scriptSourceUri;
try
{
decodedScriptSourceUri = URLDecoder.decode(this.scriptSourceUri, this.scriptSourceUriEncoding);
}
catch (UnsupportedEncodingException encodingEx)
{
Collection failedKeys = new ArrayList();
failedKeys.add(SCRIPT_SOURCE_URL_ENCODING_PREF_KEY);
throw new ValidatorException("Unsupported encoding: " + this.scriptSourceUriEncoding, failedKeys);
}
this.groovyCodeSource = new GroovyCodeSource(new File(decodedScriptSourceUri.substring(5)));
}
else if (this.scriptSourceUri.startsWith("classpath:"))
{
String resourceURL = this.groovyClassLoader.getResource(this.scriptSourceUri.substring(10))
.toString();
if (resourceURL.startsWith("file:"))
{
String decodedScriptSourceUri = resourceURL;
try
{
decodedScriptSourceUri = URLDecoder.decode(resourceURL, this.scriptSourceUriEncoding);
}
catch (UnsupportedEncodingException encodingEx)
{
Collection failedKeys = new ArrayList();
failedKeys.add(SCRIPT_SOURCE_URL_ENCODING_PREF_KEY);
throw new ValidatorException("Unsupported encoding: " + this.scriptSourceUriEncoding, failedKeys);
}
this.groovyCodeSource = new GroovyCodeSource(new File(decodedScriptSourceUri.substring(5)));
}
else
{
Collection failedKeys = new ArrayList();
failedKeys.add(SCRIPT_SOURCE_PREF_KEY);
throw new ValidatorException(SCRIPT_SOURCE_PREF_KEY
+ " with 'classpath:' prefix should indicate to a local resource", failedKeys);
}
}
else
{
Collection failedKeys = new ArrayList();
failedKeys.add(SCRIPT_SOURCE_PREF_KEY);
throw new ValidatorException("Configuration failed: " + SCRIPT_SOURCE_PREF_KEY + " should be prefixed by 'file:' or 'classpath'.", failedKeys);
}
}
catch (FileNotFoundException e)
{
Collection failedKeys = new ArrayList();
failedKeys.add(SCRIPT_SOURCE_PREF_KEY);
throw new ValidatorException("File not found: " + this.scriptSourceUri, failedKeys);
}
this.groovyCodeSource.setCachable(!this.autoRefresh);
}
}