Add API to retrieve UI configuration 45/98845/3
authorilanap <ilanap@amdocs.com>
Tue, 26 Nov 2019 09:53:36 +0000 (11:53 +0200)
committerilanap <ilanap@amdocs.com>
Wed, 27 Nov 2019 08:02:46 +0000 (10:02 +0200)
Added configuration file with the menu configuration from catalog-ui. Added to the configuration manager. to chef and to the ui rest APIs.

Issue-ID: SDC-2663
Signed-off-by: ilanap <ilanap@amdocs.com>
Change-Id: Ia5e014a273238981241821c0d81b0455bd662b28
Signed-off-by: ilanap <ilanap@amdocs.com>
catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/files/default/FE-workspace-configuration.yaml [new file with mode: 0644]
catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_2_setup_configuration.rb
catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/ConfigServlet.java
catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/ConfigServletTest.java
catalog-fe/src/test/resources/config/catalog-fe/workspace-configuration.yaml [new file with mode: 0644]
common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java
common-app-api/src/main/java/org/openecomp/sdc/fe/config/WorkspaceConfiguration.java [new file with mode: 0644]
common-app-api/src/test/java/org/openecomp/sdc/fe/config/ConfigurationManagerTest.java
common-app-api/src/test/java/org/openecomp/sdc/fe/config/WorkspaceConfigurationTest.java [new file with mode: 0644]
common-app-api/src/test/resources/config/common/workspace-configuration.yaml [new file with mode: 0644]
docs/configuration.rst

diff --git a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/files/default/FE-workspace-configuration.yaml b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/files/default/FE-workspace-configuration.yaml
new file mode 100644 (file)
index 0000000..33643d1
--- /dev/null
@@ -0,0 +1,201 @@
+# following entries defines the workspace menus that are displayed according to type/subtype of the component in the workspace
+# in addition, they can also be disabled for specific roles.
+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
index 9df2ac9..7de9dbc 100644 (file)
@@ -14,6 +14,15 @@ template "catalog-fe-config" do
    })
 end
 
+cookbook_file "#{ENV['JETTY_BASE']}/config/catalog-fe/workspace-configuration.yaml" do
+  source "FE-workspace-configuration.yaml"
+  mode 0755
+  owner "jetty"
+  group "jetty"
+end
+
+
+
 template "onboarding-fe-config" do
     path "#{ENV['JETTY_BASE']}/config/onboarding-fe/onboarding_configuration.yaml"
     source "FE-onboarding-configuration.yaml.erb"
index 138318b..08b7c43 100644 (file)
@@ -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")
index 7f54fc0..29a49bc 100644 (file)
 
 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,13 +57,31 @@ 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() {
 
@@ -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 (file)
index 0000000..ec73476
--- /dev/null
@@ -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
index aafbdc7..5aa2d1f 100644 (file)
@@ -54,6 +54,7 @@ public class ConfigurationManager implements FileChangeCallback, IEcompConfigura
         loadConfigurationClass(RestConfigurationInfo.class);
         loadConfigurationClass(EcompErrorConfiguration.class);
         loadConfigurationClass(PluginsConfiguration.class);
+        loadConfigurationClass(WorkspaceConfiguration.class);
 
     }
 
@@ -99,6 +100,15 @@ public class ConfigurationManager implements FileChangeCallback, IEcompConfigura
         return (PluginsConfiguration) configurations.get(getKey(PluginsConfiguration.class));
     }
 
