* throw an AbortException when resource does not exist
*/
public IResourceStream getResourceStream(boolean failOnError)
{
// Locate resource
IResourceStream resourceStream = Application.get()
.getResourceSettings()
.getResourceStreamLocator()
.locate(getScope(), absolutePath, style, locale, null);
// Check that resource was found
if (resourceStream == null)
{
if (!failOnError)
{
// Do not abort the request, as we are not yet serving the resource
return null;
}
String msg = "Unable to find package resource [path = " + absolutePath + ", style = " +
style + ", locale = " + locale + "]";
log.warn(msg);
if (RequestCycle.get() instanceof WebRequestCycle)
{
throw new AbortWithWebErrorCodeException(HttpServletResponse.SC_NOT_FOUND, msg);
}
else
{
throw new AbortException();
}
}
locale = resourceStream.getLocale();
if (resourceStream != null)
{
lastModifiedTime = resourceStream.lastModifiedTime();
lastModifiedTimeUpdate = System.currentTimeMillis();
}
return resourceStream;
}