Guard NPE due to empty policies.

This commit is contained in:
Min Chen 2014-01-23 18:32:20 -08:00
parent 344d3a37cc
commit d47d4bbd20
2 changed files with 9 additions and 2 deletions

View File

@ -2268,7 +2268,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
Object id = cmd.getId();
Object keyword = cmd.getKeyword();
Long domainId = cmd.getDomainId();
Boolean isRootAdmin = _accountMgr.isRootAdmin(account.getType());
Boolean isRootAdmin = _accountMgr.isRootAdmin(account.getAccountId());
// Keeping this logic consistent with domain specific zones
// if a domainId is provided, we just return the disk offering
// associated with this domain

View File

@ -137,6 +137,7 @@ public class IAMServiceImpl extends ManagerBase implements IAMService, Manager {
groupSB.selectFields(groupSB.entity().getAclGroupId());
groupSB.and("account", groupSB.entity().getAccountId(), Op.EQ);
SearchCriteria<Long> groupSc = groupSB.create();
groupSc.setParameters("account", accountId);
List<Long> groupIds = _aclGroupAccountMapDao.customSearch(groupSc, null);
@ -340,7 +341,9 @@ public class IAMServiceImpl extends ManagerBase implements IAMService, Manager {
policySc.setJoinParameters("accountgroupjoin", "account", accountId);
List<Long> policyIds = _aclGroupPolicyMapDao.customSearch(policySc, null);
if (policyIds == null || policyIds.size() == 0) {
return new ArrayList<AclPolicy>();
}
SearchBuilder<AclPolicyVO> sb = _aclPolicyDao.createSearchBuilder();
sb.and("ids", sb.entity().getId(), Op.IN);
SearchCriteria<AclPolicyVO> sc = sb.create();
@ -609,6 +612,10 @@ public class IAMServiceImpl extends ManagerBase implements IAMService, Manager {
boolean allowed = false;
if (policies == null || policies.size() == 0) {
return allowed;
}
List<Long> policyIds = new ArrayList<Long>();
for (AclPolicy policy : policies) {
policyIds.add(policy.getId());