Revise user controller to answer real data 83/1183/1
authorLott, Christopher (cl778h) <cl778h@att.com>
Fri, 18 Oct 2019 16:05:49 +0000 (12:05 -0400)
committerLott, Christopher (cl778h) <cl778h@att.com>
Fri, 18 Oct 2019 16:05:49 +0000 (12:05 -0400)
Answer requests for user data with EcompUser items supplied by Portal.
Drop the DashboardUser model and mock data.
Revise front-end to use new data type and show loginId in table.
Move creation of user mgr bean to new standalone admin config classes.

Change-Id: I4e4cf76296724456540db9c627ed1c37721dca75
Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
23 files changed:
docs/release-notes.rst
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardUserManager.java [moved from webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/DashboardUserManager.java with 95% similarity]
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/AdminConfiguration.java [new file with mode: 0644]
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/CaasIngressConfiguration.java
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/WebSecurityConfiguration.java
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/AdminController.java
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/DashboardUser.java [deleted file]
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthenticationFilter.java
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalRestCentralServiceImpl.java
webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/A1MediatorMockConfiguration.java
webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AdminMockConfiguration.java [new file with mode: 0644]
webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AnrXappMockConfiguration.java
webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AppManagerMockConfiguration.java
webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/CaasIngressMockConfiguration.java
webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/E2ManagerMockConfiguration.java
webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/WebSecurityMockConfiguration.java
webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/AdminControllerTest.java
webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/CaasIngressControllerTest.java
webapp-frontend/src/app/interfaces/dashboard.types.ts
webapp-frontend/src/app/services/dashboard/dashboard.service.ts
webapp-frontend/src/app/user/user.component.html
webapp-frontend/src/app/user/user.component.ts
webapp-frontend/src/app/user/user.datasource.ts

index f4f2dc3..aec43e6 100644 (file)
@@ -19,7 +19,7 @@
 RIC Dashboard Release Notes
 ===========================
 
-Version 1.2.4, 10 Oct 2019
+Version 1.2.4, 18 Oct 2019
 --------------------------
 * Revise a1-med-client to use API spec in new submodule ric-plt/a1;
   removed cached copy
@@ -27,6 +27,7 @@ Version 1.2.4, 10 Oct 2019
   removed cached copy
 * Add Platform page showing Kubernetes pods in aux and platform obtained from CAAS-Ingress
 * Update Angular libraries to recent stable versions
+* Revise user controller to answer data sent by portal, drop the mock implementation
 
 Version 1.2.3, 4 Oct 2019
 -------------------------
@@ -17,7 +17,7 @@
  * limitations under the License.
  * ========================LICENSE_END===================================
  */
-package org.oransc.ric.portal.dashboard.portalapi;
+package org.oransc.ric.portal.dashboard;
 
 import java.io.File;
 import java.io.IOException;
@@ -30,7 +30,6 @@ import java.util.Set;
 import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
 import org.onap.portalsdk.core.restful.domain.EcompRole;
 import org.onap.portalsdk.core.restful.domain.EcompUser;
-import org.oransc.ric.portal.dashboard.DashboardConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -40,7 +39,7 @@ import com.fasterxml.jackson.databind.JsonMappingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 
 /**
- * Provides user-management services.
+ * Provides simple user-management services.
  * 
  * This first implementation serializes user details to a file.
  * 
@@ -98,6 +97,15 @@ public class DashboardUserManager {
                }
        }
 
+       /**
+        * Gets the current users.
+        * 
+        * @return List of EcompUser objects, possibly empty
+        */
+       public List<EcompUser> getUsers() {
+               return this.users;
+       }
+
        /**
         * Gets the user with the specified login Id
         * 
diff --git a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/AdminConfiguration.java b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/AdminConfiguration.java
new file mode 100644 (file)
index 0000000..696d74f
--- /dev/null
@@ -0,0 +1,58 @@
+/*-
+ * ========================LICENSE_START=================================
+ * O-RAN-SC
+ * %%
+ * Copyright (C) 2019 AT&T Intellectual Property
+ * %%
+ * 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.oransc.ric.portal.dashboard.config;
+
+import java.io.IOException;
+import java.lang.invoke.MethodHandles;
+
+import org.oransc.ric.portal.dashboard.DashboardUserManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+
+/**
+ * Creates an instance of the user manager.
+ */
+@Configuration
+@Profile("!test")
+public class AdminConfiguration {
+
+       private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+       // Populated by the autowired constructor
+       private final String userfile;
+
+       @Autowired
+       public AdminConfiguration(@Value("${userfile}") final String userfile) {
+               logger.debug("ctor userfile '{}'", userfile);
+               this.userfile = userfile;
+       }
+
+       @Bean
+       // The bean (method) name must be globally unique
+       public DashboardUserManager userManager() throws IOException {
+               return new DashboardUserManager(userfile);
+       }
+
+}
index 55398de..397a5dc 100644 (file)
@@ -31,13 +31,14 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Profile;
 import org.springframework.web.util.DefaultUriBuilderFactory;
 
 /**
  * Creates instances of CAAS-Ingres clients.
  */
