Class HTTPDao

java.lang.Object
de.qytera.qtaf.http.HTTPDao
Direct Known Subclasses:
HTTPJsonDao

public class HTTPDao extends Object
HTTP DAO.
  • Field Details

    • client

      protected jakarta.ws.rs.client.Client client
      Web Client that can perform HTTP Requests.
    • host

      protected String host
      Host: domain name (i.e. "https://www.google.de") or IP-Address (i.e. "8.8.8.8").
    • authorizationHeaderValue

      protected String authorizationHeaderValue
      Authorization header value.
    • gson

      protected final com.google.gson.Gson gson
      String to JSON converter.
  • Constructor Details

    • HTTPDao

      public HTTPDao(String host)
      Constructor.
      Parameters:
      host - host name
  • Method Details

    • getAuthorizationHeaderValue

      public String getAuthorizationHeaderValue()
      Get authorizationHeaderValue.
      Returns:
      authorizationHeaderValue
    • setAuthorizationHeaderValue

      public HTTPDao setAuthorizationHeaderValue(String authorizationHeaderValue)
      Set authorizationHeaderValue.
      Parameters:
      authorizationHeaderValue - AuthorizationHeaderValue
      Returns:
      this
    • get

      protected <T> T get(String path, String mediaType, Class<T> c)
      Perform GET Requests.
      Type Parameters:
      T - Type that the Result gets mapped to
      Parameters:
      path - Url Path
      mediaType - the request's media type
      c - Class that the result gets mapped to
      Returns:
      Response of Type T
    • get

      public jakarta.ws.rs.core.Response get(String path, String mediaType)
      Perform GET Requests.
      Parameters:
      path - Url Path
      mediaType - Media Type
      Returns:
      Response
    • getAsString

      public String getAsString(String path, String mediaType)
      Perform GET Requests.
      Parameters:
      path - Url Path
      mediaType - Media Type
      Returns:
      Response
    • post

      protected <T> T post(String path, String mediaType, Class<T> c, Object requestEntity)
      Perform POST Requests.
      Type Parameters:
      T - Type that the Result gets mapped to
      Parameters:
      path - Url Path
      mediaType - the request's media type
      c - Class that the result gets mapped to
      requestEntity - Request body
      Returns:
      Response of Type T
    • post

      public jakarta.ws.rs.core.Response post(String path, String mediaType, Object requestEntity)
      Perform POST Requests.
      Parameters:
      path - Url Path
      mediaType - Media Type
      requestEntity - Request body
      Returns:
      Response
    • postAsString

      public String postAsString(String path, String mediaType, Object requestEntity)
      Perform POST Requests.
      Parameters:
      path - Url Path
      mediaType - Media Type
      requestEntity - Request body
      Returns:
      Response
    • put

      protected <T> T put(String path, String mediaType, Class<T> c, Object requestEntity)
      Perform PUT Requests.
      Type Parameters:
      T - Type that the Result gets mapped to
      Parameters:
      path - Url Path
      mediaType - the request's media type
      c - Class that the result gets mapped to
      requestEntity - Request body
      Returns:
      Response of Type T
    • put

      public jakarta.ws.rs.core.Response put(String path, String mediaType, Object requestEntity)
      Perform PUT Requests.
      Parameters:
      path - Url Path
      mediaType - Media Type
      requestEntity - Request body
      Returns:
      Response
    • putAsString

      public String putAsString(String path, String mediaType, Object requestEntity)
      Perform PUT Requests.
      Parameters:
      path - Url Path
      mediaType - Media Type
      requestEntity - Request body
      Returns:
      Response
    • delete

      protected <T> T delete(String path, String mediaType, Class<T> c)
      Perform DELETE Requests.
      Type Parameters:
      T - Type that the Result gets mapped to
      Parameters:
      path - Url Path
      mediaType - the request's media type
      c - Class that the result gets mapped to
      Returns:
      Response of Type T
    • delete

      public jakarta.ws.rs.core.Response delete(String path, String mediaType)
      Perform DELETE Requests.
      Parameters:
      path - Url Path
      mediaType - Media Type
      Returns:
      Response
    • deleteAsString

      public String deleteAsString(String path, String mediaType)
      Perform DELETE Requests.
      Parameters:
      path - Url Path
      mediaType - Media Type
      Returns:
      Response