Package org.ametys.core.resources
Class ImageResourceHandler
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.core.resources.SimpleResourceHandler
org.ametys.core.resources.ImageResourceHandler
- All Implemented Interfaces:
ResourceHandler,LogEnabled,Serviceable
- Direct Known Subclasses:
PdfCoverResourceHandler,WebImageResourceHandler
Resource handler for images
-
Field Summary
FieldsFields inherited from class org.ametys.core.resources.SimpleResourceHandler
_objectModel, _parameters, _readForDownload, _requestedLocation, _resolver, _source -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructorImageResourceHandler(org.ametys.core.resources.ImageResourceHandler.SizedSource sizedSource) If theSourceis already resolved by theResourceHandlerProvider, it may provide it through the constructor to avoid resolving it again. -
Method Summary
Modifier and TypeMethodDescriptionvoidgenerate(OutputStream out) Generate the resource configured during setup, and output itgetKey()Get the unique key for this resource, for cache purpose.protected booleanisUnsafeSVG(String sourceURI) Is the SVG file denoted by the uri potentially unsafe?setup(String location, Map objectModel, Parameters par, boolean readForDownload) Initialize the resource handler with a resource.Methods inherited from class org.ametys.core.resources.SimpleResourceHandler
getLastModified, getMimeType, getValidity, serviceMethods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLoggerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.ametys.core.resources.ResourceHandler
acceptRanges, generate, getLength, shouldUseSourceContentLength
-
Field Details
-
SAFE_SVG_PATTERN
url for safe svg files
-
-
Constructor Details
-
ImageResourceHandler
public ImageResourceHandler()Default constructor -
ImageResourceHandler
If theSourceis already resolved by theResourceHandlerProvider, it may provide it through the constructor to avoid resolving it again.- Parameters:
sizedSource- the source.
-
-
Method Details
-
setup
public Source setup(String location, Map objectModel, Parameters par, boolean readForDownload) throws IOException, ProcessingException Description copied from interface:ResourceHandlerInitialize the resource handler with a resource.- Specified by:
setupin interfaceResourceHandler- Overrides:
setupin classSimpleResourceHandler- Parameters:
location- The source uriobjectModel- The object modelpar- The parametersreadForDownload- if the resource is to be downloaded and not rendered.- Returns:
- the resolved source
- Throws:
IOException- If an error occursProcessingException- If an error occurs
-
isUnsafeSVG
Is the SVG file denoted by the uri potentially unsafe?- Parameters:
sourceURI- The svg file uri- Returns:
- true if the svg is not from a trusted source
-
generate
Description copied from interface:ResourceHandlerGenerate the resource configured during setup, and output it- Specified by:
generatein interfaceResourceHandler- Overrides:
generatein classSimpleResourceHandler- Parameters:
out- The output stream to write to- Throws:
IOException- If an error occursProcessingException- If an error occurs
-
getKey
Description copied from interface:ResourceHandlerGet the unique key for this resource, for cache purpose.- Specified by:
getKeyin interfaceResourceHandler- Overrides:
getKeyin classSimpleResourceHandler- Returns:
- The cache key.
-