Class AbstractServletResourceReferenceHandler<R extends org.xwiki.resource.ResourceReference>

  • Type Parameters:
    R - the resource type
    All Implemented Interfaces:
    Comparable<org.xwiki.resource.ResourceReferenceHandler>, org.xwiki.resource.ResourceReferenceHandler<org.xwiki.resource.ResourceType>

    public abstract class AbstractServletResourceReferenceHandler<R extends org.xwiki.resource.ResourceReference>
    extends org.xwiki.resource.AbstractResourceReferenceHandler<org.xwiki.resource.ResourceType>
    Base class for ResourceReferenceHandlers that can handle servlet resource requests.
    Since:
    7.4.6, 8.2.2, 8.3
    Version:
    $Id: 7cdb6d3004be4351e89bd8c28d51885c39f32b39 $
    • Constructor Detail

      • AbstractServletResourceReferenceHandler

        public AbstractServletResourceReferenceHandler()
    • Method Detail

      • handle

        public void handle​(org.xwiki.resource.ResourceReference resourceReference,
                           org.xwiki.resource.ResourceReferenceHandlerChain chain)
                    throws org.xwiki.resource.ResourceReferenceHandlerException
        Throws:
        org.xwiki.resource.ResourceReferenceHandlerException
      • isResourceAccessible

        protected boolean isResourceAccessible​(R resourceReference)
        Parameters:
        resourceReference - the reference of the requested resource
        Returns:
        true if the specified resource is accessible, false otherwise
      • isResourceCacheable

        protected boolean isResourceCacheable​(R resourceReference)
        Parameters:
        resourceReference - a resource reference
        Returns:
        true if the specified resource can be cached, false otherwise
      • getResourceStream

        protected abstract InputStream getResourceStream​(R resourceReference)
        Parameters:
        resourceReference - the reference of the requested resource
        Returns:
        the stream that can be used to read the resource
      • getResourceName

        protected abstract String getResourceName​(R resourceReference)
        Parameters:
        resourceReference - the reference of the requested resource
        Returns:
        the name of the specified resource
      • getContentType

        protected String getContentType​(InputStream resourceStream,
                                        R resourceReference)
                                 throws IOException
        Computes the content type of the resource. By default the content type is inferred by TikaUtils.detect(InputStream, String) based on the resource content and name.
        Parameters:
        resourceStream - the stream of the requested resource
        resourceReference - the reference of the request resource
        Returns:
        the content type of the resource
        Throws:
        IOException - in case of error during the content type analysis
        Since:
        13.3RC1
      • filterResource

        protected InputStream filterResource​(R resourceReference,
                                             InputStream resourceStream)
                                      throws org.xwiki.resource.ResourceReferenceHandlerException
        Filter the resource before sending it to the client.
        Parameters:
        resourceReference - the resource to filter
        resourceStream - the resource content
        Returns:
        the filtered resource content
        Throws:
        org.xwiki.resource.ResourceReferenceHandlerException