use of org.apache.wicket.request.http.flow.AbortWithHttpErrorCodeException in project wicket by apache.
the class ResourceMapper method addCachingDecoration.
protected void addCachingDecoration(Url url, PageParameters parameters) {
final List<String> segments = url.getSegments();
final int lastSegmentAt = segments.size() - 1;
final String filename = segments.get(lastSegmentAt);
if (Strings.isEmpty(filename) == false) {
final IResource resource = resourceReference.getResource();
if (resource instanceof IStaticCacheableResource) {
final IStaticCacheableResource cacheable = (IStaticCacheableResource) resource;
if (cacheable.isCachingEnabled()) {
final ResourceUrl cacheUrl = new ResourceUrl(filename, parameters);
getCachingStrategy().decorateUrl(cacheUrl, cacheable);
if (Strings.isEmpty(cacheUrl.getFileName())) {
if (Application.exists() && Application.get().usesDeploymentConfig()) {
throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_NOT_FOUND, "caching strategy returned empty name for " + resource);
} else {
throw new IllegalStateException("caching strategy returned empty name for " + resource);
}
}
segments.set(lastSegmentAt, cacheUrl.getFileName());
}
}
}
}
Aggregations