Ignore:
Timestamp:
2015-09-28T10:45:13+13:00 (9 years ago)
Author:
jmt12
Message:

Altered the collectionDatabaseFile function to no longer use hardcoded file extensions, but instead to look them up via the registered database types in the DBHelper.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSFile.java

    r27999 r30262  
    3131import org.apache.log4j.Logger;
    3232import org.greenstone.util.GlobalProperties;
     33import org.greenstone.gsdl3.util.DBHelper;
    3334
    3435/**
     
    343344    }
    344345
    345     /** the collection database file - */
    346     static public String collectionDatabaseFile(String site_home, String collection_name, String index_stem, String database_type)
    347     {
    348 
    349         String db_ext = null;
    350         if (database_type.equalsIgnoreCase("jdbm"))
    351         {
    352             db_ext = ".jdb";
    353         }
    354         else
    355         {
    356             // assume gdbm
    357             db_ext = ".gdb";
    358         }
    359 
    360         return site_home + File.separatorChar + "collect" + File.separatorChar + collection_name + File.separatorChar + "index" + File.separatorChar + "text" + File.separatorChar + index_stem + db_ext;
    361 
    362     }
     346    /** the collection database file - */
     347    static public String collectionDatabaseFile(String site_home, String collection_name, String index_stem, String database_type)
     348    {
     349    String db_ext = DBHelper.getDBExtFromDBType(database_type);
     350    if (null == db_ext || db_ext.equals("")) {
     351        logger.warn("Could not recognise database type \"" + database_type + "\", defaulting to GDBM and extension \".gdb\"");
     352        // assume gdbm
     353        db_ext = ".gdb";
     354    }
     355    return site_home + File.separatorChar + "collect" + File.separatorChar + collection_name + File.separatorChar + "index" + File.separatorChar + "text" + File.separatorChar + index_stem + db_ext;
     356    }
    363357
    364358    // some file utility methods
Note: See TracChangeset for help on using the changeset viewer.