resource.touch();
/* check whether this can now be found in a higher priority
* resource loader. if so, pass the request off to loadResource.
*/
ResourceLoader loader = DotResourceLoader.getInstance();
if (resourceLoaders.size() > 0 && resourceLoaders.indexOf(loader) > 0)
{
String name = resource.getName();
if (loader != getLoaderForResource(name))
{
return loadResource(name, resource.getType(), encoding);
}
}
if (resource.isSourceModified())
{
/*
* now check encoding info. It's possible that the newly declared
* encoding is different than the encoding already in the resource
* this strikes me as bad...
*/
if (!com.dotcms.repackage.org.apache.commons.lang.StringUtils.equals(resource.getEncoding(), encoding))
{
Logger.warn(this,"Declared encoding for template '" +
resource.getName() +
"' is different on reload. Old = '" +
resource.getEncoding() + "' New = '" + encoding);
resource.setEncoding(encoding);
}
/*
* read how old the resource is _before_
* processing (=>reading) it
*/
long howOldItWas = loader.getLastModified(resource);
String resourceKey = resource.getType() + resource.getName();
/*
* we create a copy to avoid partially overwriting a
* template which may be in use in another thread
*/
Resource newResource =
ResourceFactory.getResource(resource.getName(), resource.getType());
newResource.setName(resource.getName());
newResource.setEncoding(resource.getEncoding());
newResource.setModificationCheckInterval(loader.getModificationCheckInterval());
newResource.process();
newResource.setLastModified(howOldItWas);
resource = newResource;