atg.repository.search.config
Class LanguageDimensionService

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.repository.search.config.GenericDimensionService
              extended by atg.repository.search.config.LanguageDimensionService
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, SearchDimension, java.util.EventListener

public class LanguageDimensionService
extends GenericDimensionService

The language dimension service will expect the passed in value string to be a language string. The service will map the language to a locale and the locale of the customer request will then be checked against this to look for a match. Note that a partial match of locales is done rather than an exact match, e.g. if the customers locale is "en_US_WIN" and the language maps to the locale "en" then this will be a match however if the language maps to the locale "en_GB" then this is not a match. The mapping of language to locale is a property of the languageDimensionService.

See Also:
atg.search.query.config.SearchDimension

Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.repository.search.config.GenericDimensionService
mDimensionName, mDimensionValueKeyPrefix, mDimensionValuesLocalized, mDisplayNameKey, mDisplayNameLocalized, mFormatter
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
LanguageDimensionService()
           
 
Method Summary
 boolean dimensionMatchesValue(DynamoHttpServletRequest pRequest, java.lang.String pValue)
          Checks the request locale against a passed in string locale for a match.
 boolean dimensionMatchesValue(RepositoryItem pProfile, java.lang.String pTargetValue)
          Checks whether or not a value extracted from the given profile matches the given value.
 boolean dimensionMatchesValue(java.lang.String pSourceValue, java.lang.String pTargetValue)
          Checks whether or not a given source value matches the given target value.
protected  boolean doesLanguageMatchLocale(java.util.Locale pLocale, java.lang.String pLanguage)
          Utility method to check a language against a locale.
 void doStartService()
          This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values.
 void doStopService()
          This is called when a Service is required to shut down.
 java.lang.String getDefaultLocale()
           
 java.util.List getDimensionValues()
          Returns a list of string dimension values that are valid for this dimension.
 java.util.Map getLanguageLocaleMap()
          Returns the map of language String to java.util.Locale objects.
 java.util.Map getLanguageMap()
           
 java.lang.String getLocale(java.lang.String pLanguage)
          Returns the locale string for the given language string.
 java.lang.String getLocaleDisplayName(java.lang.String pLocaleString)
          Method to get a localised display name for a language of the locale string.
 java.util.Locale getLocaleFromProfile(RepositoryItem pProfile)
          Method to retrieve Locale from user profile.
 java.util.List getLocales()
          Returns the list of locales.
 java.lang.String getTestProfileLocaleProperty()
           
 boolean isProfileBased()
           
 void setDefaultLocale(java.lang.String pDefaultLocale)
           
 void setDimensionValues(java.util.List pDimensionValues)
           
 void setLanguageLocaleMap(java.util.Map pLanguageLocaleMap)
          Sets the mapping of language String to java.util.Locale
 void setLanguageMap(java.util.Map pLanguageMap)
           
 void setLocales(java.util.List pLocales)
           
 void setTestProfileLocaleProperty(java.lang.String pTestProfileLocaleProperty)
           
protected  boolean validateLocale(java.lang.String pLocale)
          Validates the locale conforms to a java locale and has a language part.
protected  boolean validateLocales(java.util.List pLocales)
          Validates the list of locale strings.
protected  boolean validateLocales(java.util.Map pMap)
          Validates the map of language to locale strings.
 
Methods inherited from class atg.repository.search.config.GenericDimensionService
getAllDimensionValues, getDimensionName, getDimensionValueDisplayName, getDimensionValueKeyPrefix, getDimensionValuesLocalized, getDisplayName, getDisplayNameKey, getDisplayNameLocalized, getFormatter, setDimensionName, setDimensionValueKeyPrefix, setDimensionValuesLocalized, setDisplayNameKey, setDisplayNameLocalized, setFormatter
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

LanguageDimensionService

public LanguageDimensionService()
Method Detail

getLanguageMap

public java.util.Map getLanguageMap()

setLanguageMap

public void setLanguageMap(java.util.Map pLanguageMap)

getLocales

public java.util.List getLocales()
Returns the list of locales. The list of locales is obtained from the properties file.

Returns:
List of locales

setLocales

public void setLocales(java.util.List pLocales)

getDefaultLocale

public java.lang.String getDefaultLocale()

setDefaultLocale

public void setDefaultLocale(java.lang.String pDefaultLocale)

getTestProfileLocaleProperty

public java.lang.String getTestProfileLocaleProperty()

setTestProfileLocaleProperty

public void setTestProfileLocaleProperty(java.lang.String pTestProfileLocaleProperty)

doStartService

public void doStartService()
                    throws ServiceException
Description copied from class: GenericService
This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values. The Service should override this method to start any processes it requires.

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if the Service had a problem starting up

doStopService

public void doStopService()
                   throws ServiceException
Description copied from class: GenericService
This is called when a Service is required to shut down. The Service should respond by stopping any processes that it has started.

Overrides:
doStopService in class GenericService
Throws:
ServiceException - if the Service had a problem shutting down

