summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKishore Reddy, Gujja (kg811t) <kishore.reddy.gujja@att.com>2018-10-02 16:34:42 -0400
committerKishore Reddy, Gujja (kg811t) <kishore.reddy.gujja@att.com>2018-10-03 12:33:04 -0400
commit15586620ec762ba42f2c6ec1b596ea6ea4425355 (patch)
tree81df99954e54a0c941ded02b3a8b39396ff5c4ec
parent1e3b5bdbea15453fb078ee49fe7de41efef4326f (diff)
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) <kishore.reddy.gujja@att.com>
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java2
-rw-r--r--ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java10
-rw-r--r--ecomp-portal-FE-os/client/src/directives/search-users/search-users.controller.js4
-rw-r--r--ecomp-portal-FE-os/client/src/directives/search-users/search-users.tpl.html215
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<String> 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<UserWithNameSurnameTitle> resultOfSearch = new ArrayList<UserWithNameSurnameTitle>(), resultOfAdditionalSearch = null,
resultOfSearchUserId = new ArrayList<UserWithNameSurnameTitle>();
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<UserWithNameSurnameTitle> searchUsersByUserId(EPUser attrUser) {
List<UserWithNameSurnameTitle> foundUsers = new ArrayList<UserWithNameSurnameTitle>();
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 @@
-->
<div class="search-users-directive">
- <form name="searchUsersForm" novalidate method="post">
- <div class="title" ng-bind="searchUsers.searchTitle"></div>
- <div class="main">
- <div ng-show="searchUsers.showSearch">
- <div class="search-instructions">Enter first name, last name or User ID</div>
- <div class="search">
- <input id="input-user-search"
- autocomplete="off"
- type="text"
- name="searchString"
- placeholder="Search"
- ng-model="searchUsers.searchUserString"
- ng-keyup="$event.keyCode===13 && searchUsersForm.searchString.$valid && searchUsers.searchUsers()"
- pattern="[a-zA-Z0-9-_'\s]{1,}"
- maxlength="80"
- required="true" auto-focus tabindex="0"/>
-
- <button class="btn btn-alt btn-small" tabindex="2" id="button-search-users"
- ng-class="{disabled: searchUsersForm.searchString.$invalid || searchUsers.searchUsersInProgress}"
- ng-click="searchUsersForm.searchString.$valid && searchUsers.searchUsers()">Search
- </button>
-
- <button class="btn btn-alt btn-small" id="Create-New-User-button" ng-click="searchUsers.showAddUserSection()">
- <i class="icon-people-userbookmark" aria-hidden="true"></i>&nbsp;New User
- </button>
-
- </div>
-
- <span class="ecomp-spinner" ng-show="searchUsers.isLoading"></span>
- <div ng-show="UserSearchsIsNull===false">
- <div class="search-results"
- ng-show="!searchUsers.isLoading
+ <form name="searchUsersForm" novalidate method="post">
+ <div class="title" ng-bind="searchUsers.searchTitle"></div>
+ <div class="main">
+ <div ng-show="searchUsers.showSearch">
+ <div class="search-instructions">Enter first name, last name
+ or User ID</div>
+ <div class="search">
+ <input id="input-user-search" autocomplete="off" type="text"
+ name="searchString" placeholder="Search"
+ ng-model="searchUsers.searchUserString"
+ ng-keyup="$event.keyCode===13 && searchUsersForm.searchString.$valid && searchUsers.searchUsers()"
+ pattern="[a-zA-Z0-9-_'\s]{1,}" maxlength="80" required="true"
+ auto-focus tabindex="0" />
+
+ <button class="btn btn-alt btn-small" tabindex="2"
+ id="button-search-users"
+ ng-class="{disabled: searchUsersForm.searchString.$invalid || searchUsers.searchUsersInProgress}"
+ ng-click="searchUsersForm.searchString.$valid && searchUsers.searchUsers()">Search
+ </button>
+
+ <button class="btn btn-alt btn-small" id="Create-New-User-button"
+ ng-click="searchUsers.showAddUserSection()">
+ <i class="icon-people-userbookmark" aria-hidden="true"></i>&nbsp;New
+ User
+ </button>
+
+ </div>
+
+ <span class="ecomp-spinner" ng-show="searchUsers.isLoading"></span>
+ <div ng-show="UserSearchsIsNull===false">
+ <div class="search-results"
+ ng-show="!searchUsers.isLoading
&& searchUsers.searchUsersResults
&& searchUsers.searchUsersResults.length">
- <div id="search-results" ng-show="UserSearchsIsNull===false"
- class="results-title"
- ng-bind="'Showing ' + searchUsers.searchUsersResults.length + ' results'"></div>
- <div class="results-container" scroll-top="searchUsers.scrollApi">
- <div id="search-result-{{$index}}"
- class="user"
- ng-repeat="user in (searchUsers.searchUsersResults | orderBy:['firstName','lastName','orgUserId']) | limitTo: 100 track by $index"
- ng-click="searchUsers.setSelectedUser(user)"
- ng-class="{selected: user.orgUserId === searchUsers.selectedUser.orgUserId}">
- <div id="main-name-{{$index}}" class="main-name">
- <span id="result-first-name-{{$index}}" ng-bind="::user.firstName"></span>
- <span id="result-last-name-{{$index}}" ng-bind="::user.lastName"></span>
- <span id="result-uuid-{{$index}}" ng-bind="::user.orgUserId"></span></div>
- <div id="job-title-{{$index}}" class="sub-job-title" ng-bind="::user.jobTitle"></div>
- <br/>
- </div>
- </div>
- </div>
- </div>
-
- <div class="error-text"
- id="user-search-error-403"
- ng-show="UserSearchsIsNull===true">
- No match found.
- </div>
-
- <div id="no-user-found"
- class="no-user-found"
- ng-show="searchUsers.searchUsersResults && searchUsers.searchUsersResults.length===0 && !searchUsers.searchUsersInProgress">
- No users found
- </div>
- </div>
+ <div id="search-results" ng-show="UserSearchsIsNull===false"
+ class="results-title"
+ ng-bind="'Showing ' + searchUsers.searchUsersResults.length + ' results'"></div>
+ <div class="results-container" scroll-top="searchUsers.scrollApi">
+ <div id="search-result-{{$index}}" class="user"
+ ng-repeat="user in (searchUsers.searchUsersResults | orderBy:['firstName','lastName','orgUserId']) | limitTo: 100 track by $index"
+ ng-click="searchUsers.setSelectedUser(user)"
+ ng-class="{selected: user.orgUserId === searchUsers.selectedUser.orgUserId}">
+ <div id="main-name-{{$index}}" class="main-name">
+ <span id="result-first-name-{{$index}}"
+ ng-bind="::user.firstName"></span> <span
+ id="result-last-name-{{$index}}" ng-bind="::user.lastName"></span>
+ <span id="result-uuid-{{$index}}" ng-bind="::user.orgUserId"></span>
+ </div>
+ <div id="job-title-{{$index}}" class="sub-job-title"
+ ng-bind="::user.jobTitle"></div>
+ <br />
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="error-text" id="user-search-error-403"
+ ng-show="UserSearchsIsNull===true">No match found.</div>
-
- <div id="addWidget" class="add-user-section" ng-show="searchUsers.showAddUser">
- <div>
- <div class="input-new-user-div" >
- <div class="">*First Name</div>
- <input type="text" ng-model="searchUsers.newUser.firstName"/>
+ <div id="no-user-found" class="no-user-found"
+ ng-show="searchUsers.searchUsersResults && searchUsers.searchUsersResults.length===0 && !searchUsers.searchUsersInProgress">
+ No users found</div>
+ </div>
+
+
+ <div id="addWidget" class="add-user-section"
+ ng-show="searchUsers.showAddUser">
+ <div>
+ <div class="input-new-user-div">
+ <div class="">*First Name</div>
+ <input type="text" ng-model="searchUsers.newUser.firstName" />
</div>
- <div class="input-new-user-div" >
- <div class="">Middle Name</div>
- <input type="text" ng-model="searchUsers.newUser.middleName"/>
+ <div class="input-new-user-div">
+ <div class="">Middle Name</div>
+ <input type="text" ng-model="searchUsers.newUser.middleName" />
</div>
- <div class="input-new-user-div" >
- <div class="">*Last Name</div>
- <input type="text" ng-model="searchUsers.newUser.lastName"/>
+ <div class="input-new-user-div">
+ <div class="">*Last Name</div>
+ <input type="text" ng-model="searchUsers.newUser.lastName" />
</div>
- <div class="input-new-user-div" >
- <div class="">*Email Address ID</div>
- <input type="text" ng-model="searchUsers.newUser.emailAddress"/>
+ <div class="input-new-user-div">
+ <div class="">*Email Address ID</div>
+ <input type="text" ng-model="searchUsers.newUser.emailAddress" />
</div>
- <div class="input-new-user-div" >
- <div class="">*Login ID</div>
- <input type="text" ng-model="searchUsers.newUser.loginId"/>
+ <div class="input-new-user-div">
+ <div class="">*Login ID</div>
+ <input type="text" ng-model="searchUsers.newUser.loginId" />
</div>
- <div class="input-new-user-div" >
- <div class="">*Login Password</div>
- <input type="password" ng-model="searchUsers.newUser.loginPwd" autocomplete="off"/>
+ <div class="input-new-user-div">
+ <div class="">*Login Password</div>
+ <input type="password" ng-model="searchUsers.newUser.loginPwd"
+ autocomplete="off" />
</div>
- <div class="input-new-user-div" >
- <div class="">*Confirm Login Password</div>
- <input type="password" ng-model="searchUsers.newUser.loginPwdCheck" autocomplete="off"/>
+ <div class="input-new-user-div">
+ <div class="">*Confirm Login Password</div>
+ <input type="password"
+ ng-model="searchUsers.newUser.loginPwdCheck" autocomplete="off" />
</div>
- <div ng-show="searchUsers.newUser.loginPwdCheck.length>=searchUsers.newUser.loginPwd.length&&searchUsers.newUser.loginPwdCheck.length>0&&searchUsers.newUser.loginPwd!=searchUsers.newUser.loginPwdCheck"
+ <div
+ ng-show="searchUsers.newUser.loginPwdCheck.length>=searchUsers.newUser.loginPwd.length&&searchUsers.newUser.loginPwdCheck.length>0&&searchUsers.newUser.loginPwd!=searchUsers.newUser.loginPwdCheck"
style="color: #cf2a2a; font-size: 12px;">
- <small
- style="position: absolute; margin-top: -6px;">The passwords do not match. Try again.
- </small>
- </div>
- <div ng-show="userExist==true"
+ <small style="position: absolute; margin-top: -6px;">The
+ passwords do not match. Try again. </small>
+ </div>
+ <div ng-show="userExist==true"
style="color: #cf2a2a; font-size: 12px;">
- <small
- style="position: absolute; margin-top: -6px;">User with same loginId already exists. Try again.
- </small>
- </div>
- </div>
- <div class="add-new-user-btn">
- <button class="btn btn-alt btn-small" ng-click="searchUsers.addNewUserFun()">Add New User</button>
+ <small style="position: absolute; margin-top: -6px;">User
+ with same loginId already exists. Try again. </small>
+ </div>
+ <div class="search-instructions">
+ <strong style="color: red">Note:</strong> Login ID should not
+ contain special characters except '@', '-', and '_'.
+ </div>
</div>
+ <div class="add-new-user-btn">
+ <button class="btn btn-alt btn-small"
+ ng-click="searchUsers.addNewUserFun()">Add New User</button>
</div>
-
+ </div>
- </div>
-
- </div>
- </form>
+ </div>
+</div>
+
+</form>
</div>