Package de.dlr.proseo.ui.backend
Class ServiceConnection
java.lang.Object
de.dlr.proseo.ui.backend.ServiceConnection
Service class to connect to the prosEO backend services from the user interface
- Author:
- Dr. Thomas Bassler
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteFromService(String serviceUrl, String requestPath, String username, String password) Calls a prosEO service at the given location with HTTP DELETE<T> TgetFromService(String serviceUrl, String requestPath, Class<T> clazz, String username, String password) Calls a prosEO service at the given location with HTTP GET<T> TpatchToService(String serviceUrl, String requestPath, Object restObject, Class<T> clazz, String username, String password) Calls a prosEO service at the given location with HTTP Patch<T> TpostToService(String serviceUrl, String requestPath, Object restObject, Class<T> clazz, String username, String password) Calls a prosEO service at the given location with HTTP Post<T> TputToService(String serviceUrl, String requestPath, Class<T> clazz, String username, String password) Calls a prosEO service at the given location with HTTP PUT
-
Constructor Details
-
ServiceConnection
public ServiceConnection()
-
-
Method Details
-
getFromService
public <T> T getFromService(String serviceUrl, String requestPath, Class<T> clazz, String username, String password) throws org.springframework.web.client.RestClientException, RuntimeException Calls a prosEO service at the given location with HTTP GET- Type Parameters:
T- the class of the REST object to return- Parameters:
serviceUrl- the base URL of the service (protocol, hostname, port, base URI)requestPath- the specific request path including request parametersclazz- the class of the return objectusername- the username for basic HTTP authentication (optional)password- the password for basic HTTP authentication (optional)- Returns:
- the body of the HTTP response converted into an object of the expected class
- Throws:
org.springframework.web.client.RestClientException- if an error (HTTP status code 4xx or 5xx) occurred in the communication to the serviceRuntimeException- if the service returned an HTTP status different from OK (200)
-
putToService
public <T> T putToService(String serviceUrl, String requestPath, Class<T> clazz, String username, String password) throws org.springframework.web.client.RestClientException, RuntimeException Calls a prosEO service at the given location with HTTP PUT- Type Parameters:
T- the class of the REST object to use as PUT data- Parameters:
serviceUrl- the base URL of the service (protocol, hostname, port, base URI)requestPath- the specific request path including request parametersclazz- the class of the return objectusername- the username for basic HTTP authentication (optional)password- the password for basic HTTP authentication (optional)- Returns:
- the body of the HTTP response converted into an object of the expected class
- Throws:
org.springframework.web.client.RestClientException- if an error (HTTP status code 4xx or 5xx) occurred in the communication to the serviceRuntimeException- if the service returned an HTTP status different from OK (200)
-
postToService
public <T> T postToService(String serviceUrl, String requestPath, Object restObject, Class<T> clazz, String username, String password) throws org.springframework.web.client.RestClientException, RuntimeException Calls a prosEO service at the given location with HTTP Post- Type Parameters:
T- the class of the REST object to use as POST data- Parameters:
serviceUrl- the base URL of the service (protocol, hostname, port, base URI)requestPath- the specific request path including request parametersrestObject- the object to post to the serviceclazz- the class of the expected result objectusername- the username for basic HTTP authentication (optional)password- the password for basic HTTP authentication (optional)- Returns:
- the body of the HTTP response converted into an object of the expected class
- Throws:
org.springframework.web.client.RestClientException- if an error (HTTP status code 4xx or 5xx) occurred in the communication to the serviceRuntimeException- if the service returned an HTTP status different from OK (200)
-
patchToService
public <T> T patchToService(String serviceUrl, String requestPath, Object restObject, Class<T> clazz, String username, String password) throws org.springframework.web.client.RestClientException, RuntimeException Calls a prosEO service at the given location with HTTP Patch- Type Parameters:
T- the class of the REST object to use as PATCH data- Parameters:
serviceUrl- the base URL of the service (protocol, hostname, port, base URI)requestPath- the specific request path including request parametersrestObject- the object to patch to the serviceclazz- the class of the expected result objectusername- the username for basic HTTP authentication (optional)password- the password for basic HTTP authentication (optional)- Returns:
- the body of the HTTP response converted into an object of the expected class
- Throws:
org.springframework.web.client.RestClientException- if an error (HTTP status code 4xx or 5xx) occurred in the communication to the serviceRuntimeException- if the service returned an HTTP status different from OK (200) or another unrecoverable error occurred
-
deleteFromService
public void deleteFromService(String serviceUrl, String requestPath, String username, String password) throws org.springframework.web.client.RestClientException Calls a prosEO service at the given location with HTTP DELETE- Parameters:
serviceUrl- the base URL of the service (protocol, hostname, port, base URI)requestPath- the specific request path including request parametersusername- the username for basic HTTP authentication (optional)password- the password for basic HTTP authentication (optional)- Throws:
org.springframework.web.client.RestClientException- if an error (HTTP status code 304, 4xx or 5xx) occurred in the communication to the service
-