getLanguageLocaleMap

public java.util.Map getLanguageLocaleMap()
Returns the map of language String to java.util.Locale objects.

Returns:
Map of language String to Locale

setLanguageLocaleMap

public void setLanguageLocaleMap(java.util.Map pLanguageLocaleMap)
Sets the mapping of language String to java.util.Locale

Parameters:
pLanguageLocaleMap - Map of String language to Locale

getDimensionValues

public java.util.List getDimensionValues()
Description copied from interface: SearchDimension
Returns a list of string dimension values that are valid for this dimension.

Returns:
List of language dimension values.
See Also:
Returns the language dimension values.

setDimensionValues

public void setDimensionValues(java.util.List pDimensionValues)

getLocale

public java.lang.String getLocale(java.lang.String pLanguage)
Returns the locale string for the given language string.

Parameters:
pLanguage - language string to map to locale
Returns:
String locale

dimensionMatchesValue

public boolean dimensionMatchesValue(DynamoHttpServletRequest pRequest,
                                     java.lang.String pValue)
Checks the request locale against a passed in string locale for a match.

Specified by:
dimensionMatchesValue in interface SearchDimension
Overrides:
dimensionMatchesValue in class GenericDimensionService
Parameters:
pRequest - DynamoHttpServletRequest.
pValue - locale string.
Returns:
true if locales are equal.

dimensionMatchesValue

public boolean dimensionMatchesValue(java.lang.String pSourceValue,
                                     java.lang.String pTargetValue)
Checks whether or not a given source value matches the given target value. Default implementation just matches source and target strings ignoring case.

Specified by:
dimensionMatchesValue in interface SearchDimension
Overrides:
dimensionMatchesValue in class GenericDimensionService
Parameters:
pSourceValue - String source value to check
pTargetValue - String target value to check.
Returns:
true if pSourceValue matches pTargetValue for this dimension

dimensionMatchesValue

public boolean dimensionMatchesValue(RepositoryItem pProfile,
                                     java.lang.String pTargetValue)
Description copied from class: GenericDimensionService
Checks whether or not a value extracted from the given profile matches the given value. Default implementation only returns true for the 'All others' case.

Specified by:
dimensionMatchesValue in interface SearchDimension
Overrides:
dimensionMatchesValue in class GenericDimensionService
Parameters:
pProfile - RepositoryItem profile to use
pTargetValue - String vlaue to check.
Returns:
true if pValue matches the dimension value extracted from pProfile

getLocaleFromProfile

public java.util.Locale getLocaleFromProfile(RepositoryItem pProfile)
Method to retrieve Locale from user profile. Relies on testProfileLocaleProperty being set to identify what the user profile Locale property name is. If testProfileLocaleProperty is not set then this method will return null.

Parameters:
pProfile - RepositoryItem profile to use
Returns:
Locale from derived from profile or null

getLocaleDisplayName

public java.lang.String getLocaleDisplayName(java.lang.String pLocaleString)
Method to get a localised display name for a language of the locale string. Looks up the resource bundles using a key with the format: .locale.. If it isn't found then it will use the Locale class method getLanguageDisplay() passing in the locale of the current request to localise the returned string.

Parameters:
pLocaleString - String locale
Returns:
String display name for the passed in locales language.
Throws:
java.lang.NullPointerException - if locale or resource bundle name is null.

isProfileBased

public boolean isProfileBased()
Returns:
true if this dimension can extract the dimension value from a profile.

doesLanguageMatchLocale

protected boolean doesLanguageMatchLocale(java.util.Locale pLocale,
                                          java.lang.String pLanguage)
Utility method to check a language against a locale. Need to check each locale part that is specified for the locale e.g. if the language locale mapping is: english=en_US then a check must be made against the request language and country codes. However if the language locale mapping was instead: english=en then only a check on language would be required for a match.

Parameters:
pLocale - Locale to check
pLanguage - String language to check
Returns:
true if the language of the locale matches the passed in language

validateLocales

protected boolean validateLocales(java.util.List pLocales)
Validates the list of locale strings. Each locale string must conform to a java locale and have a language part. All locales in this dimension service MUST have a non null/empty language part. Invalid entries are removed.

Parameters:
pLocales - List of String locale, e.g. "en_US"
Returns:
true if all String in the list are valid locale and contain language parts.

validateLocales

protected boolean validateLocales(java.util.Map pMap)
Validates the map of language to locale strings. Each locale string must conform to a java locale and have a language part. All locales in this dimension service MUST have a non null/empty language part. Invalid entries are removed.

Parameters:
pMap - Map of String language to String locale, e.g. "english=en_US"
Returns:
true if all String locales in the map are valid locales and contain language parts.

validateLocale

protected boolean validateLocale(java.lang.String pLocale)
Validates the locale conforms to a java locale and has a language part. All locales in this dimension service MUST have a non null/empty language part.

Parameters:
pLocale - String locale, e.g. "en_US"
Returns:
true if it is a valid locale and contains a language part.