Package org.ametys.core.resources
Class ImageResourceHandler
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.resources.DefaultResourceHandler
-
- org.ametys.core.resources.ImageResourceHandler
-
- All Implemented Interfaces:
ResourceHandler,LogEnabled,Serviceable
- Direct Known Subclasses:
PdfCoverResourceHandler
public class ImageResourceHandler extends DefaultResourceHandler
Resource handler for images
-
-
Field Summary
Fields Modifier and Type Field Description private static Collection<String>__ALLOWED_OUTPUT_FORMATSprivate static Collection<String>__UNRESIZABLE_FORMATSprivate int_cropHeightprivate int_cropWidthprivate boolean_downloadprivate int_heightprivate int_maxHeightprivate int_maxWidthprivate static Pattern_SIZE_PATTERNprivate int_width-
Fields inherited from class org.ametys.core.resources.DefaultResourceHandler
_objectModel, _parameters, _readForDownload, _requestedLocation, _resolver, _source
-
-
Constructor Summary
Constructors Constructor Description ImageResourceHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean_processImage(String fileExtension)voidgenerate(OutputStream out)Generate the resource configured during setup, and output itSerializablegetKey()Get the unique key for this resource, for cache purpose.Sourcesetup(String location, Map objectModel, Parameters par, boolean readForDownload)Initialize the resource handler with a resource.-
Methods inherited from class org.ametys.core.resources.DefaultResourceHandler
getLastModified, getLength, getMimeType, getValidity, service
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ametys.core.resources.ResourceHandler
shouldUseSourceContentLength
-
-
-
-
Field Detail
-
_SIZE_PATTERN
private static final Pattern _SIZE_PATTERN
-
__ALLOWED_OUTPUT_FORMATS
private static final Collection<String> __ALLOWED_OUTPUT_FORMATS
-
__UNRESIZABLE_FORMATS
private static final Collection<String> __UNRESIZABLE_FORMATS
-
_height
private int _height
-
_width
private int _width
-
_maxHeight
private int _maxHeight
-
_maxWidth
private int _maxWidth
-
_cropHeight
private int _cropHeight
-
_cropWidth
private int _cropWidth
-
_download
private boolean _download
-
-
Constructor Detail
-
ImageResourceHandler
public ImageResourceHandler()
-
-
Method Detail
-
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 classDefaultResourceHandler- 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
-
generate
public void generate(OutputStream out) throws IOException, ProcessingException
Description copied from interface:ResourceHandlerGenerate the resource configured during setup, and output it- Specified by:
generatein interfaceResourceHandler- Overrides:
generatein classDefaultResourceHandler- Parameters:
out- The output stream to write to- Throws:
IOException- If an error occursProcessingException- If an error occurs
-
_processImage
private boolean _processImage(String fileExtension)
-
getKey
public Serializable getKey()
Description copied from interface:ResourceHandlerGet the unique key for this resource, for cache purpose.- Specified by:
getKeyin interfaceResourceHandler- Overrides:
getKeyin classDefaultResourceHandler- Returns:
- The cache key.
-
-