Ignore:
Timestamp:
2005-07-28T15:50:17+12:00 (19 years ago)
Author:
mdewsnip
Message:

Tidied up a lot of path variables. These were all over the place, and were often duplicated. Now all GLI related paths are accessed via static methods in the Gatherer class.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/util/Utility.java

    r10330 r10342  
    6565    /** The size of the io buffer, in bytes. */
    6666    static final public int BUFFER_SIZE = 1024;
    67     /** Definition of an important directory name, in this case the base dir, or the working directory of the Gatherer. */
    68 
    69     static public String BASE_DIR  = System.getProperty("user.dir") + File.separator;
    7067    static final public String BUILD_CFG_FILENAME = "build.cfg";
    7168    static final public String CFG_COLLECTIONMETA_COLLECTIONNAME = "collectionmeta\tcollectionname";
     
    8077    static final public String CFG_FORMAT = "format";
    8178    static final public String CFG_MAINTAINER = "maintainer";
    82     /** Definition of an important directory name, in this case the parent directory of all the collections in the gsdl. */
    83     static final public String COL_DIR = "collect" + File.separator;
    8479    static final public String COLLECTION_TREE = "Collection";
    8580    /** Definition of an important directory name, in this case the file the collection configuration is expect to be in. */
     
    9186    static final public String GLI_EXTENSION = ".col";
    9287
    93     static public String TMP_DIR  = BASE_DIR + "tmp" + File.separator;
    94 
    9588    /** Definition of an important directory name, in this case the images directory for the collection. */
    9689    static final public String IMAGES_DIR = "images" + File.separator;
     
    9992    /** Definition of an important directory name, in this case the backup import directory for the collection. */
    10093    static final public String IMPORT_BAK_DIR = "import.bak" + File.separator;
    101     /** Definition of an important directory name, in this case the log directory for the collection. */
    102     static final public String LOG_DIR = "log" + File.separator;
    10394    /** Definition of an important directory name, in this case the macros directory for the collection. */
    10495    static final public String MACROS_DIR = "macros" + File.separator;
    10596    /** Definition of an important directory name, in this case the location of the expected collection metadata sets.. */
    10697    static final public String META_DIR = "metadata" + File.separator; // Col. Copy
    107     /** Definition of an important directory name, in this case the location of the default metadata sets. */
    108     static public String METADATA_DIR = BASE_DIR + "metadata" + File.separator;
    10998    /** Definition of an important zip file, in this case zipped up version of metadata file stored in JAR file */
    11099    static final public String METADATA_ZIP = "metadata.zip";
     
    119108    static final public String PROGRAM_VERSION = "v2.60";
    120109    static final public String WORKSPACE_TREE = "Workspace";
    121     static final public String XML_DIRECTORY = "xml" + File.separator;
    122 
    123     static protected File gli_user_folder = null;
    124110   
    125111
     
    326312
    327313
    328     /** Builds the cache dir by appending the user path and 'cache'.
    329      * @return a File representing the path to the private file cache within the current collection.
    330      */
    331     public static File getCacheDir() {
    332     return new File(getGLIUserFolder(), StaticStrings.CACHE_FOLDER);
    333     }
    334 
    335    
    336     /** Method which constructs the configuration file given a certain collection.
    337      * @param col_dir The location of the collection directory as a <strong>String</strong>.
    338      * @return The location of the given collections configuration file, also as a <strong>String</strong>.
    339      */
    340     static public String getConfigFile(String col_dir) {
    341     return col_dir + CONFIG_FILE;
    342     }
    343 
    344314    static public String getDateString() {
    345315    Calendar current = Calendar.getInstance();
     
    381351
    382352
    383     static final private String APPLICATION_DATA_FOLDER = "Application Data";
    384     static final private String UNIX_GLI_CONFIG_FOLDER = ".gli";
    385     static final private String USER_HOME_PROPERTY = "user.home";
    386     static final private String WIN_GLI_CONFIG_FOLDER = "Greenstone" + File.separator + "GLI";
    387 
    388     static public File setGLIUserFolder(String windows_home) {
    389         gli_user_folder = null;
    390         if(Utility.isWindows()) {
    391             if ((windows_home != null) && (windows_home != "")) {
    392                 gli_user_folder = new File(windows_home + File.separator + "GLI" + File.separator);
    393             }
    394             else {
    395                 gli_user_folder = new File(System.getProperty(USER_HOME_PROPERTY) + File.separator + APPLICATION_DATA_FOLDER + File.separator + WIN_GLI_CONFIG_FOLDER + File.separator);
    396             }
    397         }
    398         else {
    399             gli_user_folder = new File(System.getProperty(USER_HOME_PROPERTY) +
    400 File.separator + UNIX_GLI_CONFIG_FOLDER + File.separator);
    401         }
    402         return gli_user_folder;
    403     }
    404 
    405     static public File getGLIUserFolder()
    406     {
    407     return gli_user_folder;
    408     }
    409 
    410 
    411     /** Method which constructs the import directory given a certain collection.
    412      * @param col_dir The location of the collection directory as a <strong>String</strong>.
    413      * @return The location of the given collections import directory, also as a <strong>String</strong>.
    414      */
    415     public static String getImportDir(String col_dir) {
    416     return col_dir + IMPORT_DIR;
    417     }
    418 
    419     /** Method which constructs the log directory given a certain collection.
    420      * @param col_dir The location of the collection directory as a <strong>String</strong>.
    421      * @return The location of the given collections log directory, also as a <strong>String</strong>.
    422      */
    423     public static String getLogDir(String col_dir) {
    424     if(col_dir != null) {
    425         return col_dir + LOG_DIR;
    426     }
    427     else {
    428         return getGLIUserFolder().getAbsolutePath() + File.separator + LOG_DIR;
    429     }
    430     }
    431353    /** Determine this machines name.
    432354     * @return The name as a <strong>String</strong>.
Note: See TracChangeset for help on using the changeset viewer.