@RequiresSession
  public PermissionEntity findPermissionByNameAndType(String name, ResourceTypeEntity resourceType) {
    if (name.equals(PermissionEntity.VIEW_USER_PERMISSION_NAME)) {
      // VIEW.USER permission should be available for any type of views
      return findViewUsePermission();
    }
    TypedQuery<PermissionEntity> query = entityManagerProvider.get().createQuery("SELECT p FROM PermissionEntity p WHERE p.permissionName=:permissionname AND p.resourceType=:resourcetype", PermissionEntity.class);
    query.setParameter("permissionname", name);
    query.setParameter("resourcetype", resourceType);
    return daoUtils.selectSingle(query);
  }
Find a permission entity by name and type.

@param name         the permission name
@param resourceType the resource type

@return a matching permission entity or null
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/PermissionDAO.java