com.fatwire.gst.foundation.facade.mda
Class DefaultLocaleService

java.lang.Object
  extended by com.fatwire.gst.foundation.facade.mda.DefaultLocaleService
All Implemented Interfaces:
LocaleService

public class DefaultLocaleService
extends Object
implements LocaleService


Constructor Summary
DefaultLocaleService(COM.FutureTense.Interfaces.ICS ics)
          Constructor with "lang" and "locale" as variable names for langVar and localeVar.
DefaultLocaleService(COM.FutureTense.Interfaces.ICS ics, String langVar, String localeVar)
          Constructor.
 
Method Summary
 com.fatwire.assetapi.data.AssetId findTranslation(com.fatwire.assetapi.data.AssetId id, com.fatwire.mda.DimensionFilterInstance filter)
          Look up the translation for the asset specified, with the dimension filter.
 com.fatwire.assetapi.data.AssetId findTranslation(com.fatwire.assetapi.data.AssetId id, long preferredDimension, com.fatwire.mda.DimensionSetInstance dimset)
          Finds the translation for the preferred dimension and dimensionset.
 com.fatwire.assetapi.data.AssetId findTranslation(com.fatwire.assetapi.data.AssetId id, long preferredDimension, long dimensionSetId)
          Look up the translation for the asset specified, in the locale specified.
 com.fatwire.assetapi.data.AssetId findTranslation(com.fatwire.assetapi.data.AssetId id, long preferredDimension, String dimensionSetName)
          Look up the translation for the asset specified, in the locale specified.
 com.fatwire.assetapi.data.AssetId findTranslation(com.fatwire.assetapi.data.AssetId id, String site, long preferredDimension)
          Look up the translation for the asset specified, in the locale specified.
 com.fatwire.assetapi.data.AssetId findTranslation(String c, String cid, String site, String preferredLocaleDimensionId)
          Look up the translation for the asset specified, in the locale specified.
 com.fatwire.mda.DimensionableAssetManager getDAM()
          Shorthand function for returning the DimensionableAssetManager.
 com.fatwire.assetapi.data.AssetId getDimensionAssetIdForName(String name)
          Get the AssetId of the dimension asset for the name specified
 com.fatwire.mda.DimensionFilterInstance getDimensionFilter(String site)
          Return a dimension filter instance corresponding to the dimension set specified by the user (or discovered by the tag).
 com.fatwire.mda.Dimension getDimensionForName(String name)
          Get the AssetId of the dimension asset for the name specified
 long getDimensionIdForName(String name)
          Get the id of the dimension asset for the name specified
 com.fatwire.mda.DimensionSetInstance getDimensionSet(String name)
          Looksup the DimensionSetInstance for the given name.
protected  com.fatwire.mda.DimensionManager getDM()
          Shorthand function for returning the DimensionManager.
protected  com.fatwire.assetapi.data.AssetId getExplicitlySpecifiedLocale()
          Get the locale that the user explicitly specified.
 com.fatwire.mda.Dimension getLocaleForAsset(com.fatwire.assetapi.data.AssetId id)
          Return the dimension of the input asset that corresponds to its locale.
protected
<T> T
getManager(Class<T> c)
           
 String getNameForDimensionId(long dimensionid)
          Shorthand function to get the name given a dimension ID specified.
protected  Collection<com.fatwire.assetapi.data.AssetId> getPreferredLocales()
          Get the ordered list of preferred locales that the user wants.
protected  com.fatwire.system.Session getSession()
           
 long locateDimensionSetForSite(String site)
          Locates a single dimension set in a site.
 com.fatwire.mda.DimensionSetInstance locateDimensionSetInstanceForSite(String site)
          Returns the DimensionSetInstance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultLocaleService

public DefaultLocaleService(COM.FutureTense.Interfaces.ICS ics)
Constructor with "lang" and "locale" as variable names for langVar and localeVar.

Parameters:
ics -

DefaultLocaleService

public DefaultLocaleService(COM.FutureTense.Interfaces.ICS ics,
                            String langVar,
                            String localeVar)
Constructor.

Parameters:
ics -
langVar - the name of the ics variable for the current 'language', as in en_US.
localeVar - the name of the ics variable for the current dimension id.
Method Detail

findTranslation

public com.fatwire.assetapi.data.AssetId findTranslation(String c,
                                                         String cid,
                                                         String site,
                                                         String preferredLocaleDimensionId)
