Class RestApiExceptionParserImpl

java.lang.Object
org.bremersee.exception.RestApiExceptionParserImpl
All Implemented Interfaces:
RestApiExceptionParser

public class RestApiExceptionParserImpl extends Object implements RestApiExceptionParser
The default implementation of a http response parser that creates a RestApiException.
Author:
Christian Bremer
  • Constructor Details

    • RestApiExceptionParserImpl

      public RestApiExceptionParserImpl()
      Instantiates a new rest api exception parser.
    • RestApiExceptionParserImpl

      public RestApiExceptionParserImpl(Charset defaultCharset)
      Instantiates a new rest api exception parser.
      Parameters:
      defaultCharset - the default charset
    • RestApiExceptionParserImpl

      public RestApiExceptionParserImpl(org.springframework.http.converter.json.Jackson2ObjectMapperBuilder objectMapperBuilder)
      Instantiates a new rest api exception parser.
      Parameters:
      objectMapperBuilder - the object mapper builder
    • RestApiExceptionParserImpl

      public RestApiExceptionParserImpl(org.springframework.http.converter.json.Jackson2ObjectMapperBuilder objectMapperBuilder, Charset charset)
      Instantiates a new rest api exception parser.
      Parameters:
      objectMapperBuilder - the object mapper builder
      charset - the charset
    • RestApiExceptionParserImpl

      public RestApiExceptionParserImpl(com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper)
      Instantiates a new rest api exception parser.
      Parameters:
      objectMapper - the object mapper
      xmlMapper - the xml mapper
    • RestApiExceptionParserImpl

      public RestApiExceptionParserImpl(com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper, Charset defaultCharset)
      Instantiates a new rest api exception parser.
      Parameters:
      objectMapper - the object mapper
      xmlMapper - the xml mapper
      defaultCharset - the default charset
  • Method Details

    • getDefaultCharset

      protected Charset getDefaultCharset()
      Gets default charset.
      Returns:
      the default charset
    • parseException

      public RestApiException parseException(byte[] response, org.springframework.http.HttpStatusCode httpStatus, org.springframework.http.HttpHeaders headers)
      Description copied from interface: RestApiExceptionParser
      Parse exception.
      Specified by:
      parseException in interface RestApiExceptionParser
      Parameters:
      response - the response
      httpStatus - the http status
      headers - the headers
      Returns:
      the parsed exception
    • parseException

      public RestApiException parseException(String response, org.springframework.http.HttpStatusCode httpStatus, org.springframework.http.HttpHeaders headers)
      Description copied from interface: RestApiExceptionParser
      Parse exception.
      Specified by:
      parseException in interface RestApiExceptionParser
      Parameters:
      response - the response
      httpStatus - the http status
      headers - the headers
      Returns:
      the parsed exception
    • getRestApiExceptionFromHeaders

      protected RestApiException getRestApiExceptionFromHeaders(String response, org.springframework.http.HttpStatusCode httpStatus, org.springframework.http.HttpHeaders httpHeaders)
      Gets rest api exception from headers.
      Parameters:
      response - the response
      httpStatus - the http status
      httpHeaders - the http headers
      Returns:
      the rest api exception from headers
    • getContentTypeCharset

      protected Charset getContentTypeCharset(org.springframework.http.MediaType contentType)
      Gets content type charset.
      Parameters:
      contentType - the content type
      Returns:
      the content type charset
    • parseErrorTimestamp

      protected OffsetDateTime parseErrorTimestamp(String value)
      Parse the 'timestamp' header value.
      Parameters:
      value - the 'timestamp' header value
      Returns:
      the timestamp