include all VMs when projects selected not just for admins (#7667)

This commit is contained in:
dahn 2023-08-03 16:06:11 +02:00 committed by GitHub
parent c86684fbdd
commit b4032d9984
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 10 deletions

View File

@ -991,14 +991,14 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
private Pair<List<UserVmJoinVO>, Integer> searchForUserVMsInternal(ListVMsCmd cmd) {
Account caller = CallContext.current().getCallingAccount();
List<Long> permittedAccounts = new ArrayList<Long>();
List<Long> permittedAccounts = new ArrayList<>();
boolean listAll = cmd.listAll();
Long id = cmd.getId();
Long userId = cmd.getUserId();
Map<String, String> tags = cmd.getTags();
Boolean display = cmd.getDisplay();
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(cmd.getDomainId(), cmd.isRecursive(), null);
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<>(cmd.getDomainId(), cmd.isRecursive(), null);
_accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, listAll, false);
Long domainId = domainIdRecursiveListProject.first();
Boolean isRecursive = domainIdRecursiveListProject.second();
@ -1011,7 +1011,7 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
if (cmd.getIds() != null && !cmd.getIds().isEmpty()) {
throw new InvalidParameterValueException("Specify either id or ids but not both parameters");
}
ids = new ArrayList<Long>();
ids = new ArrayList<>();
ids.add(cmd.getId());
} else {
ids = cmd.getIds();

View File

@ -2955,18 +2955,17 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
if (projectId != null) {
if (!forProjectInvitation) {
if (projectId == -1L) {
if (caller.getType() == Account.Type.ADMIN) {
domainIdRecursiveListProject.third(Project.ListProjectResourcesCriteria.ListProjectResourcesOnly);
if (listAll) {
domainIdRecursiveListProject.third(ListProjectResourcesCriteria.ListAllIncludingProjectResources);
}
} else {
domainIdRecursiveListProject.third(Project.ListProjectResourcesCriteria.ListProjectResourcesOnly);
if (caller.getType() != Account.Type.ADMIN) {
permittedAccounts.addAll(_projectMgr.listPermittedProjectAccounts(caller.getId()));
// permittedAccounts can be empty when the caller is not a part of any project (a domain account)
if (permittedAccounts.isEmpty()) {
if (permittedAccounts.isEmpty() || listAll) {
permittedAccounts.add(caller.getId());
}
}
if (listAll) {
domainIdRecursiveListProject.third(ListProjectResourcesCriteria.ListAllIncludingProjectResources);
}
} else {
Project project = _projectMgr.getProject(projectId);
if (project == null) {