Package org.xwiki.resource.servlet
Class AbstractServletResourceReferenceHandler<R extends org.xwiki.resource.ResourceReference>
- java.lang.Object
-
- org.xwiki.resource.AbstractResourceReferenceHandler<org.xwiki.resource.ResourceType>
-
- org.xwiki.resource.servlet.AbstractServletResourceReferenceHandler<R>
-
- 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 forResourceReferenceHandler
s that can handle servlet resource requests.- Since:
- 7.4.6, 8.2.2, 8.3
- Version:
- $Id: 7cdb6d3004be4351e89bd8c28d51885c39f32b39 $
-
-
Constructor Summary
Constructors Constructor Description AbstractServletResourceReferenceHandler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected InputStream
filterResource(R resourceReference, InputStream resourceStream)
Filter the resource before sending it to the client.protected String
getContentType(InputStream resourceStream, R resourceReference)
Computes the content type of the resource.protected abstract String
getResourceName(R resourceReference)
protected abstract InputStream
getResourceStream(R resourceReference)
void
handle(org.xwiki.resource.ResourceReference resourceReference, org.xwiki.resource.ResourceReferenceHandlerChain chain)
protected boolean
isResourceAccessible(R resourceReference)
protected boolean
isResourceCacheable(R resourceReference)
-
Methods inherited from class org.xwiki.resource.AbstractResourceReferenceHandler
compareTo, getPriority, setPriority
-
-
-
-
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 byTikaUtils.detect(InputStream, String)
based on the resource content and name.- Parameters:
resourceStream
- the stream of the requested resourceresourceReference
- 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 filterresourceStream
- the resource content- Returns:
- the filtered resource content
- Throws:
org.xwiki.resource.ResourceReferenceHandlerException
-
-