@SuppressWarnings("unchecked") @Override public List<IAMPolicy> listRecursiveIAMPoliciesByGroup(long groupId) { List<IAMGroupPolicyMapVO> policyGrpMap = _aclGroupPolicyMapDao.listByGroupId(groupId); if (policyGrpMap == null || policyGrpMap.size() == 0) { return new ArrayList<IAMPolicy>(); } List<Long> policyIds = new ArrayList<Long>(); for (IAMGroupPolicyMapVO pg : policyGrpMap) { policyIds.add(pg.getAclPolicyId()); } SearchBuilder<IAMPolicyPermissionVO> permSb = _policyPermissionDao.createSearchBuilder(); permSb.and("isRecursive", permSb.entity().isRecursive(), Op.EQ); SearchBuilder<IAMPolicyVO> sb = _aclPolicyDao.createSearchBuilder(); sb.and("ids", sb.entity().getId(), Op.IN); sb.join( "recursivePerm", permSb, sb.entity().getId(), permSb.entity().getAclPolicyId(), JoinBuilder.JoinType.INNER); SearchCriteria<IAMPolicyVO> sc = sb.create(); sc.setParameters("ids", policyIds.toArray(new Object[policyIds.size()])); sc.setJoinParameters("recursivePerm", "isRecursive", true); @SuppressWarnings("rawtypes") List policies = _aclPolicyDao.customSearch(sc, null); return policies; }
@SuppressWarnings("unchecked") @Override public List<IAMPolicy> listIAMPoliciesByGroup(long groupId) { List<IAMGroupPolicyMapVO> policyGrpMap = _aclGroupPolicyMapDao.listByGroupId(groupId); if (policyGrpMap == null || policyGrpMap.size() == 0) { return new ArrayList<IAMPolicy>(); } List<Long> policyIds = new ArrayList<Long>(); for (IAMGroupPolicyMapVO pg : policyGrpMap) { policyIds.add(pg.getAclPolicyId()); } SearchBuilder<IAMPolicyVO> sb = _aclPolicyDao.createSearchBuilder(); sb.and("ids", sb.entity().getId(), Op.IN); SearchCriteria<IAMPolicyVO> sc = sb.create(); sc.setParameters("ids", policyIds.toArray(new Object[policyIds.size()])); @SuppressWarnings("rawtypes") List policies = _aclPolicyDao.customSearch(sc, null); return policies; }