public interface AssetManager
AssetManager
provides utility methods for assets.
The asset manager can be retrieved as follows:
... AssetManager manager = resourceResolver.adaptTo(AssetManager.class); ...
Modifier and Type | Method and Description |
---|---|
java.lang.String |
assignAssetID(Asset asset)
Ask Asset ID Provider (associated with Asset Manager) to assign ID
(if needed) to an asset and establish its parentage (dam:parentAssetID)
|
Asset |
createAsset(java.lang.String path,
java.io.InputStream is,
java.lang.String mimeType,
boolean doSave)
Creates a new
Asset at the given path . |
Asset |
createAssetForBinary(java.lang.String binaryPath,
boolean doSave)
This method creates the complete asset structure in /content/dam.
|
Revision |
createRevision(Asset asset,
java.lang.String label,
java.lang.String comment)
Create a new
Revision of the asset. |
Asset |
getAssetForBinary(java.lang.String binaryPath)
|
java.util.Collection<Revision> |
getRevisions(java.lang.String path,
java.util.Calendar cal)
Lists all available
Revision s. |
boolean |
removeAssetForBinary(java.lang.String binaryPath)
|
Asset |
restore(java.lang.String revisionId)
Restores an
Asset . |
Asset restore(java.lang.String revisionId) throws java.lang.Exception
Asset
.revisionId
- revision idAsset
java.lang.Exception
- Upon encountering an error while restoring an asset.java.util.Collection<Revision> getRevisions(java.lang.String path, java.util.Calendar cal) throws java.lang.Exception
Revision
s.path
- path of assetcal
- starting date to search revisions or null
in order to fetch allRevision
sjava.lang.Exception
- Upon encountering an error while getting the revisions for an asset.Asset createAssetForBinary(java.lang.String binaryPath, boolean doSave)
binaryPath
is translated into the final asset location (see DamUtil.binaryToAssetPath(String)
).
binaryPath
- The path of the asset's binary in /var/dam.doSave
- Whether the repository changes are saved or not.null
if the binaryPath cannot be handledAsset getAssetForBinary(java.lang.String binaryPath)
Resource
of the Asset
corresponding to the binary given with the path
parameter.
DamUtil.getAssetNode("/var/dam/myfolder/test.jpg", session) = Resource("/content/dam/myfolder/test.jpg")
binaryPath
- The path of the binary.null
if it couldn't be found.boolean removeAssetForBinary(java.lang.String binaryPath)
javax.jcr.Node
of the Asset
corresponding to the binary given with the
path
parameter.
DamUtil.removeAssetNode("/var/dam/myfolder/test.jpg", session) =i> Delete Node("/content/dam/myfolder/test.jpg")
binaryPath
- The path of the binary.true
if the asset was successfully removed.Asset createAsset(java.lang.String path, java.io.InputStream is, java.lang.String mimeType, boolean doSave)
Asset
at the given path
. If an asset
already exists at the given path
, its original rendition is
updated instead of creating a new asset. If inputStream is null new
Asset
is created without original rendition. If an asset already
exists at given path and inputstream is null, original rendition is not
updated.path
- The path of the asset to be created.is
- The input stream of the new asset's original binary.mimeType
- The mime type of the new asset's original binary.doSave
- Whether the repository changes are saved or not.null
if something exists at the given path already
or there was an unexpected errorRevision createRevision(Asset asset, java.lang.String label, java.lang.String comment) throws java.lang.Exception
Revision
of the asset. The revision will be created as a standard JCR version of the
underlying asset node.asset
- The asset to versionlabel
- version labelcomment
- version commentjava.lang.Exception
- Thrown when an error during version creation occurred.java.lang.String assignAssetID(Asset asset) throws PathNotFoundException, RepositoryException
asset
- The asset to updateRepositoryException
PathNotFoundException
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"