aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-fe/src
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-fe/src')
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/DesignerStatusBL.java78
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java78
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/FEAppContextListener.java6
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/ConfigServlet.java10
-rw-r--r--catalog-fe/src/main/resources/config/designers-configuration.yaml22
-rw-r--r--catalog-fe/src/main/resources/config/plugins-configuration.yaml22
-rw-r--r--catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/DesignerStatusBLTest.java107
-rw-r--r--catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PluginStatusBLTest.java107
8 files changed, 215 insertions, 215 deletions
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/DesignerStatusBL.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/DesignerStatusBL.java
deleted file mode 100644
index eb43df6c95..0000000000
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/DesignerStatusBL.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package org.openecomp.sdc.fe.impl;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpHead;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.openecomp.sdc.fe.config.ConfigurationManager;
-import org.openecomp.sdc.fe.config.DesignersConfiguration;
-import org.openecomp.sdc.fe.config.DesignersConfiguration.Designer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
-public class DesignerStatusBL {
-
- private static Logger log = LoggerFactory.getLogger(DesignerStatusBL.class.getName());
- private static Gson gson = new GsonBuilder().setPrettyPrinting().create();
- private CloseableHttpClient client = null;
-
- public DesignerStatusBL() {
- this.client = HttpClients.createDefault();
- }
-
- public DesignerStatusBL(CloseableHttpClient client) {
- this.client = client;
-
- }
-
- public String checkDesignerListAvailability() {
- String result = null;
-
- DesignersConfiguration designersConfiguration = ConfigurationManager.getConfigurationManager()
- .getDesignersConfiguration();
-
- if (designersConfiguration == null || designersConfiguration.getDesignersList() == null) {
- log.warn("Configuration of type {} was not found", DesignersConfiguration.class);
- } else {
- log.debug("The value returned from getConfig is {}", designersConfiguration);
-
- List<Designer> availableDesignersList = new ArrayList<>();
-
- designersConfiguration.getDesignersList().forEach(value -> {
- if (checkDesignerAvailability(value)) {
- availableDesignersList.add(value);
- }
-
- });
- result = gson.toJson(availableDesignersList);
- }
- return result;
- }
-
- private boolean checkDesignerAvailability(Designer designer) {
-
- StringBuilder requestString = new StringBuilder();
- boolean result = false;
-
- requestString.append(designer.getDesignerProtocol()).append("://").append(designer.getDesignerHost()).append(":")
- .append(designer.getDesignerPort()).append(designer.getDesignerPath());
-
- HttpHead head = new HttpHead(requestString.toString());
-
- try (CloseableHttpResponse response = this.client.execute(head)) {
- result = response != null && response.getStatusLine().getStatusCode() == 200;
- } catch (IOException e) {
- log.debug("The designer {} is offline", designer);
- }
-
- return result;
- }
-
-}
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java
new file mode 100644
index 0000000000..dcd5eef491
--- /dev/null
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java
@@ -0,0 +1,78 @@
+package org.openecomp.sdc.fe.impl;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpHead;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.openecomp.sdc.fe.config.ConfigurationManager;
+import org.openecomp.sdc.fe.config.PluginsConfiguration;
+import org.openecomp.sdc.fe.config.PluginsConfiguration.Plugin;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+public class PluginStatusBL {
+
+ private static Logger log = LoggerFactory.getLogger(PluginStatusBL.class.getName());
+ private static Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ private CloseableHttpClient client = null;
+
+ public PluginStatusBL() {
+ this.client = HttpClients.createDefault();
+ }
+
+ public PluginStatusBL(CloseableHttpClient client) {
+ this.client = client;
+
+ }
+
+ public String checkPluginsListAvailability() {
+ String result = null;
+
+ PluginsConfiguration pluginsConfiguration = ConfigurationManager.getConfigurationManager()
+ .getPluginsConfiguration();
+
+ if (pluginsConfiguration == null || pluginsConfiguration.getPluginsList() == null) {
+ log.warn("Configuration of type {} was not found", PluginsConfiguration.class);
+ } else {
+ log.debug("The value returned from getConfig is {}", pluginsConfiguration);
+
+ List<Plugin> availablePluginsList = new ArrayList<>();
+
+ pluginsConfiguration.getPluginsList().forEach(value -> {
+ if (checkPluginAvailability(value)) {
+ availablePluginsList.add(value);
+ }
+
+ });
+ result = gson.toJson(availablePluginsList);
+ }
+ return result;
+ }
+
+ private boolean checkPluginAvailability(Plugin plugin) {
+
+ StringBuilder requestString = new StringBuilder();
+ boolean result = false;
+
+ requestString.append(plugin.getPluginProtocol()).append("://").append(plugin.getPluginHost()).append(":")
+ .append(plugin.getPluginPort()).append(plugin.getPluginPath());
+
+ HttpHead head = new HttpHead(requestString.toString());
+
+ try (CloseableHttpResponse response = this.client.execute(head)) {
+ result = response != null && response.getStatusLine().getStatusCode() == 200;
+ } catch (IOException e) {
+ log.debug("The plugin {} is offline", plugin);
+ }
+
+ return result;
+ }
+
+}
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/FEAppContextListener.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/FEAppContextListener.java
index ea67efbc7e..76190bc790 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/FEAppContextListener.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/FEAppContextListener.java
@@ -30,7 +30,7 @@ import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.listener.AppContextListener;
import org.openecomp.sdc.fe.config.ConfigurationManager;
-import org.openecomp.sdc.fe.impl.DesignerStatusBL;
+import org.openecomp.sdc.fe.impl.PluginStatusBL;
import org.openecomp.sdc.fe.monitoring.FeMonitoringService;
import org.openecomp.sdc.fe.servlets.HealthCheckService;
import org.slf4j.Logger;
@@ -50,8 +50,8 @@ public class FEAppContextListener extends AppContextListener implements ServletC
ExternalConfiguration.getAppName());
context.getServletContext().setAttribute(Constants.CONFIGURATION_MANAGER_ATTR, configurationManager);
- DesignerStatusBL dsbl = new DesignerStatusBL();
- context.getServletContext().setAttribute(Constants.DESIGNER_BL_COMPONENT, dsbl);
+ PluginStatusBL pbl = new PluginStatusBL();
+ context.getServletContext().setAttribute(Constants.PLUGIN_BL_COMPONENT, pbl);
// Health Check service
HealthCheckService hcs = new HealthCheckService(context.getServletContext());
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/ConfigServlet.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/ConfigServlet.java
index ba37e94d10..cbe5c43a45 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/ConfigServlet.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/ConfigServlet.java
@@ -39,7 +39,7 @@ import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.servlets.BasicServlet;
import org.openecomp.sdc.fe.config.Configuration;
-import org.openecomp.sdc.fe.impl.DesignerStatusBL;
+import org.openecomp.sdc.fe.impl.PluginStatusBL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -115,16 +115,16 @@ public class ConfigServlet extends BasicServlet {
}
@GET
- @Path("/ui/designers")
+ @Path("/ui/plugins")
@Produces(MediaType.APPLICATION_JSON)
- public Response getDesignersConfiguration(@Context final HttpServletRequest request) {
+ public Response getPluginsConfiguration(@Context final HttpServletRequest request) {
String result = null;
ServletContext context = request.getSession().getServletContext();
- DesignerStatusBL designerStatusBL = (DesignerStatusBL) context.getAttribute(Constants.DESIGNER_BL_COMPONENT);
+ PluginStatusBL pluginStatusBL = (PluginStatusBL) context.getAttribute(Constants.PLUGIN_BL_COMPONENT);
- result = designerStatusBL.checkDesignerListAvailability();
+ result = pluginStatusBL.checkPluginsListAvailability();
return Response.status(Status.OK).entity(result).build();
diff --git a/catalog-fe/src/main/resources/config/designers-configuration.yaml b/catalog-fe/src/main/resources/config/designers-configuration.yaml
deleted file mode 100644
index f62a355589..0000000000
--- a/catalog-fe/src/main/resources/config/designers-configuration.yaml
+++ /dev/null
@@ -1,22 +0,0 @@
-designersList:
- - designerId: DCAE
- designerHost: localhost
- designerPort: 8080
- designerPath: "/dcae"
- designerStateUrl: "dcae"
- designerProtocol: http
- designerDisplayOptions:
- context:
- displayName: "Monitor"
- displayContext: ["VF", "SERVICE"]
- top:
- displayName: "DCAE"
- - designerId: WORKFLOW
- designerHost: localhost
- designerPort: 9527
- designerPath: "/"
- designerStateUrl: "workflowDesigner"
- designerProtocol: http
- designerDisplayOptions:
- top:
- displayName: "WORKFLOW" \ No newline at end of file
diff --git a/catalog-fe/src/main/resources/config/plugins-configuration.yaml b/catalog-fe/src/main/resources/config/plugins-configuration.yaml
new file mode 100644
index 0000000000..4193b506d2
--- /dev/null
+++ b/catalog-fe/src/main/resources/config/plugins-configuration.yaml
@@ -0,0 +1,22 @@
+pluginsList:
+ - pluginId: DCAE
+ pluginHost: localhost
+ pluginPort: 8080
+ pluginPath: "/dcae"
+ pluginStateUrl: "dcae"
+ pluginProtocol: http
+ pluginDisplayOptions:
+ context:
+ displayName: "Monitor"
+ displayContext: ["VF", "SERVICE"]
+ top:
+ displayName: "DCAE"
+ - pluginId: WORKFLOW
+ pluginHost: localhost
+ pluginPort: 9527
+ pluginPath: "/"
+ pluginStateUrl: "workflowDesigner"
+ pluginProtocol: http
+ pluginDisplayOptions:
+ top:
+ displayName: "WORKFLOW" \ No newline at end of file
diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/DesignerStatusBLTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/DesignerStatusBLTest.java
deleted file mode 100644
index db0fd736ec..0000000000
--- a/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/DesignerStatusBLTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package org.openecomp.sdc.fe.servlets;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.http.StatusLine;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpHead;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.openecomp.sdc.fe.config.ConfigurationManager;
-import org.openecomp.sdc.fe.config.DesignersConfiguration;
-import org.openecomp.sdc.fe.config.DesignersConfiguration.Designer;
-import org.openecomp.sdc.fe.impl.DesignerStatusBL;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
-public class DesignerStatusBLTest {
-
- final static CloseableHttpClient httpClient = Mockito.mock(CloseableHttpClient.class);
- DesignerStatusBL designerStatusBL = new DesignerStatusBL(httpClient);
- private static Gson gson = new GsonBuilder().setPrettyPrinting().create();
-
- final static ConfigurationManager configurationManager = Mockito.mock(ConfigurationManager.class);
- final static DesignersConfiguration designersConfiguration = Mockito.mock(DesignersConfiguration.class);
- final static Designer offlineDesigner = new Designer();
- final static Designer onlineDesigner = new Designer();
- final static CloseableHttpResponse httpResponse = Mockito.mock(CloseableHttpResponse.class);
- final static StatusLine statusLine = Mockito.mock(StatusLine.class);
- final static List<Designer> testDesignersList = new ArrayList<>();
-
- final static String offlineDesignerDisplayName = "offlineDesigner";
- final static String offlineDesignerHost = "192.168.10.1";
- final static String offlineDesignerPort = "1000";
- final static String offlineDesignerPath = "/offline";
- final static String offlineDesignerProtocol = "http";
-
- final static String onlineDesignerDisplayName = "onlineDesigner";
- final static String onlineDesignerHost = "192.168.20.2";
- final static String onlineDesignerPort = "2000";
- final static String onlineDesignerPath = "/online";
- final static String onlineDesignerProtocol = "http";
-
- @BeforeClass
- public static void beforeClass() {
- ConfigurationManager.setTestInstance(configurationManager);
- when(configurationManager.getDesignersConfiguration()).thenReturn(designersConfiguration);
-
- offlineDesigner.setDesignerId(offlineDesignerDisplayName);
- offlineDesigner.setDesignerHost(offlineDesignerHost);
- offlineDesigner.setDesignerPort(offlineDesignerPort);
- offlineDesigner.setDesignerPath(offlineDesignerPath);
- offlineDesigner.setDesignerProtocol(offlineDesignerProtocol);
-
- StringBuilder offlineRequestString = new StringBuilder();
- offlineRequestString.append(offlineDesignerProtocol).append("://").append(onlineDesignerHost).append(":")
- .append(offlineDesignerPort).append(offlineDesignerPath);
-
- onlineDesigner.setDesignerId(onlineDesignerDisplayName);
- onlineDesigner.setDesignerHost(onlineDesignerHost);
- onlineDesigner.setDesignerPort(onlineDesignerPort);
- onlineDesigner.setDesignerPath(onlineDesignerPath);
- onlineDesigner.setDesignerProtocol(onlineDesignerProtocol);
-
- StringBuilder onlineRequestString = new StringBuilder();
- onlineRequestString.append(onlineDesignerProtocol).append("://").append(onlineDesignerHost).append(":")
- .append(offlineDesignerPort).append(offlineDesignerPath);
-
- }
-
- @Test
- public void TestOfflineDesignerNotBeingReturnedWhenCallingCheckDesignerListAvailability() throws ClientProtocolException, IOException {
- testDesignersList.add(offlineDesigner);
- when(designersConfiguration.getDesignersList()).thenReturn(testDesignersList);
-
- when(statusLine.getStatusCode()).thenReturn(404);
- when(httpResponse.getStatusLine()).thenReturn(statusLine);
- when(httpClient.execute(Mockito.any(HttpHead.class))).thenReturn(httpResponse);
-
- assertTrue(designerStatusBL.checkDesignerListAvailability().equals("[]"));
-
- }
-
- @Test
- public void TestOnlineDesignerNotBeingReturnedWhenCallingCheckDesignerListAvailability() throws ClientProtocolException, IOException {
- testDesignersList.add(onlineDesigner);
- when(designersConfiguration.getDesignersList()).thenReturn(testDesignersList);
-
- when(statusLine.getStatusCode()).thenReturn(200);
- when(httpResponse.getStatusLine()).thenReturn(statusLine);
- when(httpClient.execute(Mockito.any())).thenReturn(httpResponse);
-
- String result = gson.toJson(testDesignersList);
-
- assertTrue(designerStatusBL.checkDesignerListAvailability().contains(result));
-
- }
-
-}
diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PluginStatusBLTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PluginStatusBLTest.java
new file mode 100644
index 0000000000..8a796a4993
--- /dev/null
+++ b/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PluginStatusBLTest.java
@@ -0,0 +1,107 @@
+package org.openecomp.sdc.fe.servlets;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.http.StatusLine;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpHead;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.sdc.fe.config.ConfigurationManager;
+import org.openecomp.sdc.fe.config.PluginsConfiguration;
+import org.openecomp.sdc.fe.config.PluginsConfiguration.Plugin;
+import org.openecomp.sdc.fe.impl.PluginStatusBL;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+public class PluginStatusBLTest {
+
+ final static CloseableHttpClient httpClient = Mockito.mock(CloseableHttpClient.class);
+ PluginStatusBL pluginStatusBL = new PluginStatusBL(httpClient);
+ private static Gson gson = new GsonBuilder().setPrettyPrinting().create();
+
+ final static ConfigurationManager configurationManager = Mockito.mock(ConfigurationManager.class);
+ final static PluginsConfiguration pluginsConfiguration = Mockito.mock(PluginsConfiguration.class);
+ final static Plugin offlinePlugin = new Plugin();
+ final static Plugin onlinePlugin = new Plugin();
+ final static CloseableHttpResponse httpResponse = Mockito.mock(CloseableHttpResponse.class);
+ final static StatusLine statusLine = Mockito.mock(StatusLine.class);
+ final static List<Plugin> testPluginsList = new ArrayList<>();
+
+ final static String offlinePluginsDisplayName = "offlinePlugin";
+ final static String offlinePluginHost = "192.168.10.1";
+ final static String offlinePluginPort = "1000";
+ final static String offlinePluginPath = "/offline";
+ final static String offlinePluginProtocol = "http";
+
+ final static String onlinePluginDisplayName = "onlinePlugin";
+ final static String onlinePluginHost = "192.168.20.2";
+ final static String onlinePluginPort = "2000";
+ final static String onlinePluginPath = "/online";
+ final static String onlinePluginProtocol = "http";
+
+ @BeforeClass
+ public static void beforeClass() {
+ ConfigurationManager.setTestInstance(configurationManager);
+ when(configurationManager.getPluginsConfiguration()).thenReturn(pluginsConfiguration);
+
+ offlinePlugin.setPluginId(offlinePluginsDisplayName);
+ offlinePlugin.setPluginHost(offlinePluginHost);
+ offlinePlugin.setPluginPort(offlinePluginPort);
+ offlinePlugin.setPluginPath(offlinePluginPath);
+ offlinePlugin.setPluginProtocol(offlinePluginProtocol);
+
+ StringBuilder offlineRequestString = new StringBuilder();
+ offlineRequestString.append(offlinePluginProtocol).append("://").append(onlinePluginHost).append(":")
+ .append(offlinePluginPort).append(offlinePluginPath);
+
+ onlinePlugin.setPluginId(onlinePluginDisplayName);
+ onlinePlugin.setPluginHost(onlinePluginHost);
+ onlinePlugin.setPluginPort(onlinePluginPort);
+ onlinePlugin.setPluginPath(onlinePluginPath);
+ onlinePlugin.setPluginProtocol(onlinePluginProtocol);
+
+ StringBuilder onlineRequestString = new StringBuilder();
+ onlineRequestString.append(onlinePluginProtocol).append("://").append(onlinePluginHost).append(":")
+ .append(offlinePluginPort).append(offlinePluginPath);
+
+ }
+
+ @Test
+ public void TestOfflinePluginNotBeingReturnedWhenCallingCheckPluginsListAvailability() throws ClientProtocolException, IOException {
+ testPluginsList.add(offlinePlugin);
+ when(pluginsConfiguration.getPluginsList()).thenReturn(testPluginsList);
+
+ when(statusLine.getStatusCode()).thenReturn(404);
+ when(httpResponse.getStatusLine()).thenReturn(statusLine);
+ when(httpClient.execute(Mockito.any(HttpHead.class))).thenReturn(httpResponse);
+
+ assertTrue(pluginStatusBL.checkPluginsListAvailability().equals("[]"));
+
+ }
+
+ @Test
+ public void TestOnlinePluginNotBeingReturnedWhenCallingCheckPluginsListAvailability() throws ClientProtocolException, IOException {
+ testPluginsList.add(onlinePlugin);
+ when(pluginsConfiguration.getPluginsList()).thenReturn(testPluginsList);
+
+ when(statusLine.getStatusCode()).thenReturn(200);
+ when(httpResponse.getStatusLine()).thenReturn(statusLine);
+ when(httpClient.execute(Mockito.any())).thenReturn(httpResponse);
+
+ String result = gson.toJson(testPluginsList);
+
+ assertTrue(pluginStatusBL.checkPluginsListAvailability().contains(result));
+
+ }
+
+}