mirror of https://github.com/apache/cloudstack.git
include all VMs when projects selected not just for admins (#7667)
This commit is contained in:
parent
c86684fbdd
commit
b4032d9984
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue