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/servlets/ConfigServlet.java35
-rw-r--r--catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/ConfigServletTest.java25
-rw-r--r--catalog-fe/src/test/resources/config/catalog-fe/workspace-configuration.yaml199
3 files changed, 259 insertions, 0 deletions
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 138318bb61..08b7c43397 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
@@ -23,6 +23,10 @@ package org.openecomp.sdc.fe.servlets;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.fe.config.FeEcompErrorManager;
import org.openecomp.sdc.fe.impl.PluginStatusBL;
+import org.openecomp.sdc.fe.config.ConfigurationManager;
+import org.openecomp.sdc.fe.config.WorkspaceConfiguration;
+import org.openecomp.sdc.exception.NotFoundException;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,6 +49,37 @@ public class ConfigServlet extends LoggingServlet {
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigServlet.class.getName());
+ @GET
+ @Path("/ui/workspace")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getUIWorkspaceConfiguration(@Context final HttpServletRequest request) {
+
+ try {
+ logFeRequest(request);
+
+ ServletContext context = request.getSession().getServletContext();
+
+ ConfigurationManager configurationManager = (ConfigurationManager) context
+ .getAttribute(Constants.CONFIGURATION_MANAGER_ATTR);
+
+ WorkspaceConfiguration configuration = configurationManager.getWorkspaceConfiguration();
+ if (configuration == null) {
+ throw new NotFoundException(WorkspaceConfiguration.class.getSimpleName());
+ }
+ LOGGER.info("The value returned from getConfig is {}", configuration);
+ String result = gson.toJson(configuration);
+ Response response = Response.status(Status.OK).entity(result).build();
+ logFeResponse(request, response);
+
+ return response;
+ } catch (Exception e) {
+ FeEcompErrorManager.getInstance().logFeHttpLoggingError("FE Response");
+ LOGGER.error("Unexpected FE response logging error :", e);
+ return Response.status(Status.INTERNAL_SERVER_ERROR).entity("{}").build();
+ }
+
+ }
+
@GET
@Path("/ui/plugins")
diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/ConfigServletTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/ConfigServletTest.java
index 7f54fc06c4..29a49bc611 100644
--- a/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/ConfigServletTest.java
+++ b/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/ConfigServletTest.java
@@ -20,11 +20,17 @@
package org.openecomp.sdc.fe.servlets;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
import org.apache.http.HttpStatus;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
+import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.api.Constants;
+import org.openecomp.sdc.common.impl.ExternalConfiguration;
+import org.openecomp.sdc.common.impl.FSConfigurationSource;
+import org.openecomp.sdc.fe.config.ConfigurationManager;
import org.openecomp.sdc.fe.impl.PluginStatusBL;
import javax.servlet.ServletContext;
@@ -51,14 +57,32 @@ public class ConfigServletTest {
private ServletContext mockedContext;
@Mock
private PluginStatusBL pluginStatusBL;
+ @Mock
+ private ConfigurationManager configManager;
@Before
public void setUp() {
initMocks(this);
+ String appConfigDir = "src/test/resources/config/catalog-fe";
+ ConfigurationSource configurationSource =
+ new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
+ configManager = new ConfigurationManager(configurationSource);
configServlet = new ConfigServlet();
}
@Test
+ public void validateWorkspaceConfiguration() {
+
+ prepareMocks();
+
+ Response response = configServlet.getUIWorkspaceConfiguration(httpServletRequest);
+
+ Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ String expected = gson.toJson(configManager.getWorkspaceConfiguration());
+ assertEquals(expected, response.getEntity().toString());
+ assertEquals(response.getStatus(), HttpStatus.SC_OK);
+ }
+ @Test
public void validateGetPluginsConfigurationReturnsCorrectConfiguration() {
final String expectedEntity = "testPluginsList";
@@ -120,6 +144,7 @@ public class ConfigServletTest {
private void prepareMocks() {
when(httpServletRequest.getSession()).thenReturn(httpSession);
when(httpSession.getServletContext()).thenReturn(mockedContext);
+ when(mockedContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configManager);
when(mockedContext.getAttribute(Constants.PLUGIN_BL_COMPONENT)).thenReturn(pluginStatusBL);
}
diff --git a/catalog-fe/src/test/resources/config/catalog-fe/workspace-configuration.yaml b/catalog-fe/src/test/resources/config/catalog-fe/workspace-configuration.yaml
new file mode 100644
index 0000000000..ec734768bc
--- /dev/null
+++ b/catalog-fe/src/test/resources/config/catalog-fe/workspace-configuration.yaml
@@ -0,0 +1,199 @@
+workspaceMenuConfiguration:
+ VFC:
+ - text: General
+ action: onMenuItemPressed
+ state: workspace.general
+ - text: Deployment Artifact
+ action: onMenuItemPressed
+ state: workspace.deployment_artifacts
+ - text: Information Artifact
+ action: onMenuItemPressed
+ state: workspace.information_artifacts
+ - text: TOSCA Artifacts
+ action: onMenuItemPressed
+ state: workspace.tosca_artifacts
+ - text: Properties
+ action: onMenuItemPressed
+ state: workspace.properties
+ - text: Attributes
+ action: onMenuItemPressed
+ state: workspace.attributes
+ - text: Req. & Capabilities
+ action: onMenuItemPressed
+ state: workspace.reqAndCap
+ - text: Activity Log
+ action: onMenuItemPressed
+ state: workspace.activity_log
+ VL:
+ - text: General
+ action: onMenuItemPressed
+ state: workspace.general
+ - text: Deployment Artifact
+ action: onMenuItemPressed
+ state: workspace.deployment_artifacts
+ - text: Information Artifact
+ action: onMenuItemPressed
+ state: workspace.information_artifacts
+ - text: TOSCA Artifacts
+ action: onMenuItemPressed
+ state: workspace.tosca_artifacts
+ - text: Properties
+ action: onMenuItemPressed
+ state: workspace.properties
+ - text: Attributes
+ action: onMenuItemPressed
+ state: workspace.attributes
+ - text: Req. & Capabilities
+ action: onMenuItemPressed
+ state: workspace.reqAndCap
+ - text: Activity Log
+ action: onMenuItemPressed
+ state: workspace.activity_log
+ CP:
+ - text: General
+ action: onMenuItemPressed
+ state: workspace.general
+ - text: Deployment Artifact
+ action: onMenuItemPressed
+ state: workspace.deployment_artifacts
+ - text: Information Artifact
+ action: onMenuItemPressed
+ state: workspace.information_artifacts
+ - text: TOSCA Artifacts
+ action: onMenuItemPressed
+ state: workspace.tosca_artifacts
+ - text: Properties
+ action: onMenuItemPressed
+ state: workspace.properties
+ - text: Attributes
+ action: onMenuItemPressed
+ state: workspace.attributes
+ - text: Req. & Capabilities
+ action: onMenuItemPressed
+ state: workspace.reqAndCap
+ - text: Activity Log
+ action: onMenuItemPressed
+ state: workspace.activity_log
+ VF:
+ - text: General
+ action: onMenuItemPressed
+ state: workspace.general
+ - text: Deployment Artifact
+ action: onMenuItemPressed
+ state: workspace.deployment_artifacts
+ - text: Information Artifact
+ action: onMenuItemPressed
+ state: workspace.information_artifacts
+ - text: TOSCA Artifacts
+ action: onMenuItemPressed
+ state: workspace.tosca_artifacts
+ - text: Composition
+ action: onMenuItemPressed
+ state: workspace.composition.details
+ - text: Operation
+ action: onMenuItemPressed
+ state: workspace.interface_operation
+ - text: Activity Log
+ action: onMenuItemPressed
+ state: workspace.activity_log
+ - text: Deployment
+ action: onMenuItemPressed
+ state: workspace.deployment
+ - text: Properties Assignment
+ action: onMenuItemPressed
+ state: workspace.properties_assignment
+ - text: Req. & Capabilities
+ action: onMenuItemPressed
+ state: workspace.reqAndCapEditable
+ PNF:
+ - text: General
+ action: onMenuItemPressed
+ state: workspace.general
+ - text: Deployment Artifact
+ action: onMenuItemPressed
+ state: workspace.deployment_artifacts
+ - text: Information Artifact
+ action: onMenuItemPressed
+ state: workspace.information_artifacts
+ - text: TOSCA Artifacts
+ action: onMenuItemPressed
+ state: workspace.tosca_artifacts
+ - text: Composition
+ action: onMenuItemPressed
+ state: workspace.composition.details
+ - text: Operation
+ action: onMenuItemPressed
+ state: workspace.interface_operation
+ - text: Activity Log
+ action: onMenuItemPressed
+ state: workspace.activity_log
+ - text: Properties Assignment
+ action: onMenuItemPressed
+ state: workspace.properties_assignment
+ - text: Req. & Capabilities
+ action: onMenuItemPressed
+ state: workspace.reqAndCapEditable
+ CR:
+ - text: General
+ action: onMenuItemPressed
+ state: workspace.general
+ - text: Deployment Artifact
+ action: onMenuItemPressed
+ state: workspace.deployment_artifacts
+ - text: Information Artifact
+ action: onMenuItemPressed
+ state: workspace.information_artifacts
+ - text: TOSCA Artifacts
+ action: onMenuItemPressed
+ state: workspace.tosca_artifacts
+ - text: Composition
+ action: onMenuItemPressed
+ state: workspace.composition.details
+ - text: Activity Log
+ action: onMenuItemPressed
+ state: workspace.activity_log
+ - text: Properties Assignment
+ action: onMenuItemPressed
+ state: workspace.properties_assignment
+ SERVICE:
+ - text: General
+ action: onMenuItemPressed
+ state: workspace.general
+ - text: TOSCA Artifacts
+ action: onMenuItemPressed
+ state: workspace.tosca_artifacts
+ - text: Composition
+ action: onMenuItemPressed
+ state: workspace.composition.details
+ - text: Operation
+ action: onMenuItemPressed
+ state: workspace.interface_operation
+ - text: Activity Log
+ action: onMenuItemPressed
+ state: workspace.activity_log
+ - text: Management Workflow
+ action: onMenuItemPressed
+ state: workspace.management_workflow
+ - text: 'Network Call Flow '
+ action: onMenuItemPressed
+ state: workspace.network_call_flow
+ - text: Distribution
+ action: onMenuItemPressed
+ state: workspace.distribution
+ disabledRoles:
+ - ADMIN
+ - TESTER
+ - GOVERNOR
+ - DESIGNER
+ - text: Deployment
+ action: onMenuItemPressed
+ state: workspace.deployment
+ - text: Properties Assignment
+ action: onMenuItemPressed
+ state: workspace.properties_assignment
+ - text: Outputs
+ action: onMenuItemPressed
+ state: workspace.outputs_assignment
+ - text: Req. & Capabilities
+ action: onMenuItemPressed
+ state: workspace.reqAndCapEditable