Class DefaultImpersonationService

java.lang.Object
de.hybris.platform.commerceservices.impersonation.impl.DefaultImpersonationService
All Implemented Interfaces:
ImpersonationService

public class DefaultImpersonationService extends Object implements ImpersonationService
The impersonation service executes code passed in a ImpersonationService.Executor in the context of user, currency, language, site, etc.
  • Constructor Details

    • DefaultImpersonationService

      public DefaultImpersonationService()
  • Method Details

    • executeInContext

      public <R, T extends Throwable> R executeInContext(ImpersonationContext context, ImpersonationService.Executor<R,T> wrapper) throws T
      Description copied from interface: ImpersonationService
      Execute the wrapper code in the context of the specified user
      Specified by:
      executeInContext in interface ImpersonationService
      Type Parameters:
      R - The type of the return value
      T - The type of the exception thrown by the wrapper
      Parameters:
      context - The context to execute in
      wrapper - The code to execute in that context
      Returns:
      The result of method being executed
      Throws:
      T - The exception thrown by the wrapper if an error occurs
    • configureSession

      protected void configureSession(ImpersonationContext context)
      Impersonates local session with parameters passed in context.
      Parameters:
      context - The context to impersonate
    • determineSessionBaseSite

      protected BaseSiteModel determineSessionBaseSite(ImpersonationContext context)
      Parameters:
      context - The context to impersonate
      Returns:
      base site that should be used in session context. No null returned.
    • determineSessionCurrency

      protected CurrencyModel determineSessionCurrency(ImpersonationContext context)
      Parameters:
      context - The context to impersonate
      Returns:
      currency that should be used in session context. No null returned.
    • determineSessionLanguage

      protected LanguageModel determineSessionLanguage(ImpersonationContext context)
      Parameters:
      context - The context to impersonate
      Returns:
      language that should be used in session context. No null returned.
    • determineSessionCatalogVersions

      protected Collection<CatalogVersionModel> determineSessionCatalogVersions(ImpersonationContext context)
      Parameters:
      context - The context to impersonate
      Returns:
      catalog versions that should be used in session context. No null returned.
    • determineSessionTaxGroup

      protected UserTaxGroup determineSessionTaxGroup(ImpersonationContext context)
      Parameters:
      context - The context to impersonate
      Returns:
      tax group that should be used into session context.
    • determineSessionUser

      protected UserModel determineSessionUser(ImpersonationContext context)
      Parameters:
      context - The context to impersonate
      Returns:
      user that should be used into session context. No null returned.
    • getSessionCatalogVersionsForUser

      protected Set<CatalogVersionModel> getSessionCatalogVersionsForUser(UserModel user)
      Get the session catalog versions for the specified user. Get the set of catalog versions that should be visible to the specified user and should be set on the user's session. These catalog versions will be used in all search restrictions for code run in the impersonation context of the user. The default implementation is to get all the active catalog versions. Sub-classes can implement a different strategy.
      Parameters:
      user - The user
      Returns:
      The set of catalog versions for this specified user
    • getActiveCatalogVersions

      protected Collection<CatalogVersionModel> getActiveCatalogVersions()
      Get all the active catalog versions in the system.
      Returns:
      The active catalog versions or an empty list if none found
    • getSessionService

      protected SessionService getSessionService()
    • setSessionService

      public void setSessionService(SessionService sessionService)
    • getCatalogVersionService

      protected CatalogVersionService getCatalogVersionService()
    • setCatalogVersionService

      public void setCatalogVersionService(CatalogVersionService catalogVersionService)
    • getUserService

      protected UserService getUserService()
    • setUserService

      public void setUserService(UserService userService)
    • getSearchRestrictionService

      protected SearchRestrictionService getSearchRestrictionService()
    • setSearchRestrictionService

      public void setSearchRestrictionService(SearchRestrictionService searchRestrictionService)
    • getFlexibleSearchService

      protected FlexibleSearchService getFlexibleSearchService()
    • setFlexibleSearchService

      public void setFlexibleSearchService(FlexibleSearchService flexibleSearchService)
    • getI18nService

      protected CommonI18NService getI18nService()
    • setI18nService

      public void setI18nService(CommonI18NService i18nService)
    • getBaseStoreService

      protected BaseStoreService getBaseStoreService()
    • setBaseStoreService

      public void setBaseStoreService(BaseStoreService baseStoreService)
    • getBaseSiteService

      protected BaseSiteService getBaseSiteService()
    • setBaseSiteService

      public void setBaseSiteService(BaseSiteService baseSiteService)