public static Database filterDbIfEnabled(
      boolean isFilterEnabled,
      MetaStoreFilterHook filterHook,
      Database db) throws MetaException, NoSuchObjectException {

    if (isFilterEnabled) {
      Database filteredDb = filterHook.filterDatabase(db);

      if (filteredDb == null) {
        throw new NoSuchObjectException("DB " + db.getName() + " not found.");
      }
    }

    return  db;
  }
Filter the DB if filtering is enabled. Otherwise, return original DB object
@param isFilterEnabled true: filtering is enabled; false: filtring is disabled.
@param filterHook: the object that does filtering
@param db: the database object from HMS metadata
@return the original database object if current user has access;
        otherwise, throw NoSuchObjectException exception
@throws MetaException
@throws NoSuchObjectException
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/FilterUtils.java