Interface RestApi

All Known Implementing Classes:
RestClient

public interface RestApi

This client provides wrappers, helper-methods and exception-handling to facilitate requests to the REST API. It is initialized with a URL pointing to the base-location providing the services. After a successful login, a WebTarget-object can be retrieved that is then used to assemble and send requests; response-objects are returned from the server, containing the requested data and further information in the case of an error.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Checks if the version of the REST API on the server is the same that is used by the client; if there is a mismatch between the two versions, a RestException is thrown
    void
    Analyzes the response of a finished request and asserts that it was executed without errors; if a problem occurred during the request, a specialized RestException is thrown
    jakarta.ws.rs.client.WebTarget
    Provides access to the WebTarget that is used as the base for all commands to the server
    Get the cookie handler
    List<org.apache.http.cookie.Cookie>
    Get the cookies currently stored in the client
    void
    login(String username, String password)
    Logs the specified user into the system using the password given
    void
    Logs out the current user
    void
    setApiToken(String apiToken)
    Set the API Token, that should be used
    void
    Performs login on an SSO system - before this works, necessary filters have to be defined
  • Method Details

    • login

      void login(String username, String password) throws RestException
      Logs the specified user into the system using the password given
      Parameters:
      username - user name
      password - password
      Throws:
      RestException - If the login failed
    • ssologin

      void ssologin() throws RestException
      Performs login on an SSO system - before this works, necessary filters have to be defined
      Throws:
      RestException - If the login via SSO failed
    • logout

      void logout() throws RestException
      Logs out the current user
      Throws:
      RestException - If the logout failed
    • assertResponse

      void assertResponse(GenericResponse response) throws RestException
      Analyzes the response of a finished request and asserts that it was executed without errors; if a problem occurred during the request, a specialized RestException is thrown
      Parameters:
      response - The response of the request that needs to be checked
      Throws:
      RestException - Thrown if the request was not successful, and contains further information of the reason of failure
    • assertMatchingVersion

      void assertMatchingVersion() throws RestException
      Checks if the version of the REST API on the server is the same that is used by the client; if there is a mismatch between the two versions, a RestException is thrown
      Throws:
      RestException - Mismatch between the versions detected
    • base

      jakarta.ws.rs.client.WebTarget base() throws RestException
      Provides access to the WebTarget that is used as the base for all commands to the server
      Returns:
      The base resource, with the active SID already set
      Throws:
      RestException - If no valid SID is registered with the client
    • setApiToken

      void setApiToken(String apiToken)
      Set the API Token, that should be used
      Parameters:
      apiToken - api token
    • getCookies

      List<org.apache.http.cookie.Cookie> getCookies() throws RestException
      Get the cookies currently stored in the client
      Returns:
      stored cookies
      Throws:
      RestException
    • getCookieHandler

      CookieHandler getCookieHandler()
      Get the cookie handler
      Returns:
      cookie handler