class RoleAuthorizationResourceProvider extends ReadOnlyResourceProvider {

  @Override
  public Set<Resource> getResources(Request request, Predicate predicate)
      throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {

    Set<String> requestedIds = getRequestPropertyIds(request, predicate);
    Set<Resource> resources = new HashSet<>();

    Set<Map<String, Object>> propertyMaps;

    if (predicate == null) {
      // The request must be from /
      propertyMaps = Collections.singleton(Collections.<String, Object>emptyMap());
    } else {
      propertyMaps = getPropertyMaps(predicate);
    }

    if (propertyMaps != null) {
      for (Map<String, Object> propertyMap : propertyMaps) {
        Object object = propertyMap.get(PERMISSION_ID_PROPERTY_ID);
        Collection<RoleAuthorizationEntity> authorizationEntities;
        Integer permissionId;

        if (object instanceof String) {
          try {
            permissionId = Integer.valueOf((String) object);
          } catch (NumberFormatException e) {
            LOG.warn(PERMISSION_ID_PROPERTY_ID + " is not a valid integer value", e);
            throw new NoSuchResourceException("The requested resource doesn't exist: Authorization not found, " + predicate, e);
          }
        } else if (object instanceof Number) {
          permissionId = ((Number) object).intValue();
        } else {
          permissionId = null;
        }

        if (permissionId == null) {
          authorizationEntities = roleAuthorizationDAO.findAll();
        } else {
          PermissionEntity permissionEntity = permissionDAO.findById(permissionId);

          if (permissionEntity == null) {
            authorizationEntities = null;
          } else {
            authorizationEntities = permissionEntity.getAuthorizations();
          }
        }

        if (authorizationEntities != null) {
          String authorizationId = (String) propertyMap.get(AUTHORIZATION_ID_PROPERTY_ID);

          if (!StringUtils.isEmpty(authorizationId)) {
            // Filter the entities
            Iterator<RoleAuthorizationEntity> iterator = authorizationEntities.iterator();
            while (iterator.hasNext()) {
              if (!authorizationId.equals(iterator.next().getAuthorizationId())) {
                iterator.remove();
              }
            }
          }

          for (RoleAuthorizationEntity entity : authorizationEntities) {
            resources.add(toResource(permissionId, entity, requestedIds));
          }
        }
      }
    }

    return resources;
  }

  public  RoleAuthorizationResourceProvider(AmbariManagementController managementController);

}