Class AbstractCatalogEntityDeletedEventHandler

java.lang.Object
com.broadleafcommerce.catalog.messaging.entitydeletion.handlers.AbstractCatalogEntityDeletedEventHandler
All Implemented Interfaces:
CatalogEntityDeletedEventHandler
Direct Known Subclasses:
CategoryAssetCatalogEntityDeletedEventHandler, CategoryProductCatalogEntityDeletedEventHandler, OptionTemplateCatalogEntityDeletedEventHandler, ProductAssetCatalogEntityDeletedEventHandler, ProductTagCatalogEntityDeletedEventHandler, PromotionalCategoryProductCatalogEntityDeletedEventHandler, PromotionalProductCatalogEntityDeletedEventHandler, TranslationCatalogEntityDeletedEventHandler, VariantCatalogEntityDeletedEventHandler

public abstract class AbstractCatalogEntityDeletedEventHandler extends Object implements CatalogEntityDeletedEventHandler
Provides common processing functionality to all CatalogEntityDeletedEventHandler instances.
Author:
Sunny Yu
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractCatalogEntityDeletedEventHandler(com.broadleafcommerce.data.tracking.core.tenant.service.CommonCatalogService<com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog> catalogService, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.data.tracking.core.web.ContextRequestHydrator contextRequestHydrator)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected com.broadleafcommerce.data.tracking.core.context.ContextInfo
    buildContext(@NonNull com.broadleafcommerce.data.tracking.core.type.OperationType operationType, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextRequest contextRequest)
     
    protected com.broadleafcommerce.data.tracking.core.context.ContextInfo
    buildHydratedContextInfo(@NonNull com.broadleafcommerce.data.tracking.core.context.ContextRequest dehydratedContextRequest)
    Hydrates and builds a ContextInfo based on the given ContextRequest.
    protected com.broadleafcommerce.data.tracking.core.context.ContextInfo
    buildMatchingContextInfo(@NonNull org.springframework.context.ApplicationEvent event)
    Builds a hydrated ContextInfo that matches the context of the deleted entity from the given event.
    protected com.broadleafcommerce.data.tracking.core.context.ContextRequest
    buildMatchingContextRequest(@NonNull com.broadleafcommerce.common.messaging.notification.domain.InternalPersistenceEvent event)
    Builds a matching ContextInfo based on the given InternalPersistenceEvent.
    protected com.broadleafcommerce.data.tracking.core.context.ContextRequest
    buildMatchingContextRequest(@NonNull com.broadleafcommerce.data.tracking.core.catalog.CatalogEntityDeletedEvent event)
    Builds a matching ContextInfo based on the given CatalogEntityDeletedEvent.
    boolean
    canHandle(@NonNull org.springframework.context.ApplicationEvent event)
    Whether the given ApplicationEvent can be handled.
    protected com.broadleafcommerce.data.tracking.core.tenant.service.CommonCatalogService<com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog>
     
    protected com.broadleafcommerce.data.tracking.core.web.ContextRequestHydrator
     
    getDeletedEntityClassFromEvent(@NonNull org.springframework.context.ApplicationEvent event)
    Gets the deleted entity class from the given event.
    com.broadleafcommerce.data.tracking.core.Trackable
    getDeletedEntityFromEvent(@NonNull org.springframework.context.ApplicationEvent event)
    Gets the deleted entity from the given event.
    protected com.fasterxml.jackson.databind.ObjectMapper
     
    abstract Set<Class<?>>
    An abstract method to return a Set of classes of the deleted entities that are supported.
    protected com.broadleafcommerce.common.extension.TypeFactory
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.broadleafcommerce.catalog.messaging.entitydeletion.handlers.CatalogEntityDeletedEventHandler

    handle
  • Constructor Details

    • AbstractCatalogEntityDeletedEventHandler

      public AbstractCatalogEntityDeletedEventHandler(com.broadleafcommerce.data.tracking.core.tenant.service.CommonCatalogService<com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog> catalogService, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.data.tracking.core.web.ContextRequestHydrator contextRequestHydrator)
  • Method Details

    • getSupportedDeletedEntityClasses

      public abstract Set<Class<?>> getSupportedDeletedEntityClasses()
      An abstract method to return a Set of classes of the deleted entities that are supported.

      For example, if a CatalogEntityDeletedEventHandler instance can only handle the event when the JpaProduct is deleted, this handler instance would be skipped when the emitted event is for a JpaCategoryProduct.

    • getDeletedEntityClassFromEvent

      public Class<?> getDeletedEntityClassFromEvent(@NonNull @NonNull org.springframework.context.ApplicationEvent event)
      Gets the deleted entity class from the given event.
      Parameters:
      event - the ApplicationEvent that was emitted for the deleted entity
      Returns:
      the deleted entity class from the given event
    • getDeletedEntityFromEvent

      public com.broadleafcommerce.data.tracking.core.Trackable getDeletedEntityFromEvent(@NonNull @NonNull org.springframework.context.ApplicationEvent event)
      Gets the deleted entity from the given event.
      Parameters:
      event - the ApplicationEvent that was emitted for the deleted entity
      Returns:
      the deleted entity from the given event
    • canHandle

      public boolean canHandle(@NonNull @NonNull org.springframework.context.ApplicationEvent event)
      Description copied from interface: CatalogEntityDeletedEventHandler
      Whether the given ApplicationEvent can be handled.
      Specified by:
      canHandle in interface CatalogEntityDeletedEventHandler
      Parameters:
      event - the ApplicationEvent that potentially represents the catalog entity deletion
      Returns:
      true if the given ApplicationEvent can be handled, otherwise false
    • buildMatchingContextInfo

      protected com.broadleafcommerce.data.tracking.core.context.ContextInfo buildMatchingContextInfo(@NonNull @NonNull org.springframework.context.ApplicationEvent event) throws UnsupportedOperationException
      Builds a hydrated ContextInfo that matches the context of the deleted entity from the given event.
      Parameters:
      event - the ApplicationEvent that was emitted for the deleted entity
      Returns:
      a ContextInfo that matches the context of the deleted entity from the given event
      Throws:
      UnsupportedOperationException - if the given ApplicationEvent is not supported
    • buildMatchingContextRequest

      protected com.broadleafcommerce.data.tracking.core.context.ContextRequest buildMatchingContextRequest(@NonNull @NonNull com.broadleafcommerce.common.messaging.notification.domain.InternalPersistenceEvent event)
      Builds a matching ContextInfo based on the given InternalPersistenceEvent.
    • buildMatchingContextRequest

      protected com.broadleafcommerce.data.tracking.core.context.ContextRequest buildMatchingContextRequest(@NonNull @NonNull com.broadleafcommerce.data.tracking.core.catalog.CatalogEntityDeletedEvent event)
      Builds a matching ContextInfo based on the given CatalogEntityDeletedEvent.
    • buildHydratedContextInfo

      protected com.broadleafcommerce.data.tracking.core.context.ContextInfo buildHydratedContextInfo(@NonNull @NonNull com.broadleafcommerce.data.tracking.core.context.ContextRequest dehydratedContextRequest)
      Hydrates and builds a ContextInfo based on the given ContextRequest.

      Note that ContextRequest.isForceFilterByCatalogExcludeInheritance() is set to true, which is to ensure that the relationship entities are only fetched from the specified catalog instead of from the entire catalog hierarchy. Since the catalog tree is walked and an event is emitted for each level, there is no need to fetch entities from other catalogs that are not explicitly specified in the current context.

      Parameters:
      dehydratedContextRequest - the ContextRequest to hydrate
      Returns:
      a hydrated ContextInfo based on the given ContextRequest
    • buildContext

      protected com.broadleafcommerce.data.tracking.core.context.ContextInfo buildContext(@NonNull @NonNull com.broadleafcommerce.data.tracking.core.type.OperationType operationType, @NonNull @NonNull com.broadleafcommerce.data.tracking.core.context.ContextRequest contextRequest)
    • getCatalogService

      protected com.broadleafcommerce.data.tracking.core.tenant.service.CommonCatalogService<com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog> getCatalogService()
    • getObjectMapper

      protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • getContextRequestHydrator

      protected com.broadleafcommerce.data.tracking.core.web.ContextRequestHydrator getContextRequestHydrator()