Class AbstractLocaleDAOImpl

java.lang.Object
org.alfresco.repo.domain.locale.AbstractLocaleDAOImpl
All Implemented Interfaces:
LocaleDAO
Direct Known Subclasses:
LocaleDAOImpl

public abstract class AbstractLocaleDAOImpl extends Object implements LocaleDAO
Abstract implementation for Locale DAO.

This provides basic services such as caching, but defers to the underlying implementation for CRUD operations. Since locales are system-wide and immutable, we can cache lookups in both directions.

Since:
3.4
Author:
janv
  • Constructor Details

    • AbstractLocaleDAOImpl

      protected AbstractLocaleDAOImpl()
      Default constructor.

      This sets up the DAO accessors to bypass any caching to handle the case where the caches are not supplied in the setters.

  • Method Details

    • setLocaleEntityCache

      public void setLocaleEntityCache(SimpleCache<Long,String> localeEntityCache)
      Set the cache that maintains the ID-Locale mappings and vice-versa (bi-directional)
      Parameters:
      localeEntityCache - the cache
    • getLocalePair

      public Pair<Long,Locale> getLocalePair(Locale locale)
      Specified by:
      getLocalePair in interface LocaleDAO
      Parameters:
      locale - the locale to fetch or null to get the default locale
      Returns:
      the locale or null if no such locale exists
    • getDefaultLocalePair

      public Pair<Long,Locale> getDefaultLocalePair()
      Specified by:
      getDefaultLocalePair in interface LocaleDAO
      Returns:
      the locale pair for the default locale. Although the Locale object will be populated, the ID will point to an instance that generically refers to the system's default locale i.e. the value returned can vary depending on the executing thread's default locale.
    • getLocalePair

      public Pair<Long,Locale> getLocalePair(Long id)
      Specified by:
      getLocalePair in interface LocaleDAO
      Parameters:
      id - the unique ID of the entity
      Returns:
      the locale pair (never null)
    • getOrCreateLocalePair

      public Pair<Long,Locale> getOrCreateLocalePair(Locale locale)
      Gets the locale ID for an existing instance or creates a new entity if one doesn't exist.
      Specified by:
      getOrCreateLocalePair in interface LocaleDAO
      Parameters:
      locale - the locale to fetch or null to get or create the default locale.
      Returns:
      the locale - never null
    • getOrCreateDefaultLocalePair

      public Pair<Long,Locale> getOrCreateDefaultLocalePair()
      Find or create the details representing the default locale.
      Specified by:
      getOrCreateDefaultLocalePair in interface LocaleDAO
      Returns:
      the locale pair for the default locale. Although the Locale object will be populated, the ID will point to an instance that generically refers to the system's default locale i.e. the value returned can vary depending on the executing thread's default locale.
    • getLocaleEntity

      protected abstract LocaleEntity getLocaleEntity(Long id)
    • getLocaleEntity

      protected abstract LocaleEntity getLocaleEntity(String locale)
    • createLocaleEntity

      protected abstract LocaleEntity createLocaleEntity(String locale)