Merge release branch 4.17 to main

* 4.17:
  server: fix exception while list users with keyword (#7169)
This commit is contained in:
Daan Hoogland 2023-02-10 14:08:15 +01:00
commit 3b67be2d52

View File

@ -132,6 +132,7 @@ import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.EnumUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -532,7 +533,7 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
Object type = null; Object type = null;
String accountName = null; String accountName = null;
Object state = null; Object state = null;
Object keyword = null; String keyword = null;
Pair<List<UserAccountJoinVO>, Integer> result = getUserListInternal(caller, permittedAccounts, listAll, id, username, type, accountName, state, keyword, domainId, recursive, Pair<List<UserAccountJoinVO>, Integer> result = getUserListInternal(caller, permittedAccounts, listAll, id, username, type, accountName, state, keyword, domainId, recursive,
null); null);
@ -561,7 +562,7 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
Object type = cmd.getAccountType(); Object type = cmd.getAccountType();
String accountName = cmd.getAccountName(); String accountName = cmd.getAccountName();
Object state = cmd.getState(); Object state = cmd.getState();
Object keyword = cmd.getKeyword(); String keyword = cmd.getKeyword();
Long domainId = cmd.getDomainId(); Long domainId = cmd.getDomainId();
boolean recursive = cmd.isRecursive(); boolean recursive = cmd.isRecursive();
@ -574,7 +575,7 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
} }
private Pair<List<UserAccountJoinVO>, Integer> getUserListInternal(Account caller, List<Long> permittedAccounts, boolean listAll, Long id, Object username, Object type, private Pair<List<UserAccountJoinVO>, Integer> getUserListInternal(Account caller, List<Long> permittedAccounts, boolean listAll, Long id, Object username, Object type,
String accountName, Object state, Object keyword, Long domainId, boolean recursive, Filter searchFilter) { String accountName, Object state, String keyword, Long domainId, boolean recursive, Filter searchFilter) {
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(domainId, recursive, null); Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(domainId, recursive, null);
_accountMgr.buildACLSearchParameters(caller, id, accountName, null, permittedAccounts, domainIdRecursiveListProject, listAll, false); _accountMgr.buildACLSearchParameters(caller, id, accountName, null, permittedAccounts, domainIdRecursiveListProject, listAll, false);
domainId = domainIdRecursiveListProject.first(); domainId = domainIdRecursiveListProject.first();
@ -618,7 +619,9 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
ssc.addOr("email", Op.LIKE, "%" + keyword + "%"); ssc.addOr("email", Op.LIKE, "%" + keyword + "%");
ssc.addOr("state", Op.LIKE, "%" + keyword + "%"); ssc.addOr("state", Op.LIKE, "%" + keyword + "%");
ssc.addOr("accountName", Op.LIKE, "%" + keyword + "%"); ssc.addOr("accountName", Op.LIKE, "%" + keyword + "%");
ssc.addOr("accountType", Op.LIKE, "%" + keyword + "%"); if (EnumUtils.isValidEnum(Account.Type.class, keyword.toUpperCase())) {
ssc.addOr("accountType", Op.EQ, EnumUtils.getEnum(Account.Type.class, keyword.toUpperCase()));
}
sc.addAnd("username", Op.SC, ssc); sc.addAnd("username", Op.SC, ssc);
} }