info.magnolia.dam.api
Interface AssetProvider

All Known Implementing Classes:
AbstractAssetProvider

public interface AssetProvider

An AssetProvider exposes Folders and Assets from a particular source. Specifics of the storage of these items are left to implementations. While most provider implementations will only use the ItemKey.assetId field of keys passed to the various get methods, the entire key object is passed for consistency and flexibility, making it possible to implement delegating/aggregating providers, for example.


Nested Class Summary
static class AssetProvider.AssetNotFoundException
          Thrown when the given ItemKey can't be found.
static class AssetProvider.IllegalItemKeyException
          Thrown when the given ItemKey isn't usable by the provider.
 
Method Summary
 Asset getAsset(ItemKey assetKey)
          Cast-less convenience method for getItem(ItemKey).
 Folder getFolder(ItemKey folderKey)
          Cast-less convenience method for getItem(ItemKey).
 String getIdentifier()
          Return the AssetProvider identifier.
 Item getItem(ItemKey itemKey)
          Returns the item associated with the given ItemKey, regardless of its type.
 AssetRenderer getRendererFor(Asset asset, com.google.common.net.MediaType to)
          Returns an appropriate AssetRenderer if this provider has specific renderers, or null if there is none.
 Folder getRootFolder()
          The top-most folder available from this AssetProvider.
 Iterator<Item> list(AssetQuery assetQuery)
          Returns an iterator over the results matching the given AssetQuery.
 boolean provides(com.google.common.net.MediaType mediaType)
          Whether this provider provides or allows the given MediaType.
 boolean supports(AssetProviderCapability capability)
          Returns true if the provider supports the given AssetProviderCapability.
 boolean supports(Class<? extends AssetMetadata> metaData)
          Whether this provider supports the given AssetMetadata type.
 

Method Detail

getIdentifier

String getIdentifier()
Return the AssetProvider identifier.


supports

boolean supports(AssetProviderCapability capability)
Returns true if the provider supports the given AssetProviderCapability.


supports

boolean supports(Class<? extends AssetMetadata> metaData)
Whether this provider supports the given AssetMetadata type.


provides

boolean provides(com.google.common.net.MediaType mediaType)
Whether this provider provides or allows the given MediaType. Some providers can be configured to only be used for a given set or subset of types.


getAsset

Asset getAsset(ItemKey assetKey)
               throws AssetProvider.AssetNotFoundException,
                      AssetProvider.IllegalItemKeyException
Cast-less convenience method for getItem(ItemKey).

Throws:
IllegalArgumentException - if the key does not correspond to an Item of the Asset type.
AssetProvider.AssetNotFoundException
AssetProvider.IllegalItemKeyException

getFolder

Folder getFolder(ItemKey folderKey)
                 throws AssetProvider.AssetNotFoundException,
                        AssetProvider.IllegalItemKeyException
Cast-less convenience method for getItem(ItemKey).

Throws:
IllegalArgumentException - if the key does not correspond to an Item of the Folder type.
AssetProvider.AssetNotFoundException
AssetProvider.IllegalItemKeyException

getItem

Item getItem(ItemKey itemKey)
             throws AssetProvider.AssetNotFoundException,
                    AssetProvider.IllegalItemKeyException
Returns the item associated with the given ItemKey, regardless of its type.

Throws:
IllegalArgumentException - if the key does not correspond to an Item of the Folder or Asset type.
AssetProvider.AssetNotFoundException
AssetProvider.IllegalItemKeyException

getRootFolder

Folder getRootFolder()
The top-most folder available from this AssetProvider. See notes at Folder.isRoot().


list

Iterator<Item> list(AssetQuery assetQuery)
Returns an iterator over the results matching the given AssetQuery. Depending on the specific values of the AssetQuery and the AssetProvider implementation, this might list direct children, execute a query, ... It is up to the provider to validate the query - some combinations of criteria might not be supported by all providers.

See Also:
AssetProviderCapability

getRendererFor

AssetRenderer getRendererFor(Asset asset,
                             com.google.common.net.MediaType to)
Returns an appropriate AssetRenderer if this provider has specific renderers, or null if there is none.

See Also:
AssetProviderRegistry#getRendererFor(Asset, com.google.common.net.MediaType)}, which is what client code should be using rather than this method here. TODO: overdoing it if we move this to abstract to hide it from client code ?


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