Interface AdminPermissionContextValidator<P extends AdminPermission>
- All Known Implementing Classes:
DefaultAdminPermissionContextValidator
public interface AdminPermissionContextValidator<P extends AdminPermission>
Various context-related validation functions for use when performing CRUD operations related to
an admin permission.
This performs only context-related validations. AdminPermissionValidator 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.
- Author:
- Samarth Dhruva (samarthd)
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanisMutableFromContext(P permission, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns whether or not the given entity is mutable from the given context.org.springframework.validation.ErrorsvalidateCreate(P permission, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates a create operation is allowed in the current context.voidvalidateCreate(P permission, 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.ErrorsvalidateDelete(P permission, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates a delete operation is allowed in the current context.voidvalidateDelete(P permission, 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.ErrorsvalidateUpdate(String id, P permission, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates an update operation is allowed in the current context.voidvalidateUpdate(String id, P permission, 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 permission, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates a create operation is allowed in the current context.- Parameters:
permission- The permission to validatecontextInfo- The current context- Returns:
- An
Errorsobject bound to a {code permission} - 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 permission, @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 permission being updated, explicitly provided such that it can be used to find the existing record even ifAdminPermission.idis unsupplied inpermission.permission- The permission to validatecontextInfo- The current context- Returns:
- An
Errorsobject bound to a {code permission} - 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 permission is immutable from the given context- See Also:
-
validateDelete
org.springframework.validation.Errors validateDelete(P permission, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates a delete operation is allowed in the current context.- Parameters:
permission- the permission being deleted to validatecontextInfo- The current context- Returns:
- An
Errorsobject bound to a {code permission} - 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 permission is immutable from the given context- See Also:
-
validateCreate
void validateCreate(P permission, 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:
permission- The permission to validateerrors- An errors object bound to thepermissionto 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 permission, 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 permission being updated, explicitly provided such that it can be used to find the existing record even ifAdminPermission.idis unsupplied inpermission.permission- The permission to validateerrors- An errors object bound to thepermissionto 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 permission is immutable from the given context
-
validateDelete
void validateDelete(P permission, 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:
permission- The permission being deleted to validateerrors- An errors object bound to thepermissionto 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 permission is immutable from the given context
-
isMutableFromContext
boolean isMutableFromContext(P permission, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns whether or not the given entity is mutable from the given context.- Parameters:
permission- 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
-