Package fr.gouv.vitam.common.model

# Class RequestResponse<T>

java.lang.Object
fr.gouv.vitam.common.model.RequestResponse<T>

Direct Known Subclasses:
  `RequestResponseOK`, `VitamError`

public abstract class RequestResponse<T> extends Object
Abstract RequestResponse for all request response in Vitam

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RequestResponse()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `RequestResponse<T>`
  `addHeader(String key, String value)`
  `String`
  `getHeaderString(String key)`
  `int`
  `getHttpCode()`
  `int`
  `getStatus()`
  `Map<String,String>`
  `getVitamHeaders()`
  `boolean`
  `isOk()`
  `static boolean`
  `isRequestResponseEmpty(com.fasterxml.jackson.databind.JsonNode requestResponseAsJsonNode)`
  Check if the JsonNode is a RequestResponse and result is Empty
  `static boolean`
  `isRequestResponseOk(com.fasterxml.jackson.databind.JsonNode requestResponseAsJsonNode)`
  Check if the JsonNode is a RequestResponse and OK
  `static RequestResponse<com.fasterxml.jackson.databind.JsonNode>`
  `parseFromResponse(jakarta.ws.rs.core.Response response)`
  Parser the response for a RequestResponse object.
  Might return an empty VitamError in case response is empty with only the HttpCode set and the Code set to empty String.
  `static <T> RequestResponse<T>`
  `parseFromResponse(jakarta.ws.rs.core.Response response, Class<T> clazz)`
  Parser the response for a RequestResponse object.
  Might return an empty VitamError in case response is empty with only the HttpCode set and the Code set to empty String.
  `RequestResponse<T>`
  `parseHeadersFromResponse(jakarta.ws.rs.core.Response response)`
  `static RequestResponseOK<com.fasterxml.jackson.databind.JsonNode>`
  `parseRequestResponseOk(jakarta.ws.rs.core.Response response)`
  `static <T> RequestResponseOK<T>`
  `parseRequestResponseOk(jakarta.ws.rs.core.Response response, Class<T> clasz)`
  `static VitamError<com.fasterxml.jackson.databind.JsonNode>`
  `parseVitamError(jakarta.ws.rs.core.Response response)`
  `static <T> VitamError<T>`
  `parseVitamError(jakarta.ws.rs.core.Response response, Class<T> clasz)`
  `RequestResponse<T>`
  `setHttpCode(int httpCode)`
  `com.fasterxml.jackson.databind.JsonNode`
  `toJsonNode()`
  `abstract jakarta.ws.rs.core.Response`
  `toResponse()`
  transform a RequestResponse to a standard response
  `String`
  `toString()`
  `void`
  `unSetVitamHeaders()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### RequestResponse

    public RequestResponse()

- ## Method Details

  - ### getHttpCode

    public int getHttpCode()
    Returns:
      the httpCode

  - ### setHttpCode

    public RequestResponse<T> setHttpCode(int httpCode)
    Parameters:
      `httpCode` - the httpCode to set
    Returns:
      this

  - ### getStatus

    public int getStatus()

  - ### isOk

    public boolean isOk()
    Returns:
      True if this RequestResponse is an Ok response

  - ### addHeader

    public RequestResponse<T> addHeader(String key, String value)

  - ### getHeaderString

    public String getHeaderString(String key)

  - ### getVitamHeaders

    public Map<String,String> getVitamHeaders()

  - ### unSetVitamHeaders

    public void unSetVitamHeaders()

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### toJsonNode

    public com.fasterxml.jackson.databind.JsonNode toJsonNode()
    Returns:
      the Json representation
    Throws:
      `IllegalStateException` - if JsonNode parse exception occurred

  - ### parseHeadersFromResponse

    public RequestResponse<T> parseHeadersFromResponse(jakarta.ws.rs.core.Response response)

  - ### parseFromResponse

    public static RequestResponse<com.fasterxml.jackson.databind.JsonNode> parseFromResponse(jakarta.ws.rs.core.Response response) throws IllegalStateException
    Parser the response for a RequestResponse object.
    Might return an empty VitamError in case response is empty with only the HttpCode set and the Code set to empty String.
    Parameters:
      `response` - to parse in RequestResponse
    Returns:
      The associate RequestResponseOk or VitamError
    Throws:
      `IllegalStateException` - if the response cannot be parsed to one of the two model

  - ### parseFromResponse

    public static <T> RequestResponse<T> parseFromResponse(jakarta.ws.rs.core.Response response, Class<T> clazz) throws IllegalStateException
    Parser the response for a RequestResponse object.
    Might return an empty VitamError in case response is empty with only the HttpCode set and the Code set to empty String.
    Parameters:
      `response` - to parse in RequestResponse
    Returns:
      The associate RequestResponseOk or VitamError
    Throws:
      `IllegalStateException` - if the response cannot be parsed to one of the two model

  - ### parseRequestResponseOk

    public static <T> RequestResponseOK<T> parseRequestResponseOk(jakarta.ws.rs.core.Response response, Class<T> clasz) throws InvalidParseOperationException
    Parameters:
      `response` - to parse in RequestResponse
    Returns:
      the RequestResponseOk
    Throws:
      `InvalidParseOperationException` - if JsonNode parse exception occurred

  - ### parseRequestResponseOk

    public static RequestResponseOK<com.fasterxml.jackson.databind.JsonNode> parseRequestResponseOk(jakarta.ws.rs.core.Response response) throws InvalidParseOperationException
    Parameters:
      `response` - to parse in RequestResponse
    Returns:
      the RequestResponseOk
    Throws:
      `InvalidParseOperationException` - if JsonNode parse exception occurred

  - ### parseVitamError

    public static <T> VitamError<T> parseVitamError(jakarta.ws.rs.core.Response response, Class<T> clasz) throws InvalidParseOperationException
    Parameters:
      `response` - to parse in RequestResponse
    Returns:
      the VitamError
    Throws:
      `InvalidParseOperationException` - if JsonNode parse exception occurred

  - ### parseVitamError

    public static VitamError<com.fasterxml.jackson.databind.JsonNode> parseVitamError(jakarta.ws.rs.core.Response response) throws InvalidParseOperationException
    Parameters:
      `response` - to parse in RequestResponse
    Returns:
      the VitamError
    Throws:
      `InvalidParseOperationException` - if JsonNode parse exception occurred

  - ### isRequestResponseOk

    public static boolean isRequestResponseOk(com.fasterxml.jackson.databind.JsonNode requestResponseAsJsonNode) throws IllegalStateException
    Check if the JsonNode is a RequestResponse and OK
    Parameters:
      `requestResponseAsJsonNode` - as request response as a JsonNode
    Returns:
      true if JsonNode contains httpCode as 2xx or 3xx, false if httpCode as 4xx or 5xx
    Throws:
      `IllegalStateException` - if JsonNode is not a valid instance of requestResponse

  - ### isRequestResponseEmpty

    public static boolean isRequestResponseEmpty(com.fasterxml.jackson.databind.JsonNode requestResponseAsJsonNode)
    Check if the JsonNode is a RequestResponse and result is Empty
    Parameters:
      `requestResponseAsJsonNode` - as request response as a JsonNode
    Returns:
      true if JsonNode contains hits and total = 0

  - ### toResponse

    public abstract jakarta.ws.rs.core.Response toResponse()
    transform a RequestResponse to a standard response
    Returns:
      Response