Class ServiceConnection
java.lang.Object
de.dlr.proseo.notification.service.ServiceConnection
The HTTP service to post the message. This service is responsible for sending an HTTP POST request to a specified endpoint,
providing the necessary authentication, headers, and message body.
- Author:
- Ernst Melchinger
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) NotificationConfigurationThe configuration of the notification service -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionpostToService(String endpoint, String user, String password, String subject, org.springframework.http.MediaType mediaType, String messageCode, String message, String sender) Constructs and sends an HTTP POST request to the specified endpoint, including the necessary authentication, headers, and message body.
-
Field Details
-
config
The configuration of the notification service
-
-
Constructor Details
-
ServiceConnection
public ServiceConnection()
-
-
Method Details
-
postToService
public Object postToService(String endpoint, String user, String password, String subject, org.springframework.http.MediaType mediaType, String messageCode, String message, String sender) throws org.springframework.web.client.RestClientException, RuntimeException Constructs and sends an HTTP POST request to the specified endpoint, including the necessary authentication, headers, and message body. It handles exceptions and returns appropriate response entities based on the HTTP status codes received.- Parameters:
endpoint- The HTTP addressuser- The user name for basic HTTP authenticationpassword- The password for basic HTTP authenticationsubject- The message subjectmediaType- The media type of the message bodymessageCode- The message codemessage- The message bodysender- The message sender- Returns:
- The response entity
- 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)
-