Class DefaultImpersonationService

    • Constructor Detail

      • DefaultImpersonationService

        public DefaultImpersonationService()
    • Method Detail

      • executeInContext

        public <R,​T extends java.lang.Throwable> R executeInContext​(ImpersonationContext context,
                                                                          ImpersonationService.Executor<R,​T> wrapper)
                                                                   throws T extends java.lang.Throwable
        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
        T extends java.lang.Throwable
      • 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 java.util.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 java.util.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 java.util.Collection<CatalogVersionModel> getActiveCatalogVersions()
        Get all the active catalog versions in the system.
        Returns:
        The active catalog versions or an empty list if none found
      • setSessionService

        public void setSessionService​(SessionService sessionService)
      • setCatalogVersionService

        public void setCatalogVersionService​(CatalogVersionService catalogVersionService)
      • getUserService

        protected UserService getUserService()
      • setUserService

        public void setUserService​(UserService userService)
      • setSearchRestrictionService

        public void setSearchRestrictionService​(SearchRestrictionService searchRestrictionService)
      • setFlexibleSearchService

        public void setFlexibleSearchService​(FlexibleSearchService flexibleSearchService)
      • setBaseStoreService

        public void setBaseStoreService​(BaseStoreService baseStoreService)
      • setBaseSiteService

        public void setBaseSiteService​(BaseSiteService baseSiteService)