Class AbstractRestConnector

java.lang.Object
com.almis.awe.config.ServiceConfig
com.almis.awe.service.connector.AbstractRestConnector
All Implemented Interfaces:
ServiceConnector, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
MicroserviceConnector, RestConnector

public abstract class AbstractRestConnector extends ServiceConfig
Launches a Rest service
  • Constructor Details

    • AbstractRestConnector

      protected AbstractRestConnector(org.springframework.http.client.ClientHttpRequestFactory requestFactory, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
      Autowired constructor
      Parameters:
      requestFactory - Request factory
      objectMapper - Object Mapper
  • Method Details

    • doRequest

      protected ServiceData doRequest(String url, AbstractServiceRest service, Map<String,Object> paramsMapFromRequest) throws AWException
      Generates the request and launches it
      Parameters:
      url - where the rest service is located
      service - object information
      paramsMapFromRequest - parameter values received
      Returns:
      response
      Throws:
      AWException - Error launching request
    • generateRequest

      protected org.springframework.http.HttpEntity generateRequest(AbstractServiceRest rest, org.springframework.web.util.UriComponentsBuilder uriBuilder, Map<String,Object> urlParameters, Map<String,Object> paramsMapFromRequest) throws com.fasterxml.jackson.core.JsonProcessingException
      Generate rest request
      Parameters:
      rest - Rest service
      uriBuilder - Url Builder
      urlParameters - Url parameters
      paramsMapFromRequest - Request parameters
      Returns:
      Request
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - See JsonProcessingException
    • checkServiceResponse

      protected void checkServiceResponse(ServiceData serviceData) throws AWException
      Check service response and send exception if failed or warning
      Parameters:
      serviceData - Service data
      Throws:
      AWException - Service data is error or warning
    • subscribe

      public ServiceData subscribe(Query query)
      Launches a subscription to a service
      Parameters:
      query - Subscribed query
      Returns:
      Service data