listRouters: don't list Project routers when projectId is not specified in the call

This commit is contained in:
Alena Prokharchyk 2011-12-07 12:58:48 -08:00
parent 352377e8d7
commit 033afe05a9
2 changed files with 17 additions and 1 deletions

View File

@ -1574,6 +1574,11 @@ public class ManagementServerImpl implements ManagementServer {
Pair<List<Long>, Long> accountDomainPair = _accountMgr.finalizeAccountDomainForList(caller, cmd.getAccountName(), cmd.getDomainId(), cmd.getProjectId());
List<Long> permittedAccounts = accountDomainPair.first();
Long domainId = accountDomainPair.second();
boolean skipProjectRouters = true;
if (cmd.getProjectId() != null) {
skipProjectRouters = false;
}
Filter searchFilter = new Filter(DomainRouterVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
@ -1601,6 +1606,12 @@ public class ManagementServerImpl implements ManagementServer {
domainSearch.and("path", domainSearch.entity().getPath(), SearchCriteria.Op.LIKE);
sb.join("domainSearch", domainSearch, sb.entity().getDomainId(), domainSearch.entity().getId(), JoinBuilder.JoinType.INNER);
}
if (skipProjectRouters) {
SearchBuilder<AccountVO> accountSearch = _accountDao.createSearchBuilder();
accountSearch.and("type", accountSearch.entity().getType(), SearchCriteria.Op.NEQ);
sb.join("accountSearch", accountSearch, sb.entity().getAccountId(), accountSearch.entity().getId(), JoinBuilder.JoinType.INNER);
}
if (networkId != null) {
SearchBuilder<NicVO> nicSearch = _nicDao.createSearchBuilder();
@ -1614,6 +1625,11 @@ public class ManagementServerImpl implements ManagementServer {
}
SearchCriteria<DomainRouterVO> sc = sb.create();
if (skipProjectRouters) {
sc.setJoinParameters("accountSearch", "type", Account.ACCOUNT_TYPE_PROJECT);
}
if (keyword != null) {
SearchCriteria<DomainRouterVO> ssc = _routerDao.createSearchCriteria();
ssc.addOr("hostName", SearchCriteria.Op.LIKE, "%" + keyword + "%");

View File

@ -1386,7 +1386,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
//set project information
if (projectId != null) {
if (projectId == -1) {
permittedAccounts.addAll(_projectMgr.listPermittedProjectAccounts(caller.getId()));
permittedAccounts.addAll(_projectMgr.listPermittedProjectAccounts(caller.getId()));
} else {
permittedAccounts.clear();
Project project = _projectMgr.getProject(projectId);