Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -4443,6 +4444,8 @@
boolean showRemovedTmpl = cmd.getShowRemoved();
Account caller = CallContext.current().getCallingAccount();
Long parentTemplateId = cmd.getParentTemplateId();
Long domainId = cmd.getDomainId();
boolean isRecursive = cmd.isRecursive();

Check warning on line 4448 in server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java#L4447-L4448

Added lines #L4447 - L4448 were not covered by tests

boolean listAll = false;
if (templateFilter != null && templateFilter == TemplateFilter.all) {
Expand All @@ -4453,7 +4456,7 @@
}

List<Long> permittedAccountIds = new ArrayList<Long>();
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<>(cmd.getDomainId(), cmd.isRecursive(), null);
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<>(domainId, isRecursive, null);

Check warning on line 4459 in server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java#L4459

Added line #L4459 was not covered by tests
accountMgr.buildACLSearchParameters(
caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccountIds,
domainIdRecursiveListProject, listAll, false
Expand Down Expand Up @@ -4481,7 +4484,7 @@
null, cmd.getPageSizeVal(), cmd.getStartIndex(), cmd.getZoneId(), cmd.getStoragePoolId(),
cmd.getImageStoreId(), hypervisorType, showDomr, cmd.listInReadyState(), permittedAccounts, caller,
listProjectResourcesCriteria, tags, showRemovedTmpl, cmd.getIds(), parentTemplateId, cmd.getShowUnique(),
templateType, isVnf);
templateType, isVnf, domainId, isRecursive);
}

private Pair<List<TemplateJoinVO>, Integer> searchForTemplatesInternal(Long templateId, String name, String keyword,
Expand All @@ -4490,7 +4493,7 @@
boolean showDomr, boolean onlyReady, List<Account> permittedAccounts, Account caller,
ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String, String> tags,
boolean showRemovedTmpl, List<Long> ids, Long parentTemplateId, Boolean showUnique, String templateType,
Boolean isVnf) {
Boolean isVnf, Long domainId, boolean isRecursive) {

Check warning on line 4496 in server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java#L4496

Added line #L4496 was not covered by tests

// check if zone is configured, if not, just return empty list
List<HypervisorType> hypers = null;
Expand Down Expand Up @@ -4572,7 +4575,7 @@
if (!permittedAccounts.isEmpty()) {
domain = _domainDao.findById(permittedAccounts.get(0).getDomainId());
} else {
domain = _domainDao.findById(caller.getDomainId());
domain = _domainDao.findById(Objects.requireNonNullElse(domainId, caller.getDomainId()));

Check warning on line 4578 in server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java#L4578

Added line #L4578 was not covered by tests
}

setIdsListToSearchCriteria(sc, ids);
Expand All @@ -4584,10 +4587,14 @@
sc.addAnd("accountType", SearchCriteria.Op.EQ, Account.Type.PROJECT);
}

// add criteria for domain path in case of domain admin
// add criteria for domain path in case of admins
if ((templateFilter == TemplateFilter.self || templateFilter == TemplateFilter.selfexecutable)
&& (caller.getType() == Account.Type.DOMAIN_ADMIN || caller.getType() == Account.Type.RESOURCE_DOMAIN_ADMIN)) {
sc.addAnd("domainPath", SearchCriteria.Op.LIKE, domain.getPath() + "%");
&& (accountMgr.isAdmin(caller.getAccountId()))) {
if (isRecursive) {
sc.addAnd("domainPath", SearchCriteria.Op.LIKE, domain.getPath() + "%");

Check warning on line 4594 in server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java#L4594

Added line #L4594 was not covered by tests
} else {
sc.addAnd("domainPath", SearchCriteria.Op.EQ, domain.getPath());

Check warning on line 4596 in server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java#L4596

Added line #L4596 was not covered by tests
}
}

List<Long> relatedDomainIds = new ArrayList<Long>();
Expand Down Expand Up @@ -4893,6 +4900,8 @@
Map<String, String> tags = cmd.getTags();
boolean showRemovedISO = cmd.getShowRemoved();
Account caller = CallContext.current().getCallingAccount();
Long domainId = cmd.getDomainId();
boolean isRecursive = cmd.isRecursive();

Check warning on line 4904 in server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java#L4903-L4904

Added lines #L4903 - L4904 were not covered by tests

boolean listAll = false;
if (isoFilter != null && isoFilter == TemplateFilter.all) {
Expand All @@ -4904,7 +4913,7 @@


List<Long> permittedAccountIds = new ArrayList<>();
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<>(cmd.getDomainId(), cmd.isRecursive(), null);
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<>(domainId, isRecursive, null);

Check warning on line 4916 in server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java#L4916

Added line #L4916 was not covered by tests
accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccountIds, domainIdRecursiveListProject, listAll, false);
ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
List<Account> permittedAccounts = new ArrayList<>();
Expand All @@ -4917,7 +4926,8 @@
return searchForTemplatesInternal(cmd.getId(), cmd.getIsoName(), cmd.getKeyword(), isoFilter, true, cmd.isBootable(),
cmd.getPageSizeVal(), cmd.getStartIndex(), cmd.getZoneId(), cmd.getStoragePoolId(), cmd.getImageStoreId(),
hypervisorType, true, cmd.listInReadyState(), permittedAccounts, caller, listProjectResourcesCriteria,
tags, showRemovedISO, null, null, cmd.getShowUnique(), null, null);
tags, showRemovedISO, null, null, cmd.getShowUnique(), null, null,

Check warning on line 4929 in server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java#L4929

Added line #L4929 was not covered by tests
domainId, isRecursive);
}

@Override
Expand Down
3 changes: 3 additions & 0 deletions ui/src/components/view/InfoCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,9 @@ export default {
if (item.name === 'template') {
query.templatefilter = 'self'
query.filter = 'self'
} else if (item.name === 'iso') {
query.isofilter = 'self'
query.filter = 'self'
}

if (item.param === 'account') {
Expand Down
5 changes: 5 additions & 0 deletions ui/src/config/section/domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ export default {
name: 'template',
title: 'label.templates',
param: 'domainid'
},
{
name: 'iso',
title: 'label.isos',
param: 'domainid'
}],
tabs: [
{
Expand Down