* an error has been sent back to the client)
* @throws IOException
*/
private Resource findResourceAndValidateDigest(Response response, String resourcePath) throws IOException
{
Resource resource = new ClasspathResource(resourcePath);
if (!_resourceCache.requiresDigest(resource)) return resource;
String file = resource.getFile();
// Somehow this code got real ugly, but it's all about preventing NPEs when a resource
// that should have a digest doesn't.
boolean valid = false;
Resource result = resource;
int lastdotx = file.lastIndexOf('.');
if (lastdotx > 0)
{
int prevdotx = file.lastIndexOf('.', lastdotx - 1);
if (prevdotx > 0)
{
String requestDigest = file.substring(prevdotx + 1, lastdotx);
// Strip the digest out of the file name.
String realFile = file.substring(0, prevdotx) + file.substring(lastdotx);
result = resource.forFile(realFile);
String actualDigest = _resourceCache.getDigest(result);
valid = requestDigest.equals(actualDigest);
}