Class AbstractCatalogEntityDeletedEventHandler
- All Implemented Interfaces:
CatalogEntityDeletedEventHandler
- Direct Known Subclasses:
CategoryAssetCatalogEntityDeletedEventHandler,CategoryProductCatalogEntityDeletedEventHandler,OptionTemplateCatalogEntityDeletedEventHandler,ProductAssetCatalogEntityDeletedEventHandler,ProductTagCatalogEntityDeletedEventHandler,PromotionalCategoryProductCatalogEntityDeletedEventHandler,PromotionalProductCatalogEntityDeletedEventHandler,TranslationCatalogEntityDeletedEventHandler,VariantCatalogEntityDeletedEventHandler
CatalogEntityDeletedEventHandler
instances.- Author:
- Sunny Yu
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractCatalogEntityDeletedEventHandler(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 TypeMethodDescriptionprotected com.broadleafcommerce.data.tracking.core.context.ContextInfobuildContext(@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.ContextInfobuildHydratedContextInfo(@NonNull com.broadleafcommerce.data.tracking.core.context.ContextRequest dehydratedContextRequest) Hydrates and builds aContextInfobased on the givenContextRequest.protected com.broadleafcommerce.data.tracking.core.context.ContextInfobuildMatchingContextInfo(@NonNull org.springframework.context.ApplicationEvent event) Builds a hydratedContextInfothat matches the context of the deleted entity from the given event.protected com.broadleafcommerce.data.tracking.core.context.ContextRequestbuildMatchingContextRequest(@NonNull com.broadleafcommerce.common.messaging.notification.domain.InternalPersistenceEvent event) Builds a matchingContextInfobased on the givenInternalPersistenceEvent.protected com.broadleafcommerce.data.tracking.core.context.ContextRequestbuildMatchingContextRequest(@NonNull com.broadleafcommerce.data.tracking.core.catalog.CatalogEntityDeletedEvent event) Builds a matchingContextInfobased on the givenCatalogEntityDeletedEvent.booleancanHandle(@NonNull org.springframework.context.ApplicationEvent event) Whether the givenApplicationEventcan be handled.protected <R> RdoWithoutPolicyValidation(Supplier<R> returningWork) Executes the givenreturningWorkwith security policy validations disabled.protected com.broadleafcommerce.data.tracking.core.tenant.service.CommonCatalogService<com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog>protected com.broadleafcommerce.data.tracking.core.web.ContextRequestHydratorClass<?>getDeletedEntityClassFromEvent(@NonNull org.springframework.context.ApplicationEvent event) Gets the deleted entity class from the given event.com.broadleafcommerce.data.tracking.core.TrackablegetDeletedEntityFromEvent(@NonNull org.springframework.context.ApplicationEvent event) Gets the deleted entity from the given event.protected com.fasterxml.jackson.databind.ObjectMapperAn abstract method to return aSetof classes of the deleted entities that are supported.protected com.broadleafcommerce.common.extension.TypeFactoryMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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
An abstract method to return aSetof classes of the deleted entities that are supported.For example, if a
CatalogEntityDeletedEventHandlerinstance can only handle the event when theJpaProductis deleted, this handler instance would be skipped when the emitted event is for aJpaCategoryProduct. -
getDeletedEntityClassFromEvent
public Class<?> getDeletedEntityClassFromEvent(@NonNull @NonNull org.springframework.context.ApplicationEvent event) Gets the deleted entity class from the given event.- Parameters:
event- theApplicationEventthat 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- theApplicationEventthat 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:CatalogEntityDeletedEventHandlerWhether the givenApplicationEventcan be handled.- Specified by:
canHandlein interfaceCatalogEntityDeletedEventHandler- Parameters:
event- theApplicationEventthat potentially represents the catalog entity deletion- Returns:
- true if the given
ApplicationEventcan 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 hydratedContextInfothat matches the context of the deleted entity from the given event.- Parameters:
event- theApplicationEventthat was emitted for the deleted entity- Returns:
- a
ContextInfothat matches the context of the deleted entity from the given event - Throws:
UnsupportedOperationException- if the givenApplicationEventis not supported
-
buildMatchingContextRequest
protected com.broadleafcommerce.data.tracking.core.context.ContextRequest buildMatchingContextRequest(@NonNull @NonNull com.broadleafcommerce.common.messaging.notification.domain.InternalPersistenceEvent event) Builds a matchingContextInfobased on the givenInternalPersistenceEvent. -
buildMatchingContextRequest
protected com.broadleafcommerce.data.tracking.core.context.ContextRequest buildMatchingContextRequest(@NonNull @NonNull com.broadleafcommerce.data.tracking.core.catalog.CatalogEntityDeletedEvent event) Builds a matchingContextInfobased on the givenCatalogEntityDeletedEvent. -
buildHydratedContextInfo
protected com.broadleafcommerce.data.tracking.core.context.ContextInfo buildHydratedContextInfo(@NonNull @NonNull com.broadleafcommerce.data.tracking.core.context.ContextRequest dehydratedContextRequest) Hydrates and builds aContextInfobased on the givenContextRequest.Note that
ContextRequest.isForceFilterByCatalogExcludeInheritance()is set totrue, 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- theContextRequestto hydrate- Returns:
- a hydrated
ContextInfobased on the givenContextRequest
-
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) -
doWithoutPolicyValidation
Executes the given
returningWorkwith security policy validations disabled.In almost all cases,
CatalogEntityDeletedEventHandlercomponents will run without anyAuthenticationin theSecurityContext, as they are run by the system internally. This is typically sufficient to bypass most security validations inTrackablePolicyUtils, but there are certain checks that are always applied.The primary example is the check that validates against
Application.isDeactivated(). We want to bypass this validation, particularly becauseCatalogEntityDeletedEventHandlercomponents are special and will want to clean up data even from applications that are currently deactivated.- Type Parameters:
R- the return type of the work- Parameters:
returningWork- the work to execute- Returns:
- the result of executing the work
- Since:
- CatalogServices 2.2.0, Release Train 2.2.0, CatalogServices 2.1.4, Release Train 2.1.4
-
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()
-