Package com.day.cq.dam.api
Interface AssetManager
-
public interface AssetManagerTheAssetManagerprovides utility methods for assets.The asset manager can be retrieved as follows:
... AssetManager manager = resourceResolver.adaptTo(AssetManager.class); ...
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description java.lang.StringassignAssetID(Asset asset)Ask Asset ID Provider (associated with Asset Manager) to assign ID (if needed) to an asset and establish its parentage (dam:parentAssetID)AssetcreateAsset(java.lang.String path, java.io.InputStream is, java.lang.String mimeType, boolean doSave)Deprecated.In AEM as a Cloud Service, assets should instead take advantage of direct binary access.AssetcreateAssetForBinary(java.lang.String binaryPath, boolean doSave)Deprecated.In AEM as a Cloud Service, assets should instead take advantage of direct binary access.AssetcreateOrReplaceAsset(java.lang.String path, Binary binary, java.lang.String mimeType, boolean doSave)Creates a newAssetat the givenpath.AssetcreateOrUpdateAsset(java.lang.String path, Binary binary, java.lang.String mimeType, boolean doSave)Creates a newAssetat the givenpath.AssetcreateOrUpdateAsset(java.lang.String path, Binary binary, java.lang.String mimeType, boolean doSave, boolean createRevision, java.lang.String revisionLabel, java.lang.String revisionComment)Creates a newAssetat the givenpath.RevisioncreateRevision(Asset asset, java.lang.String label, java.lang.String comment)Create a newRevisionof the asset.RevisioncreateRevision(Asset asset, java.lang.String label, java.lang.String comment, User versionCreator)Create a newRevisionof the asset.AssetgetAssetForBinary(java.lang.String binaryPath)Deprecated.This method was used by an older paradigm of asset upload, where a binary would be uploaded to /var with an asset separately created under /content.java.util.Collection<Revision>getRevisions(java.lang.String path, java.util.Calendar cal)Lists all availableRevisions.booleanremoveAssetForBinary(java.lang.String binaryPath)Deprecated.This method was used by an older paradigm of asset upload, where a binary would be uploaded to /var with an asset separately created under /content.Assetrestore(java.lang.String revisionId)Restores anAsset.
-
-
-
Method Detail
-
restore
Asset restore(java.lang.String revisionId) throws java.lang.Exception
Restores anAsset.- Parameters:
revisionId- revision id- Returns:
- the restored
Asset - Throws:
java.lang.Exception- Upon encountering an error while restoring an asset.
-
getRevisions
java.util.Collection<Revision> getRevisions(java.lang.String path, java.util.Calendar cal) throws java.lang.Exception
Lists all availableRevisions.- Parameters:
path- path of assetcal- starting date to search revisions ornullin order to fetch all- Returns:
- all available
Revisions - Throws:
java.lang.Exception- Upon encountering an error while getting the revisions for an asset.
-
createAssetForBinary
@Deprecated Asset createAssetForBinary(java.lang.String binaryPath, boolean doSave)
Deprecated.In AEM as a Cloud Service, assets should instead take advantage of direct binary access. A discussion of this change as well as an SDK to ease implementation of this new pattern can be found at aem-upload.This method creates the complete asset structure in /content/dam. The following structure is created: <xmp> + file.jpg (dam:Asset) + jcr:content )(dam:AssetContent) + renditions (sling:OrderedFolder) + metadata (nt:unstructured)</xmp>
The given
binaryPathis translated into the final asset location (seeDamUtil.binaryToAssetPath(String)).- Parameters:
binaryPath- The path of the asset's binary in /var/dam.doSave- Whether the repository changes are saved or not.- Returns:
- The newly created asset or
nullif the binaryPath cannot be handled - See Also:
- aem-upload
-
getAssetForBinary
@Deprecated Asset getAssetForBinary(java.lang.String binaryPath)
Deprecated.This method was used by an older paradigm of asset upload, where a binary would be uploaded to /var with an asset separately created under /content. In AEM as a Cloud Service, assets should instead take advantage of direct binary access. As a result, this method should no longer be needed. A discussion of this change as well as an SDK to ease implementation of this new pattern can be found at aem-upload.Returns theResourceof theAssetcorresponding to the binary given with thepathparameter.DamUtil.getAssetNode("/var/dam/myfolder/test.jpg", session) = Resource("/content/dam/myfolder/test.jpg")- Parameters:
binaryPath- The path of the binary.- Returns:
- The resource representing the binary's asset, or
nullif it couldn't be found. - See Also:
- aem-upload
-
removeAssetForBinary
@Deprecated boolean removeAssetForBinary(java.lang.String binaryPath)
Deprecated.This method was used by an older paradigm of asset upload, where a binary would be uploaded to /var with an asset separately created under /content. In AEM as a Cloud Service, assets should instead take advantage of direct binary access. As a result, this method should no longer be needed. A discussion of this change as well as an SDK to ease implementation of this new pattern can be found at aem-upload.Removes theNodeof theAssetcorresponding to the binary given with thepathparameter.DamUtil.removeAssetNode("/var/dam/myfolder/test.jpg", session) =i> Delete Node("/content/dam/myfolder/test.jpg")- Parameters:
binaryPath- The path of the binary.- Returns:
trueif the asset was successfully removed.- See Also:
- aem-upload
-
createAsset
@Deprecated Asset createAsset(java.lang.String path, java.io.InputStream is, java.lang.String mimeType, boolean doSave)
Deprecated.In AEM as a Cloud Service, assets should instead take advantage of direct binary access. A discussion of this change as well as an SDK to ease implementation of this new pattern can be found at aem-upload.Creates a newAssetat the givenpath. If an asset already exists at the givenpath, its original rendition is updated instead of creating a new asset. If inputStream is null newAssetis created without original rendition. If an asset already exists at given path and inputstream is null, original rendition is not updated.- Parameters:
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.- Returns:
- The newly created asset or
nullif something exists at the given path already or there was an unexpected error - See Also:
- aem-upload
-
createOrUpdateAsset
Asset createOrUpdateAsset(java.lang.String path, Binary binary, java.lang.String mimeType, boolean doSave)
Creates a newAssetat the givenpath. If an asset already exists at the givenpath, its original rendition is updated instead of creating a new asset. If binary is null newAssetis created without original rendition. If an asset already exists at given path, original rendition is not updated.- Parameters:
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.- Returns:
- The newly created asset or
nullif something exists at the given path already or there was an unexpected error
-
createOrUpdateAsset
Asset createOrUpdateAsset(java.lang.String path, Binary binary, java.lang.String mimeType, boolean doSave, boolean createRevision, java.lang.String revisionLabel, java.lang.String revisionComment)
Creates a newAssetat the givenpath. If an asset already exists at the givenpath, its original rendition is updated instead of creating a new asset. If binary is null newAssetis created without original rendition. If an asset already exists at given path, original rendition is not updated. If asset already exists and create revision is true, the given revision label and revision comment will be used to create a new revision.- Parameters:
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.createRevision- Whether or not a new revision will be created.revisionLabel- The label to associate with the newly created revision.revisionComment- The comment to associate with the newly created revision.- Returns:
- The newly created asset or
nullif something exists at the given path already or there was an unexpected error
-
createOrReplaceAsset
Asset createOrReplaceAsset(java.lang.String path, Binary binary, java.lang.String mimeType, boolean doSave)
Creates a newAssetat the givenpath. If an asset already exists at the givenpath, it will be removed and re-created. If binary is null newAssetis created without original rendition.- Parameters:
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.- Returns:
- The newly created asset or
nullthere was an unexpected error.
-
createRevision
Revision createRevision(Asset asset, java.lang.String label, java.lang.String comment) throws java.lang.Exception
Create a newRevisionof the asset. The revision will be created as a standard JCR version of the underlying asset node. Owner of the session through whichAssetwas created is added asDamConstants.PN_VERSION_CREATORof the asset.- Parameters:
asset- The asset to versionlabel- version labelcomment- version comment- Returns:
- The created revision
- Throws:
java.lang.Exception- Thrown when an error during version creation occurred.
-
createRevision
Revision createRevision(Asset asset, java.lang.String label, java.lang.String comment, User versionCreator) throws java.lang.Exception
Create a newRevisionof 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 aDamConstants.PN_VERSION_CREATORof the asset being versioned.- Parameters:
asset- The asset to versionlabel- version labelcomment- version commentversionCreator- version creator. If null, this API is equivalent tocreateRevision(com.day.cq.dam.api.Asset,java.lang.String,java.lang.String)- Returns:
- The created revision
- Throws:
java.lang.Exception- Thrown when an error during version creation occurred.
-
assignAssetID
java.lang.String assignAssetID(Asset asset) throws PathNotFoundException, RepositoryException
Ask Asset ID Provider (associated with Asset Manager) to assign ID (if needed) to an asset and establish its parentage (dam:parentAssetID)- Parameters:
asset- The asset to update- Returns:
- The ID assigned to the asset
- Throws:
RepositoryException- thrown if an error occurs while accessing the assetPathNotFoundException- thrown if no item exists in the path
-
-