java.lang.Object
com.broadleafcommerce.adminuser.user.service.ContextUtil

public class ContextUtil extends Object
Contains various utility functions related to determining the current context.
  • Constructor Details

    • ContextUtil

      public ContextUtil()
  • Method Details

    • inApplicationContext

      public static boolean inApplicationContext(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Returns true if in an application context, else false.
      Parameters:
      contextInfo - The current context
      Returns:
      true if user is in the context of an application, else false. Note: A null context always returns false
    • inTenantContext

      public static boolean inTenantContext(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Returns true if in tenant context, else false.
      Parameters:
      contextInfo - The current context.
      Returns:
      true if in tenant context, else false. Note: A null context always returns false
    • isGlobalContext

      public static boolean isGlobalContext(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Returns true if in global context, else false.
      Parameters:
      contextInfo - The current context.
      Returns:
      true if in global context, else false. Note: A null context always returns false
    • getApplicationId

      public static String getApplicationId(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Retrieve the current application context ID
      Parameters:
      contextInfo - The current context
      Returns:
      The application ID, or null if not in an application context
    • getApplication

      public static Optional<com.broadleafcommerce.data.tracking.core.tenant.domain.Application> getApplication(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getTenantId

      @Nullable public static String getTenantId(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Retrieve the current tenant ID
      Parameters:
      contextInfo - The current context
      Returns:
      The tenant ID, or null if not in a tenant context
    • userTenantMatchesContext

      public static boolean userTenantMatchesContext(AdminUser user, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Checks if the value of AdminUser.getTenantId() matches the tenant in the current context
      Parameters:
      user - The user to check
      contextInfo - The current context
      Returns:
      true if user tenant matches the current context, else false.
    • userApplicationMatchesCurrentContext

      public static boolean userApplicationMatchesCurrentContext(AdminUser user, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Checks if the AdminUser.getApplicationIds() match the current application context.

      Note that a tenant level user creating another tenant level user will always return false.

      Parameters:
      user - The user to check
      contextInfo - The current context
      Returns:
      true if the user application matches the current context, else false.
    • isTenantOnlyUser

      public static boolean isTenantOnlyUser(AdminUser user)
      Check if this is a tenant level only user.
      Parameters:
      user - The user to check.
      Returns:
      true if tenant level only user, else false.
    • isApplicationOnlyUser

      public static boolean isApplicationOnlyUser(AdminUser user)
      Check if this is an application level only user.
      Parameters:
      user - The user to check.
      Returns:
      true if an application level only user, else false.
    • isGlobalLevelUser

      public static boolean isGlobalLevelUser(AdminUser user)