Class ProviderUtils
java.lang.Object
com.broadleafcommerce.bulkoperations.service.provider.utils.ProviderUtils
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
TheApiError.getType()
that indicates entity is not found. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected RuntimeException
buildNotFoundException
(org.springframework.web.reactive.function.client.WebClientResponseException.NotFound nfe) Builds a not found exception that correlates to the givenWebClientResponseException.NotFound
exception.<T> T
executeRequest
(Supplier<T> request) Executes a request with default Web Client error handling.org.springframework.http.HttpHeaders
getHeaders
(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.ObjectMapper
protected boolean
isEntityNotFound
(org.springframework.http.ResponseEntity<com.broadleafcommerce.common.error.ApiError> apiError) Determines if the givenResponseEntity
indicates entity not found.protected String
orderToParamValue
(org.springframework.data.domain.Sort.Order order) Converts a sort order into a query parameter value (e.g.pageableToParams
(org.springframework.data.domain.Pageable pageable) Converts a pageable into its corresponding query parameters.
-
Field Details
-
ENTITY_NOT_FOUND
TheApiError.getType()
that indicates entity is not found.- See Also:
-
-
Constructor Details
-
ProviderUtils
public ProviderUtils(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
getHeaders
public 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
-ContextInfo
from 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.NotFound
exception.If the exception is of type
ENTITY_NOT_FOUND
, anEntityMissingException
is thrown. Otherwise it's wrapped inProviderApiException
.- Parameters:
nfe
- theWebClientResponseException.NotFound
to build the not found exception from- Returns:
- a not found exception that correlates to the given
WebClientResponseException.NotFound
exception
-
isEntityNotFound
protected boolean isEntityNotFound(org.springframework.http.ResponseEntity<com.broadleafcommerce.common.error.ApiError> apiError) Determines if the givenResponseEntity
indicates entity not found.This is useful to distinguish a
HttpStatus.NOT_FOUND
response indicating entity cannot be found from a response indicating the endpoint/url cannot be found.- Parameters:
apiError
- theResponseEntity
to check against- Returns:
- true if the given
ResponseEntity
indicates entity not found
-
pageableToParams
public 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
-
orderToParamValue
Converts a sort order into a query parameter value (e.g. name,asc).- Parameters:
order
- the sort order to convert- Returns:
- the query parameter value for the sort order
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
-