@ProviderType
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.
|
Asset |
createOrUpdateAsset(java.lang.String path,
Binary binary,
java.lang.String mimeType,
boolean doSave)
Creates a new
Asset at the given path . |
Revision |
createRevision(Asset asset,
java.lang.String label,
java.lang.String comment)
Create a new
Revision of the asset. |
Revision |
createRevision(Asset asset,
java.lang.String label,
java.lang.String comment,
User versionCreator)
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)
</xmp>
The given 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)
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 errorAsset createOrUpdateAsset(java.lang.String path, Binary binary, 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 binary is null new
Asset
is created without original rendition. If an asset already exists at given path, original rendition
is not updated.path
- The path of the asset to be created.binary
- The binary for new asset's originalmimeType
- 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. Owner of the session through which Asset
was created is added as
DamConstants.PN_VERSION_CREATOR
of the asset.asset
- The asset to versionlabel
- version labelcomment
- version commentjava.lang.Exception
- Thrown when an error during version creation occurred.Revision createRevision(Asset asset, java.lang.String label, java.lang.String comment, User versionCreator) throws java.lang.Exception
Revision
of the asset. The revision will be created as a standard JCR version of the
underlying asset node. This API allows specifying principal of an AEM User to be added a
DamConstants.PN_VERSION_CREATOR
of the asset being versioned.asset
- The asset to versionlabel
- version labelcomment
- version commentversionCreator
- version creator. If null, this API is equivalent to
createRevision(Asset asset, String label, String comment)
java.lang.Exception
- Thrown when an error during version creation occurred.java.lang.String assignAssetID(Asset asset) throws PathNotFoundException, RepositoryException
asset
- The asset to updateRepositoryException
- thrown if an error occurs while accessing the assetPathNotFoundException
- thrown if no item exists in the pathCopyright © 2010 - 2020 Adobe. All Rights Reserved