class ViewPermissionResourceProvider extends AbstractResourceProvider {

  @Override
  public Set<Resource> getResources(Request request, Predicate predicate)
      throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
    ViewRegistry  viewRegistry = ViewRegistry.getInstance();
    Set<Resource> resources    = new HashSet<>();
    Set<String>   requestedIds = getRequestPropertyIds(request, predicate);

    PermissionEntity viewUsePermission = permissionDAO.findViewUsePermission();
    for (Map<String, Object> propertyMap: getPropertyMaps(predicate)) {
      Object viewName = propertyMap.get(VIEW_NAME);
      Object viewVersion = propertyMap.get(VERSION);
      if (viewName != null && viewVersion != null) {
        ViewEntity viewEntity = viewRegistry.getDefinition(viewName.toString(), viewVersion.toString());

        // do not report permissions for views that are not loaded.
        if (viewEntity.isDeployed()) {
          ViewPermissionResponse viewPermissionResponse = getResponse(viewUsePermission, viewEntity.getResourceType(), viewEntity);
          resources.add(toResource(viewPermissionResponse, requestedIds));
        }
      }
    }

    for(PermissionEntity permissionEntity : permissionDAO.findAll()){
      ResourceTypeEntity resourceType = permissionEntity.getResourceType();

      ViewEntity viewEntity = viewRegistry.getDefinition(resourceType);

      if (viewEntity != null && viewEntity.isDeployed()) {
        ViewPermissionResponse viewPermissionResponse = getResponse(permissionEntity, resourceType, viewEntity);
        resources.add(toResource(viewPermissionResponse, requestedIds));
      }
    }

    return resources;
  }

  public  ViewPermissionResourceProvider();

}