Description copied from interface: LocaleService
Look up the translation for the asset specified, in the locale specified.

If the desired translation is not available, null will be returned.

If a dimension set for the site has been configured that returns the asset other than the preferred locale, that is considered to be fine and not really the problem of the end user. In other words, a dimension set may dictate that a "backup" language can be returned to the user.

Null, however, is a valid option.

Specified by:
findTranslation in interface LocaleService
Parameters:
c - asset type of asset to look up
cid - asset id of asset to look up
site - name of site
preferredLocaleDimensionId - id of locale desired
Returns:
AssetId of translation asset.

findTranslation

public com.fatwire.assetapi.data.AssetId findTranslation(com.fatwire.assetapi.data.AssetId id,
                                                         String site,
                                                         long preferredDimension)
Description copied from interface: LocaleService
Look up the translation for the asset specified, in the locale specified.

If the desired translation is not available, null will be returned.

If a dimension set for the site has been configured that returns the asset other than the preferred locale, that is considered to be fine and not really the problem of the end user. In other words, a dimension set may dictate that a "backup" language can be returned to the user.

Null, however, is a valid option.

Specified by:
findTranslation in interface LocaleService
Parameters:
id - id of asset to look up
site - name of site
preferredDimension - id of locale desired
Returns:
AssetId of translation asset, or null if none is returned by the dimension set filter.

findTranslation

public com.fatwire.assetapi.data.AssetId findTranslation(com.fatwire.assetapi.data.AssetId id,
                                                         long preferredDimension,
                                                         long dimensionSetId)
Description copied from interface: LocaleService
Look up the translation for the asset specified, in the locale specified.

If the desired translation is not available, null will be returned.

If a dimension set for the site has been configured that returns the asset other than the preferred locale, that is considered to be fine and not really the problem of the end user. In other words, a dimension set may dictate that a "backup" language can be returned to the user.

Null, however, is a valid option.

Specified by:
findTranslation in interface LocaleService
Parameters:
id - id of asset to look up
preferredDimension - id of locale desired
dimensionSetId - dimension set to use to find the translation
Returns:
AssetId of translation asset, or null if none is returned by the dimension set filter.

findTranslation

public com.fatwire.assetapi.data.AssetId findTranslation(com.fatwire.assetapi.data.AssetId id,
                                                         long preferredDimension,
                                                         String dimensionSetName)
Description copied from interface: LocaleService
Look up the translation for the asset specified, in the locale specified.

If the desired translation is not available, null will be returned.

If a dimension set has been configured that returns the asset other than the preferred locale, that is considered to be fine and not really the problem of the end user. In other words, a dimension set may dictate that a "backup" language can be returned to the user.

Null, however, is a valid option.

Specified by:
findTranslation in interface LocaleService
Parameters:
id - id of asset to look up
preferredDimension - id of locale desired
dimensionSetName - the name of the dimension set to use to find the translation
Returns:
AssetId of translation asset, or null if none is returned by the dimension set filter. The id parameters is returned if the asset does not have a locale or if the locale is already of the preferredDimension

findTranslation

public com.fatwire.assetapi.data.AssetId findTranslation(com.fatwire.assetapi.data.AssetId id,
                                                         long preferredDimension,
                                                         com.fatwire.mda.DimensionSetInstance dimset)
Description copied from interface: LocaleService
Finds the translation for the preferred dimension and dimensionset.

Specified by:
findTranslation in interface LocaleService
Returns:
assetid of translated asset.

locateDimensionSetForSite

public long locateDimensionSetForSite(String site)
Locates a single dimension set in a site. If no match is found, an exception is thrown. If more than one match is found, an exception is thrown.

Parameters:
site - site containing a dimension set
Returns:
DimensionSet ID

getDimensionSet

public com.fatwire.mda.DimensionSetInstance getDimensionSet(String name)
Description copied from interface: LocaleService
Looksup the DimensionSetInstance for the given name.

Specified by:
getDimensionSet in interface LocaleService
Returns:
the DimensionSetInstance by the provided name

getDAM

public com.fatwire.mda.DimensionableAssetManager getDAM()
Shorthand function for returning the DimensionableAssetManager.

Returns:
DimensionableAssetManager

getDM

protected com.fatwire.mda.DimensionManager getDM()
Shorthand function for returning the DimensionManager.

Returns:
DimensionManager

