@Override
  public Set<Resource> getResourcesAuthorized(Request request, Predicate predicate)
      throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
    Set<Resource> resources    = new HashSet<>();
    Set<String>   requestedIds = getRequestPropertyIds(request, predicate);
    Set<Long>     resourceIds  = new HashSet<>();

    Set<Map<String, Object>> propertyMaps = getPropertyMaps(predicate);

    if (propertyMaps.isEmpty()) {
      propertyMaps.add(Collections.emptyMap());
    }

    for (Map<String, Object> properties : propertyMaps) {
      Map<Long, T> resourceEntities;
      try {
        resourceEntities = getResourceEntities(properties);
      } catch (AmbariException e) {
        throw new SystemException("Could not get resource list from request", e);
      }

      resourceIds.addAll(resourceEntities.keySet());

      Set<PrivilegeEntity> entitySet = new HashSet<>();
      List<PrincipalEntity> userPrincipals = new LinkedList<>();
      List<PrincipalEntity> groupPrincipals = new LinkedList<>();
      List<PrincipalEntity> rolePrincipals = new LinkedList<>();

      List<PrivilegeEntity> entities = privilegeDAO.findAll();

      for(PrivilegeEntity privilegeEntity : entities){
        if (resourceIds.contains(privilegeEntity.getResource().getId())) {
          PrincipalEntity principal = privilegeEntity.getPrincipal();
          String principalType = principal.getPrincipalType().getName();

          entitySet.add(privilegeEntity);

          if(PrincipalTypeEntity.USER_PRINCIPAL_TYPE_NAME.equals(principalType)) {
            userPrincipals.add(principal);
          }
          else if(PrincipalTypeEntity.GROUP_PRINCIPAL_TYPE_NAME.equals(principalType)) {
            groupPrincipals.add(principal);
          }
          else if(PrincipalTypeEntity.ROLE_PRINCIPAL_TYPE_NAME.equals(principalType)) {
            rolePrincipals.add(principal);
          }
        }
      }

      Map<Long, UserEntity> userEntities = new HashMap<>();
      if(!userPrincipals.isEmpty()) {
        List<UserEntity> userList = userDAO.findUsersByPrincipal(userPrincipals);
        for (UserEntity userEntity : userList) {
          userEntities.put(userEntity.getPrincipal().getId(), userEntity);
        }
      }

      Map<Long, GroupEntity> groupEntities = new HashMap<>();
      if(!groupPrincipals.isEmpty()) {
        List<GroupEntity> groupList = groupDAO.findGroupsByPrincipal(groupPrincipals);
        for (GroupEntity groupEntity : groupList) {
          groupEntities.put(groupEntity.getPrincipal().getId(), groupEntity);
        }
      }

      Map<Long, PermissionEntity> roleEntities = new HashMap<>();
      if (!rolePrincipals.isEmpty()){
        List<PermissionEntity> roleList = permissionDAO.findPermissionsByPrincipal(rolePrincipals);
        for (PermissionEntity roleEntity : roleList) {
          roleEntities.put(roleEntity.getPrincipal().getId(), roleEntity);
        }
      }

      for(PrivilegeEntity privilegeEntity : entitySet){
        Resource resource = toResource(privilegeEntity, userEntities, groupEntities, roleEntities, resourceEntities, requestedIds);
        if (resource != null && (predicate == null || predicate.evaluate(resource))) {
          resources.add(resource);
        }
      }
    }

    return resources;
  }
Get the id for the resource specified by predicate.

@param predicate predicate

@return the resource id
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PrivilegeResourceProvider.java