Class AbstractEndpointClient

java.lang.Object
es.kukenan.smartfi.microservice.clients.service.backoffice.AbstractEndpointClient
Direct Known Subclasses:
AbstractInternalEndpointClient, AbstractUsersCoreEndpoint

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

    Fields
    Modifier and Type
    Field
    Description
    private es.kukenan.smartfi.common.context.RequestContextManager
    Request context manager.
    Core base url.
    protected static final String
    User profile identifier header.
    private es.kukenan.smartfi.common.context.config.ContextPropagationProperties
    Context propagation properties.
  • 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 org.springframework.http.HttpHeaders
    Create the default request HTTP headers used in any API method.
    org.springframework.http.HttpHeaders
    defaultRequestHeaders(String contentType, String userId)
    Create the default request HTTP headers used in any Core API method.
    protected org.springframework.http.HttpHeaders
    defaultRequestHeaders(String contentType, String userId, String userAgent, String userIP)
    Create the default request HTTP headers used in any Core API method.
    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

    • HEADER_USERPROFILEID

      protected static final String HEADER_USERPROFILEID
      User profile identifier header.
      See Also:
    • contextManager

      @Autowired private es.kukenan.smartfi.common.context.RequestContextManager contextManager
      Request context manager.
    • properties

      @Autowired private es.kukenan.smartfi.common.context.config.ContextPropagationProperties properties
      Context propagation properties.
    • coreBasseUrl

      @Value("${core.baseUrl}") public String coreBasseUrl
      Core base url.
  • 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.
    • defaultRequestHeaders

      protected org.springframework.http.HttpHeaders defaultRequestHeaders()
      Create the default request HTTP headers used in any API method.
      Returns:
      the default request HTTP headers
    • defaultRequestHeaders

      public org.springframework.http.HttpHeaders defaultRequestHeaders(String contentType, String userId)
      Create the default request HTTP headers used in any Core API method.
      Parameters:
      contentType - request body content type. Can be null.
      userId - user identifier, mandatory.
      Returns:
      the default request HTTP headers used in any Core API method.
    • defaultRequestHeaders

      protected org.springframework.http.HttpHeaders defaultRequestHeaders(String contentType, String userId, String userAgent, String userIP)
      Create the default request HTTP headers used in any Core API method.
      Parameters:
      contentType - request body content type. Can be null.
      userId - user identifier, mandatory.
      userAgent - user-agent to call core endpoint
      userIP - ip to call core endpoint
      Returns:
      the default request HTTP headers used in any Core API method.