From 15586620ec762ba42f2c6ec1b596ea6ea4425355 Mon Sep 17 00:00:00 2001 From: "Kishore Reddy, Gujja (kg811t)" Date: Tue, 2 Oct 2018 16:34:42 -0400 Subject: [PATCH] search user changes Issue-ID: PORTAL-386 failed to create user with special char in login_id Change-Id: I613daa21efed9f6f137bd817a1a8aa2f9669cee8 Signed-off-by: Kishore Reddy, Gujja (kg811t) --- .../portalapp/portal/utils/EcompPortalUtils.java | 2 +- .../portal/service/SearchServiceImpl.java | 10 +- .../search-users/search-users.controller.js | 4 + .../directives/search-users/search-users.tpl.html | 215 +++++++++++---------- 4 files changed, 118 insertions(+), 113 deletions(-) diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java index 809e42f9..f8d1116b 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java @@ -86,7 +86,7 @@ public class EcompPortalUtils { * otherwise */ public static boolean legitimateUserId(String orgUserId) { - return orgUserId.matches("^[a-zA-Z0-9]+$"); + return orgUserId.matches("^[a-zA-Z0-9/_/-/@]+$"); } /** diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java index e0934713..0e9932e0 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java @@ -39,12 +39,10 @@ package org.onap.portalapp.portal.service; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import org.onap.portalapp.portal.domain.EPUser; import org.onap.portalapp.portal.logging.aop.EPMetricsLog; -import org.onap.portalapp.portal.service.SearchService; -import org.onap.portalapp.portal.service.SearchServiceImpl; -import org.onap.portalapp.portal.service.UserService; import org.onap.portalapp.portal.transport.UserWithNameSurnameTitle; import org.onap.portalapp.portal.utils.EcompPortalUtils; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; @@ -75,15 +73,14 @@ public class SearchServiceImpl implements SearchService { return searchUsersInFnTable(searchString); } + @Override public String searchUsersInFnTable(String searchString) { - String orgUserId = null; List tokens = EcompPortalUtils.parsingByRegularExpression(searchString, " "); while (tokens.size() > 2) { // we use no more then first 2 tokens (userId is removed, see above) tokens.remove(tokens.size() - 1); } EPUser attrUser = new EPUser(); - attrUser.setOrgUserId(orgUserId); List resultOfSearch = new ArrayList(), resultOfAdditionalSearch = null, resultOfSearchUserId = new ArrayList(); if (tokens.size() == 2) { @@ -101,6 +98,7 @@ public class SearchServiceImpl implements SearchService { } } else if (tokens.size() == 1) { attrUser.setFirstName(tokens.get(0)); + attrUser.setOrgUserId(tokens.get(0)); resultOfSearch = this.searchUsersByName(attrUser); resultOfSearchUserId = this.searchUsersByUserId(attrUser); resultOfSearch = this.removeWrongFirstNames(resultOfSearch, tokens.get(0)); @@ -115,6 +113,7 @@ public class SearchServiceImpl implements SearchService { resultOfSearch.addAll(resultOfAdditionalSearch); } resultOfSearch.addAll(resultOfSearchUserId); + resultOfSearch.stream().distinct().collect(Collectors.toList()); resultOfSearch = this.cutSearchResultToMaximumSize(resultOfSearch); ObjectMapper mapper = new ObjectMapper(); String result = "[]"; @@ -126,7 +125,6 @@ public class SearchServiceImpl implements SearchService { return result; } - @SuppressWarnings("rawtypes") public List searchUsersByUserId(EPUser attrUser) { List foundUsers = new ArrayList(); diff --git a/ecomp-portal-FE-os/client/src/directives/search-users/search-users.controller.js b/ecomp-portal-FE-os/client/src/directives/search-users/search-users.controller.js index c2067cc1..fc7fd7c2 100644 --- a/ecomp-portal-FE-os/client/src/directives/search-users/search-users.controller.js +++ b/ecomp-portal-FE-os/client/src/directives/search-users/search-users.controller.js @@ -78,6 +78,10 @@ var warningMsg = "Passwords do not match, please try again."; confirmBoxService.showInformation(warningMsg).then(isConfirmed => {return;}); return; + } else if(/[^a-zA-Z0-9\-\@\_]/.test(this.newUser.loginId)){ + var warningMsg = "Login ID should not contain special characters except '@', '-', and '_'."; + confirmBoxService.showInformation(warningMsg).then(isConfirmed => {return;}); + return; } else { // check password length complexity. diff --git a/ecomp-portal-FE-os/client/src/directives/search-users/search-users.tpl.html b/ecomp-portal-FE-os/client/src/directives/search-users/search-users.tpl.html index d8a476d2..ff8d86ec 100644 --- a/ecomp-portal-FE-os/client/src/directives/search-users/search-users.tpl.html +++ b/ecomp-portal-FE-os/client/src/directives/search-users/search-users.tpl.html @@ -36,126 +36,129 @@ -->
-
-
-
-
-
Enter first name, last name or User ID
- - - -
-
+
+
+
+
Enter first name, last name + or User ID
+ + + +
+
-
-
-
-
- - -
-
-
-
-
-
-
- -
- No match found. -
- -
- No users found -
-
+
+
+
+
+ + +
+
+
+
+
+
+
+ +
No match found.
- -
-
-
-
*First Name
- +
+ No users found
+
+ + +
+
+
+
*First Name
+
-
-
Middle Name
- +
+
Middle Name
+
-
-
*Last Name
- +
+
*Last Name
+
-
-
*Email Address ID
- +
+
*Email Address ID
+
-
-
*Login ID
- +
+
*Login ID
+
-
-
*Login Password
- +
+
*Login Password
+
-
-
*Confirm Login Password
- +
+
*Confirm Login Password
+
-
- The passwords do not match. Try again. - -
-
The + passwords do not match. Try again. +
+
- User with same loginId already exists. Try again. - -
-
-
- + User + with same loginId already exists. Try again. +
+
+ Note: Login ID should not + contain special characters except '@', '-', and '_'. +
+
+
- +
-
- -
- +
+
+ +
-- 2.16.6