com.fatwire.assetapi.data
Class AssetDataManagerImpl
java.lang.Object
com.fatwire.assetapi.data.AssetDataManagerImpl
- All Implemented Interfaces:
- AssetDataManager
public class AssetDataManagerImpl
- extends java.lang.Object
- implements AssetDataManager
AssetDataManager
implementation class
The class has two variant of read methods:
1. read with a set of attribute names to retrieve specified
- in this case, attribute names are specified either directly in the method signature, for example readAttributes (AssetId id, List attributeNames)
or in the query read(Query query). We consider the user is intending to read only the attribute specified (immediateonly) and do not want to retrieve
the inherited data from parent
2. read with only id specified but no attribute names
- in this case, we assume that user wants all the attributes with inherited values
AssetDataManagerImpl is the entry point for retrieving Content Server asset data and it defaults the
actual operatoin of reading the data to the specific strategies for each different asset types.
Each asset read strategy is an implementation of AssetDataReadStrategy interface and deal with a special
type of asset.
At the heart of all the read strategies is BasicAssetDataReadStrategy, which reads all the basic
asset types including some system asset types like Page, Collection, Query, Link, DimensionSet, and Dimension,
sample asset types including Article, Linkset , and Image, Asset Maker asset types, Flex Attributes,
Flex Parent definitions, Flex Definitions, Flex Filters, and the basic values of other asset types.
On top of BasicAssetReadStrategy, we have FlexAssetDataReadStrategy and several other asset
data read strategies to read other special asset types like Template, CSElement, AdvCols(Recommendation),
Promotions, HField, HistoryVals, ScalarVals
Method Summary |
protected java.lang.Iterable |
_getAssets(Query query)
Get a Iterator of asset data, this method is common for both readonly load and mutuable load of assets
In this case, we only return a Iterable and cast the returned data according to the usage |
MutableAssetData |
deepCopy(AssetData example)
Create a deep copy of an AssetData, all the data will be copied |
void |
delete(java.util.List<AssetId> data)
Deletes a given Iterator of AssetIds from database. |
void |
insert(java.util.List<AssetData> data)
if there is guareentee that all the data are from the same asset type, we would potentially use Asset.Save( ics, assettype, IAsset[] )
however there is no guareentee of that, we would have to save asset one by one |
AssetData |
newAssetData(java.lang.String assetTypeName,
AssetData example)
Creates an instance of AssetData (with copied instances of AttributeData from the example AssetData) |
MutableAssetData |
newAssetData(java.lang.String assetTypeName,
java.lang.String subtype)
Create an empty instance of AssetData with empty instance of AttributeData |
AttributeData |
newAttribiteData(java.lang.String attributeName,
java.lang.String assetTypeName,
java.lang.String subtype)
Creates an empty instance of AttributeData (of appropriate type and default) |
AttributeData |
newAttributeData(AttributeDef attributeDef)
Create an attributeData with an attribute definition specified |
java.lang.Iterable<AssetData> |
read(java.util.List<AssetId> ids)
Reads asset data for all given AssetId s. |
java.lang.Iterable<AssetData> |
read(Query query)
read a list of Asset Data that satisfy the query. |
AssetData |
readAttributes(AssetId id,
java.util.List<java.lang.String> attributeNames)
Reads given set attribute data and returns an AssetData instance containing them. |
java.lang.Iterable<MutableAssetData> |
readForUpdate(java.util.List<AssetId> ids)
read a list of asset data to update |
java.lang.Iterable<MutableAssetData> |
readForUpdate(Query query)
Reads all asset data that satisfies a given Query and results in mutable results. |
void |
update(java.util.List<AssetData> data)
Updates a given list of AssetData in the database. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AssetDataManagerImpl
public AssetDataManagerImpl(ICS ics)
read
public java.lang.Iterable<AssetData> read(Query query)
throws AssetAccessException
- read a list of Asset Data that satisfy the query. The query against flex assets is considered to only to retrieve immediately only attributes
it will not retrieve the parent inherited attributes
- Specified by:
read
in interface AssetDataManager
- Parameters:
query
- the Query object
- Returns:
- Iterator of asset data
- Throws:
AssetAccessException
_getAssets
protected java.lang.Iterable _getAssets(Query query)
throws AssetAccessException
- Get a Iterator of asset data, this method is common for both readonly load and mutuable load of assets
In this case, we only return a Iterable and cast the returned data according to the usage
- Parameters:
query
- - the query passed in
- Returns:
- the Iterator of returned assets
- Throws:
AssetAccessException
- - in case of errros, exception is thrown
readForUpdate
public java.lang.Iterable<MutableAssetData> readForUpdate(Query query)
throws AssetAccessException
- Description copied from interface:
AssetDataManager
- Reads all asset data that satisfies a given Query and results in mutable results.
- Specified by:
readForUpdate
in interface AssetDataManager
- Parameters:
query
- Query to be satisfied.
- Returns:
- Iterator of MutableAssetData instances.
- Throws:
AssetAccessException
- is the layer specific failures and wraps other internal exceptions.
read
public java.lang.Iterable<AssetData> read(java.util.List<AssetId> ids)
throws AssetAccessException,
AssetNotExistException
- Description copied from interface:
AssetDataManager
- Reads asset data for all given
AssetId
s.
- Specified by:
read
in interface AssetDataManager
- Parameters:
ids
- the list of asset ids to read
- Returns:
- Iterator of asset data
- Throws:
AssetAccessException
- rethrown excetpion
AssetNotExistException
readForUpdate
public java.lang.Iterable<MutableAssetData> readForUpdate(java.util.List<AssetId> ids)
throws AssetAccessException,
AssetNotExistException
- read a list of asset data to update
- Specified by:
readForUpdate
in interface AssetDataManager
- Parameters:
ids
- the list of asset ids to read
- Returns:
- Iterator of asset data
- Throws:
AssetAccessException
AssetNotExistException
readAttributes
public AssetData readAttributes(AssetId id,
java.util.List<java.lang.String> attributeNames)
throws AssetAccessException,
AssetNotExistException
- Description copied from interface:
AssetDataManager
- Reads given set attribute data and returns an AssetData instance containing them.
- Specified by:
readAttributes
in interface AssetDataManager
- Parameters:
id
- AssetId to read attributes forattributeNames
- names of the attributes
- Returns:
- AssetData containing values for requested attributes.
- Throws:
AssetAccessException
- if thrown if the AssetId does not exist or attrbute names passed are incorrect
for the asset. AssetAccessException also wraps any AssetExcptions thrown by the internal implementation.
AssetNotExistException
insert
public void insert(java.util.List<AssetData> data)
throws AssetAccessException
- if there is guareentee that all the data are from the same asset type, we would potentially use Asset.Save( ics, assettype, IAsset[] )
however there is no guareentee of that, we would have to save asset one by one
- Specified by:
insert
in interface AssetDataManager
- Parameters:
data
- the list of AssetData to insert to Content Server
- Throws:
AssetAccessException
update
public void update(java.util.List<AssetData> data)
throws AssetAccessException
- Description copied from interface:
AssetDataManager
- Updates a given list of AssetData in the database. Content Server will use the AssetId in AssetData
objects to dertermine which Asset in Content Server to update. An AssetAccessException will be
thrown if the AssetData passed in does not exist in Content Server
- Specified by:
update
in interface AssetDataManager
- Parameters:
data
- AssetData to be updated.
- Throws:
AssetAccessException
- captures layer specific failures and wraps other internal exceptions.
delete
public void delete(java.util.List<AssetId> data)
throws AssetAccessException
- Description copied from interface:
AssetDataManager
- Deletes a given Iterator of AssetIds from database.
- Specified by:
delete
in interface AssetDataManager
- Parameters:
data
- AssetIds to be deleted.
- Throws:
AssetAccessException
- captures layer specific failures and wraps other internal exceptions.
newAttribiteData
public AttributeData newAttribiteData(java.lang.String attributeName,
java.lang.String assetTypeName,
java.lang.String subtype)
- Description copied from interface:
AssetDataManager
- Creates an empty instance of AttributeData (of appropriate type and default)
- Specified by:
newAttribiteData
in interface AssetDataManager
- Parameters:
attributeName
- name of the attributeassetTypeName
- name of asset typesubtype
- subtype of asset type.
- Returns:
- empty AttributeData for a given attribute name and attribute type.
newAttributeData
public AttributeData newAttributeData(AttributeDef attributeDef)
- Description copied from interface:
AssetDataManager
- Create an attributeData with an attribute definition specified
- Specified by:
newAttributeData
in interface AssetDataManager
- Parameters:
attributeDef
- the definition of the attribute
- Returns:
- the attribute data with empty value
newAssetData
public MutableAssetData newAssetData(java.lang.String assetTypeName,
java.lang.String subtype)
throws AssetAccessException
- Description copied from interface:
AssetDataManager
- Create an empty instance of AssetData with empty instance of AttributeData
- Specified by:
newAssetData
in interface AssetDataManager
- Parameters:
assetTypeName
- the name of the assettypesubtype
- the name of the aset subtype
- Returns:
- empty instance of AssetData
- Throws:
AssetAccessException
newAssetData
public AssetData newAssetData(java.lang.String assetTypeName,
AssetData example)
- Description copied from interface:
AssetDataManager
- Creates an instance of AssetData (with copied instances of AttributeData from the example AssetData)
- Specified by:
newAssetData
in interface AssetDataManager
- Parameters:
assetTypeName
- name of the asset typeexample
- optional example AsetData the returned will be based on.
- Returns:
- an instance of AssetData
deepCopy
public MutableAssetData deepCopy(AssetData example)
throws AssetAccessException
- Create a deep copy of an AssetData, all the data will be copied
- Parameters:
example
- the asset data where to copy the data from
- Returns:
- the deep copy of the asset data
- Throws:
AssetAccessException
- throws exception if error met creating the copy
Copyright (c) 2003 - 2010 FatWire Corporation All Rights Reserved.