-@org.springframework.context.annotation.Configuration
+@Configuration
 @Profile("!test")
 public class CaasIngressConfiguration {
 
index 9d25916..33458ba 100644 (file)
@@ -24,17 +24,18 @@ import java.lang.invoke.MethodHandles;
 import java.lang.reflect.InvocationTargetException;
 
 import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
+import org.oransc.ric.portal.dashboard.DashboardUserManager;
 import org.oransc.ric.portal.dashboard.controller.A1MediatorController;
 import org.oransc.ric.portal.dashboard.controller.AdminController;
 import org.oransc.ric.portal.dashboard.controller.AnrXappController;
 import org.oransc.ric.portal.dashboard.controller.AppManagerController;
 import org.oransc.ric.portal.dashboard.controller.E2ManagerController;
 import org.oransc.ric.portal.dashboard.controller.SimpleErrorController;
-import org.oransc.ric.portal.dashboard.portalapi.DashboardUserManager;
 import org.oransc.ric.portal.dashboard.portalapi.PortalAuthManager;
 import org.oransc.ric.portal.dashboard.portalapi.PortalAuthenticationFilter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -69,8 +70,9 @@ public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
        private String decryptor;
        @Value("${portalapi.usercookie}")
        private String userCookie;
-       @Value("${userfile}")
-       private String userFilePath;
+
+       @Autowired
+       DashboardUserManager userManager;
 
        protected void configure(HttpSecurity http) throws Exception {
                logger.debug("configure: portalapi.username {}", userName);
@@ -117,11 +119,6 @@ public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
                return new PortalAuthManager(appName, userName, password, decryptor, userCookie);
        }
 
-       @Bean
-       public DashboardUserManager dashboardUserManagerBean() throws IOException {
-               return new DashboardUserManager(userFilePath);
-       }
-
        /*
         * If this is annotated with @Bean, it is created automatically AND REGISTERED,
         * and Spring processes annotations in the source of the class. However, the
@@ -135,7 +132,7 @@ public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
                        throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException,
                        IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
                PortalAuthenticationFilter portalAuthenticationFilter = new PortalAuthenticationFilter(portalapiSecurity,
-                               portalAuthManagerBean(), dashboardUserManagerBean());
+                               portalAuthManagerBean(), this.userManager);
                return portalAuthenticationFilter;
        }
 
index 6b420d3..041ddaa 100644 (file)
 package org.oransc.ric.portal.dashboard.controller;
 
 import java.lang.invoke.MethodHandles;
+import java.util.List;
 
 import javax.servlet.http.HttpServletResponse;
 
+import org.onap.portalsdk.core.restful.domain.EcompUser;
 import org.oransc.ric.portal.dashboard.DashboardApplication;
 import org.oransc.ric.portal.dashboard.DashboardConstants;
-import org.oransc.ric.portal.dashboard.model.DashboardUser;
+import org.oransc.ric.portal.dashboard.DashboardUserManager;
 import org.oransc.ric.portal.dashboard.model.ErrorTransport;
 import org.oransc.ric.portal.dashboard.model.IDashboardResponse;
 import org.oransc.ric.portal.dashboard.model.SuccessTransport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.MediaType;
 import org.springframework.security.access.annotation.Secured;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.RestController;
 
 import io.swagger.annotations.ApiOperation;
 
@@ -57,25 +60,16 @@ public class AdminController {
        public static final String VERSION_METHOD = DashboardConstants.VERSION_METHOD;
        public static final String XAPPMETRICS_METHOD = "metrics";
 
-       private final DashboardUser[] users;
-
-       private static final String ACTIVE = "Active";
-       private static final String INACTIVE = "Inactive";
-
        @Value("${metrics.url.ac}")
        private String acAppMetricsUrl;
 
        @Value("${metrics.url.mc}")
        private String mcAppMetricsUrl;
 
+       @Autowired
+       private DashboardUserManager dashboardUserManager;
+
        public AdminController() {
-               // Mock data
-               users = new DashboardUser[] { //
-                               new DashboardUser(1, "John", "Doe", ACTIVE), //
-                               new DashboardUser(2, "Alice", "Nolan", ACTIVE), //
-                               new DashboardUser(3, "Pierce", "King", INACTIVE), //
-                               new DashboardUser(4, "Paul", "Smith", INACTIVE), //
-                               new DashboardUser(5, "Jack", "Reacher", ACTIVE) };
        }
 
        @ApiOperation(value = "Gets the Dashboard MANIFEST.MF property Implementation-Version.", response = SuccessTransport.class)
@@ -97,16 +91,17 @@ public class AdminController {
                return new SuccessTransport(200, "Dashboard is healthy!");
        }
 
-       @ApiOperation(value = "Gets the list of application users.", response = DashboardUser.class, responseContainer = "List")
+       @ApiOperation(value = "Gets the list of application users.", response = EcompUser.class, responseContainer = "List")
        @GetMapping(USER_METHOD)
-       @Secured({ DashboardConstants.ROLE_ADMIN })
-       public DashboardUser[] getUsers() {
+       @Secured({ DashboardConstants.ROLE_ADMIN }) // regular users should not see this
+       public List<EcompUser> getUsers() {
                logger.debug("getUsers");
-               return users;
+               return dashboardUserManager.getUsers();
        }
 
        @ApiOperation(value = "Gets the kibana metrics URL for the specified app.", response = SuccessTransport.class)
        @GetMapping(XAPPMETRICS_METHOD)
+       // No role required
        public IDashboardResponse getAppMetricsUrl(@RequestParam String app, HttpServletResponse response) {
                String metricsUrl = null;
                if (DashboardConstants.APP_NAME_AC.equals(app))
@@ -121,4 +116,5 @@ public class AdminController {
                        return new ErrorTransport(400, "Client provided app name is invalid as: " + app);
                }
        }
+
 }
diff --git a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/DashboardUser.java b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/DashboardUser.java
deleted file mode 100644 (file)
index e17f86d..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * ========================LICENSE_START=================================
- * O-RAN-SC
- * %%
- * Copyright (C) 2019 AT&T Intellectual Property
- * %%
- * 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===================================
- */
-
-/*
- * TODO: this mocks user properties until integration with ONAP Portal is done.
- */
-package org.oransc.ric.portal.dashboard.model;
-
-public class DashboardUser {
-
-       private long id;
-       private String firstName;
-       private String lastName;
-       private String status;
-
-       public DashboardUser() {
-       }
-
-       public DashboardUser(long id, String firstName, String lastName, String status) {
-               this.id = id;
-               this.firstName = firstName;
-               this.lastName = lastName;
-               this.status = status;
-       }
-
-       public long getId() {
-               return id;
-       }
-
-       public void setId(long id) {
-               this.id = id;
-       }
-
-       public String getFirstName() {
-               return firstName;
-       }
-
-       public void setFirstName(String firstName) {
-               this.firstName = firstName;
-       }
-
-       public String getLastName() {
-               return lastName;
-       }
-
-       public void setLastName(String lastName) {
-               this.lastName = lastName;
-       }
-
-       public String getStatus() {
-               return status;
-       }
-
-       public void setStatus(String status) {
-               this.status = status;
-       }
-
-}
index 10fef82..febf8c9 100644 (file)
@@ -41,6 +41,7 @@ import org.onap.portalsdk.core.onboarding.util.PortalApiProperties;
 import org.onap.portalsdk.core.restful.domain.EcompRole;
 import org.onap.portalsdk.core.restful.domain.EcompUser;
 import org.oransc.ric.portal.dashboard.DashboardConstants;
+import org.oransc.ric.portal.dashboard.DashboardUserManager;
 import org.oransc.ric.portal.dashboard.model.EcompUserDetails;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index 7bce975..581ca25 100644 (file)
@@ -28,6 +28,7 @@ import javax.servlet.http.HttpServletRequest;
 import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestCentralService;
 import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
 import org.onap.portalsdk.core.restful.domain.EcompUser;
+import org.oransc.ric.portal.dashboard.DashboardUserManager;
 import org.oransc.ric.portal.dashboard.config.SpringContextCache;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index 2d31c0e..877f097 100644 (file)
@@ -44,8 +44,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
 /**
  * Creates a mock implementation of the A1 mediator client API.
  */
-@Profile("test")
 @Configuration
+@Profile("test")
 public class A1MediatorMockConfiguration {
 
        private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
diff --git a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AdminMockConfiguration.java b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AdminMockConfiguration.java
new file mode 100644 (file)
index 0000000..7c52b99
--- /dev/null
@@ -0,0 +1,76 @@
+/*-
+ * ========================LICENSE_START=================================
+ * O-RAN-SC
+ * %%
+ * Copyright (C) 2019 AT&T Intellectual Property
+ * %%
+ * 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.oransc.ric.portal.dashboard.config;
+
+import java.io.IOException;
+import java.lang.invoke.MethodHandles;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
+import org.onap.portalsdk.core.restful.domain.EcompRole;
+import org.onap.portalsdk.core.restful.domain.EcompUser;
+import org.oransc.ric.portal.dashboard.DashboardUserManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+
+/**
+ * Creates a user manager with mock data.
+ */
+@Configuration
+@Profile("test")
+public class AdminMockConfiguration {
+
+       private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+       @Autowired
+       public AdminMockConfiguration() {
+       }
+
+       @Bean
+       // The bean (method) name must be globally unique
+       public DashboardUserManager userManager() throws IOException, PortalAPIException {
+               logger.debug("userManager: adding mock data");
+               DashboardUserManager mgr = new DashboardUserManager(true);
+               String[] firsts = { "John", "Alice", "Pierce", "Paul", "Jack" };
+               String[] lasts = { "Doe", "Nolan", "King", "Smith", "Reacher" };
+               String[] logins = { "jdoe", "anolan", "pking", "psmith", "jreacher" };
+               boolean[] actives = { true, true, false, false, true };
+               EcompRole role = new EcompRole();
+               role.setName("view");
+               Set<EcompRole> roles = new HashSet<>();
+               roles.add(role);
+               for (int i = 0; i < firsts.length; ++i) {
+                       EcompUser eu = new EcompUser();
+                       eu.setFirstName(firsts[i]);
+                       eu.setLastName(lasts[i]);
+                       eu.setLoginId(logins[i]);
+                       eu.setActive(actives[i]);
+                       eu.setRoles(roles);
+                       mgr.createUser(eu);
+               }
+               return mgr;
+       }
+
+}
index 29cc8a8..dac3ff6 100644 (file)
@@ -46,8 +46,8 @@ import org.springframework.http.HttpStatus;
 /**
  * Creates a mock implementation of the ANR xApp client APIs.
  */
-@Profile("test")
 @Configuration
+@Profile("test")
 public class AnrXappMockConfiguration {
 
        private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
index f08df05..09a9d09 100644 (file)
@@ -52,8 +52,8 @@ import org.springframework.http.HttpStatus;
  * Creates an implementation of the xApp manager client that answers requests
  * with mock data.
  */
-@Profile("test")
 @Configuration
+@Profile("test")
 public class AppManagerMockConfiguration {
 
        private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
index b75ab5a..6b12493 100644 (file)
@@ -39,8 +39,8 @@ import org.springframework.context.annotation.Profile;
  * Creates mock implementations of Kubernetes clients that answer requests with
  * sample data read from the filesystem.
  */
-@Profile("test")
 @Configuration
+@Profile("test")
 public class CaasIngressMockConfiguration {
 
        private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
index d76cb83..b3b4c9c 100644 (file)
@@ -49,8 +49,8 @@ import org.springframework.http.HttpStatus;
 /**
  * Creates a mock implementation of the E2 Manager client API.
  */
-@Profile("test")
 @Configuration
+@Profile("test")
 public class E2ManagerMockConfiguration {
 
        private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
index c3623e9..80cde66 100644 (file)
  */
 package org.oransc.ric.portal.dashboard.config;
 
-import java.io.IOException;
 import java.lang.invoke.MethodHandles;
-import java.util.HashSet;
-import java.util.Set;
 
-import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
-import org.onap.portalsdk.core.restful.domain.EcompRole;
-import org.onap.portalsdk.core.restful.domain.EcompUser;
 import org.oransc.ric.portal.dashboard.DashboardConstants;
-import org.oransc.ric.portal.dashboard.portalapi.DashboardUserManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Profile;
 import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
@@ -89,23 +81,4 @@ public class WebSecurityMockConfiguration extends WebSecurityConfigurerAdapter {
                web.ignoring().antMatchers("/", "/csrf"); // allow swagger-ui to load
        }
 
-       // This implementation is so light it can be used during tests.
-       @Bean
-       public DashboardUserManager dashboardUserManager() throws IOException, PortalAPIException {
-               DashboardUserManager dum = new DashboardUserManager(true);
-               // Mock user for convenience in testing
-               EcompUser demo = new EcompUser();
-               demo.setLoginId("demo");
-               demo.setFirstName("Demo");
-               demo.setLastName("User");
-               demo.setActive(true);
-               EcompRole role = new EcompRole();
-               role.setName("view");
-               Set<EcompRole> roles = new HashSet<>();
-               roles.add(role);
-               demo.setRoles(roles);
-               dum.createUser(demo);
-               return dum;
-       }
-
 }
index c11591e..8e426ad 100644 (file)
@@ -27,8 +27,8 @@ import java.util.Map;
 
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
+import org.onap.portalsdk.core.restful.domain.EcompUser;
 import org.oransc.ric.portal.dashboard.DashboardConstants;
-import org.oransc.ric.portal.dashboard.model.DashboardUser;
 import org.oransc.ric.portal.dashboard.model.ErrorTransport;
 import org.oransc.ric.portal.dashboard.model.SuccessTransport;
 import org.slf4j.Logger;
@@ -61,8 +61,8 @@ public class AdminControllerTest extends AbstractControllerTest {
        public void getUsersTest() {
                URI uri = buildUri(null, AdminController.CONTROLLER_PATH, AdminController.USER_METHOD);
                logger.info("Invoking {}", uri);
-               ResponseEntity<List<DashboardUser>> response = testRestTemplateAdminRole().exchange(uri, HttpMethod.GET, null,
-                               new ParameterizedTypeReference<List<DashboardUser>>() {
+               ResponseEntity<List<EcompUser>> response = testRestTemplateAdminRole().exchange(uri, HttpMethod.GET, null,
+                               new ParameterizedTypeReference<List<EcompUser>>() {
                                });
                Assertions.assertFalse(response.getBody().isEmpty());
        }
index 3016b07..40ee7f6 100644 (file)
@@ -35,7 +35,8 @@ public class CaasIngressControllerTest extends AbstractControllerTest {
        public void auxTest() {
                final String nsAux = "ricaux";
                URI uri = buildUri(null, CaasIngressController.CONTROLLER_PATH, CaasIngressController.PODS_METHOD,
-                               CaasIngressController.PP_CLUSTER, CaasIngressController.CLUSTER_AUX, CaasIngressController.PP_NAMESPACE, nsAux);
+                               CaasIngressController.PP_CLUSTER, CaasIngressController.CLUSTER_AUX, CaasIngressController.PP_NAMESPACE,
+                               nsAux);
                logger.info("Invoking {}", uri);
                String s = testRestTemplateStandardRole().getForObject(uri, String.class);
                Assertions.assertFalse(s.isEmpty());
@@ -46,7 +47,8 @@ public class CaasIngressControllerTest extends AbstractControllerTest {
        public void pltTest() {
                final String nsPlt = "ricplt";
                URI uri = buildUri(null, CaasIngressController.CONTROLLER_PATH, CaasIngressController.PODS_METHOD,
-                               CaasIngressController.PP_CLUSTER, CaasIngressController.CLUSTER_PLT, CaasIngressController.PP_NAMESPACE, nsPlt);
+                               CaasIngressController.PP_CLUSTER, CaasIngressController.CLUSTER_PLT, CaasIngressController.PP_NAMESPACE,
+                               nsPlt);
                logger.info("Invoking {}", uri);
                String s = testRestTemplateStandardRole().getForObject(uri, String.class);
                Assertions.assertFalse(s.isEmpty());
index 906549f..90dfd15 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -25,9 +25,33 @@ export interface DashboardSuccessTransport {
   data: string;
 }
 
-export interface DashboardUser {
+export interface EcompRoleFunction {
+  name: string;
+  code: string;
+  type: string;
+  action: string;
+}
+
+export interface EcompRole {
   id: number;
-  firstName: string;
-  lastName: string;
-  status: string;
+  name: string;
+  [position: number]: EcompRoleFunction;
+}
+
+export interface EcompUser {
+  orgId?: number;
+  managerId?: string;
+  firstName?: string;
+  middleInitial?: string;
+  lastName?: string;
+  phone?: string;
+  email?: string;
+  hrid?: string;
+  orgUserId?: string;
+  orgCode?: string;
+  orgManagerUserId?: string;
+  jobTitle?: string;
+  loginId: string;
+  active: boolean;
+  [position: number]: EcompRole;
 }
index 3f42059..a9f2df6 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -20,7 +20,7 @@
 import { Injectable } from '@angular/core';
 import { HttpClient } from '@angular/common/http';
 import { Observable } from 'rxjs';
-import { DashboardSuccessTransport, DashboardUser } from '../../interfaces/dashboard.types';
+import { DashboardSuccessTransport, EcompUser } from '../../interfaces/dashboard.types';
 
 @Injectable({
   providedIn: 'root'
@@ -55,10 +55,10 @@ export class DashboardService {
 
   /**
    * Gets Dashboard users
-   * @returns Observable that should yield a DashboardUser array
+   * @returns Observable that should yield a EcompUser array
    */
-  getUsers(): Observable<DashboardUser[]> {
-    return this.httpClient.get<DashboardUser[]>(this.basePath + 'user');
+  getUsers(): Observable<EcompUser[]> {
+    return this.httpClient.get<EcompUser[]>(this.basePath + 'user');
   }
 
 }
index 54c23e3..69a94e6 100644 (file)
@@ -25,9 +25,9 @@
   </div>
   <table mat-table [dataSource]="dataSource" matSort class="user-table mat-elevation-z8">
 
-    <ng-container matColumnDef="id">
-      <mat-header-cell *matHeaderCellDef mat-sort-header> ID </mat-header-cell>
-      <mat-cell *matCellDef="let element"> {{element.id}} </mat-cell>
+    <ng-container matColumnDef="loginId">
+      <mat-header-cell *matHeaderCellDef mat-sort-header> Login ID </mat-header-cell>
+      <mat-cell *matCellDef="let element"> {{element.loginId}} </mat-cell>
     </ng-container>
 
     <ng-container matColumnDef="firstName">
@@ -40,9 +40,9 @@
       <mat-cell *matCellDef="let element"> {{element.lastName}} </mat-cell>
     </ng-container>
 
-    <ng-container matColumnDef="status">
-      <mat-header-cell *matHeaderCellDef mat-sort-header> Status </mat-header-cell>
-      <mat-cell *matCellDef="let element"> {{element.status}} </mat-cell>
+    <ng-container matColumnDef="active">
+      <mat-header-cell *matHeaderCellDef mat-sort-header> Active? </mat-header-cell>
+      <mat-cell *matCellDef="let element"> {{element.active}} </mat-cell>
     </ng-container>
 
     <ng-container matColumnDef="action">
index 75cf1c2..dfa7809 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -22,7 +22,7 @@ import { MatDialog } from '@angular/material/dialog';
 import { MatSort } from '@angular/material/sort';
 import { DashboardService } from '../services/dashboard/dashboard.service';
 import { ErrorDialogService } from '../services/ui/error-dialog.service';
-import { DashboardUser } from './../interfaces/dashboard.types';
+import { EcompUser } from './../interfaces/dashboard.types';
 import { NotificationService } from './../services/ui/notification.service';
 import { UserDataSource } from './user.datasource';
 import { AddDashboardUserDialogComponent } from './add-dashboard-user-dialog/add-dashboard-user-dialog.component';
@@ -36,7 +36,7 @@ import { EditDashboardUserDialogComponent } from './edit-dashboard-user-dialog/e
 
 export class UserComponent implements OnInit {
 
-  displayedColumns: string[] = ['id', 'firstName', 'lastName', 'status', 'action'];
+  displayedColumns: string[] = ['loginId', 'firstName', 'lastName', 'active', 'action'];
   dataSource: UserDataSource;
   @ViewChild(MatSort, {static: true}) sort: MatSort;
 
@@ -51,7 +51,7 @@ export class UserComponent implements OnInit {
     this.dataSource.loadTable();
   }
 
-  editUser(user: DashboardUser) {
+  editUser(user: EcompUser) {
     const dialogRef = this.dialog.open(EditDashboardUserDialogComponent, {
       width: '450px',
       data: user
index 805085f..09d1741 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -26,13 +26,13 @@ import { BehaviorSubject } from 'rxjs/BehaviorSubject';
 import { merge } from 'rxjs';
 import { of } from 'rxjs/observable/of';
 import { catchError, finalize, map } from 'rxjs/operators';
-import { DashboardUser } from '../interfaces/dashboard.types';
+import { EcompUser } from '../interfaces/dashboard.types';
 import { DashboardService } from '../services/dashboard/dashboard.service';
 import { NotificationService } from '../services/ui/notification.service';
 
-export class UserDataSource extends DataSource<DashboardUser> {
+export class UserDataSource extends DataSource<EcompUser> {
 
-  private userSubject = new BehaviorSubject<DashboardUser[]>([]);
+  private userSubject = new BehaviorSubject<EcompUser[]>([]);
 
   private loadingSubject = new BehaviorSubject<boolean>(false);
 
@@ -57,13 +57,13 @@ export class UserDataSource extends DataSource<DashboardUser> {
         }),
         finalize(() => this.loadingSubject.next(false))
       )
-      .subscribe( (users: DashboardUser[]) => {
+      .subscribe( (users: EcompUser[]) => {
         this.rowCount = users.length;
         this.userSubject.next(users);
       });
   }
 
-  connect(collectionViewer: CollectionViewer): Observable<DashboardUser[]> {
+  connect(collectionViewer: CollectionViewer): Observable<EcompUser[]> {
     const dataMutations = [
       this.userSubject.asObservable(),
       this.sort.sortChange
@@ -78,18 +78,18 @@ export class UserDataSource extends DataSource<DashboardUser> {
     this.loadingSubject.complete();
   }
 
-  private getSortedData(data: DashboardUser[]) {
+  private getSortedData(data: EcompUser[]) {
     if (!this.sort.active || this.sort.direction === '') {
       return data;
     }
 
-    return data.sort((a: DashboardUser, b: DashboardUser) => {
+    return data.sort((a: EcompUser, b: EcompUser) => {
       const isAsc = this.sort.direction === 'asc';
       switch (this.sort.active) {
-        case 'id': return this.compare(a.id, b.id, isAsc);
+        case 'loginId': return this.compare(a.loginId, b.loginId, isAsc);
         case 'firstName': return this.compare(a.firstName, b.firstName, isAsc);
         case 'lastName': return this.compare(a.lastName, b.lastName, isAsc);
-        case 'status': return this.compare(a.status, b.status, isAsc);
+        case 'active': return this.compare(a.active, b.active, isAsc);
         default: return 0;
       }
     });