Class AbstractExternalProvider
java.lang.Object
com.broadleafcommerce.pricing.provider.external.AbstractExternalProvider
- Direct Known Subclasses:
 ExternalPricingCartProvider,ExternalPricingOrderProvider
- 
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringTheApiError.getType()that indicates entity is not found. - 
Constructor Summary
ConstructorsConstructorDescriptionAbstractExternalProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory)  - 
Method Summary
Modifier and TypeMethodDescriptionprotected RuntimeExceptionbuildNotFoundException(org.springframework.web.reactive.function.client.WebClientResponseException.NotFound nfe) Builds a not found exception that correlates to the givenWebClientResponseException.NotFoundexception.protected <T> TexecuteRequest(Supplier<T> request) Executes a request with default Web Client error handling.protected org.springframework.http.HttpHeadersgetHeaders(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds the headers to be passed along with the request to the provider.protected com.fasterxml.jackson.databind.ObjectMapperprotected com.broadleafcommerce.common.extension.TypeFactoryprotected org.springframework.web.reactive.function.client.WebClientprotected booleanisEntityNotFound(org.springframework.http.ResponseEntity<com.broadleafcommerce.common.error.ApiError> apiError) Determines if the givenResponseEntityindicates entity not found.pageableToParams(org.springframework.data.domain.Pageable pageable) Converts a pageable into its corresponding query parameters.Convenience method to generate a map of variables. 
- 
Field Details
- 
ENTITY_NOT_FOUND
TheApiError.getType()that indicates entity is not found.- See Also:
 
 
 - 
 - 
Constructor Details
- 
AbstractExternalProvider
public AbstractExternalProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory)  
 - 
 - 
Method Details
- 
getHeaders
protected org.springframework.http.HttpHeaders getHeaders(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds the headers to be passed along with the request to the provider.- Parameters:
 contextInfo-ContextInfofrom the original request containing tenant and sandbox info- Returns:
 - The headers to be passed along with the request to the provider.
 
 - 
executeRequest
Executes a request with default Web Client error handling.- Type Parameters:
 T- the return type of the request operation- Parameters:
 request- the request to execute- Returns:
 - the value generated by the supplier
 
 - 
buildNotFoundException
protected RuntimeException buildNotFoundException(org.springframework.web.reactive.function.client.WebClientResponseException.NotFound nfe) Builds a not found exception that correlates to the givenWebClientResponseException.NotFoundexception.If the exception is of type
ENTITY_NOT_FOUND, anEntityMissingExceptionis thrown. Otherwise it's wrapped inProviderApiException.- Parameters:
 nfe- theWebClientResponseException.NotFoundto build the not found exception from- Returns:
 - a not found exception that correlates to the given
         
WebClientResponseException.NotFoundexception 
 - 
isEntityNotFound
protected boolean isEntityNotFound(org.springframework.http.ResponseEntity<com.broadleafcommerce.common.error.ApiError> apiError) Determines if the givenResponseEntityindicates entity not found.This is useful to distinguish a
HttpStatus.NOT_FOUNDresponse indicating entity cannot be found from a response indicating the endpoint/url cannot be found.- Parameters:
 apiError- theResponseEntityto check against- Returns:
 - true if the given 
ResponseEntityindicates entity not found 
 - 
uriVars
Convenience method to generate a map of variables.- Parameters:
 keysAndValues- the keys and values (in pairs, alternating) to transform into a map- Returns:
 - the keys and values as a map
 
 - 
pageableToParams
protected org.springframework.util.MultiValueMap<String,String> pageableToParams(@Nullable org.springframework.data.domain.Pageable pageable) Converts a pageable into its corresponding query parameters.- Parameters:
 pageable- the pageable to convert- Returns:
 - a map of query parameters
 
 - 
getWebClient
protected org.springframework.web.reactive.function.client.WebClient getWebClient() - 
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() - 
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() 
 -