132132import org .apache .cloudstack .storage .datastore .db .StoragePoolDetailsDao ;
133133import org .apache .cloudstack .storage .datastore .db .StoragePoolVO ;
134134import org .apache .commons .collections .CollectionUtils ;
135+ import org .apache .commons .lang3 .EnumUtils ;
135136import org .apache .commons .lang3 .StringUtils ;
136137import org .apache .log4j .Logger ;
137138import org .springframework .stereotype .Component ;
@@ -531,7 +532,7 @@ public ListResponse<UserResponse> searchForUsers(Long domainId, boolean recursiv
531532 Object type = null ;
532533 String accountName = null ;
533534 Object state = null ;
534- Object keyword = null ;
535+ String keyword = null ;
535536
536537 Pair <List <UserAccountJoinVO >, Integer > result = getUserListInternal (caller , permittedAccounts , listAll , id , username , type , accountName , state , keyword , domainId , recursive ,
537538 null );
@@ -560,7 +561,7 @@ private Pair<List<UserAccountJoinVO>, Integer> searchForUsersInternal(ListUsersC
560561 Object type = cmd .getAccountType ();
561562 String accountName = cmd .getAccountName ();
562563 Object state = cmd .getState ();
563- Object keyword = cmd .getKeyword ();
564+ String keyword = cmd .getKeyword ();
564565
565566 Long domainId = cmd .getDomainId ();
566567 boolean recursive = cmd .isRecursive ();
@@ -573,7 +574,7 @@ private Pair<List<UserAccountJoinVO>, Integer> searchForUsersInternal(ListUsersC
573574 }
574575
575576 private Pair <List <UserAccountJoinVO >, Integer > getUserListInternal (Account caller , List <Long > permittedAccounts , boolean listAll , Long id , Object username , Object type ,
576- String accountName , Object state , Object keyword , Long domainId , boolean recursive , Filter searchFilter ) {
577+ String accountName , Object state , String keyword , Long domainId , boolean recursive , Filter searchFilter ) {
577578 Ternary <Long , Boolean , ListProjectResourcesCriteria > domainIdRecursiveListProject = new Ternary <Long , Boolean , ListProjectResourcesCriteria >(domainId , recursive , null );
578579 _accountMgr .buildACLSearchParameters (caller , id , accountName , null , permittedAccounts , domainIdRecursiveListProject , listAll , false );
579580 domainId = domainIdRecursiveListProject .first ();
@@ -617,7 +618,9 @@ private Pair<List<UserAccountJoinVO>, Integer> getUserListInternal(Account calle
617618 ssc .addOr ("email" , Op .LIKE , "%" + keyword + "%" );
618619 ssc .addOr ("state" , Op .LIKE , "%" + keyword + "%" );
619620 ssc .addOr ("accountName" , Op .LIKE , "%" + keyword + "%" );
620- ssc .addOr ("accountType" , Op .LIKE , "%" + keyword + "%" );
621+ if (EnumUtils .isValidEnum (Account .Type .class , keyword .toUpperCase ())) {
622+ ssc .addOr ("accountType" , Op .EQ , EnumUtils .getEnum (Account .Type .class , keyword .toUpperCase ()));
623+ }
621624
622625 sc .addAnd ("username" , Op .SC , ssc );
623626 }
0 commit comments