|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Asset
The Asset interface describes the digital asset with its methods.
| Method Summary | |
|---|---|
Revision |
createRevision(String label,
String comment)
Create a new Revision of the asset. |
Resource |
getCurrentOriginal()
Returns the Resource representing the asset's rendition currently marked as
the asset's unmodified, original version. |
long |
getLastModified()
Returns the date of last modification of the asset's main content node (jcr:lastModified property). |
Map<String,Object> |
getMetadata()
Returns all available metadata as map. |
Object |
getMetadata(String name)
Returns the generic metadata value of an asset by the given property name. |
String |
getMetadataValue(String name)
Returns the metadata String value of an asset by the given property name. |
String |
getModifier()
Returns the name of the modifier who modified the asset last |
String |
getName()
Returns the name of the asset. |
Resource |
getOriginal()
Returns the Resource of the original file. |
String |
getPath()
Returns the repository path of the asset. |
Resource |
getRendition(RenditionPicker picker)
Returns the file Resource of a rendition, based on a custom RenditionPicker implementation. |
Resource |
getRendition(String name)
This method returns the Resource of an asset's rendition specified by its
name. |
List<Resource> |
getRenditions()
Lists all available renditions. |
boolean |
isSubAsset()
Indicates if this asset is a Sub Asset. |
void |
setCurrentOriginal(String name)
Defines which rendition is marked as the asset's original version. |
Resource |
setRendition(String name,
InputStream is)
Deprecated. since 5.3 use setRendition(String, java.io.InputStream, String) |
Resource |
setRendition(String name,
InputStream is,
String mimeType)
Saves a new rendition and returns the newly saved file Resource. |
| Methods inherited from interface org.apache.sling.api.adapter.Adaptable |
|---|
adaptTo |
| Method Detail |
|---|
String getPath()
String getName()
String getMetadataValue(String name)
...
Asset asset = resource.adaptTo(Asset.class);
String assetTitle = asset.getMetadataValue("dc:title");
...
name - metadata property name
Object getMetadata(String name)
...
Asset asset = resource.adaptTo(Asset.class);
Calendar modified = (Calendar) asset.getMetadata("dc:modified");
...
name - metadata property name
Object or null if the property does not exist.long getLastModified()
Resource getRendition(String name)
Resource of an asset's rendition specified by its
name. Available renditions are configured as part of the DAM Asset Update Workflow (see:
http://dev.day.com/docs/en/cq/current/dam/customizing_and_extendingcq5dam.html#Customizing%20Renditions).
Renditions are stored under the asset's main content node in the "renditions" folder, e.g.
/content/dam/geometrixx/banners/banner-mono.png/jcr:content/renditions. The node name of a rendition in
this folder is the name to be used as the method argument. For example the rendition path
/content/dam/geometrixx/banners/banner-mono.png/jcr:content/renditions/cq5dam.thumbnail.140.100.png
results in the rendition name "cq5dam.thumbnail.140.100.png". Sample:
...
Asset asset = resource.adaptTo(Asset.class);
Resource rendition = asset.getRendition("cq5dam.thumbnail.140.100.png");
...
name - rendition name
nullResource getOriginal()
Resource of the original file. The original file represents the
binary file that was initially uploaded as the asset. It is the unmodified version of the asset. The original
also represents a rendition of the asset, as such its storage path is in the asset's rendition folder, e.g.
/content/dam/geometrixx/banners/banner-mono.png/jcr:content/renditions/original. The original, as any
rendition, is persisted as a node of type nt:file in the repository. Subsequently access to the original's
file data works through accessing its jcr:content subnode via resource API, or using the Download or Image class. The Download and Image
convenience classes automatically retrieve the rendition with the name original from the given asset
resource.
Using the resource API:
...
Asset asset = resource.adaptTo(Asset.class);
Resource original = asset.getOriginal();
InputStream stream = original.adaptTo(InputStream.class);
...
Using the asset as a download via the Download class:
...
Asset asset = resource.adaptTo(Asset.class);
Download download = new Download(resource);
String title = download.getTitle();
String mimeType = download.getMimeType();
javax.jcr.Property p = download.getData();
javax.jcr.Binary b = p.getBinary();
long size = b.getSize();
InputStream stream = b.getStream();
...
Using the asset's original as an image via the Image class:
...
Asset asset = resource.adaptTo(Asset.class);
Image image = new Image(resource);
Layer layer = image.getLayer(true, true, true);
...
Resource getCurrentOriginal()
Resource representing the asset's rendition currently marked as
the asset's unmodified, original version. A rendition is marked as the original of an asset via the existence of
the property currentOriginal on the asset's content node. The property contains the path of the rendition
to be considered the original. E.g. /content/dam/geometrixx/banners/banner-mono.png/jcr:content/currentOriginal
with value /content/dam/geometrixx/banners/banner-mono.png/jcr:content/renditions/myOriginal.
getOriginal()boolean isSubAsset()
Sub Asset. Sub assets are assets stored under another asset, as a
result of splitting up the asset in fragments during its import, e.g. the single pages of a multi-page PDF file.
true if it is a Sub AssetMap<String,Object> getMetadata()
getMetadataValue(String)
Resource setRendition(String name,
InputStream is)
setRendition(String, java.io.InputStream, String)
name - rendition nameis - inputstream of rendition
setRendition(String, java.io.InputStream, String)
Resource setRendition(String name,
InputStream is,
String mimeType)
Resource. The
modification date of the asset will be set automatically.
name - rendition nameis - InputStream of renditionmimeType - The mime type of the rendition
getRendition(String),
getRenditions()void setCurrentOriginal(String name)
original version.
name - name of renditiongetCurrentOriginal()
Revision createRevision(String label,
String comment)
throws Exception
Revision of the asset. The revision will be created as a standard JCR version of the
underlying asset node.
label - version labelcomment - version comment
Exception - Thrown when an error during version creation occurred.List<Resource> getRenditions()
Resource getRendition(RenditionPicker picker)
Resource of a rendition, based on a custom RenditionPicker implementation. RenditionPicker implementations are free to
choose which rendition is to be returned.
picker - The RenditionPicker implementation to use for selecting an asset's rendition.
null if not existing.String getModifier()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||