@ProviderType public interface Asset extends Resource
Asset
represents a digital resource.
Asset is an extension of a Sling Resource, therefore its adaptable.
Asset is created by AssetManager
and can be retrieved either via AssetManager
or by
adapting a asset Resource
to an Asset
.
eg: // to create an asset AssetManager assetManager = resolver.adaptTo(AssetManager.class); Asset newAsset = assetManager.createAsset("/path/to/asset/document.pdf"); // to get an existing asset Asset asset = assetManager.getAsset("/path/to/asset/document.pdf"); // to get asset by adapting Asset asset = resource.adaptTo(Asset.class);
Asset properties can be retrieved or set by adapting it to a ValueMap.
eg: // to get Asset properties value map ValueMap map = asset.adaptTo(ValueMap.class);
Implementor's Note: Implementations are required to provide an adapter to a writable
ValueMap
.
AssetManager
,
ValueMap
RESOURCE_TYPE_NON_EXISTING
Modifier and Type | Method and Description |
---|---|
AssetRelation |
addRelation(java.lang.String name,
java.lang.String assetPath)
adds a new relation to this Asset.
|
AssetRelation |
addRelation(java.lang.String name,
java.lang.String assetPath,
java.util.Map<java.lang.String,java.lang.Object> map)
Adds a new relation to this Asset with additional properties
|
AssetMetadata |
getAssetMetadata()
Returns the metadata of this Asset.
|
java.lang.String |
getIdentifier()
Get unique Asset identifier
|
Rendition |
getRendition(java.lang.String name)
Returns a named
Rendition if available. |
java.util.Iterator<? extends Asset> |
listRelated(java.lang.String name)
Get all related Asset with the given name.
|
java.util.Iterator<? extends AssetRelation> |
listRelations(java.lang.String name)
Get asset relations for a given relation name.
|
java.util.Iterator<? extends Rendition> |
listRenditions()
Returns an iterator for all
Rendition s of this asset. |
void |
orderRelationBefore(java.lang.String name,
java.lang.String srcAssetPath,
java.lang.String destAssetPath)
This method inserts the related asset at
srcAssetPath
into the related asset list at the position immediately before the related asset at destAssetPath . |
void |
removeRelation(java.lang.String name)
Removes all relations for the given name.
|
void |
removeRelation(java.lang.String name,
java.lang.String assetPath)
Removes Asset relation.
|
void |
removeRendition(java.lang.String name)
Remove
Rendition with the given name. |
void |
setRelation(java.lang.String name,
java.lang.String assetPath)
Deprecated.
As of 1.3, please use
addRelation(String, String) |
Rendition |
setRendition(java.lang.String name,
Binary binary,
java.util.Map<java.lang.String,java.lang.Object> map)
Create or update the
Rendition . |
Rendition |
setRendition(java.lang.String name,
java.io.InputStream is,
java.util.Map<java.lang.String,java.lang.Object> map)
Create or update the
Rendition . |
getChild, getChildren, getName, getParent, getPath, getResourceMetadata, getResourceResolver, getResourceSuperType, getResourceType, getValueMap, hasChildren, isResourceType, listChildren
Rendition getRendition(java.lang.String name)
Rendition
if available.name
- Name of the Rendition to getAssetException
- If an error occurs trying to load the Rendition objectjava.util.Iterator<? extends Rendition> listRenditions()
Rendition
s of this asset.java.util.Iterator<? extends Asset> listRelated(java.lang.String name)
name
- Name of the related asset collectionjava.util.Iterator<? extends AssetRelation> listRelations(java.lang.String name)
name
- Name of the relationAssetRelation
or an empty iterator if relations cannot be found with the given name.AssetMetadata getAssetMetadata()
AssetMetadata
AssetRelation addRelation(java.lang.String name, java.lang.String assetPath, java.util.Map<java.lang.String,java.lang.Object> map)
name
- of the relation to be createdassetPath
- Path of the Asset to set a relation formap
- to be used to set additional relation properties.AssetRelation
AssetException
- if Asset relation cannot be set.@Deprecated void setRelation(java.lang.String name, java.lang.String assetPath)
addRelation(String, String)
name
- of the relation to be createdassetPath
- Path of the Asset to set a relation forAssetException
- if Asset relation cannot be set.AssetRelation addRelation(java.lang.String name, java.lang.String assetPath)
name
- of the relation to be createdassetPath
- Path of the Asset to set a relation forAssetRelation
AssetException
- if Asset relation cannot be set.void orderRelationBefore(java.lang.String name, java.lang.String srcAssetPath, java.lang.String destAssetPath)
srcAssetPath
into the related asset list at the position immediately before the related asset at destAssetPath
.
To insert the related asset into last position, destAssetPath
can be null.name
- Name of the relation to be orderedsrcAssetPath
- asset path that needs to be moved in the orderdestAssetPath
- path of the related asset before which the srcAssetPath
will be placed.java.lang.IllegalArgumentException
- if srcAssetPath is null or srcAssetPath is not related to Asset.
if srcAssetPath and destAssetPath represents the same Asset.void removeRelation(java.lang.String name, java.lang.String assetPath)
name
- of the relationassetPath
- Path of the Asset to be removed from the relationsAssetException
- if relation cannot be deletedvoid removeRelation(java.lang.String name)
name
- of the relationAssetException
- if relation cannot be deletedjava.lang.String getIdentifier()
Rendition setRendition(java.lang.String name, java.io.InputStream is, java.util.Map<java.lang.String,java.lang.Object> map)
Rendition
. If a rendition with the given name
already exists,
it will be replaced. Actual creation of rendition is delegated to the RenditionHandler
.name
- to be used for this renditionis
- InputStream to create this rendition or null if stream is not required by the RenditionHandlermap
- to be used by the rendition handler. If the map contains RenditionHandler.PROPERTY_ID
,
implementation is required to delegate to the RenditionHandler registered with this id. Otherwise, a default
rendition handler must be used. Implementations are free to define the semantics of what constitutes a
default rendition handler.AssetException
- if new rendition cannot be setjava.lang.NullPointerException
- if the given map is nullRendition setRendition(java.lang.String name, Binary binary, java.util.Map<java.lang.String,java.lang.Object> map)
Rendition
. If a rendition with the given name
already exists, it will
be replaced. Not like the setRendition(String, InputStream, Map)
, this method does not delegate to
any RenditionHandler
.name
- to be used for this renditionbinary
- binary to create this rendition or null if binary is not required by the RenditionHandlermap
- to be used for passing through mimeType etc. properties for the rendition. Not like the setRendition(String, InputStream, Map)
, this method does not delegate to any RenditionHandler
. so any renditionHandlerID passed through the map does not work hereAssetException
- if new rendition cannot be setjava.lang.NullPointerException
- if the given map is nullvoid removeRendition(java.lang.String name)
Rendition
with the given name.name
- of the RenditionAssetException
- if Rendition cannot be removedCopyright © 2010 - 2020 Adobe. All Rights Reserved