Class HTTPDao

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

public class HTTPDao extends Object
HTTP DAO
  • Field Details

    • client

      protected com.sun.jersey.api.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
      c - Class that the result gets mapped to
      Returns:
      Response of Type T
    • get

      public com.sun.jersey.api.client.ClientResponse 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
      c - Class that the result gets mapped to
      requestEntity - Request body
      Returns:
      Response of Type T
    • post

      public com.sun.jersey.api.client.ClientResponse 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
      c - Class that the result gets mapped to
      requestEntity - Request body
      Returns:
      Response of Type T
    • put

      public com.sun.jersey.api.client.ClientResponse 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
      c - Class that the result gets mapped to
      Returns:
      Response of Type T
    • delete

      public com.sun.jersey.api.client.ClientResponse 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