public class AssetAccessTemplate extends Object
AssetDataManager
use in a simplified
way in delivery ContentServer templates.
This class is inspired by springframework data access template classes like org.springframework.jdbc.core.JdbcTemplate.
This class is not thread safe and should not be shared between threads.
Constructor and Description |
---|
AssetAccessTemplate(COM.FutureTense.Interfaces.ICS ics)
Constructor that accepts ICS as an argument.
|
AssetAccessTemplate(com.fatwire.system.Session session) |
Modifier and Type | Method and Description |
---|---|
com.fatwire.assetapi.data.AssetId |
createAssetId(String c,
long cid)
Helper method to create an AssetId from c and cid as string values.
|
com.fatwire.assetapi.data.AssetId |
createAssetId(String c,
String cid)
Helper method to create an AssetId from c and cid as string values.
|
com.fatwire.assetapi.query.SimpleQuery |
createNameQuery(String assetType,
String assetName)
Creates a Query to retrieve the asset by it's name.
|
com.fatwire.assetapi.data.AssetId |
findByName(COM.FutureTense.Interfaces.ICS ics,
String assetType,
String name)
Finds the assetid by the name of the asset.
|
com.fatwire.assetapi.data.AssetId |
findByName(COM.FutureTense.Interfaces.ICS ics,
String assetType,
String name,
long siteid)
Finds the assetid by the name of the asset in a particular site.
|
protected com.fatwire.assetapi.data.AssetDataManager |
getAssetDataManager() |
<T> Iterable<T> |
query(String assetType,
String subType,
String query,
AssetMapper<T> mapper)
Queries for a list of objects as mapped by the AssetMapper.
|
<T> Iterable<T> |
query(String assetType,
String subType,
String query,
AssetMapper<T> mapper,
String... attributes)
Queries for a list of objects as mapped by the AssetMapper.
|
com.fatwire.assetapi.data.AssetData |
readAsset(com.fatwire.assetapi.data.AssetId id) |
void |
readAsset(com.fatwire.assetapi.data.AssetId id,
AssetClosure closure)
Method to read an asset and pass the results to the closure for further
handling.
|
void |
readAsset(com.fatwire.assetapi.data.AssetId id,
AssetClosure closure,
String... attributes)
Method to read an asset and provide the AssetClosure with the AssetData.
|
<T> T |
readAsset(com.fatwire.assetapi.data.AssetId id,
AssetMapper<T> mapper)
Method to read an asset and use the AssetMapper to transform the
AssetData into another object as specified by the AssetMapper.
|
<T> T |
readAsset(com.fatwire.assetapi.data.AssetId id,
AssetMapper<T> mapper,
String... attributes)
Method to read an asset and use the AssetMapper to transform the
AssetData into another object as specified by the AssetMapper.
|
com.fatwire.assetapi.data.AssetData |
readAsset(com.fatwire.assetapi.data.AssetId id,
String... attributes)
Reads an asset based on the listed attribute names
|
void |
readAsset(Iterable<com.fatwire.assetapi.data.AssetId> ids,
AssetClosure closure,
String... attributes)
Method to read an asset and pass the results to the closure for further
handling.
|
void |
readAsset(List<com.fatwire.assetapi.data.AssetId> ids,
AssetClosure closure)
Method to read an asset and pass the results to the closure for further
handling.
|
<T> T |
readAsset(String c,
long cid,
AssetMapper<T> mapper)
Method to read an asset and use the AssetMapper to transform the
AssetData into another object as specified by the AssetMapper.
|
<T> T |
readAsset(String c,
String cid,
AssetMapper<T> mapper)
Method to read an asset and use the AssetMapper to transform the
AssetData into another object as specified by the AssetMapper interface..
|
Iterable<com.fatwire.assetapi.data.AssetData> |
readAssets(com.fatwire.assetapi.query.Query query) |
void |
readAssets(com.fatwire.assetapi.query.Query query,
AssetClosure closure)
Invokes the work(asset) method on the provided Closure for assets
returned by the Query.
|
<T> Iterable<T> |
readAssets(com.fatwire.assetapi.query.Query query,
AssetMapper<T> mapper)
Reading assets with the Query and using the mapper to transform the
AssetData into another object, as specified by T.
|
Collection<com.fatwire.assetapi.data.AssetId> |
readAssociatedAssetIds(com.fatwire.assetapi.data.AssetId id,
String associationType)
Reads the associated assets of the asset and returns the AssetIds.
|
void |
readAssociatedAssets(com.fatwire.assetapi.data.AssetId id,
String associationType,
AssetClosure closure,
String... attributes)
Reads the associated assets of an asset and returns them as a
ScatteredAsset.
|
com.fatwire.assetapi.site.Site |
readSite(String name)
Finds the Site object by the given name.
|
com.fatwire.assetapi.site.SiteInfo |
readSiteInfo(String name) |
public AssetAccessTemplate(com.fatwire.system.Session session)
session
- session objectpublic AssetAccessTemplate(COM.FutureTense.Interfaces.ICS ics)
ics
- Content Server context objectpublic com.fatwire.assetapi.data.AssetId createAssetId(String c, String cid)
c
- current assetcid
- content idpublic com.fatwire.assetapi.data.AssetId createAssetId(String c, long cid)
c
- current assetcid
- content idpublic <T> T readAsset(com.fatwire.assetapi.data.AssetId id, AssetMapper<T> mapper)
T
- type specified from asset mapperid
- asset idmapper
- asset mapperpublic <T> T readAsset(String c, String cid, AssetMapper<T> mapper)
T
- type specified from asset mapperc
- the assetTypecid
- the asset idmapper
- asset mapperpublic <T> T readAsset(String c, long cid, AssetMapper<T> mapper)
T
- type specified from asset mapperc
- the assetTypecid
- the asset idmapper
- asset mapperpublic <T> T readAsset(com.fatwire.assetapi.data.AssetId id, AssetMapper<T> mapper, String... attributes)
T
- type specified from asset mapperid
- asset idmapper
- asset mapperattributes
- array of attribute namespublic void readAsset(com.fatwire.assetapi.data.AssetId id, AssetClosure closure, String... attributes)
id
- asset idclosure
- asset closureattributes
- array of attribute namespublic void readAsset(com.fatwire.assetapi.data.AssetId id, AssetClosure closure)
id
- the assetid to readclosure
- the closurepublic void readAsset(List<com.fatwire.assetapi.data.AssetId> ids, AssetClosure closure)
ids
- a list of AssetIdsclosure
- the closurepublic void readAsset(Iterable<com.fatwire.assetapi.data.AssetId> ids, AssetClosure closure, String... attributes)
ids
- a list of AssetIdsclosure
- the closureattributes
- array of attribute namespublic com.fatwire.assetapi.data.AssetData readAsset(com.fatwire.assetapi.data.AssetId id, String... attributes)
TODO: do we need to load the attribute values and prevent access to non-listed attributes (prevent lazy loading)
id
- the assetidattributes
- the list of attributes to returnprotected com.fatwire.assetapi.data.AssetDataManager getAssetDataManager()
public com.fatwire.assetapi.data.AssetData readAsset(com.fatwire.assetapi.data.AssetId id)
id
- the assetid to readpublic Iterable<com.fatwire.assetapi.data.AssetData> readAssets(com.fatwire.assetapi.query.Query query)
query
- query objectpublic void readAssets(com.fatwire.assetapi.query.Query query, AssetClosure closure)
query
- the queryclosure
- the closurepublic <T> Iterable<T> readAssets(com.fatwire.assetapi.query.Query query, AssetMapper<T> mapper)
T
- type specified from asset mapperquery
- query objectmapper
- asset mapperpublic com.fatwire.assetapi.data.AssetId findByName(COM.FutureTense.Interfaces.ICS ics, String assetType, String name, long siteid)
ics
- Content Server context objectassetType
- the type of the asset.name
- the name of the asset.siteid
- the Site id.public com.fatwire.assetapi.data.AssetId findByName(COM.FutureTense.Interfaces.ICS ics, String assetType, String name)
ics
- Content Server context objectassetType
- the type of the asset.name
- the name of the asset.public com.fatwire.assetapi.query.SimpleQuery createNameQuery(String assetType, String assetName)
assetType
- string value of asset typeassetName
- string value of asset namepublic com.fatwire.assetapi.site.Site readSite(String name)
name
- the name of the site.public com.fatwire.assetapi.site.SiteInfo readSiteInfo(String name)
name
- site namepublic Collection<com.fatwire.assetapi.data.AssetId> readAssociatedAssetIds(com.fatwire.assetapi.data.AssetId id, String associationType)
id
- asset idassociationType
- association typepublic void readAssociatedAssets(com.fatwire.assetapi.data.AssetId id, String associationType, AssetClosure closure, String... attributes)
id
- the parent assetassociationType
- the name of the association or '-' for an unnamed
associationclosure
- the AssetClosure to work on.attributes
- the list of attributes to loadpublic <T> Iterable<T> query(String assetType, String subType, String query, AssetMapper<T> mapper, String... attributes)
Sample queries are:
T
- type specified by asset mapperassetType
- asset typesubType
- sub-typequery
- string value of querymapper
- asset mapperattributes
- array of attribute namesquery(String, String, String, AssetMapper,
String...)
public <T> Iterable<T> query(String assetType, String subType, String query, AssetMapper<T> mapper)
Sample queries are:
T
- type specified by asset mapperassetType
- asset typesubType
- sub-typequery
- string value of querymapper
- asset mapperCopyright © 2010–2017. All rights reserved.