public abstract class AbstractAssetHandler extends java.lang.Object implements AssetHandler
AbstractAssetHandler
serves as basis for all other asset handler implementations and provides common
used functionality.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PROPERTY_DEACTIVATED_MIME_TYPES
The property for deactivated mime types.
|
Constructor and Description |
---|
AbstractAssetHandler() |
Modifier and Type | Method and Description |
---|---|
boolean |
canHandleSubAssets()
Indicates if the handler supports processing of
sub assets |
void |
createThumbnails(Asset asset)
Creates thumbnails for this asset.
|
void |
createThumbnails(Asset asset,
java.util.Collection<ThumbnailConfig> configs)
Thumbnails of an asset are created during import/update of an asset and it's original binary.
|
void |
createThumbnails(Asset asset,
Rendition rendition,
java.util.Collection<ThumbnailConfig> configs)
|
void |
exportAsset(Asset asset,
java.io.OutputStream stream)
This method exports the asset into the given
OutputStream . |
java.awt.image.BufferedImage |
getImage(Rendition rendition)
|
java.awt.image.BufferedImage |
getImage(Rendition rendition,
java.awt.Dimension maxDimension)
|
java.util.Iterator<? extends AssetRelation> |
processRelated(Asset asset)
extracts and stores the links to the assets related with provided asset.
|
java.util.List<java.lang.String> |
processSubAssets(Asset asset)
Handler implementations may choose to support sub asset creation for the file types it handles.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
extractMetadata, getMimeTypes
public static java.lang.String PROPERTY_DEACTIVATED_MIME_TYPES
public void createThumbnails(Asset asset, java.util.Collection<ThumbnailConfig> configs) throws java.io.IOException
CreateThumbnailProcess
and the CommandLineProcess
as part of the DAM Update Asset workflow. Implementations
may choose to create asset thumbnails for every entry in the thumbnailConfigs
list 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 (see Asset.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); ...
createThumbnails
in interface AssetHandler
asset
- the asset/file for which the thumbnails are generatedconfigs
- thumbnail configurationsjava.io.IOException
- is thrown in case while an error occurred while fetching the imageAsset.addRendition(String, java.io.InputStream, String)
,
Asset.getRenditions()
,
)
,
Asset.getRendition(com.day.cq.dam.api.RenditionPicker)
public void createThumbnails(Asset asset) throws java.io.IOException
createThumbnails
in interface AssetHandler
asset
- The asset for which to create thumbnails.java.io.IOException
- If an error occurred while extracting the image.public void createThumbnails(Asset asset, Rendition rendition, java.util.Collection<ThumbnailConfig> configs) throws java.io.IOException
createThumbnails
in interface AssetHandler
asset
- The asset for which to created thumbnails.rendition
- The rendition serving as the thumbnail basis.configs
- The thumbnail configurations.java.io.IOException
- If an error occurred extracting an image from the rendition.public boolean canHandleSubAssets()
sub assets
canHandleSubAssets
in interface AssetHandler
true
if handler is able to process sub assetspublic java.util.List<java.lang.String> processSubAssets(Asset asset)
AssetHandler
CreateSubAssetsProcess
during 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 asset
argument represents the javax.jcr.Node
of type nt:file holding the binary
content or the DAM Asset node (type dam:Asset), for which its original rendition would be retrieved.processSubAssets
in interface AssetHandler
asset
- asset to extract sub assetsAssetHandler.canHandleSubAssets()
,
Asset.isSubAsset()
public java.util.Iterator<? extends AssetRelation> processRelated(Asset asset)
AssetHandler
processRelated
in interface AssetHandler
asset
- asset to processAssetRelation
or an empty iterator if no related assets are availablepublic java.awt.image.BufferedImage getImage(Rendition rendition) throws java.io.IOException
AssetHandler
Asset
s given Rendition
. For images the
BufferedImage
of the original image is returned, for other formats the first page is retrieved as
BufferedImage
getImage
in interface AssetHandler
rendition
- The rendition for which to retrieve its graphical representation.BufferedImage
if a graphical representation exists, otherwise null
java.io.IOException
- in case an error is thrown while fetching the buffered imagepublic java.awt.image.BufferedImage getImage(Rendition rendition, java.awt.Dimension maxDimension) throws java.io.IOException
AssetHandler
Asset
s given Rendition
. For images the
BufferedImage
of the original image is returned, for other formats the first page is retrieved as
BufferedImage
.
If maxDimension
is 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.
getImage
in interface AssetHandler
rendition
- The rendition for which to retrieve its graphical representation.maxDimension
- optional constraint for the maximal dimension of the image.BufferedImage
if a graphical representation exists, otherwise null
java.io.IOException
- in case an error is thrown while fetching the buffered imagepublic void exportAsset(Asset asset, java.io.OutputStream stream) throws AssetHandlerException
OutputStream
. The Asset
s original binary is
served.exportAsset
in interface AssetHandler
asset
- The asset to export.stream
- The output stream to export into.AssetHandlerException
- If an error occurred during export."Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"