Class ExternalProviderUtility

java.lang.Object
com.broadleafcommerce.customer.client.provider.external.ExternalProviderUtility

public class ExternalProviderUtility extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The ApiError.getType() that indicates entity is not found.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    buildNotFoundException(com.fasterxml.jackson.databind.ObjectMapper objectMapper, org.springframework.web.reactive.function.client.WebClientResponseException.NotFound nfe)
    Builds a not found exception that correlates to the given WebClientResponseException.NotFound exception.
    org.springframework.http.HttpHeaders
    getCommonHeaders(com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Builds the headers to be passed along with the request to the provider.
    protected boolean
    isEntityNotFound(org.springframework.http.ResponseEntity<com.broadleafcommerce.common.error.ApiError> apiError)
    Determines if the given ResponseEntity 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.
    org.springframework.util.MultiValueMap<String,String>
    pageableToParams(org.springframework.data.domain.Pageable pageable)
    Converts a pageable into its corresponding query parameters.
    uriVars(Object... keysAndValues)
    Convenience method to generate a map of variables.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ENTITY_NOT_FOUND

      public static final String ENTITY_NOT_FOUND
      The ApiError.getType() that indicates entity is not found.
      See Also:
  • Constructor Details

    • ExternalProviderUtility

      public ExternalProviderUtility()
  • Method Details

    • getCommonHeaders

      public org.springframework.http.HttpHeaders getCommonHeaders(com.fasterxml.jackson.databind.ObjectMapper objectMapper, @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.
    • buildNotFoundException

      protected RuntimeException buildNotFoundException(com.fasterxml.jackson.databind.ObjectMapper objectMapper, org.springframework.web.reactive.function.client.WebClientResponseException.NotFound nfe)
      Builds a not found exception that correlates to the given WebClientResponseException.NotFound exception.

      If the exception is of type ENTITY_NOT_FOUND, an EntityMissingException is thrown. Otherwise it's wrapped in ProviderApiException.

      Parameters:
      nfe - the WebClientResponseException.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 given ResponseEntity 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 - the ResponseEntity to check against
      Returns:
      true if the given ResponseEntity indicates entity not found
    • uriVars

      public Map<String,Object> uriVars(Object... keysAndValues)
      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

      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

      protected String orderToParamValue(org.springframework.data.domain.Sort.Order order)
      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