Search in sources :

Example 6 with AbortWithHttpErrorCodeException

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());
            }
        }
    }
}
Also used : IStaticCacheableResource(org.apache.wicket.request.resource.caching.IStaticCacheableResource) AbortWithHttpErrorCodeException(org.apache.wicket.request.http.flow.AbortWithHttpErrorCodeException) IResource(org.apache.wicket.request.resource.IResource) ResourceUrl(org.apache.wicket.request.resource.caching.ResourceUrl)

Aggregations

AbortWithHttpErrorCodeException (org.apache.wicket.request.http.flow.AbortWithHttpErrorCodeException)6 Vertex (com.tinkerpop.blueprints.Vertex)3 OrientGraph (com.tinkerpop.blueprints.impls.orient.OrientGraph)3 Template (eu.esdihumboldt.hale.server.model.Template)3 User (eu.esdihumboldt.hale.server.model.User)3 NonUniqueResultException (eu.esdihumboldt.util.blueprints.entities.NonUniqueResultException)3 Label (org.apache.wicket.markup.html.basic.Label)3 StringValue (org.apache.wicket.util.string.StringValue)3 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 PopoverConfig (de.agilecoders.wicket.core.markup.html.bootstrap.components.PopoverConfig)1 TransformationWorkspace (eu.esdihumboldt.hale.common.headless.transform.TransformationWorkspace)1 DeleteTemplateLink (eu.esdihumboldt.hale.server.templates.war.components.DeleteTemplateLink)1 ProjectURLPopover (eu.esdihumboldt.hale.server.templates.war.components.ProjectURLPopover)1 ResourcesPanel (eu.esdihumboldt.hale.server.templates.war.components.ResourcesPanel)1 TemplateForm (eu.esdihumboldt.hale.server.templates.war.components.TemplateForm)1 TemplateUploadForm (eu.esdihumboldt.hale.server.templates.war.components.TemplateUploadForm)1 JobPanel (eu.esdihumboldt.hale.server.webapp.components.JobPanel)1 HTMLPopoverBehavior (eu.esdihumboldt.hale.server.webapp.components.bootstrap.HTMLPopoverBehavior)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1