+ /**
+ * Get DMI plugin health status.
+ *
+ * @param dmiPluginBaseUrl the base URL of the dmi-plugin
+ * @return plugin health status ("UP" is all OK, "" (not-specified) in case of any exception)
+ */
+ public String getDmiHealthStatus(final String dmiPluginBaseUrl) {
+ final HttpEntity<Object> httpHeaders = new HttpEntity<>(configureHttpHeaders(new HttpHeaders(), null));
+ try {
+ final JsonNode responseHealthStatus =
+ restTemplate.getForObject(dmiPluginBaseUrl + HEALTH_CHECK_URL_EXTENSION,
+ JsonNode.class, httpHeaders);
+ return responseHealthStatus == null ? NOT_SPECIFIED :
+ responseHealthStatus.get("status").asText();
+ } catch (final Exception e) {
+ log.warn("Failed to retrieve health status from {}. Error Message: {}", dmiPluginBaseUrl, e.getMessage());
+ return NOT_SPECIFIED;
+ }
+ }
+
+ private HttpHeaders configureHttpHeaders(final HttpHeaders httpHeaders, final String authorization) {
+ if (dmiProperties.isDmiBasicAuthEnabled()) {
+ httpHeaders.setBasicAuth(dmiProperties.getAuthUsername(), dmiProperties.getAuthPassword());
+ } else if (authorization != null && authorization.toLowerCase(Locale.getDefault()).startsWith("bearer ")) {
+ httpHeaders.add(HttpHeaders.AUTHORIZATION, authorization);
+ }