private Map<String, List<String>> getEntities(final Request request, final String type) {
    Map<String, List<String>> entities = new HashMap<>();

    for (Map<String, Object> propertyMap : request.getBody().getPropertySets()) {
      String ptype = String.valueOf(propertyMap.get(ViewPrivilegeResourceProvider.PRINCIPAL_TYPE));
      if (type.equals(ptype)) {
        String role = String.valueOf(propertyMap.get(ViewPrivilegeResourceProvider.PERMISSION_NAME));
        String name = String.valueOf(propertyMap.get(ViewPrivilegeResourceProvider.PRINCIPAL_NAME));
        if (!entities.containsKey(role)) {
          entities.put(role, new LinkedList<>());
        }

        entities.get(role).add(name);
      }
    }
    return entities;
  }
Assembles entities from the request. The result can contain users or groups based on the value of type parameter
@param request
@param type
@return a map of role -> [user|group] names
ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ViewPrivilegeEventCreator.java