Changeset 9045 for trunk


Ignore:
Timestamp:
2005-02-15T15:39:48+13:00 (19 years ago)
Author:
mdewsnip
Message:

Made major rearrangements to the way path variables are calculated. This is to facilitate being able to specify a "-collectdir" argument to the GLI so one GLI installation can be used in a networked, multi-user situation. Hope I haven't broken anything!

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

Legend:

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

    r9039 r9045  
    6969    /** All of the external applications that must exit before we close the Gatherer. */
    7070    public Vector apps = new Vector();
     71    static private String non_standard_collect_directory_path = null;
    7172    static public String open_collection_file_path = null;
    7273    /** A public reference to the FileAssociationManager. */
     
    410411        if(c_man.saved()) {
    411412        ///ystem.err.println("Collection has been recently saved, so I'll remember it for next time.");
    412         Configuration.setString("general.open_collection", true, c_man.getCollectionFilename());
     413        Configuration.setString("general.open_collection", true, c_man.getCollectionFilePath());
    413414        }
    414415        c_man.closeCollection();
     
    448449        g_man.setVisible(false);
    449450    }
     451    }
     452
     453
     454    static public String getCollectDirectoryPath()
     455    {
     456    if (non_standard_collect_directory_path != null) {
     457        return non_standard_collect_directory_path;
     458    }
     459
     460    if (!GS3) {
     461        return Configuration.gsdl_path + "collect" + File.separator;
     462    }
     463    else {
     464        return getSitesDirectoryPath() + Configuration.site_name + File.separator + "collect" + File.separator;
     465    }
     466    }
     467
     468
     469    static public String getSitesDirectoryPath()
     470    {
     471    return Configuration.gsdl3_path + File.separator + "web" + File.separator + "sites" + File.separator;
     472    }
     473
     474
     475    static public void setCollectDirectoryPath(String collect_directory_path)
     476    {
     477    non_standard_collect_directory_path = collect_directory_path;
    450478    }
    451479
  • trunk/gli/src/org/greenstone/gatherer/GathererApplet.java

    r9039 r9045  
    143143    }
    144144
    145     File col_dir = new File(Utility.getCollectDir(go.gsdl_path));
     145    Gatherer.setCollectDirectoryPath(go.gsdl_path + "collect" + File.separator);
     146    File col_dir = new File(Gatherer.getCollectDirectoryPath());
    146147    if (!col_dir.exists()) {
    147148        col_dir.mkdir();
     
    242243           
    243244        // set up output stream for zip download
    244         String col_dir = Utility.getCollectDir(Configuration.gsdl_path);
    245         String zip_fname = col_dir + col_name + ".zip";
     245        String collect_directory_path = Gatherer.getCollectDirectoryPath();
     246        String zip_fname = collect_directory_path + col_name + ".zip";
    246247        FileOutputStream zip_fos = new FileOutputStream(zip_fname);
    247248        BufferedOutputStream zip_bfos = new BufferedOutputStream(zip_fos);
     
    271272    final int maxBufferSize = 1024;
    272273
    273     String col_dir = Utility.getCollectDir(Configuration.gsdl_path);
    274     String zip_fname = col_dir + col_name + ".zip";
     274    String collect_directory_path = Gatherer.getCollectDirectoryPath();
     275    String zip_fname = collect_directory_path + col_name + ".zip";
    275276    String upload_cgi = Gatherer.cgiBase + "upload";
    276277
  • trunk/gli/src/org/greenstone/gatherer/cdm/CollectionDesignManager.java

    r8620 r9045  
    216216        if (formats_changed && Gatherer.c_man.built()) {
    217217        // upload etc/collect.cfg to server to reflect changes
    218         Utility.zipup(collection_name, Utility.CONFIG_FILE);
     218        Utility.zipup(Gatherer.getCollectDirectoryPath(), collection_name, Utility.CONFIG_FILE);
    219219        GathererApplet.upload_url_zip(collection_name, "etc");
    220220        }
  • trunk/gli/src/org/greenstone/gatherer/cdm/GeneralManager.java

    r8606 r9045  
    473473        public void actionPerformed(ActionEvent event) {
    474474        // Open an almost standard file browser to the images folder of the current collection
    475         File images_folder = new File(Gatherer.c_man.getCollectionImages());
     475        File images_folder = new File(Gatherer.c_man.getCollectionImagesDirectoryPath());
    476476        // If images isn't already there, create it
    477477        if(!images_folder.exists()) {
  • trunk/gli/src/org/greenstone/gatherer/cdm/MetadataSetView.java

    r8386 r9045  
    300300            // Re-read all the metadata.xml files to account for this case
    301301            MetadataXMLFileManager.clearMetadataXMLFiles();
    302             MetadataXMLFileManager.loadMetadataXMLFiles(new File(Gatherer.c_man.getCollectionImport()));
     302            MetadataXMLFileManager.loadMetadataXMLFiles(new File(Gatherer.c_man.getCollectionImportDirectoryPath()));
    303303        }
    304304        }
  • trunk/gli/src/org/greenstone/gatherer/cdm/SuperCollectionManager.java

    r8884 r9045  
    196196        current_coll_name = Gatherer.c_man.getCollection().getName();
    197197
    198         File gsdl_collection_directory;
    199         if (Gatherer.GS3) {
    200         gsdl_collection_directory = new File(Utility.getCollectDir(Configuration.gsdl3_path, Configuration.site_name));
    201         }
    202         else {
    203         gsdl_collection_directory = new File(Utility.getCollectDir(Configuration.gsdl_path));
    204         }
    205 
    206         File[] possible_collections = gsdl_collection_directory.listFiles();
     198        File collect_directory = new File(Gatherer.getCollectDirectoryPath());
     199        File[] possible_collections = collect_directory.listFiles();
    207200        for(int i = 0; possible_collections != null && i < possible_collections.length; i++) {
    208201        File collect_cfg_file = new File(possible_collections[i], Utility.CONFIG_FILE);
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r9039 r9045  
    172172    if(collection != null) {
    173173        // Determine if the collection has been built by looking for the build.cfg file
    174         File build_cfg_file = new File(getCollectionIndex() + Utility.BUILD_CFG_FILENAME);
     174        File build_cfg_file = new File(getCollectionIndexDirectoryPath() + Utility.BUILD_CFG_FILENAME);
    175175        return build_cfg_file.exists();
    176176    }
     
    200200
    201201    // Remove the lock on this file, then remove the collection.
    202     String collection_dir;
    203     if (Gatherer.GS3) {
    204         collection_dir = Utility.getCollectionDir(Configuration.gsdl3_path, Configuration.site_name, collection.getName());
    205     } else {
    206         collection_dir = Utility.getCollectionDir(Configuration.gsdl_path, collection.getName());
    207 
    208     }
    209     File lock_file = new File(collection_dir + LOCK_FILE);
     202    String collection_directory_path = getCollectionDirectoryPath(collection.getName());
     203    File lock_file = new File(collection_directory_path + LOCK_FILE);
    210204    lock_file.delete();
    211205    if(lock_file.exists()) {
     
    328322        // *******************
    329323        //check that this creation has worked - simply by checking for the existence of the collect.cfg file
    330         String collection_dir;
    331         if (Gatherer.GS3) {
    332         collection_dir = Utility.getCollectionDir(Configuration.gsdl3_path, Configuration.site_name, name);
    333         } else {
    334         collection_dir = Utility.getCollectionDir(Configuration.gsdl_path, name);
    335         }
    336         File config_file = new File(Utility.getConfigFile(collection_dir));
     324        String collection_directory_path = getCollectionDirectoryPath(name);
     325        File config_file = new File(Utility.getConfigFile(collection_directory_path));
    337326        if (!config_file.exists()) {
    338327        // no point continuing
     
    343332       
    344333        // ACTIVE_DIR/log/
    345         File log_dir_temp = new File(Utility.getLogDir(collection_dir)+"temp.dat");
     334        File log_dir_temp = new File(Utility.getLogDir(collection_directory_path)+"temp.dat");
    346335        File log_dir = log_dir_temp.getParentFile();
    347336        log_dir.mkdirs();
     
    349338
    350339        // Make sure an import folder exists
    351         File import_directory = new File(Utility.getImportDir(collection_dir));
     340        File import_directory = new File(Utility.getImportDir(collection_directory_path));
    352341        if (!import_directory.exists()) {
    353342        import_directory.mkdirs();
     
    357346
    358347        // Now create the collection object around the directory.
    359         collection = new Collection(new File(collection_dir, name + ".col"));
     348        collection = new Collection(new File(collection_directory_path, name + ".col"));
    360349
    361350        MetadataSetManager.clearMetadataSets();
     
    368357        }
    369358
    370         ProfileXMLFileManager.loadProfileXMLFile(new File(collection_dir, Utility.META_DIR));
     359        ProfileXMLFileManager.loadProfileXMLFile(new File(collection_directory_path, Utility.META_DIR));
    371360
    372361        // Before creating the CollectionDesignManager check if we are basing it upon some other collection
     
    375364        collection.setBaseCollection(base_collection_directory.getAbsolutePath());
    376365        // copy over other needed directories
    377         copyExtraBaseCollStuff(new File(collection_dir), base_collection_directory);
     366        copyExtraBaseCollStuff(new File(collection_directory_path), base_collection_directory);
    378367        // Try to import any existing metadata sets for this collection
    379368        // Look in base_collection_directory/metadata and import any metadata sets found.
     
    407396        // Now we update our collect.cfg
    408397        DebugStream.println("Copy and update collect.cfg from base collection.");
    409         updateCollectionCFG(new File(base_collection_directory, Utility.CONFIG_FILE), new File(collection_dir, Utility.CONFIG_FILE), description, email, title);
     398        updateCollectionCFG(new File(base_collection_directory, Utility.CONFIG_FILE), new File(collection_directory_path, Utility.CONFIG_FILE), description, email, title);
    410399        }
    411400
     
    416405        }
    417406
    418         collection.cdm = new CollectionDesignManager(new File(getCollectionConfig()));
     407        collection.cdm = new CollectionDesignManager(new File(getCollectionConfigFilePath()));
    419408
    420409        // Now that we have a CDM, update several settings, such as if we created this collection by basing it on another, set it as public automatically
     
    455444
    456445        // Create a lock file.
    457         File lock_file = new File(collection_dir, LOCK_FILE);
     446        File lock_file = new File(collection_directory_path, LOCK_FILE);
    458447        FileOutputStream out = new FileOutputStream(lock_file);
    459448        out.write(LOCK_FILE.getBytes());
     
    499488    public boolean deleteCollection(String collection_name)
    500489    {
    501     File collection_directory = null;
    502     if (Gatherer.GS3) {
    503         collection_directory = new File(Utility.getCollectionDir(Configuration.gsdl3_path, Configuration.site_name, collection_name));
    504     }
    505     else {
    506         collection_directory = new File(Utility.getCollectionDir(Configuration.gsdl_path, collection_name));
    507     }
    508 
     490    File collection_directory = new File(getCollectionDirectoryPath(collection_name));
    509491    return Utility.delete(collection_directory);
    510492    }
     
    528510
    529511
    530     /** Constructs the absolute filename of the collection archive directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/archive/"
     512    /** Constructs the absolute filename of the collection's directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;"
     513     * @return A <strong>String</strong> containing the directory name.
     514     */
     515    static public String getCollectionDirectoryPath(String collection_name)
     516    {
     517    return Gatherer.getCollectDirectoryPath() + collection_name + File.separator;
     518    }
     519
     520
     521    /** Constructs the absolute filename of the collection's .col file, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/&lt;col_name&gt;.col"
    531522     * @return A <strong>String</strong> containing the filename.
    532      * @see org.greenstone.gatherer.Configuration
    533      * @see org.greenstone.gatherer.Gatherer
    534      * @see org.greenstone.gatherer.collection.Collection
    535      * @see org.greenstone.gatherer.util.Utility
    536      */
    537     public String getCollectionArchives() {
    538     if (Gatherer.GS3) {
    539         return Utility.getCollectionDir(Configuration.gsdl3_path, Configuration.site_name, collection.getName()) + "archives" + File.separator;
    540     } else {
    541         return Utility.getCollectionDir(Configuration.gsdl_path, collection.getName()) + "archives" + File.separator;
    542     }
    543     }
    544     /** Constructs the absolute filename of the collection building directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/building/"
     523     */
     524    public String getCollectionFilePath()
     525    {
     526    return getCollectionDirectoryPath(collection.getName()) + collection.getName() + ".col";
     527    }
     528
     529
     530    /** Constructs the absolute filename of the collection's archives directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/archives/"
    545531     * @return A <strong>String</strong> containing the filename.
    546      * @see org.greenstone.gatherer.Configuration
    547      * @see org.greenstone.gatherer.Gatherer
    548      * @see org.greenstone.gatherer.collection.Collection
    549      * @see org.greenstone.gatherer.util.Utility
    550      */
    551     public String getCollectionBuild() {
    552     if (Gatherer.GS3) {
    553         return Utility.getCollectionDir(Configuration.gsdl3_path, Configuration.site_name, collection.getName()) + "building" + File.separator;
    554     } else {
    555         return Utility.getCollectionDir(Configuration.gsdl_path, collection.getName()) + "building" + File.separator;
    556     }
    557     }
    558     /** Constructs the absolute filename of the collection config file, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/etc/collect.cfg"
     532     */
     533    public String getCollectionArchivesDirectoryPath()
     534    {
     535    return getCollectionDirectoryPath(collection.getName()) + "archives" + File.separator;
     536    }
     537
     538
     539    /** Constructs the absolute filename of the collection's building directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/building/"
    559540     * @return A <strong>String</strong> containing the filename.
    560      * @see org.greenstone.gatherer.Configuration
    561      * @see org.greenstone.gatherer.Gatherer
    562      * @see org.greenstone.gatherer.collection.Collection
    563      * @see org.greenstone.gatherer.util.Utility
    564      */
    565     public String getCollectionConfig() {
    566     if (Gatherer.GS3) {
    567         return Utility.getConfigFile(Utility.getCollectionDir(Configuration.gsdl3_path, Configuration.site_name, collection.getName()));
    568     } else {
    569         return Utility.getConfigFile(Utility.getCollectionDir(Configuration.gsdl_path, collection.getName()));
    570     }
    571     }
    572 
    573     /** Constructs the absolute filename of the collection directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;"
    574      * @return A <strong>String</strong> containing the directory name.
    575      * @see org.greenstone.gatherer.Configuration
    576      * @see org.greenstone.gatherer.Gatherer
    577      * @see org.greenstone.gatherer.collection.Collection
    578      * @see org.greenstone.gatherer.util.Utility
    579      */
    580     public String getCollectionDirectory() {
    581     if (Gatherer.GS3) {
    582         return Utility.getCollectionDir(Configuration.gsdl3_path, Configuration.site_name, collection.getName());
    583     } else {
    584         return Utility.getCollectionDir(Configuration.gsdl_path,  collection.getName());
    585     }
    586     }
    587 
    588     /** Constructs the absolute filename of the collection etc directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/etc/"
     541     */
     542    public String getCollectionBuildingDirectoryPath()
     543    {
     544    return getCollectionDirectoryPath(collection.getName()) + "building" + File.separator;
     545    }
     546
     547
     548    /** Constructs the absolute filename of the collection's collect.cfg file, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/etc/collect.cfg"
    589549     * @return A <strong>String</strong> containing the filename.
    590      * @see org.greenstone.gatherer.Configuration
    591      * @see org.greenstone.gatherer.Gatherer
    592      * @see org.greenstone.gatherer.collection.Collection
    593      * @see org.greenstone.gatherer.util.Utility
    594      */
    595     public String getCollectionEtc() {
    596     if (Gatherer.GS3) {
    597         return Utility.getCollectionDir(Configuration.gsdl3_path, Configuration.site_name, collection.getName()) + "etc" + File.separator;
    598     } else {
    599         return Utility.getCollectionDir(Configuration.gsdl_path, collection.getName()) + "etc" + File.separator;
    600     }
    601     }
    602     /** Constructs the absolute filename of the collection file, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/&lt;col_name&gt;.col"
     550     */
     551    public String getCollectionConfigFilePath()
     552    {
     553    return getCollectionEtcDirectoryPath() + "collect.cfg";
     554    }
     555
     556
     557    /** Constructs the absolute filename of the collection's etc directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/etc/"
    603558     * @return A <strong>String</strong> containing the filename.
    604      * @see org.greenstone.gatherer.Configuration
    605      * @see org.greenstone.gatherer.Gatherer
    606      * @see org.greenstone.gatherer.collection.Collection
    607      * @see org.greenstone.gatherer.util.Utility
    608      */
    609     public String getCollectionFilename() {
    610     if (Gatherer.GS3) {
    611         return Utility.getCollectionDir(Configuration.gsdl3_path, Configuration.site_name, collection.getName()) + collection.getName() + ".col";
    612     } else {
    613         return Utility.getCollectionDir(Configuration.gsdl_path, collection.getName()) + collection.getName() + ".col";
    614     }
    615     }
    616     /** Constructs the absolute filename of the collection images directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/images/"
     559     */
     560    public String getCollectionEtcDirectoryPath()
     561    {
     562    return getCollectionDirectoryPath(collection.getName()) + "etc" + File.separator;
     563    }
     564
     565
     566    /** Constructs the absolute filename of the collection's images directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/images/"
    617567     * @return A <strong>String</strong> containing the filename.
    618      * @see org.greenstone.gatherer.Configuration
    619      * @see org.greenstone.gatherer.Gatherer
    620      * @see org.greenstone.gatherer.collection.Collection
    621      * @see org.greenstone.gatherer.util.Utility
    622      */
    623     public String getCollectionImages() {
    624     if (Gatherer.GS3) {
    625         return Utility.getImagesDir(Utility.getCollectionDir(Configuration.gsdl3_path, Configuration.site_name, collection.getName()));
    626     } else {
    627         return Utility.getImagesDir(Utility.getCollectionDir(Configuration.gsdl_path, collection.getName()));
    628     }
    629     }
    630     /** Constructs the absolute filename of the collection import directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/import/"
     568     */
     569    public String getCollectionImagesDirectoryPath()
     570    {
     571    return getCollectionDirectoryPath(collection.getName()) + "images" + File.separator;
     572    }
     573
     574
     575    /** Constructs the absolute filename of the collection's import directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/import/"
    631576     * @return A <strong>String</strong> containing the filename.
    632      * @see org.greenstone.gatherer.Configuration
    633      * @see org.greenstone.gatherer.Gatherer
    634      * @see org.greenstone.gatherer.collection.Collection
    635      * @see org.greenstone.gatherer.util.Utility
    636      */
    637     public String getCollectionImport() {
    638     if (Gatherer.GS3) {
    639         return Utility.getImportDir(Utility.getCollectionDir(Configuration.gsdl3_path, Configuration.site_name, collection.getName()));
    640     } else {
    641         return Utility.getImportDir(Utility.getCollectionDir(Configuration.gsdl_path, collection.getName()));
    642     }
    643     }
    644     /** Constructs the absolute filename of the collection index directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/index/"
     577     */
     578    public String getCollectionImportDirectoryPath()
     579    {
     580    return getCollectionDirectoryPath(collection.getName()) + "import" + File.separator;
     581    }
     582
     583
     584    /** Constructs the absolute filename of the collection's index directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/index/"
    645585     * @return A <strong>String</strong> containing the filename.
    646      * @see org.greenstone.gatherer.Configuration
    647      * @see org.greenstone.gatherer.Gatherer
    648      * @see org.greenstone.gatherer.collection.Collection
    649      * @see org.greenstone.gatherer.util.Utility
    650      */
    651     public String getCollectionIndex() {
    652     if (Gatherer.GS3) {
    653         return Utility.getCollectionDir(Configuration.gsdl3_path, Configuration.site_name, collection.getName()) + "index" + File.separator;
    654     } else {
    655         return Utility.getCollectionDir(Configuration.gsdl_path, collection.getName()) + "index" + File.separator;
    656     }
    657     }
    658     /** Constructs the absolute filename of the collection log directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/log/"
     586     */
     587    public String getCollectionIndexDirectoryPath()
     588    {
     589    return getCollectionDirectoryPath(collection.getName()) + "index" + File.separator;
     590    }
     591
     592
     593    /** Constructs the absolute filename of the collection's log directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/log/"
    659594     * @return A <strong>String</strong> containing the filename.
    660      * @see org.greenstone.gatherer.Configuration
    661      * @see org.greenstone.gatherer.Gatherer
    662      * @see org.greenstone.gatherer.collection.Collection
    663      * @see org.greenstone.gatherer.util.Utility
    664      */
    665     public String getCollectionLog() {
    666     if (Gatherer.GS3) {
    667         return Utility.getLogDir(Utility.getCollectionDir(Configuration.gsdl3_path, Configuration.site_name, collection.getName()));
    668     } else {
    669         return Utility.getLogDir(Utility.getCollectionDir(Configuration.gsdl_path, collection.getName()));
    670     }
    671     }
    672     /** Constructs the absolute filename of the collection metadata directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/metadata/"
     595     */
     596    public String getCollectionLogDirectoryPath()
     597    {
     598    return getCollectionDirectoryPath(collection.getName()) + "log" + File.separator;
     599    }
     600
     601
     602    /** Constructs the absolute filename of the collection's metadata directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/metadata/"
    673603     * @return A <strong>String</strong> containing the filename.
    674      * @see org.greenstone.gatherer.Configuration
    675      * @see org.greenstone.gatherer.Gatherer
    676      * @see org.greenstone.gatherer.collection.Collection
    677      * @see org.greenstone.gatherer.util.Utility
    678      */
    679     public String getCollectionMetadata() {
    680     if (Gatherer.GS3) {
    681         return Utility.getCollectionDir(Configuration.gsdl3_path, Configuration.site_name, collection.getName()) + "metadata" + File.separator;
    682     } else {
    683         return Utility.getCollectionDir(Configuration.gsdl_path, collection.getName()) + "metadata" + File.separator;
    684     }
     604     */
     605    public String getCollectionMetadataDirectoryPath()
     606    {
     607    return getCollectionDirectoryPath(collection.getName()) + "metadata" + File.separator;
    685608    }
    686609
     
    691614    if (collection_model == null && collection != null) {
    692615        // Use the import directory to generate a new CollectionTreeModel
    693         collection_model = new CollectionTreeModel(new CollectionTreeNode(new File(getCollectionImport())));
     616        collection_model = new CollectionTreeModel(new CollectionTreeNode(new File(getCollectionImportDirectoryPath())));
    694617        // Ensure that the manager is a change listener for the tree.
    695618        if (fm_tree_model_listener == null) {
     
    722645    DebugStream.println("CollectionManager.importCollection()");
    723646    //check that we can remove the old index before starting import
    724     File index_dir = new File(getCollectionIndex(), "temp.txt");
    725     index_dir = index_dir.getParentFile();
    726     if(index_dir.exists()) {
     647    File index_dir = new File(getCollectionIndexDirectoryPath());
     648    if (index_dir.exists()) {
    727649        DebugStream.println("Old Index = " + index_dir.getAbsolutePath()+", testing for deletability");
    728650        if (!canDelete(index_dir)) {
     
    788710
    789711    // ...and only if it doesn't already exist
    790     File metadata_set_file = new File(getCollectionMetadata(), external_metadata_set_file.getName());
     712    File metadata_set_file = new File(getCollectionMetadataDirectoryPath(), external_metadata_set_file.getName());
    791713    if (!metadata_set_file.exists()) {
    792714        try {
     
    953875
    954876        // Read through the doc.xml files in the archives directory
    955         File collection_archives_directory = new File(getCollectionArchives());
     877        File collection_archives_directory = new File(getCollectionArchivesDirectoryPath());
    956878        DocXMLFileManager.clearDocXMLFiles();
    957879        DocXMLFileManager.loadDocXMLFiles(collection_archives_directory);
     
    987909
    988910
    989     public void makeCollection(String description, String email, String name, String title) {
     911    private void makeCollection(String description, String email, String name, String title) {
    990912    // Encode the description so it is safe to write to shell
    991913    if(Utility.isWindows()) {
     
    12391161
    12401162    // Create a backup of the collection file, just in case anything goes wrong
    1241     File collection_file = new File(Gatherer.c_man.getCollectionFilename());
     1163    File collection_file = new File(getCollectionFilePath());
    12421164    if (collection_file.exists()) {
    12431165        File collection_file_backup = new File(collection_file.getAbsolutePath() + "~");
     
    12551177
    12561178    // Write hfiles for the loaded metadata elements into the collection "etc" directory
    1257     MetadataSetManager.writeHierarchyFiles(new File(Gatherer.c_man.getCollectionEtc()));
     1179    MetadataSetManager.writeHierarchyFiles(new File(getCollectionEtcDirectoryPath()));
    12581180
    12591181    // Change cursor back to normal
     
    12941216    // used as arg in the perl scripts
    12951217    private String getCollectDirectory() {
    1296     String collect_dir;
    1297     if (Gatherer.GS3) {
    1298         collect_dir = Utility.getCollectDir(Configuration.gsdl3_path, Configuration.site_name);
    1299     } else {
    1300         collect_dir = Utility.getCollectDir(Configuration.gsdl_path);
    1301     }
     1218    String collect_dir = Gatherer.getCollectDirectoryPath();
    13021219
    13031220    // Remove erroneous file windows file separator as it causes problems when running import.pl
     
    13241241        }
    13251242
    1326         File index_dir = new File(getCollectionIndex());
     1243        File index_dir = new File(getCollectionIndexDirectoryPath());
    13271244        DebugStream.println("Index = " + index_dir.getAbsolutePath());
    13281245
    1329         File building_dir = new File(getCollectionBuild());
     1246        File building_dir = new File(getCollectionBuildingDirectoryPath());
    13301247        DebugStream.println("Building = " + building_dir.getAbsolutePath());
    13311248
  • trunk/gli/src/org/greenstone/gatherer/file/WorkspaceTree.java

    r8846 r9045  
    7979    if (refresh_reason == DragTree.COLLECTION_CONTENTS_CHANGED) {
    8080        DebugStream.println("...Reason: collection contents changed.");
    81         String import_directory_str = Gatherer.c_man.getCollectionImport();
     81        String import_directory_str = Gatherer.c_man.getCollectionImportDirectoryPath();
    8282        refreshEveryNodeShowingFolder(import_directory_str);
    8383    }
  • trunk/gli/src/org/greenstone/gatherer/file/WorkspaceTreeNode.java

    r8787 r9045  
    128128        File start;
    129129        if (is_gs3_site_node) {
    130             start = new File(Utility.getCollectDir(Configuration.gsdl3_path, title));
     130            start = new File(Gatherer.getSitesDirectoryPath() + title + File.separator + "collect" + File.separator);
    131131        } else {
    132             start = new File(Utility.getCollectDir(Configuration.gsdl_path));
     132            start = new File(Gatherer.getCollectDirectoryPath());
    133133        }
    134134        File cols[] = start.listFiles();
  • trunk/gli/src/org/greenstone/gatherer/gui/DeleteCollectionPrompt.java

    r9018 r9045  
    215215    private void scanForCollections() {
    216216    // Start at the collect dir.
    217     File collect_directory;
    218     if (Gatherer.GS3) {
    219         collect_directory = new File(Utility.getCollectDir(Configuration.gsdl3_path, Configuration.site_name));
    220     } else {
    221         collect_directory = new File(Utility.getCollectDir(Configuration.gsdl_path));
    222     }
    223     if(collect_directory.exists()) {
     217    File collect_directory = new File(Gatherer.getCollectDirectoryPath());
     218    if (collect_directory.exists()) {
    224219        // Now for each child directory see if it contains a .col file and
    225220        // if so try to load it..
  • trunk/gli/src/org/greenstone/gatherer/gui/ExportCollectionPrompt.java

    r9018 r9045  
    335335    private void scanForCollections() {
    336336    // Start at the collect dir.
    337     File collect_directory;
    338     if (Gatherer.GS3) {
    339         collect_directory = new File(Utility.getCollectDir(Configuration.gsdl3_path, Configuration.site_name));
    340     } else {
    341         collect_directory = new File(Utility.getCollectDir(Configuration.gsdl_path));
    342     }
    343     if(collect_directory.exists()) {
     337    File collect_directory = new File(Gatherer.getCollectDirectoryPath());
     338    if (collect_directory.exists()) {
    344339        // Now for each child directory see if it contains a .col file and
    345340        // if so try to load it..
  • trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r9035 r9045  
    621621    }
    622622    else if(user_choice == SimpleOpenCollectionDialog.BROWSE_OPTION) {
    623         File file;
     623        File collect_directory;
    624624        if (Gatherer.GS3) {
    625         if (Configuration.gsdl3_path != null) {
    626             file = new File(Utility.getSitesDir(Configuration.gsdl3_path));
    627         } else {
    628             file = new File(Utility.BASE_DIR);
    629         }
    630 
    631         } else {
    632 
    633         if(Configuration.gsdl_path != null) {
    634             file = new File(Utility.getCollectDir(Configuration.gsdl_path));
    635         }
    636         else {
    637             file = new File(Utility.BASE_DIR);
    638         }
    639         }
    640         OpenCollectionDialog chooser = new OpenCollectionDialog(file);
    641         file = null;
     625        collect_directory = new File(Utility.getSitesDir(Configuration.gsdl3_path));
     626        }
     627        else {
     628        collect_directory = new File(Gatherer.getCollectDirectoryPath());
     629        }
     630        OpenCollectionDialog chooser = new OpenCollectionDialog(collect_directory);
    642631        filename = chooser.getFileName();
    643632        chooser.destroy();
  • trunk/gli/src/org/greenstone/gatherer/gui/NewCollectionDetailsPrompt.java

    r8803 r9045  
    4949        return false;
    5050    }
    51     File collection_directory;
    52     if (Gatherer.GS3) {
    53         collection_directory = new File(Utility.getCollectDir(Configuration.gsdl3_path, Configuration.site_name));
    54     } else {
    55         collection_directory = new File(Utility.getCollectDir(Configuration.gsdl_path));
    56     }
    57     File children[] = collection_directory.listFiles();
     51    File collect_directory = new File(Gatherer.getCollectDirectoryPath());
     52    File children[] = collect_directory.listFiles();
    5853    for(int i = 0; children != null && i < children.length; i++) {
    5954        if(children[i].isDirectory()) {
     
    10297    // need to modify this to base a coll on any collection from any site
    10398    if (Gatherer.GS3) {
    104         File sites_dir = new File(Utility.getSitesDir(Configuration.gsdl3_path));
     99        File sites_dir = new File(Gatherer.getSitesDirectoryPath());
    105100        File [] sites = sites_dir.listFiles();
    106101        for (int i=0; i<sites.length; i++) {
    107         File collect_dir = new File(Utility.getCollectDir(Configuration.gsdl3_path, sites[i].getName()));
    108         if (collect_dir.exists()) {
    109             addCollectionsToModel(base_collection_model, collect_dir, sites[i].getName());
     102        File collect_directory = new File(sites_dir + sites[i].getName() + File.separator + "collect");
     103        if (collect_directory.exists()) {
     104            addCollectionsToModel(base_collection_model, collect_directory, sites[i].getName());
    110105        }
    111106        }
    112107    } else {
    113        File gsdl_collection_directory = new File(Utility.getCollectDir(Configuration.gsdl_path));
    114        addCollectionsToModel(base_collection_model, gsdl_collection_directory, null);
     108       File collect_directory = new File(Gatherer.getCollectDirectoryPath());
     109       addCollectionsToModel(base_collection_model, collect_directory, null);
    115110    }
    116111
     
    266261    }
    267262   
    268     private boolean filenameClashes(String filename) {
    269     File collection_directory;
    270     if (Gatherer.GS3) {
    271         collection_directory = new File(Utility.getCollectDir(Configuration.gsdl3_path, Configuration.site_name));
    272     } else {
    273         collection_directory = new File(Utility.getCollectDir(Configuration.gsdl_path));
    274     }
    275 
    276     File children[] = collection_directory.listFiles();
     263    private boolean filenameClashes(String filename)
     264    {
     265    File collect_directory = new File(Gatherer.getCollectDirectoryPath());
     266    File children[] = collect_directory.listFiles();
    277267    for(int i = 0; children != null && i < children.length; i++) {
    278268        if(children[i].getName().equals(filename)) {
  • trunk/gli/src/org/greenstone/gatherer/gui/OptionsPane.java

    r8313 r9045  
    236236        // Build a list of the log files available, ordering by last modified. Log files are like build_log.date.txt
    237237        DefaultListModel contents = new DefaultListModel();
    238         File log_directory = new File(Gatherer.c_man.getCollectionLog());
     238        File log_directory = new File(Gatherer.c_man.getCollectionLogDirectoryPath());
    239239        File children[] = log_directory.listFiles();
    240240        for(int i = 0; children != null && i < children.length; i++) {
     
    289289    name.append(".txt");
    290290    // just in case there is no log directory
    291     File file = new File(Gatherer.c_man.getCollectionLog() + name.toString());
     291    File file = new File(Gatherer.c_man.getCollectionLogDirectoryPath() + name.toString());
    292292    File parent_file = file.getParentFile();
    293293    parent_file.mkdirs();
  • trunk/gli/src/org/greenstone/gatherer/gui/SimpleOpenCollectionDialog.java

    r8243 r9045  
    264264    public CollectionListModel() {
    265265        data = new TreeSet();
    266         File collect_folder;
    267         if (Gatherer.GS3) {
    268         collect_folder = new File(Utility.getCollectDir(Configuration.gsdl3_path, Configuration.site_name) );
    269         } else {
    270         collect_folder = new File(Utility.getCollectDir(Configuration.gsdl_path));
    271         }
    272         if (!collect_folder.exists()) {
    273         collect_folder = null;
     266        File collect_directory = new File(Gatherer.getCollectDirectoryPath());
     267        if (!collect_directory.exists()) {
     268        collect_directory = null;
    274269        return;
    275270        }
    276         File[] collection_folders = collect_folder.listFiles();
     271        File[] collection_folders = collect_directory.listFiles();
    277272        for(int i = 0; i < collection_folders.length; i++) {
    278273        File collection_folder = collection_folders[i];
     
    290285        }
    291286        collection_folders = null;
    292         collect_folder = null;
     287        collect_directory = null;
    293288    }
    294289
  • trunk/gli/src/org/greenstone/gatherer/shell/GShell.java

    r9021 r9045  
    464464        }
    465465
     466        String collect_directory_path = Gatherer.getCollectDirectoryPath();
     467
    466468        // zip up import folder
    467         Utility.zipup(col_name,"import");
     469        Utility.zipup(collect_directory_path, col_name, "import");
    468470        // upload it to gsdl server
    469         GathererApplet.upload_url_zip(col_name,"import");
     471        GathererApplet.upload_url_zip(col_name, "import");
    470472
    471473        // upload etc folder to server (need collect.cfg and any hfiles)
    472         Utility.zipup(col_name, "etc");
    473         GathererApplet.upload_url_zip(col_name,"etc");
    474 
    475         String col_dir = Utility.getCollectionDir(Configuration.gsdl_path, col_name);
    476         File img_dir = new File(Utility.getImagesDir(col_dir));
     474        Utility.zipup(collect_directory_path, col_name, "etc");
     475        GathererApplet.upload_url_zip(col_name, "etc");
     476
     477        String collection_directory_path = Gatherer.c_man.getCollectionDirectoryPath(col_name);
     478        File img_dir = new File(Gatherer.c_man.getCollectionImagesDirectoryPath());
    477479        if (img_dir.exists() && img_dir.list().length > 0) {
    478480            // upload images/ directory to server
    479             Utility.zipup(col_name,"images");
    480             GathererApplet.upload_url_zip(col_name,"images");
     481            Utility.zipup(collect_directory_path, col_name, "images");
     482            GathererApplet.upload_url_zip(col_name, "images");
    481483        }
    482484
     
    520522        if (Gatherer.isGsdlRemote) {
    521523            GathererApplet.download_url_zip(col_name,".");
    522             Utility.unzip(col_name);
     524            Utility.unzip(Gatherer.getCollectDirectoryPath(), col_name);
    523525        }
    524526        }
     
    533535
    534536
    535             Utility.delete(Gatherer.c_man.getCollectionArchives()); // remove current archives
     537            Utility.delete(Gatherer.c_man.getCollectionArchivesDirectoryPath()); // remove current archives
    536538            GathererApplet.download_url_zip(col_name,"archives");
    537             Utility.unzip(col_name);
     539            Utility.unzip(Gatherer.getCollectDirectoryPath(), col_name);
    538540
    539541            if (progress!=null) {
     
    545547        fireMessage(type, typeAsString(type) + "> " + Dictionary.get("GShell.Parsing_Metadata_Start"), status, null);
    546548        DocXMLFileManager.clearDocXMLFiles();
    547         DocXMLFileManager.loadDocXMLFiles(new File(Gatherer.c_man.getCollectionArchives()));
     549        DocXMLFileManager.loadDocXMLFiles(new File(Gatherer.c_man.getCollectionArchivesDirectoryPath()));
    548550        fireMessage(type, typeAsString(type) + "> " + Dictionary.get("GShell.Parsing_Metadata_Complete"), status, null);
    549551        }
     
    556558            }
    557559
    558             Utility.delete(Gatherer.c_man.getCollectionBuild()); // remove current build dir
     560            Utility.delete(Gatherer.c_man.getCollectionBuildingDirectoryPath()); // remove current build dir
    559561            GathererApplet.download_url_zip(col_name,"building");
    560             Utility.unzip(col_name);
     562            Utility.unzip(Gatherer.getCollectDirectoryPath(), col_name);
    561563
    562564            if (progress!=null) {
  • trunk/gli/src/org/greenstone/gatherer/util/Utility.java

    r9036 r9045  
    345345    return new File(getGLIUserFolder(), StaticStrings.CACHE_FOLDER);
    346346    }
    347     /** Method which constructs the collect directory for Greenstone.
    348      * @param gsdl_path The location of the gsdl installation directory as a <strong>String</strong>.
    349      * @return The location of the collection directory, also as a <strong>String</strong>.
    350      */
    351     public static String getCollectDir(String gsdl_path) {
    352     return gsdl_path + COL_DIR;
    353     }
    354     static public String getCollectDir(String gsdl3_path, String site_name) {
    355     return getSitesDir(gsdl3_path) + site_name + File.separator + COL_DIR;
    356     }
    357 
    358    
    359     /** Method which constructs a collection's top level directory
    360      * @@param gsdl_path The location of the gsdl installation directory as a <strong>String</strong>.
    361      * @param The name of the collection as a <strong>String</strong>.
    362      * @return The location of the collection's base directory
    363      */
    364     public static String getCollectionDir(String gsdl_path, String coll_name) {
    365     return getCollectDir(gsdl_path) + coll_name + File.separator;
    366     }
    367     public static String getCollectionDir(String gsdl3_path, String site_name, String coll_name) {
    368     return getCollectDir(gsdl3_path, site_name) + coll_name + File.separator;
    369     }
    370347
    371348   
     
    485462    }
    486463
    487     /** Method which constructs the images directory given a certain collection.
    488      * @param col_dir The location of the collection directory as a <strong>String</strong>.
    489      * @return The location of the given collections images directory, also as a <strong>String</strong>.
    490      */
    491     public static String getImagesDir(String col_dir) {
    492     return col_dir + IMAGES_DIR;
    493     }
     464
    494465    /** Method which constructs the import directory given a certain collection.
    495466     * @param col_dir The location of the collection directory as a <strong>String</strong>.
     
    709680
    710681
    711     static public void zipup(String col_name, String dir_or_file)
    712     {
    713     String col_dir = Utility.getCollectDir(Configuration.gsdl_path);
     682    static public void zipup(String col_dir, String col_name, String dir_or_file)
     683    {
    714684    int prefix_strip = col_dir.length();
    715685
     
    762732   
    763733
    764     static public void unzip(String col_name)
    765     {
    766     String col_dir = Utility.getCollectDir(Configuration.gsdl_path);
     734    static public void unzip(String col_dir, String col_name)
     735    {
    767736    String zip_fname = col_dir + col_name + ".zip";
    768737    int zip_mode = ZipFile.OPEN_READ | ZipFile.OPEN_DELETE;
Note: See TracChangeset for help on using the changeset viewer.