getLocaleForAsset

public com.fatwire.mda.Dimension getLocaleForAsset(com.fatwire.assetapi.data.AssetId id)
Description copied from interface: LocaleService
Return the dimension of the input asset that corresponds to its locale. If the asset does not have a locale set, returns null

Specified by:
getLocaleForAsset in interface LocaleService
Parameters:
id - asset
Returns:
locale dimension or null

getDimensionIdForName

public long getDimensionIdForName(String name)
Description copied from interface: LocaleService
Get the id of the dimension asset for the name specified

Specified by:
getDimensionIdForName in interface LocaleService
Parameters:
name - dimension name, or locale like en_US
Returns:
dimension id, -1 is not found.

getDimensionAssetIdForName

public com.fatwire.assetapi.data.AssetId getDimensionAssetIdForName(String name)
Description copied from interface: LocaleService
Get the AssetId of the dimension asset for the name specified

Specified by:
getDimensionAssetIdForName in interface LocaleService
Parameters:
name - dimension name, or locale like en_US
Returns:
dimension id, null if not found

getDimensionForName

public com.fatwire.mda.Dimension getDimensionForName(String name)
Description copied from interface: LocaleService
Get the AssetId of the dimension asset for the name specified

Specified by:
getDimensionForName in interface LocaleService
Parameters:
name - dimension name, or locale like en_US
Returns:
dimension id, null if not found

getNameForDimensionId

public String getNameForDimensionId(long dimensionid)
Description copied from interface: LocaleService
Shorthand function to get the name given a dimension ID specified.

Specified by:
getNameForDimensionId in interface LocaleService
Parameters:
dimensionid - ID of a locale. Note the dimension group is not verified
Returns:
dimension name, or locale name, like en_CA, null if not found

getSession

protected com.fatwire.system.Session getSession()

getManager

protected <T> T getManager(Class<T> c)

findTranslation

public com.fatwire.assetapi.data.AssetId findTranslation(com.fatwire.assetapi.data.AssetId id,
                                                         com.fatwire.mda.DimensionFilterInstance filter)
Description copied from interface: LocaleService
Look up the translation for the asset specified, with the dimension filter.

Specified by:
findTranslation in interface LocaleService
Parameters:
id - asset id of asset to look up
filter - the dimensionset to use
Returns:
AssetId of translation asset.

getDimensionFilter

public com.fatwire.mda.DimensionFilterInstance getDimensionFilter(String site)
Return a dimension filter instance corresponding to the dimension set specified by the user (or discovered by the tag). The dimension filter is configured with the preferred dimensions of the user (also configured).

The preferred locales are identified by checking the following locations, in the order specified:

  1. set by the lang attribute by locale name
  2. detected by finding the locale dimension id in the ics variable "locale"
  3. detected by finding the locale name in the ics variable "locale"
  4. detected by finding the locale dimension id in the ics session variable "locale"
  5. detected by finding the locale name in the ics session variable "locale"
  6. detected by reading the Accept-Language header
The dimension set is identified by checking in the following places, in order:
  1. set by the dimset attribute by name of dimension set
  2. set by dimset attribute by the id of the dimension set
  3. looked up by finding the site name in the ics variable "site" and loading the single dimension set associated with that site

Specified by:
getDimensionFilter in interface LocaleService
Returns:
a dimension filter, configured with the set preferred locales, or null, if either the dimension set or the preferred dimensions could not be found (with extensive errors)

getExplicitlySpecifiedLocale

protected final com.fatwire.assetapi.data.AssetId getExplicitlySpecifiedLocale()
Get the locale that the user explicitly specified. If not set, null is returned.

Returns:
the id of the locale that the user explicitly set. Handles setting by name or assetid.

getPreferredLocales

protected final Collection<com.fatwire.assetapi.data.AssetId> getPreferredLocales()
Get the ordered list of preferred locales that the user wants. Multiple attempts are made to figure out the right locale.

Returns:
collection of asset identifiers of the preferred locales

locateDimensionSetInstanceForSite

public final com.fatwire.mda.DimensionSetInstance locateDimensionSetInstanceForSite(String site)
Returns the DimensionSetInstance. This implementation expects one DimensionSet enabled for the current site.

Specified by:
locateDimensionSetInstanceForSite in interface LocaleService
Parameters:
ics -
Returns:


Copyright © 2010-2013 Oracle Corporation. All Rights Reserved.