Interface AdminRoleContextValidator<P extends AdminRole>
- All Known Implementing Classes:
DefaultAdminRoleContextValidator
public interface AdminRoleContextValidator<P extends AdminRole>
Various context-related validation functions for use when performing CRUD operations related to
an admin role.
This performs only context-related validations. AdminRoleValidator
is used for the more
basic field validations.
If the ContextInfo
argument or tenant id is null on the context, certain validation
should still be performed, such as verifying the current authentication is not
application-restricted and all assigned AdminRole.permissions
are accessible from the
role's context.
- Author:
- Samarth Dhruva (samarthd)
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
isMutableFromContext
(P role, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns whether or not the given entity is mutable from the given context.org.springframework.validation.Errors
validateCreate
(P role, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates a create operation is allowed in the current context.void
validateCreate
(P role, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates a create operation is allowed in the current context.org.springframework.validation.Errors
validateDelete
(P role, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates a delete operation is allowed in the current context.void
validateDelete
(P role, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates a delete operation is allowed in the current context.org.springframework.validation.Errors
validateUpdate
(String id, P role, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates an update operation is allowed in the current context.void
validateUpdate
(String id, P role, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates an update operation is allowed in the current context.
-
Method Details
-
validateCreate
org.springframework.validation.Errors validateCreate(P role, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates a create operation is allowed in the current context.- Parameters:
role
- The role to validatecontextInfo
- The current context- Returns:
- An
Errors
object bound to a {code role} - Throws:
com.broadleafcommerce.data.tracking.core.exception.NotPermittedException
- if the current authentication cannot perform the operation (ex: the current authentication is application-restricted and therefore cannot perform this tenant-level operation)- See Also:
-
validateUpdate
org.springframework.validation.Errors validateUpdate(String id, P role, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates an update operation is allowed in the current context.- Parameters:
id
- the id of the role being updated, explicitly provided such that it can be used to find the existing record even ifAdminRole.id
is unsupplied inrole
.role
- The role to validatecontextInfo
- The current context- Returns:
- An
Errors
object bound to a {code role} - Throws:
com.broadleafcommerce.data.tracking.core.exception.NotPermittedException
- if the current authentication cannot perform the operation (ex: the current authentication is application-restricted and therefore cannot perform this tenant-level operation)com.broadleafcommerce.data.tracking.core.exception.InvalidContextRequestException
- if the role is immutable from the given context- See Also:
-
validateDelete
org.springframework.validation.Errors validateDelete(P role, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates a delete operation is allowed in the current context.- Parameters:
role
- the role being deleted to validatecontextInfo
- The current context- Returns:
- An
Errors
object bound to a {code role} - Throws:
com.broadleafcommerce.data.tracking.core.exception.NotPermittedException
- if the current authentication cannot perform the operation (ex: the current authentication is application-restricted and therefore cannot perform this tenant-level operation)com.broadleafcommerce.data.tracking.core.exception.InvalidContextRequestException
- if the role is immutable from the given context- See Also:
-
validateCreate
void validateCreate(P role, org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates a create operation is allowed in the current context.- Parameters:
role
- The role to validateerrors
- An errors object bound to therole
to be validatedcontextInfo
- The current context- Throws:
com.broadleafcommerce.data.tracking.core.exception.NotPermittedException
- if the current authentication cannot perform the operation (ex: the current authentication is application-restricted and therefore cannot perform this tenant-level operation)
-
validateUpdate
void validateUpdate(String id, P role, org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates an update operation is allowed in the current context.- Parameters:
id
- the id of the role being updated, explicitly provided such that it can be used to find the existing record even ifAdminRole.id
is unsupplied inrole
.role
- The role to validateerrors
- An errors object bound to therole
to be validatedcontextInfo
- The current context- Throws:
com.broadleafcommerce.data.tracking.core.exception.NotPermittedException
- if the current authentication cannot perform the operation (ex: the current authentication is application-restricted and therefore cannot perform this tenant-level operation)com.broadleafcommerce.data.tracking.core.exception.InvalidContextRequestException
- if the role is immutable from the given context
-
validateDelete
void validateDelete(P role, org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates a delete operation is allowed in the current context.- Parameters:
role
- The role being deleted to validateerrors
- An errors object bound to therole
to be validatedcontextInfo
- The current context- Throws:
com.broadleafcommerce.data.tracking.core.exception.NotPermittedException
- if the current authentication cannot perform the operation (ex: the current authentication is application-restricted and therefore cannot perform this tenant-level operation)com.broadleafcommerce.data.tracking.core.exception.InvalidContextRequestException
- if the role is immutable from the given context
-
isMutableFromContext
boolean isMutableFromContext(P role, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns whether or not the given entity is mutable from the given context.- Parameters:
role
- the entity whose mutability should be checkedcontextInfo
- the context in which mutability should be checked- Returns:
- true if the entity is mutable from the given context, false otherwise
-