Changeset 13591


Ignore:
Timestamp:
2007-01-12T14:39:03+13:00 (15 years ago)
Author:
mdewsnip
Message:

Tidied up all the CollectionManager functions for getting loaded collection paths, and made them static, as part of making CollectionManager fully static.

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

Legend:

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

    r13586 r13591  
    323323        public void actionPerformed(ActionEvent event) {
    324324        // Open an almost standard file browser to the images folder of the current collection
    325         File images_folder = new File(Gatherer.c_man.getCollectionImagesDirectoryPath());
     325        File images_folder = new File(CollectionManager.getLoadedCollectionImagesDirectoryPath());
    326326        // If images isn't already there, create it
    327327        if(!images_folder.exists()) {
  • trunk/gli/src/org/greenstone/gatherer/cdm/MacrosManager.java

    r13586 r13591  
    178178    private void readMacroFile() {
    179179        macros_textarea.setText("");
    180         File extra_dm = new File(CollectionManager.getCollectionDirectoryPath()+"macros"+File.separator+"extra.dm");
     180        File extra_dm = new File(CollectionManager.getLoadedCollectionMacrosDirectoryPath() + "extra.dm");
    181181       
    182182        if (extra_dm.exists()) {
     
    198198   
    199199    private void writeMacroFile() {
    200         File extra_dm_file = new File(CollectionManager.getCollectionDirectoryPath()+"macros"+File.separator+"extra.dm");
     200        File extra_dm_file = new File(CollectionManager.getLoadedCollectionMacrosDirectoryPath() + "extra.dm");
    201201        try {
    202202        if (!extra_dm_file.exists()) {
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r13586 r13591  
    197197    if(collection != null) {
    198198        // Determine if the collection has been built by looking for the build.cfg file
    199         File build_cfg_file = new File(getCollectionIndexDirectoryPath() + "build.cfg");
     199        File build_cfg_file = new File(getLoadedCollectionIndexDirectoryPath() + "build.cfg");
    200200        return build_cfg_file.exists();
    201201    }
     
    225225
    226226    // Remove the lock on this file, then remove the collection.
    227     File lock_file = new File(getCollectionDirectoryPath() + LOCK_FILE);
     227    File lock_file = new File(getLoadedCollectionDirectoryPath() + LOCK_FILE);
    228228    lock_file.delete();
    229229    if (lock_file.exists()) {
     
    458458        addRequiredMetadataSets();
    459459
    460         collection.cdm = new CollectionDesignManager(new File(getCollectionConfigFilePath()));
     460        collection.cdm = new CollectionDesignManager(new File(getLoadedCollectionCfgFilePath()));
    461461
    462462        // We always set title and description here rather than calling mkcol.pl with Unicode arguments
     
    565565
    566566
     567    /** Returns the absolute filename of the specified collection's directory.
     568     */
     569    static public String getCollectionDirectoryPath(String collection_name)
     570    {
     571    return Gatherer.getCollectDirectoryPath() + collection_name + File.separator;
     572    }
     573
     574
     575    /** Returns the absolute filename of the loaded collection's archives directory.
     576     */
     577    static public String getLoadedCollectionArchivesDirectoryPath()
     578    {
     579    return getLoadedCollectionDirectoryPath() + "archives" + File.separator;
     580    }
     581
     582
     583    /** Returns the absolute filename of the loaded collection's building directory.
     584     */
     585    static public String getLoadedCollectionBuildingDirectoryPath()
     586    {
     587    return getLoadedCollectionDirectoryPath() + "building" + File.separator;
     588    }
     589
     590
     591    /** Returns the absolute filename of the loaded collection's collect.cfg file.
     592     */
     593    static public String getLoadedCollectionCfgFilePath()
     594    {
     595    return getLoadedCollectionEtcDirectoryPath() + "collect.cfg";
     596    }
     597
     598
     599    /** Returns the absolute filename of the loaded collection's directory.
     600     */
     601    static public String getLoadedCollectionDirectoryPath()
     602    {
     603    return Gatherer.getCollectDirectoryPath() + collection.getName() + File.separator;
     604    }
     605
     606
     607    /** Returns the absolute filename of the loaded collection's etc directory.
     608     */
     609    static public String getLoadedCollectionEtcDirectoryPath()
     610    {
     611    return getLoadedCollectionDirectoryPath() + "etc" + File.separator;
     612    }
     613
     614
     615    /** Returns the absolute filename of the loaded collection's .col file.
     616     */
     617    static public String getLoadedCollectionColFilePath()
     618    {
     619    return getLoadedCollectionDirectoryPath() + collection.getName() + ".col";
     620    }
     621
     622
     623    /** Returns the absolute filename of the loaded collection's images directory.
     624     */
     625    static public String getLoadedCollectionImagesDirectoryPath()
     626    {
     627    return getLoadedCollectionDirectoryPath() + "images" + File.separator;
     628    }
     629
     630
     631    /** Returns the absolute filename of the loaded collection's import directory.
     632     */
     633    static public String getLoadedCollectionImportDirectoryPath()
     634    {
     635    return getLoadedCollectionDirectoryPath() + "import" + File.separator;
     636    }
     637
     638
     639    /** Returns the absolute filename of the loaded collection's index directory.
     640     */
     641    static public String getLoadedCollectionIndexDirectoryPath()
     642    {
     643    return getLoadedCollectionDirectoryPath() + "index" + File.separator;
     644    }
     645
     646
     647    /** Returns the absolute filename of the loaded collection's log directory.
     648     */
     649    static public String getLoadedCollectionLogDirectoryPath()
     650    {
     651    return getLoadedCollectionDirectoryPath() + "log" + File.separator;
     652    }
     653
     654
     655    /** Returns the absolute filename of the loaded collection's macros directory.
     656     */
     657    static public String getLoadedCollectionMacrosDirectoryPath()
     658    {
     659    return getLoadedCollectionDirectoryPath() + "macros" + File.separator;
     660    }
     661
     662
     663    /** Returns the absolute filename of the loaded collection's metadata directory.
     664     */
     665    static public String getLoadedCollectionMetadataDirectoryPath()
     666    {
     667    return getLoadedCollectionDirectoryPath() + "metadata" + File.separator;
     668    }
     669
     670
    567671    /** Returns the name of the loaded collection.
    568672     */
     
    577681
    578682
    579     static public String getCollectionDirectoryPath()
    580     {
    581     return Gatherer.getCollectDirectoryPath() + collection.getName() + File.separator;
    582     }
    583 
    584 
    585     /** Constructs the absolute filename of the collection's directory, which should resemble "$GSDLHOME/collect/<col_name>"
    586      * @return A <strong>String</strong> containing the directory name.
    587      */
    588     static public String getCollectionDirectoryPath(String collection_name)
    589     {
    590     return Gatherer.getCollectDirectoryPath() + collection_name + File.separator;
    591     }
    592 
    593 
    594     /** Constructs the absolute filename of the collection's .col file, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/&lt;col_name&gt;.col"
    595      * @return A <strong>String</strong> containing the filename.
    596      */
    597     public String getCollectionFilePath()
    598     {
    599     return getCollectionDirectoryPath() + collection.getName() + ".col";
    600     }
    601 
    602 
    603     /** Constructs the absolute filename of the collection's archives directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/archives/"
    604      * @return A <strong>String</strong> containing the filename.
    605      */
    606     public String getCollectionArchivesDirectoryPath()
    607     {
    608     return getCollectionDirectoryPath() + "archives" + File.separator;
    609     }
    610 
    611 
    612     /** Constructs the absolute filename of the collection's building directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/building/"
    613      * @return A <strong>String</strong> containing the filename.
    614      */
    615     public String getCollectionBuildingDirectoryPath()
    616     {
    617     return getCollectionDirectoryPath() + "building" + File.separator;
    618     }
    619 
    620 
    621     /** Constructs the absolute filename of the collection's collect.cfg file, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/etc/collect.cfg"
    622      * @return A <strong>String</strong> containing the filename.
    623      */
    624     public String getCollectionConfigFilePath()
    625     {
    626     return getCollectionEtcDirectoryPath() + "collect.cfg";
    627     }
    628 
    629 
    630     /** Constructs the absolute filename of the collection's etc directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/etc/"
    631      * @return A <strong>String</strong> containing the filename.
    632      */
    633     public String getCollectionEtcDirectoryPath()
    634     {
    635     return getCollectionDirectoryPath() + "etc" + File.separator;
    636     }
    637 
    638 
    639     /** Constructs the absolute filename of the collection's images directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/images/"
    640      * @return A <strong>String</strong> containing the filename.
    641      */
    642     public String getCollectionImagesDirectoryPath()
    643     {
    644     return getCollectionDirectoryPath() + "images" + File.separator;
    645     }
    646 
    647 
    648     /** Constructs the absolute filename of the collection's import directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/import/"
    649      * @return A <strong>String</strong> containing the filename.
    650      */
    651     public String getCollectionImportDirectoryPath()
    652     {
    653     return getCollectionDirectoryPath() + "import" + File.separator;
    654     }
    655 
    656 
    657     /** Constructs the absolute filename of the collection's index directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/index/"
    658      * @return A <strong>String</strong> containing the filename.
    659      */
    660     public String getCollectionIndexDirectoryPath()
    661     {
    662     return getCollectionDirectoryPath() + "index" + File.separator;
    663     }
    664 
    665 
    666     /** Constructs the absolute filename of the collection's log directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/log/"
    667      * @return A <strong>String</strong> containing the filename.
    668      */
    669     public String getCollectionLogDirectoryPath()
    670     {
    671     return getCollectionDirectoryPath() + "log" + File.separator;
    672     }
    673 
    674 
    675     /** Constructs the absolute filename of the collection's metadata directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/metadata/"
    676      * @return A <strong>String</strong> containing the filename.
    677      */
    678     public String getCollectionMetadataDirectoryPath()
    679     {
    680     return getCollectionDirectoryPath() + "metadata" + File.separator;
    681     }
    682 
    683     /** Constructs the absolute filename of the collection's metadata directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/metadata/"
    684      * @return A <strong>String</strong> containing the filename.
    685      */
    686     public String getCollectionPluginsDirectoryPath()
    687     {
    688     return getCollectionDirectoryPath() + "perllib" + File.separator +
    689         "plugins" + File.separator;
    690     }
    691     /** Constructs the absolute filename of the collection's metadata directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/metadata/"
    692      * @return A <strong>String</strong> containing the filename.
    693      */
    694     public String getCollectionClassifiersDirectoryPath()
    695     {
    696     return getCollectionDirectoryPath() + "perllib" + File.separator +
    697         "classify" + File.separator;
    698     }
    699 
    700 
    701683    public CollectionTree getCollectionTree()
    702684    {
     
    714696    if (collection_tree_model == null && collection != null) {
    715697        // Use the import directory to generate a new CollectionTreeModel
    716         collection_tree_model = new CollectionTreeModel(new CollectionTreeNode(new File(getCollectionImportDirectoryPath())));
     698        collection_tree_model = new CollectionTreeModel(new CollectionTreeNode(new File(getLoadedCollectionImportDirectoryPath())));
    717699        // Ensure that the manager is a change listener for the tree.
    718700        if (fm_tree_model_listener == null) {
     
    746728    DebugStream.println("Is event dispatch thread: " + SwingUtilities.isEventDispatchThread());
    747729    //check that we can remove the old index before starting import
    748     File index_dir = new File(getCollectionIndexDirectoryPath());
     730    File index_dir = new File(getLoadedCollectionIndexDirectoryPath());
    749731    if (index_dir.exists()) {
    750732        DebugStream.println("Old Index = " + index_dir.getAbsolutePath()+", testing for deletability");
     
    806788
    807789    // ...and only if it doesn't already exist
    808     File metadata_set_file = new File(getCollectionMetadataDirectoryPath(), external_metadata_set_file.getName());
     790    File metadata_set_file = new File(getLoadedCollectionMetadataDirectoryPath(), external_metadata_set_file.getName());
    809791    if (!metadata_set_file.exists()) {
    810792        try {
     
    1000982
    1001983        // Read through the doc.xml files in the archives directory
    1002         File collection_archives_directory = new File(getCollectionArchivesDirectoryPath());
     984        File collection_archives_directory = new File(getLoadedCollectionArchivesDirectoryPath());
    1003985        DocXMLFileManager.clearDocXMLFiles();
    1004986        DocXMLFileManager.loadDocXMLFiles(collection_archives_directory);
     
    12671249
    12681250    // Create a backup of the collection file, just in case anything goes wrong
    1269     File collection_file = new File(getCollectionFilePath());
     1251    File collection_file = new File(getLoadedCollectionColFilePath());
    12701252    if (collection_file.exists()) {
    12711253        File collection_file_backup = new File(collection_file.getAbsolutePath() + "~");
     
    13371319        Gatherer.configGS3Server(Configuration.site_name, ServletConfiguration.DEACTIVATE_COMMAND + collection.getName());
    13381320        }
    1339         File index_dir = new File(getCollectionIndexDirectoryPath());
     1321        File index_dir = new File(getLoadedCollectionIndexDirectoryPath());
    13401322        DebugStream.println("Index = " + index_dir.getAbsolutePath());
    13411323
    1342         File building_dir = new File(getCollectionBuildingDirectoryPath());
     1324        File building_dir = new File(getLoadedCollectionBuildingDirectoryPath());
    13431325        DebugStream.println("Building = " + building_dir.getAbsolutePath());
    13441326
     
    13621344
    13631345        if (Gatherer.isGsdlRemote) {
    1364             RemoteGreenstoneServer.deleteCollectionFile(collection.getName(), new File(getCollectionIndexDirectoryPath()));
    1365             RemoteGreenstoneServer.moveCollectionFile(collection.getName(), new File(getCollectionBuildingDirectoryPath()), new File(getCollectionIndexDirectoryPath()));
     1346            RemoteGreenstoneServer.deleteCollectionFile(collection.getName(), new File(getLoadedCollectionIndexDirectoryPath()));
     1347            RemoteGreenstoneServer.moveCollectionFile(collection.getName(), new File(getLoadedCollectionBuildingDirectoryPath()), new File(getLoadedCollectionIndexDirectoryPath()));
    13661348        }
    13671349
  • trunk/gli/src/org/greenstone/gatherer/file/WorkspaceTree.java

    r11622 r13591  
    3636import org.greenstone.gatherer.Dictionary;
    3737import org.greenstone.gatherer.Gatherer;
     38import org.greenstone.gatherer.collection.CollectionManager;
    3839import org.greenstone.gatherer.gui.CreateShortcutPrompt;
    3940import org.greenstone.gatherer.gui.tree.DragTree;
     
    120121    if (refresh_reason == DragTree.COLLECTION_CONTENTS_CHANGED) {
    121122        DebugStream.println("...Reason: collection contents changed.");
    122         String collection_import_directory_path = Gatherer.c_man.getCollectionImportDirectoryPath();
     123        String collection_import_directory_path = CollectionManager.getLoadedCollectionImportDirectoryPath();
    123124        refreshEveryNodeShowingFolder(collection_import_directory_path);
    124125    }
  • trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r13583 r13591  
    458458    // If we have a collection open remember it for next time, then save it and close it
    459459    if (Gatherer.c_man.ready()) {
    460         Configuration.setString("general.open_collection", true, Gatherer.c_man.getCollectionFilePath());
     460        Configuration.setString("general.open_collection", true, CollectionManager.getLoadedCollectionColFilePath());
    461461        saveThenCloseCurrentCollection();
    462462    }
  • trunk/gli/src/org/greenstone/gatherer/gui/OptionsPane.java

    r12822 r13591  
    241241        // Build a list of the log files available, ordering by last modified. Log files are like build_log.date.txt
    242242        DefaultListModel contents = new DefaultListModel();
    243         File log_directory = new File(Gatherer.c_man.getCollectionLogDirectoryPath());
     243        File log_directory = new File(CollectionManager.getLoadedCollectionLogDirectoryPath());
    244244        File children[] = log_directory.listFiles();
    245245        for(int i = 0; children != null && i < children.length; i++) {
     
    293293    name.append(".txt");
    294294    // just in case there is no log directory
    295     File file = new File(Gatherer.c_man.getCollectionLogDirectoryPath() + name.toString());
     295    File file = new File(CollectionManager.getLoadedCollectionLogDirectoryPath() + name.toString());
    296296    File parent_file = file.getParentFile();
    297297    parent_file.mkdirs();
  • trunk/gli/src/org/greenstone/gatherer/remote/RemoteGreenstoneServer.java

    r13464 r13591  
    456456
    457457        // Delete the existing (local) collection archives
    458         Utility.delete(new File(Gatherer.c_man.getCollectionArchivesDirectoryPath()));
     458        Utility.delete(new File(CollectionManager.getLoadedCollectionArchivesDirectoryPath()));
    459459
    460460        // Unzip the collection archives just downloaded
  • trunk/gli/src/org/greenstone/gatherer/shell/GShell.java

    r13458 r13591  
    5353import org.greenstone.gatherer.cdm.CollectionMetaManager;
    5454import org.greenstone.gatherer.cdm.CollectionMeta;
     55import org.greenstone.gatherer.collection.CollectionManager;
    5556import org.greenstone.gatherer.metadata.DocXMLFileManager;
    5657import org.greenstone.gatherer.remote.RemoteGreenstoneServer;
     
    392393        fireMessage(type, typeAsString(type) + "> " + Dictionary.get("GShell.Parsing_Metadata_Start"), status, null);
    393394        DocXMLFileManager.clearDocXMLFiles();
    394         DocXMLFileManager.loadDocXMLFiles(new File(Gatherer.c_man.getCollectionArchivesDirectoryPath()));
     395        DocXMLFileManager.loadDocXMLFiles(new File(CollectionManager.getLoadedCollectionArchivesDirectoryPath()));
    395396        fireMessage(type, typeAsString(type) + "> " + Dictionary.get("GShell.Parsing_Metadata_Complete"), status, null);
    396397        }
     
    404405
    405406            // Only need to download build.cfg file
    406             File build_cfg_file = new File(Gatherer.c_man.getCollectionBuildingDirectoryPath(), "build.cfg");
     407            File build_cfg_file = new File(CollectionManager.getLoadedCollectionBuildingDirectoryPath(), "build.cfg");
    407408            RemoteGreenstoneServer.downloadCollectionFile(col_name, build_cfg_file);
    408409           
Note: See TracChangeset for help on using the changeset viewer.