Class CustomerSingleIndexRequestHandler


  • public class CustomerSingleIndexRequestHandler
    extends com.broadleafcommerce.search.index.common.messaging.handler.AbstractSingleIndexRequestHandler
    Listens for single index requests originating from changes to Customers and sends them to be updated in the index.
    • Constructor Detail

      • CustomerSingleIndexRequestHandler

        public CustomerSingleIndexRequestHandler​(CustomerService customerService,
                                                 com.broadleafcommerce.search.index.core.service.ReindexDelegationService reindexDelegationService,
                                                 com.broadleafcommerce.search.index.core.service.ReindexService reindexService,
                                                 com.fasterxml.jackson.databind.ObjectMapper objectMapper)
    • Method Detail

      • hook

        @StreamListener("singleIndexRequestInputCustomer")
        public void hook​(String singleIndexRequest)
        Specified by:
        hook in class com.broadleafcommerce.search.index.common.messaging.handler.AbstractSingleIndexRequestHandler
      • processSingleIndexRequest

        public void processSingleIndexRequest​(com.fasterxml.jackson.databind.JsonNode singleIndexRequest)
        Specified by:
        processSingleIndexRequest in class com.broadleafcommerce.search.index.common.messaging.handler.AbstractSingleIndexRequestHandler
      • indexCustomer

        protected void indexCustomer​(com.fasterxml.jackson.databind.JsonNode singleIndexRequest)
                              throws com.broadleafcommerce.search.api.SearchIndexException
        Throws:
        com.broadleafcommerce.search.api.SearchIndexException
      • deleteCustomerFromIndex

        protected void deleteCustomerFromIndex​(com.fasterxml.jackson.databind.JsonNode singleIndexRequest)
                                        throws com.broadleafcommerce.search.api.SearchIndexException
        Deletes a customer from the index.
        Parameters:
        singleIndexRequest - The JSON representation of the single index request
        Throws:
        com.broadleafcommerce.search.api.SearchIndexException - If the deletion fails.
      • isDelete

        protected boolean isDelete​(com.fasterxml.jackson.databind.JsonNode singleIndexRequest)
        Parameters:
        singleIndexRequest - The JSON representation of the single index request
        Returns:
        true if this is a customer delete, else false.
      • readCustomer

        @Nullable
        protected com.broadleafcommerce.search.customer.core.domain.Customer readCustomer​(com.fasterxml.jackson.databind.JsonNode singleIndexRequest)
                                                                                   throws com.broadleafcommerce.search.api.SearchIndexException
        Read all state versions of customers with the context ID of the customer associated with the given object.
        Parameters:
        singleIndexRequest - The JSON representation of the single index request
        Returns:
        list of all state versions of customers with the object's customer context ID
        Throws:
        com.broadleafcommerce.search.api.SearchIndexException - if the object has no context ID for a customer
      • getCustomerCtxId

        protected String getCustomerCtxId​(com.fasterxml.jackson.databind.JsonNode singleIndexRequest)
                                   throws com.broadleafcommerce.search.api.SearchIndexException
        Read the context ID of the customer associated with the given object.
        Parameters:
        singleIndexRequest - The JSON representation of the single index request
        Returns:
        the context ID of the associated customer
        Throws:
        com.broadleafcommerce.search.api.SearchIndexException - if the object has no context ID for a customer
      • getSupportedSimpleTypeNames

        public String[] getSupportedSimpleTypeNames()
        Specified by:
        getSupportedSimpleTypeNames in class com.broadleafcommerce.search.index.common.messaging.handler.AbstractSingleIndexRequestHandler
      • getCustomerCtxIdPath

        protected String getCustomerCtxIdPath()
        Get the path for retrieving the customer context ID from a single index request JSON payload.
        Returns:
        path to customer context ID
      • getCustomerDeleteProperty

        protected String getCustomerDeleteProperty()
      • getReindexDelegationService

        protected com.broadleafcommerce.search.index.core.service.ReindexDelegationService getReindexDelegationService()
      • getReindexService

        protected com.broadleafcommerce.search.index.core.service.ReindexService getReindexService()