Changeset 7224


Ignore:
Timestamp:
2004-04-23T14:56:30+12:00 (20 years ago)
Author:
kjdon
Message:

tidied up the getXXXDir methods in Utility. Utility.getCollectionDir (which returns the path to the collect directory) has been renamed to getCollectDir, and a new Utility.getCollectionDir is provided which returns the path to an individual collection's base dir

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/cdm/SuperCollectionManager.java

    r6144 r7224  
    191191        // We start by building a model of the installed collections.
    192192        collection_checklist_model = new ArrayList();
    193         File gsdl_collection_directory = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path));
     193        File gsdl_collection_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl_path));
    194194        current_coll_name = Gatherer.c_man.getCollection().getName();
    195195        File[] possible_collections = gsdl_collection_directory.listFiles();
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r7207 r7224  
    215215    closing_thread = Thread.currentThread();
    216216    // Remove the lock on this file, then remove the collection.
    217     File lock_file = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator + LOCK_FILE);
     217    File lock_file = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName()) + LOCK_FILE);
    218218    lock_file.delete();
    219219    if(lock_file.exists()) {
     
    257257        makeCollection(description, email, name, title);
    258258        progress.setProgress(1);
    259         String a_dir = Utility.getCollectionDir(Gatherer.config.gsdl_path) + name + File.separator;
     259        String a_dir = Utility.getCollectionDir(Gatherer.config.gsdl_path, name);
    260260
    261261        // ACTIVE_DIR/log/
     
    491491     */
    492492    public String getCollectionArchive() {
    493     return Utility.getArchiveDir(Gatherer.config.gsdl_path, collection.getName());
     493    return Utility.getArchiveDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName()));
    494494    }
    495495    /** Constructs the absolute filename of the collection building directory, which should resemble "$GSDLHOME/collect/<col_name>/building/"
     
    501501     */
    502502    public String getCollectionBuild() {
    503     return Utility.getBuildDir(Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator);
     503    return Utility.getBuildDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName()));
    504504    }
    505505
     
    512512     */
    513513    public String getCollectionConfig() {
    514     return Utility.getConfigDir(Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator);
     514    return Utility.getConfigDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName()));
    515515    }
    516516
     
    523523     */
    524524    public String getCollectionDirectory() {
    525     return Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator;
     525    return Utility.getCollectionDir(Gatherer.config.gsdl_path,  collection.getName());
    526526    }
    527527
     
    534534     */
    535535    public String getCollectionEtc() {
    536     return Utility.getEtcDir(Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator);
     536    return Utility.getEtcDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName()));
    537537    }
    538538    /** Constructs the absolute filename of the collection file, which should resemble "$GSDLHOME/collect/<col_name>/<col_name>.col"
     
    544544     */
    545545    public String getCollectionFilename() {
    546     return Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator + collection.getName() + ".col";
     546    return Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName()) + collection.getName() + ".col";
    547547    }
    548548    /** Constructs the absolute filename of the collection images directory, which should resemble "$GSDLHOME/collect/<col_name>/images/"
     
    554554     */
    555555    public String getCollectionImages() {
    556     return Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator + StaticStrings.IMAGES_FOLDER;
     556    return Utility.getImagesDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName()));
    557557    }
    558558    /** Constructs the absolute filename of the collection import directory, which should resemble "$GSDLHOME/collect/<col_name>/import/"
     
    564564     */
    565565    public String getCollectionImport() {
    566     return Utility.getImportDir(Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator);
     566    return Utility.getImportDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName()));
    567567    }
    568568    /** Constructs the absolute filename of the collection index directory, which should resemble "$GSDLHOME/collect/<col_name>/index/"
     
    574574     */
    575575    public String getCollectionIndex() {
    576     return Utility.getIndexDir(Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator);
     576    return Utility.getIndexDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName()));
    577577    }
    578578    /** Constructs the absolute filename of the collection log directory, which should resemble "$GSDLHOME/collect/<col_name>/log/"
     
    584584     */
    585585    public String getCollectionLog() {
    586     return Utility.getLogDir(Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator);
     586    return Utility.getLogDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName()));
    587587    }
    588588    /** Constructs the absolute filename of the collection metadata directory, which should resemble "$GSDLHOME/collect/<col_name>/metadata/"
     
    594594     */
    595595    public String getCollectionMetadata() {
    596     return Utility.getMetadataDir(Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator);
     596    return Utility.getMetadataDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName()));
    597597    }
    598598
  • trunk/gli/src/org/greenstone/gatherer/collection/DeleteCollectionPrompt.java

    r6842 r7224  
    217217    private void scanForCollections() {
    218218    // Start at the collect dir.
    219     String collect_directory_name = Utility.getCollectionDir(Gatherer.config.gsdl_path);
     219    String collect_directory_name = Utility.getCollectDir(Gatherer.config.gsdl_path);
    220220    File collect_directory = new File(collect_directory_name);
    221221    if(collect_directory.exists()) {
     
    311311        }
    312312
    313         File delete_me = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getShortName() + File.separator);
     313        File delete_me = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getShortName()));
    314314        if(Utility.delete(delete_me)) {
    315315        if (Gatherer.c_man.getCollection() != null && collection.getShortName().equals(Gatherer.c_man.getCollection().getName())) {
  • trunk/gli/src/org/greenstone/gatherer/collection/ExportCollectionPrompt.java

    r7160 r7224  
    345345    private void scanForCollections() {
    346346    // Start at the collect dir.
    347     String collect_directory_name = Utility.getCollectionDir(Gatherer.config.gsdl_path);
     347    String collect_directory_name = Utility.getCollectDir(Gatherer.config.gsdl_path);
    348348    File collect_directory = new File(collect_directory_name);
    349349    if(collect_directory.exists()) {
  • trunk/gli/src/org/greenstone/gatherer/collection/SaveCollectionTask.java

    r6842 r7224  
    163163        ArrayList files = new ArrayList();
    164164        File collection_file = new File(Gatherer.c_man.getCollectionFilename());
    165         File copied_dir = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path) + name);
     165        File copied_dir = new File(Utility.getCollectDir(Gatherer.config.gsdl_path) + name);
    166166        files.add(collection_file.getParentFile());
    167167        while(files.size() > 0) {
  • trunk/gli/src/org/greenstone/gatherer/file/FileNode.java

    r7122 r7224  
    273273        ///atherer.println("Map the 'Greenstone Collections' node.");
    274274        // For each of the children directories, which are collections...
    275         File start = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path));
     275        File start = new File(Utility.getCollectDir(Gatherer.config.gsdl_path));
    276276        File cols[] = start.listFiles();
    277277        ArrayTools.sort(cols);
  • trunk/gli/src/org/greenstone/gatherer/gui/BuildOptions.java

    r5589 r7224  
    156156     */
    157157    public BuildOptions() {
    158     collectdir_value = Utility.getCollectionDir(Gatherer.config.gsdl_path);
     158    collectdir_value = Utility.getCollectDir(Gatherer.config.gsdl_path);
    159159    // If we have a collection open gets its details.
    160160    if(Gatherer.c_man.ready()) {
  • trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r6879 r7224  
    719719        File file;
    720720        if(Gatherer.config.gsdl_path != null) {
    721         file = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path));
     721        file = new File(Utility.getCollectDir(Gatherer.config.gsdl_path));
    722722        }
    723723        else {
  • trunk/gli/src/org/greenstone/gatherer/gui/NewCollectionDetailsPrompt.java

    r7158 r7224  
    5151        return false;
    5252    }
    53     File collection_directory = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path));
     53    File collection_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl_path));
    5454    File children[] = collection_directory.listFiles();
    5555    for(int i = 0; children != null && i < children.length; i++) {
     
    104104    // Model building. Build a model of all of the collections in the gsdl collect directory with the appropriate directories.
    105105    Vector base_collection_model = new Vector();
    106     File gsdl_collection_directory = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path));
     106    File gsdl_collection_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl_path));
    107107    File[] possible_collections = gsdl_collection_directory.listFiles();
    108108    for (int i = 0; possible_collections != null && i < possible_collections.length; i++) {
     
    322322
    323323    private boolean filenameClashes(String filename) {
    324     File collection_directory = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path));
     324    File collection_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl_path));
    325325    File children[] = collection_directory.listFiles();
    326326    for(int i = 0; children != null && i < children.length; i++) {
     
    342342        File file;
    343343        if(Gatherer.config.gsdl_path != null) {
    344         file = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path));
     344        file = new File(Utility.getCollectDir(Gatherer.config.gsdl_path));
    345345        }
    346346        else {
     
    417417           if(name_final.length() > 0) {
    418418           // Determine if this filename is already in use.
    419            File collection_directory = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path));
     419           File collection_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl_path));
    420420           File children[] = collection_directory.listFiles();
    421421           for(int i = 0; children != null && i < children.length; i++) {
  • trunk/gli/src/org/greenstone/gatherer/mem/MEMNode.java

    r6203 r7224  
    149149            boolean is_descendant = false;
    150150            File source_path = new File((String)userObject);
    151             File collect_path = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path));
     151            File collect_path = new File(Utility.getCollectDir(Gatherer.config.gsdl_path));
    152152            File current_path = source_path;
    153153            while(!is_descendant && current_path != null) {
  • trunk/gli/src/org/greenstone/gatherer/util/Utility.java

    r7014 r7224  
    110110    /** Definition of an important directory name, in this case the location of help documentation. */
    111111    static final public String HELP_DIR = BASE_DIR + "help" + File.separator;
     112    /** Definition of an important directory name, in this case the images directory for the collection. */
     113    static final public String IMAGES_DIR = "images" + File.separator;
    112114    /** Definition of an important directory name, in this case the import directory for the collection. */
    113115    static final public String IMPORT_DIR = "import" + File.separator;
     
    460462
    461463    /** Method which constructs the archive directory given a certain collection.
    462      * @param gsdl_path The location of the greenstone installation  as a <strong>String</strong>.
    463      * @param col_name The collection name
     464     * @param gsdl_path The location of the collection directory as a <strong>String</strong>.
    464465     * @return The location of the given collections archive directory, also as a <strong>String</strong>.
    465466     */
    466     static public String getArchiveDir(String gsdl_path, String col_name) {
    467     return gsdl_path + File.separator + COL_DIR + col_name + File.separator + ARCHIVE_DIR;
     467    static public String getArchiveDir(String col_dir) {
     468    return col_dir + ARCHIVE_DIR;
    468469    }
    469470    /** Method which constructs the build directory given a certain collection.
     
    483484    return new File(getGLIUserFolder(), StaticStrings.CACHE_FOLDER);
    484485    }
    485     /** Method which constructs the collection directory for Greenstone.
     486    /** Method which constructs the collect directory for Greenstone.
    486487     * @param gsdl_path The location of the gsdl installation directory as a <strong>String</strong>.
    487488     * @return The location of the collection directory, also as a <strong>String</strong>.
    488489     */
    489     public static String getCollectionDir(String gsdl_path) {
     490    public static String getCollectDir(String gsdl_path) {
    490491    return gsdl_path + COL_DIR;
    491492    }
     493   
     494    /** Method which constructs a collection's top level directory
     495     * @@param gsdl_path The location of the gsdl installation directory as a <strong>String</strong>.
     496     * @param The name of the collection as a <strong>String</strong>.
     497     * @return The location of the collection's base directory
     498     */
     499    public static String getCollectionDir(String gsdl_path, String coll_name) {
     500    return getCollectDir(gsdl_path) + coll_name + File.separator;
     501    }
     502   
    492503    /** Method which constructs the configuration file given a certain collection.
    493504     * @param col_dir The location of the collection directory as a <strong>String</strong>.
     
    610621    }
    611622
     623    /** Method which constructs the images directory given a certain collection.
     624     * @param col_dir The location of the collection directory as a <strong>String</strong>.
     625     * @return The location of the given collections images directory, also as a <strong>String</strong>.
     626     */
     627    public static String getImagesDir(String col_dir) {
     628    return col_dir + IMAGES_DIR;
     629    }
    612630    /** Method which constructs the import directory given a certain collection.
    613631     * @param col_dir The location of the collection directory as a <strong>String</strong>.
Note: See TracChangeset for help on using the changeset viewer.