info.magnolia.dam.templating.functions
Class DamTemplatingFunctions

java.lang.Object
  extended by info.magnolia.dam.templating.functions.DamTemplatingFunctions

@Singleton
public class DamTemplatingFunctions
extends Object

Asset templating function exposed in FTL's as "damfn". This class exposed useful methods for FTL's and Model Class.


Field Summary
static String DAM_VERSION_1_PROVIDER_ID
           
static String METADATA_KEY_ACCESS
           
 
Constructor Summary
DamTemplatingFunctions(info.magnolia.dam.api.AssetProviderRegistry providerRegistry)
           
 
Method Summary
 info.magnolia.dam.api.Asset getAsset(String itemKey)
           
 info.magnolia.dam.api.Asset getAsset(String providerId, String assetPath)
           
 info.magnolia.dam.api.Asset getAssetForAbsolutePath(String providerId, String absoluteAssetPath)
           
 info.magnolia.dam.api.Asset getAssetForId(String assetIdentifier)
          Deprecated. use getAsset(String).
 info.magnolia.dam.api.Asset getAssetForPath(String assetPath)
          Deprecated. use getAssetForAbsolutePath(String, String).
 String getAssetLink(info.magnolia.dam.api.Asset asset, com.google.common.net.MediaType mediaType, String renditionName)
           
 String getAssetLink(String assetKey)
           
 String getAssetLink(String itemKey, String renditionName)
           
 String getAssetLinkForId(String assetKey)
          Deprecated. use getAssetLink(String).
 String getAssetLinkForId(String itemKey, String renditionName)
          Deprecated. use getAssetLink(String, String).
 Map<String,Object> getAssetMap(info.magnolia.dam.api.Asset asset)
          Create a read only map containing:
