mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Fixes for listDomains API command:
* return all domains in the system when command is executed via 8096 * for domain admin return only his domains and subdomains.
This commit is contained in:
parent
6f44238109
commit
28dd8185dd
@ -3453,18 +3453,12 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
public List<DomainVO> searchForDomains(ListDomainsCmd cmd) throws PermissionDeniedException {
|
||||
Long domainId = cmd.getId();
|
||||
Account account = UserContext.current().getAccount();
|
||||
String path = null;
|
||||
|
||||
if(account == null || account.getType() == Account.ACCOUNT_TYPE_ADMIN){
|
||||
return _domainDao.listAll();
|
||||
}
|
||||
|
||||
if (account != null) {
|
||||
if (domainId != null) {
|
||||
if (!_domainDao.isChildDomain(account.getDomainId(), domainId)) {
|
||||
throw new PermissionDeniedException("Unable to list domains for domain id " + domainId + ", permission denied.");
|
||||
}
|
||||
}else {
|
||||
domainId = account.getDomainId();
|
||||
if (account != null && account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) {
|
||||
DomainVO domain = _domainDao.findById(account.getDomainId());
|
||||
if (domain != null) {
|
||||
path = domain.getPath();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3484,7 +3478,6 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
if (keyword != null) {
|
||||
SearchCriteria<DomainVO> ssc = _domainDao.createSearchCriteria();
|
||||
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
|
||||
sc.addAnd("name", SearchCriteria.Op.SC, ssc);
|
||||
}
|
||||
|
||||
@ -3499,6 +3492,10 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
if (domainId != null) {
|
||||
sc.setParameters("id", domainId);
|
||||
}
|
||||
|
||||
if (path != null) {
|
||||
sc.setParameters("path", path);
|
||||
}
|
||||
|
||||
return _domainDao.search(sc, searchFilter);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user