Class CustomerSingleIndexRequestHandler
- java.lang.Object
-
- com.broadleafcommerce.search.index.common.messaging.handler.AbstractSingleIndexRequestHandler
-
- com.broadleafcommerce.search.index.customer.messaging.handler.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.
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_DELETE_PROPERTY
-
Constructor Summary
Constructors Constructor Description 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 Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
deleteCustomerFromIndex(com.fasterxml.jackson.databind.JsonNode singleIndexRequest)
Deletes a customer from the index.protected String
getCustomerCtxId(com.fasterxml.jackson.databind.JsonNode singleIndexRequest)
Read the context ID of the customer associated with the given object.protected String
getCustomerCtxIdPath()
Get the path for retrieving the customer context ID from a single index request JSON payload.protected String
getCustomerDeleteProperty()
protected CustomerService
getCustomerService()
protected com.broadleafcommerce.search.index.core.service.ReindexDelegationService
getReindexDelegationService()
protected com.broadleafcommerce.search.index.core.service.ReindexService
getReindexService()
String[]
getSupportedSimpleTypeNames()
void
hook(String singleIndexRequest)
protected void
indexCustomer(com.fasterxml.jackson.databind.JsonNode singleIndexRequest)
protected boolean
isDelete(com.fasterxml.jackson.databind.JsonNode singleIndexRequest)
void
processSingleIndexRequest(com.fasterxml.jackson.databind.JsonNode singleIndexRequest)
protected com.broadleafcommerce.search.customer.core.domain.Customer
readCustomer(com.fasterxml.jackson.databind.JsonNode singleIndexRequest)
Read all state versions of customers with the context ID of the customer associated with the given object.
-
-
-
Field Detail
-
DEFAULT_DELETE_PROPERTY
public static final String DEFAULT_DELETE_PROPERTY
- See Also:
- Constant Field Values
-
-
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 classcom.broadleafcommerce.search.index.common.messaging.handler.AbstractSingleIndexRequestHandler
-
processSingleIndexRequest
public void processSingleIndexRequest(com.fasterxml.jackson.databind.JsonNode singleIndexRequest)
- Specified by:
processSingleIndexRequest
in classcom.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 classcom.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()
-
getCustomerService
protected CustomerService getCustomerService()
-
getReindexDelegationService
protected com.broadleafcommerce.search.index.core.service.ReindexDelegationService getReindexDelegationService()
-
getReindexService
protected com.broadleafcommerce.search.index.core.service.ReindexService getReindexService()
-
-