- All asset property names and values
- a metadata child map containing all supported metadata property names and values.
 Map<String,Object> getAssetMap(String itemKey)
           
 Map<String,Object> getAssetMapForAssetId(String assetKey)
           
 info.magnolia.dam.api.Asset getAssetRendition(info.magnolia.dam.api.Asset asset, String renditionName)
          Deprecated. use getRendition(Asset, MediaType, String).
 info.magnolia.dam.api.Asset getAssetRenditionForAssetId(String itemKey, String renditionName)
          Deprecated. use getRendition(String, MediaType, String).
 List<info.magnolia.dam.api.Asset> getAssetsForFilter(info.magnolia.dam.api.AssetQuery assetQuery)
          Deprecated. use getItems(String, AssetQuery).
 List<info.magnolia.dam.api.Asset> getAssetsFromFolderId(String folderKey)
          Deprecated. use getFolder(String) and the Folder.getChildren().
 info.magnolia.dam.api.Folder getFolder(String itemKey)
           
 info.magnolia.dam.api.Folder getFolder(String providerId, String folderPath)
           
 Iterator<info.magnolia.dam.api.Item> getItems(String providerId, info.magnolia.dam.api.AssetQuery assetQuery)
          Set AssetQuery.includesFolders() or AssetQuery.includesAssets() in order to restrict the returned Items.
 info.magnolia.dam.api.AssetRendition getRendition(info.magnolia.dam.api.Asset asset, com.google.common.net.MediaType mediaType, String renditionName)
          Based on the passed MediaType and Asset, get an appropriate AssetRenderer.
 info.magnolia.dam.api.AssetRendition getRendition(info.magnolia.dam.api.Asset asset, String renditionName)
           
 info.magnolia.dam.api.AssetRendition getRendition(String itemKey, com.google.common.net.MediaType mediaType, String renditionName)
           
 info.magnolia.dam.api.AssetRendition getRendition(String itemKey, String renditionName)
           
 boolean provides(String providerId, com.google.common.net.MediaType mediaType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

METADATA_KEY_ACCESS

public static final String METADATA_KEY_ACCESS
See Also:
Constant Field Values

DAM_VERSION_1_PROVIDER_ID

public static final String DAM_VERSION_1_PROVIDER_ID
See Also:
Constant Field Values
Constructor Detail

DamTemplatingFunctions

@Inject
public DamTemplatingFunctions(info.magnolia.dam.api.AssetProviderRegistry providerRegistry)
Method Detail

getAsset

public info.magnolia.dam.api.Asset getAsset(String itemKey)
Parameters:
itemKey - ItemKey.asString().
Returns:
null if asset was not found.

getAsset

public info.magnolia.dam.api.Asset getAsset(String providerId,
                                            String assetPath)
Parameters:
providerId -
assetPath - relative path to the Asset.
Returns:
null if asset was not found.
Throws:
IllegalArgumentException - if the requested provider is not an implementation of PathAwareAssetProvider.

getAssetForAbsolutePath

public info.magnolia.dam.api.Asset getAssetForAbsolutePath(String providerId,
                                                           String absoluteAssetPath)
Parameters:
providerId -
assetPath - absolute path to the Asset.
Returns:
null if asset was not found.
Throws:
IllegalArgumentException - if the requested provider is not an implementation of PathAwareAssetProvider.

getFolder

public info.magnolia.dam.api.Folder getFolder(String itemKey)
Parameters:
itemKey - ItemKey.asString().
Returns:
null if folder was not found.

getFolder

public info.magnolia.dam.api.Folder getFolder(String providerId,
                                              String folderPath)
Parameters:
providerId -
folderPath - relative path to the Folder.
Returns:
null if folder was not found.
Throws:
IllegalArgumentException - if the requested provider is not an implementation of PathAwareAssetProvider.

getItems

public Iterator<info.magnolia.dam.api.Item> getItems(String providerId,
                                                     info.magnolia.dam.api.AssetQuery assetQuery)
Set AssetQuery.includesFolders() or AssetQuery.includesAssets() in order to restrict the returned Items.


getRendition

public info.magnolia.dam.api.AssetRendition getRendition(info.magnolia.dam.api.Asset asset,
                                                         com.google.common.net.MediaType mediaType,
                                                         String renditionName)
Based on the passed MediaType and Asset, get an appropriate AssetRenderer. From the AssetRenderer get the AssetRendition for the given renditionName.


getRendition

public info.magnolia.dam.api.AssetRendition getRendition(info.magnolia.dam.api.Asset asset,
                                                         String renditionName)
Returns:
AssetRendition based on the MediaType builded from the Asset.getMimeType().

getRendition

public info.magnolia.dam.api.AssetRendition getRendition(String itemKey,
                                                         String renditionName)

getRendition

public info.magnolia.dam.api.AssetRendition getRendition(String itemKey,
                                                         com.google.common.net.MediaType mediaType,
                                                         String renditionName)

provides

public boolean provides(String providerId,
                        com.google.common.net.MediaType mediaType)
Returns:
AssetProvider.provides(MediaType) or false in case of any exceptions.

getAssetMap

public Map<String,Object> getAssetMap(info.magnolia.dam.api.Asset asset)
Create a read only map containing:
- All asset property names and values
- a metadata child map containing all supported metadata property names and values.


getAssetMap

public Map<String,Object> getAssetMap(String itemKey)

getAssetLink

public String getAssetLink(String assetKey)
Returns:
The Asset.getLink() or null in case of exception or if Asset is not found.

getAssetLink

public String getAssetLink(String itemKey,
                           String renditionName)
Returns:
The AssetRendition.getLink() or null in case of exception or if Asset or AssetRendition are not found.

getAssetLink

public String getAssetLink(info.magnolia.dam.api.Asset asset,
                           com.google.common.net.MediaType mediaType,
                           String renditionName)
Returns:
The AssetRendition.getLink() or null in case of exception or if Asset or AssetRendition are not found.

getAssetMapForAssetId

public Map<String,Object> getAssetMapForAssetId(String assetKey)
Returns:
getAssetMap(Asset) for the Asset corresponding to the assetKey. Null in case of exception or if the Asset was not found.

getAssetsFromFolderId

@Deprecated
public List<info.magnolia.dam.api.Asset> getAssetsFromFolderId(String folderKey)
Deprecated. use getFolder(String) and the Folder.getChildren().

Retrieve an Asset List based on a folder identifier (ItemKey.asString()).

Returns:
The Assets List found for this folder identifier, or an Empty List if nothing found or in case of Exception.

getAssetForPath

@Deprecated
public info.magnolia.dam.api.Asset getAssetForPath(String assetPath)
Deprecated. use getAssetForAbsolutePath(String, String).

Returns:
Asset found under this path for the DamConstants#DEFAULT_JCR_PROVIDER_ID or null otherwise.

getAssetForId

@Deprecated
public info.magnolia.dam.api.Asset getAssetForId(String assetIdentifier)
Deprecated. use getAsset(String).


getAssetRendition

@Deprecated
public info.magnolia.dam.api.Asset getAssetRendition(info.magnolia.dam.api.Asset asset,
                                                                String renditionName)
Deprecated. use getRendition(Asset, MediaType, String).

Returns:
The specified Asset based on the rendition Name.
In case of no rendition found, return the same Asset.
Return null in case of exception.

getAssetRenditionForAssetId

@Deprecated
public info.magnolia.dam.api.Asset getAssetRenditionForAssetId(String itemKey,
                                                                          String renditionName)
Deprecated. use getRendition(String, MediaType, String).

Returns:
The Asset based on the rendition Name and itemKey.
In case of no rendition found, return the same Asset.
Return null in case of exception.

getAssetLinkForId

@Deprecated
public String getAssetLinkForId(String assetKey)
Deprecated. use getAssetLink(String).

Returns:
The Asset.getLink() or null in case of exception or if Asset is not found.

getAssetLinkForId

@Deprecated
public String getAssetLinkForId(String itemKey,
                                           String renditionName)
Deprecated. use getAssetLink(String, String).

Returns:
The AssetRendition.getLink() or null in case of exception or if Asset is not found.

getAssetsForFilter

@Deprecated
public List<info.magnolia.dam.api.Asset> getAssetsForFilter(info.magnolia.dam.api.AssetQuery assetQuery)
Deprecated. use getItems(String, AssetQuery).

Returns:
an Asset List found for this asset assetQuery and DamConstants#DEFAULT_JCR_PROVIDER_ID assetProvider, or an empty list if nothing found or in case of Exception.


Copyright © 2014 Magnolia International Ltd.. All Rights Reserved.