- private boolean checkPluginAvailability(Plugin plugin) {
- boolean result = false;
-
- HttpHead head = new HttpHead(plugin.getPluginDiscoveryUrl());
-
- try (CloseableHttpResponse response = this.client.execute(head)) {
- result = response != null && response.getStatusLine().getStatusCode() == 200;
- } catch (IOException e) {
- log.debug("The plugin {} is offline", plugin.getPluginId());
+ public String getPluginsList() {
+ String result = null;
+
+ if (pluginsConfiguration == null || pluginsConfiguration.getPluginsList() == null) {
+ log.warn("Configuration of type {} was not found", PluginsConfiguration.class);
+ throw new InvalidArgumentException("the plugin configuration was not read successfully.");
+
+ } else {
+ log.debug("The value returned from getConfig is {}", pluginsConfiguration);
+
+ result = gson.toJson(pluginsConfiguration.getPluginsList());
+ }
+ return result;
+ }
+
+ public String getPluginAvailability(String pluginId) {
+ String result = null;
+
+ if (pluginsConfiguration == null || pluginsConfiguration.getPluginsList() == null) {
+ log.warn("Configuration of type {} was not found", PluginsConfiguration.class);
+ throw new InvalidArgumentException("the plugin configuration was not read successfully.");
+
+ } else {
+ log.debug("The value returned from getConfig is {}", pluginsConfiguration);
+ Integer connectionTimeout = pluginsConfiguration.getConnectionTimeout();
+ this.requestConfig = RequestConfig.custom()
+ .setSocketTimeout(connectionTimeout)
+ .setConnectTimeout(connectionTimeout)
+ .setConnectionRequestTimeout(connectionTimeout).build();
+
+
+ Plugin wantedPlugin = pluginsConfiguration.getPluginsList().stream()
+ .filter(plugin -> plugin.getPluginId().equals(pluginId))
+ .findAny()
+ .orElse(null);
+
+ if (wantedPlugin != null) {
+ result = gson.toJson(checkPluginAvailability(wantedPlugin));
+ }
+ }
+ return result;
+ }
+
+ private boolean checkPluginAvailability(Plugin plugin) {
+ boolean result = false;
+ log.debug("sending head request to id:{} url:{}", plugin.getPluginId(), plugin.getPluginDiscoveryUrl());
+ HttpHead head = new HttpHead(plugin.getPluginDiscoveryUrl());
+
+ head.setConfig(this.requestConfig);
+ if (this.client == null) {
+ log.debug("The plugin {} will not run because https is not configured on the FE server",plugin.getPluginId());
+ return false;