+
+    public WorkspaceConfiguration getWorkspaceConfiguration() {
+
+        logger.info("requested plugins configuration and got this:{}", configurations.get(getKey(WorkspaceConfiguration.class)));
+
+        return (WorkspaceConfiguration) configurations.get(getKey(WorkspaceConfiguration.class));
+    }
+
+
     public Configuration getConfigurationAndWatch(ConfigurationListener configurationListener) {
 
         if (configurationListener != null) {
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/WorkspaceConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/WorkspaceConfiguration.java
new file mode 100644 (file)
index 0000000..caaaf5a
--- /dev/null
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.fe.config;
+
+import org.openecomp.sdc.common.api.BasicConfiguration;
+
+import java.util.List;
+import java.util.Map;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class WorkspaceConfiguration extends BasicConfiguration {
+
+    private Map<String, List<MenuConfiguration>> workspaceMenuConfiguration;
+
+    @Getter
+    @Setter
+    private static class MenuConfiguration {
+        private String text;
+        private String action;
+        private String state;
+        private Integer menuIndex;
+        private List<String> disabledRoles;
+    }
+}
index a0c19b3..0cf350c 100644 (file)
@@ -49,6 +49,7 @@ public class ConfigurationManagerTest {
     private class TestPluginsConfiguration extends PluginsConfiguration {}
     private class TestRestConfigurationInfo extends RestConfigurationInfo {}
     private class TestEcompErrorConfiguration extends EcompErrorConfiguration {}
+    private class TestWorkspaceConfiguration extends WorkspaceConfiguration {}
 
     @Test
     public void validateConfigurationManageIsConstructWithAllConfiguration() {
@@ -64,6 +65,9 @@ public class ConfigurationManagerTest {
         when(configurationSource.
                 getAndWatchConfiguration(eq(EcompErrorConfiguration.class),any(ConfigurationListener.class))
         ).thenReturn(new TestEcompErrorConfiguration());
+        when(configurationSource.
+                getAndWatchConfiguration(eq(WorkspaceConfiguration.class),any(ConfigurationListener.class))
+        ).thenReturn(new TestWorkspaceConfiguration());
 
         configurationManager = new ConfigurationManager(configurationSource);
 
@@ -71,6 +75,7 @@ public class ConfigurationManagerTest {
         assertEquals(configurationManager.getPluginsConfiguration().getClass(), TestPluginsConfiguration.class);
         assertEquals(configurationManager.getRestClientConfiguration().getClass(), TestRestConfigurationInfo.class);
         assertEquals(configurationManager.getEcompErrorConfiguration().getClass(), TestEcompErrorConfiguration.class);
+        assertEquals(configurationManager.getWorkspaceConfiguration().getClass(), TestWorkspaceConfiguration.class);
     }
 
     @Test
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/fe/config/WorkspaceConfigurationTest.java b/common-app-api/src/test/java/org/openecomp/sdc/fe/config/WorkspaceConfigurationTest.java
new file mode 100644 (file)
index 0000000..dd1fe8b
--- /dev/null
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.fe.config;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.openecomp.sdc.common.api.ConfigurationSource;
+import org.openecomp.sdc.common.impl.ExternalConfiguration;
+import org.openecomp.sdc.common.impl.FSConfigurationSource;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(MockitoJUnitRunner.class)
+public class WorkspaceConfigurationTest {
+    private WorkspaceConfiguration workspaceConfiguration = new WorkspaceConfiguration();
+
+    @Mock
+    private ConfigurationManager configurationManager;
+
+    @Before
+    public void setUp() {
+        String appConfigDir = "src/test/resources/config/common";
+        ConfigurationSource configurationSource =
+                new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
+        configurationManager = new ConfigurationManager(configurationSource);
+    }
+
+    @Test
+    public void validateInstanceGetsProperTestManager() {
+        workspaceConfiguration = configurationManager.getWorkspaceConfiguration();
+        assertEquals(7,workspaceConfiguration.getWorkspaceMenuConfiguration().size());
+        assertTrue(workspaceConfiguration.getWorkspaceMenuConfiguration().containsKey("VFC"));
+    }
+}
diff --git a/common-app-api/src/test/resources/config/common/workspace-configuration.yaml b/common-app-api/src/test/resources/config/common/workspace-configuration.yaml
new file mode 100644 (file)
index 0000000..fd38259
--- /dev/null
@@ -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
index 10bab0d..59f571d 100644 (file)
@@ -1423,6 +1423,91 @@ FE-plugins-configuration.yaml
    # how long we will wait for the plugin to respond before cutting it.
    connectionTimeout: 1000
 
+FE-workspace-configuration.yaml
+*****************************
+::
+
+# this file contains the different configurable UI workspace items that can be set according to resource and service type.
+# the workspaceMenuConfiguration entry defines the workspace menus that are displayed according to type/subtype of the component in the workspace
+# in addition, they can also be disabled for specific roles. the key is the resource type or service type and it will return the list of the menu
+# items that will be displayed.
+#
+# each key had a list of menu items with the following data:
+#   - text: display text,
+#   - state: the state for the screen
+#   - action: action associated
+#   - index: optional - an integer that will be used to decide on the order of appearance
+# following are 2 example
+    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
+      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
+
+
 Onboarding configuration
 ------------------------