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 TypeMethodDescriptionvoidChecks 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 thrownvoidassertResponse(GenericResponse response) 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 thrownjakarta.ws.rs.client.WebTargetbase()Provides access to the WebTarget that is used as the base for all commands to the serverGet the cookie handlerList<org.apache.http.cookie.Cookie>Get the cookies currently stored in the clientvoidLogs the specified user into the system using the password givenvoidlogout()Logs out the current uservoidsetApiToken(String apiToken) Set the API Token, that should be usedvoidssologin()Performs login on an SSO system - before this works, necessary filters have to be defined
-
Method Details
-
login
Logs the specified user into the system using the password given- Parameters:
username- user namepassword- password- Throws:
RestException- If the login failed
-
ssologin
Performs login on an SSO system - before this works, necessary filters have to be defined- Throws:
RestException- If the login via SSO failed
-
logout
Logs out the current user- Throws:
RestException- If the logout failed
-
assertResponse
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
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
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
Set the API Token, that should be used- Parameters:
apiToken- api token
-
getCookies
Get the cookies currently stored in the client- Returns:
- stored cookies
- Throws:
RestException
-
getCookieHandler
CookieHandler getCookieHandler()Get the cookie handler- Returns:
- cookie handler
-