Class ApplicationCatalogValidator

java.lang.Object
com.broadleafcommerce.tenant.service.validation.ApplicationCatalogValidator

public class ApplicationCatalogValidator extends Object
A validator specifically intended for use in the ApplicationCatalogService. It intentionally does not implement EntityValidator, as it does not apply in the normal CRUD flow.

Its purpose is to perform any validation that specifically applies to CRUD operations on ApplicationCatalogRef from an application context.

Author:
Samarth Dhruva (samarthd)
See Also:
  • Constructor Details

    • ApplicationCatalogValidator

      public ApplicationCatalogValidator()
  • Method Details

    • validateForCreate

      public void validateForCreate(@NonNull @NonNull Application application, @NonNull @NonNull ApplicationCatalog applicationCatalog, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, @NonNull @NonNull org.springframework.validation.Errors errors)
      This method is intended to perform any validation on applicationCatalog that should specifically apply when creating and assigning a Catalog from an application context.

      This should be invoked before any validations on Catalog or Application apply.

      Parameters:
      application - the application for which a catalog is being created
      applicationCatalog - the application catalog to validate
      contextInfo - context information surrounding sandboxing and multitenant state
      errors - the errors object bound to applicationCatalog on which errors can be registered
      See Also:
    • validateForReplace

      public void validateForReplace(@NonNull @NonNull Application application, @NonNull @NonNull Catalog referencedCatalog, @NonNull @NonNull ApplicationCatalogRef original, @NonNull @NonNull ApplicationCatalogRef replacement, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, @NonNull @NonNull org.springframework.validation.Errors errors)
      This method is intended to perform any validation on replacement that should specifically apply when replacing one of an Application's catalog refs from an application context.

      This should be invoked before any validations on Catalog or Application apply.

      Parameters:
      application - the application for which an ApplicationCatalogRef is being replaced. This should be the fully-hydrated value from the data store.
      referencedCatalog - the fully-hydrated catalog corresponding to the id referenced by ApplicationCatalogRef.getId() on original
      original - the ApplicationCatalogRef that currently exists on the Application and is being replaced
      replacement - the ApplicationCatalogRef that will replace original on the application. This is the object that should be validated.
      contextInfo - context information surrounding sandboxing and multitenant state
      errors - the errors object bound to the replacement on which errors can be registered
      See Also:
    • validateImmutableFieldsForGlobalCatalogRefReplacement

      protected void validateImmutableFieldsForGlobalCatalogRefReplacement(ApplicationCatalogRef original, ApplicationCatalogRef replacement, org.springframework.validation.Errors errors)
      When an ApplicationCatalogRef is for a catalog not created by the current application, certain fields are immutable from the application context.
      Parameters:
      original - the ApplicationCatalogRef that currently exists on the Application and is being replaced
      replacement - the ApplicationCatalogRef that will replace original on the application
      errors - the errors object bound to the replacement on which errors can be registered
    • prefixWithValidationMessageKey

      protected String prefixWithValidationMessageKey(String errorCode)