Class ContextUtil
java.lang.Object
com.broadleafcommerce.adminuser.user.service.ContextUtil
Contains various utility functions related to determining the current context.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<com.broadleafcommerce.data.tracking.core.tenant.domain.Application>
getApplication
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) static String
getApplicationId
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve the current application context IDstatic String
getTenantId
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve the current tenant IDstatic boolean
inApplicationContext
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns true if in an application context, else false.static boolean
inTenantContext
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns true if in tenant context, else false.static boolean
Check if this is an application level only user.static boolean
isGlobalContext
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns true if in global context, else false.static boolean
isGlobalLevelUser
(AdminUser user) static boolean
isTenantOnlyUser
(AdminUser user) Check if this is a tenant level only user.static boolean
userApplicationMatchesCurrentContext
(AdminUser user, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Checks if theAdminUser.getApplicationIds()
match the current application context.static boolean
userTenantMatchesContext
(AdminUser user, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Checks if the value ofAdminUser.getTenantId()
matches the tenant in 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 ofAdminUser.getTenantId()
matches the tenant in the current context- Parameters:
user
- The user to checkcontextInfo
- 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 theAdminUser.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 checkcontextInfo
- The current context- Returns:
- true if the user application matches the current context, else false.
-
isTenantOnlyUser
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
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
-