public Path determineDatabasePath(Catalog cat, Database db) throws MetaException {
    if (db.getType() == DatabaseType.REMOTE) {
      return getDefaultDatabasePath(db.getName(), true);
    }
    if (db.isSetLocationUri()) {
      return getDnsPath(new Path(db.getLocationUri()));
    }
    if (cat == null || cat.getName().equalsIgnoreCase(DEFAULT_CATALOG_NAME)) {
      if (db.getName().equalsIgnoreCase(DEFAULT_DATABASE_NAME)) {
        return getWhRootExternal();
      } else {
        return new Path(getWhRootExternal(), dbDirFromDbName(db));
      }
    } else {
      return new Path(getDnsPath(new Path(cat.getLocationUri())), dbDirFromDbName(db));
    }
  }
Build the database path based on catalog name and database name.  This should only be used
when a database is being created or altered.  If you just want to find out the path a
database is already using call {@link #getDatabasePath(Database)}.  If the passed in
database already has a path set that will be used.  If not the location will be built using
catalog's path and the database name.
@param cat catalog the database is in
@param db database object
@return Path representing the directory for the database
@throws MetaException when the file path cannot be properly determined from the configured
file system.
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java