Class AbstractEndpointClient

java.lang.Object
es.kukenan.smartfi.microservice.contracts.service.AbstractEndpointClient
Direct Known Subclasses:
AbstractCoreEndpointClient

public class AbstractEndpointClient extends Object
Base class with core functionality for any endpoint implementation.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    Flag that signals if the processing must stop if there is any king of client or mapping error.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected URI
    createUri(String uriPath)
    Create a URI object from the given Minstait relative endpoint path.
    protected URI
    createUri(String uriPath, String queryParams)
    Create a URI object from the given relative endpoint path.
    protected <T> T
    extractResponseData(org.springframework.http.ResponseEntity<T> responseEntity)
    Extract the response data from the given ResponseEntity.
    protected <T> T
    Performs the operation encapsulated in the supplier instance to handle connection exceptions.
    protected String
    message(org.springframework.web.client.ResourceAccessException e)
    Construct an error message from a given ResourceAccessException.

    Methods inherited from class java.lang.Object

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

    • haltOnErrors

      @Value("${services.client.halt-on-errors}") protected boolean haltOnErrors
      Flag that signals if the processing must stop if there is any king of client or mapping error.
  • Constructor Details

    • AbstractEndpointClient

      public AbstractEndpointClient()
  • Method Details

    • createUri

      protected URI createUri(String uriPath)
      Create a URI object from the given Minstait relative endpoint path.
      Parameters:
      uriPath - Minstait relative endpoint path.
      Returns:
      URI object with absolute endpoint path.
    • createUri

      protected URI createUri(String uriPath, String queryParams)
      Create a URI object from the given relative endpoint path.
      Parameters:
      uriPath - relative endpoint path.
      queryParams - Query PArams to add at endpoint path.
      Returns:
      URI object with absolute endpoint path.
    • handleConnectionException

      protected <T> T handleConnectionException(Supplier<T> supplier)
      Performs the operation encapsulated in the supplier instance to handle connection exceptions.
      Type Parameters:
      T - the result type of the operation.
      Parameters:
      supplier - an operation encapsulated a the supplier instance.
      Returns:
      the result of the operation if no exception has been thrown.
    • message

      protected String message(org.springframework.web.client.ResourceAccessException e)
      Construct an error message from a given ResourceAccessException.
      Parameters:
      e - a ResourceAccessException.
      Returns:
      a message describing the exception reason.
    • extractResponseData

      protected <T> T extractResponseData(org.springframework.http.ResponseEntity<T> responseEntity)
      Extract the response data from the given ResponseEntity.
      Type Parameters:
      T - CoreResponse type.
      Parameters:
      responseEntity - ResponseEntity.
      Returns:
      core response data.