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 Type
    Method
    Description
    boolean
    isMutableFromContext(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.Errors
    validateCreate(P permission, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Validates a create operation is allowed in the current context.
    void
    validateCreate(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.Errors
    validateDelete(P permission, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Validates a delete operation is allowed in the current context.
    void
    validateDelete(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.Errors
    validateUpdate(String id, P permission, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Validates an update operation is allowed in the current context.
    void
    validateUpdate(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 validate
      contextInfo - The current context
      Returns:
      An Errors object 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 if AdminPermission.id is unsupplied in permission.
      permission - The permission to validate
      contextInfo - The current context
      Returns:
      An Errors object 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 validate
      contextInfo - The current context
      Returns:
      An Errors object 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 validate
      errors - An errors object bound to the permission to be validated
      contextInfo - 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 if AdminPermission.id is unsupplied in permission.
      permission - The permission to validate
      errors - An errors object bound to the permission to be validated
      contextInfo - 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 validate
      errors - An errors object bound to the permission to be validated
      contextInfo - 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 checked
      contextInfo - the context in which mutability should be checked
      Returns:
      true if the entity is mutable from the given context, false otherwise