if (fileDir != null) {
// explicitly stated so
File dir = new File(fileDir);
if (dir.exists()) {
logger.info("ResourceManager initialised: type[file] [" + fileDir + "]");
return new FileResourceSource(fileDir);
} else {
String msg = "ResourceManager could not find directory [" + fileDir + "]";
throw new NotFoundException(msg);
}
}
// try to guess the directory starting from the current working
// directory, and searching to a maximum depth of 3 subdirectories
File guessDir = DirectoryFinder.find(null, "WEB-INF", 3);
if (guessDir != null) {
// Typically this means we found the WEB-INF directory below the
// current working directory
logger.info("ResourceManager initialised: type[file] [" + guessDir.getPath() + "]");
return new FileResourceSource(guessDir.getPath());
}
// default to the current working directory
File workingDir = new File(".");
return new FileResourceSource(workingDir);
}