Class AbstractExternalProvider

java.lang.Object
com.broadleafcommerce.orderoperation.service.provider.external.AbstractExternalProvider
Direct Known Subclasses:
ExternalCampaignProvider, ExternalCartProvider, ExternalFulfillmentCaptureClaimProvider, ExternalFulfillmentProvider, ExternalOfferProvider, ExternalOrderProvider, ExternalPaymentProvider, ExternalResourceLockProvider, ExternalReturnAuthorizationProvider

public abstract class AbstractExternalProvider extends Object
  • Field Summary

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

    Constructors
    Constructor
    Description
    AbstractExternalProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    buildNotFoundException(org.springframework.web.reactive.function.client.WebClientResponseException.NotFound nfe)
    Builds a not found exception that correlates to the given WebClientResponseException.NotFound exception.
    protected <T> T
    Executes a request with default Web Client error handling.
    protected 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 com.broadleafcommerce.common.extension.TypeFactory
     
    protected org.springframework.web.reactive.function.client.WebClient
     
    protected boolean
    isEntityNotFound(org.springframework.http.ResponseEntity<com.broadleafcommerce.common.error.ApiError> apiError)
    Determines if the given ResponseEntity indicates entity not found.
    protected org.springframework.util.MultiValueMap<String,String>
    pageableToParams(org.springframework.data.domain.Pageable pageable)
    Converts a pageable into its corresponding query parameters.

    Methods inherited from class java.lang.Object

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

  • 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 - ContextInfo from the original request containing tenant and sandbox info
      Returns:
      The headers to be passed along with the request to the provider.
    • 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
    • executeRequest

      protected <T> T executeRequest(Supplier<T> request)
      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 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
    • 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()