Package com.day.cq.dam.commons.handler
Class AbstractAssetHandler
java.lang.Object
com.day.cq.dam.commons.handler.AbstractAssetHandler
- All Implemented Interfaces:
AssetHandler
- Direct Known Subclasses:
StandardImageHandler
The
AbstractAssetHandler serves as basis for all other asset handler implementations and provides common
used functionality.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates if the handler supports processing ofsub assetsvoidcreateThumbnails(Asset asset) Creates thumbnails for this asset.voidcreateThumbnails(Asset asset, Rendition rendition, Collection<ThumbnailConfig> configs) voidcreateThumbnails(Asset asset, Collection<ThumbnailConfig> configs) Thumbnails of an asset are created during import/update of an asset and it's original binary.voidexportAsset(Asset asset, OutputStream stream) This method exports the asset into the givenOutputStream.Iterator<? extends AssetRelation> processRelated(Asset asset) extracts and stores the links to the assets related with provided asset.processSubAssets(Asset asset) Handler implementations may choose to support sub asset creation for the file types it handles.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.day.cq.dam.api.handler.AssetHandler
extractMetadata, getMimeTypes
-
Field Details
-
PROPERTY_DEACTIVATED_MIME_TYPES
The property for deactivated mime types.
-
-
Constructor Details
-
AbstractAssetHandler
public AbstractAssetHandler()
-
-
Method Details
-
createThumbnails
Thumbnails of an asset are created during import/update of an asset and it's original binary. Currently this method is used by theCreateThumbnailProcessand theCommandLineProcessas part of the DAM Update Asset workflow. Implementations may choose to create asset thumbnails for every entry in thethumbnailConfigslist argument, to not create any thumbnails at all, or to create a generic thumbnail independent of the given config. Thumbnails themselves are renditions of an asset and must be persisted as such (seeAsset.addRendition(String, java.io.InputStream, String)).The thumbnail renditions are created depending on the given configuration list:
Sample:{ height:h1, width: w1, doCenter: true (or false) }, { ... }... final ArrayList<Map<String, Object>> config = new ArrayList<Map<String, Object>>(); config.add(new HashMap<String, Object>() {{ put("width", 140); put("height", 100); put("doCenter", true); }}); config.add(new HashMap<String, Object>() {{ put("width", 80); put("height", 80); put("doCenter", true); }}); handler.createThumbnailsExt( getTiff(), asset.adaptTo(Node.class).getNode("jcr:content/renditions"), session, config); ...- Specified by:
createThumbnailsin interfaceAssetHandler- Parameters:
asset- the asset/file for which the thumbnails are generatedconfigs- thumbnail configurations- Throws:
IOException- is thrown in case while an error occurred while fetching the image- See Also:
-
createThumbnails
Creates thumbnails for this asset. Which thumbnails are created is automatically derived from the existing thumbnails (renditions with the cq5dam.thumbnail prefix). This essentially amounts to re-creating existing thumbnails.- Specified by:
createThumbnailsin interfaceAssetHandler- Parameters:
asset- The asset for which to create thumbnails.- Throws:
IOException- If an error occurred while extracting the image.
-
createThumbnails
public void createThumbnails(Asset asset, Rendition rendition, Collection<ThumbnailConfig> configs) throws IOException - Specified by:
createThumbnailsin interfaceAssetHandler- Parameters:
asset- The asset for which to created thumbnails.rendition- The rendition serving as the thumbnail basis.configs- The thumbnail configurations.- Throws:
IOException- If an error occurred extracting an image from the rendition.
-
canHandleSubAssets
public boolean canHandleSubAssets()Indicates if the handler supports processing ofsub assets- Specified by:
canHandleSubAssetsin interfaceAssetHandler- Returns:
trueif handler is able to process sub assets
-
processSubAssets
Description copied from interface:AssetHandlerHandler implementations may choose to support sub asset creation for the file types it handles. The method is called by theCreateSubAssetsProcessduring import/update of an asset and its binary, as part of the DAM Update Asset workflow. Sub assets represent fragments of the original asset, for example every page of a multi-page PDF document are sub assets. Sub assets are stored as assets themselves under the parent asset. Sub assets are stored in the subassets folder of the main asset, e.g. at /content/dam/geometrixx/documents/ECM Artikel.pdf/subassets.The
assetargument represents theNodeof type nt:file holding the binary content or the DAM Asset node (type dam:Asset), for which its original rendition would be retrieved.- Specified by:
processSubAssetsin interfaceAssetHandler- Parameters:
asset- asset to extract sub assets- Returns:
- List constaining all paths to the newly created assets
- See Also:
-
processRelated
Description copied from interface:AssetHandlerextracts and stores the links to the assets related with provided asset.- Specified by:
processRelatedin interfaceAssetHandler- Parameters:
asset- asset to process- Returns:
- Iterator of
AssetRelationor an empty iterator if no related assets are available
-
getImage
Description copied from interface:AssetHandlerThis method retrieves the graphical representation of anAssets givenRendition. For images theBufferedImageof the original image is returned, for other formats the first page is retrieved asBufferedImage- Specified by:
getImagein interfaceAssetHandler- Parameters:
rendition- The rendition for which to retrieve its graphical representation.- Returns:
BufferedImageif a graphical representation exists, otherwisenull- Throws:
IOException- in case an error is thrown while fetching the buffered image
-
getImage
Description copied from interface:AssetHandlerThis method retrieves the graphical representation of anAssets givenRendition. For images theBufferedImageof the original image is returned, for other formats the first page is retrieved asBufferedImage.If
maxDimensionis given, the handler should return an image where no dimension extends the given value. This can be used to reduce the memory footprint of large buffered images if the full resolution is not needed.- Specified by:
getImagein interfaceAssetHandler- Parameters:
rendition- The rendition for which to retrieve its graphical representation.maxDimension- optional constraint for the maximal dimension of the image.- Returns:
BufferedImageif a graphical representation exists, otherwisenull- Throws:
IOException- in case an error is thrown while fetching the buffered image
-
exportAsset
This method exports the asset into the givenOutputStream. TheAssets original binary is served.- Specified by:
exportAssetin interfaceAssetHandler- Parameters:
asset- The asset to export.stream- The output stream to export into.- Throws:
AssetHandlerException- If an error occurred during export.
-