Changeset 10342


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.

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

Legend:

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

    r10330 r10342  
    155155
    156156    // If the existing user config.xml file isn't recent enough, backup the old version and update it
    157     File config_xml_file = new File(Utility.getGLIUserFolder(), config_xml_file_name);
     157    File config_xml_file = new File(Gatherer.getGLIUserDirectoryPath() + config_xml_file_name);
    158158    if (config_xml_file != null && config_xml_file.exists()) {
    159159        just_updated_config_xml_file = updateUserConfigXMLFileIfNecessary(config_xml_file);
     
    732732    }
    733733    try {
    734         user_config_xml = new File(Utility.getGLIUserFolder(), config_xml_name);
     734        user_config_xml = new File(Gatherer.getGLIUserDirectoryPath() + config_xml_name);
    735735        ///ystem.err.println("Trying to save to: " + user_config_xml.getAbsolutePath());
    736736        ///ystem.err.println("Writing.");
     
    740740    catch(Exception exception) {
    741741        user_config_xml = null;
    742     }
    743     // Always do this if the above fails.
    744     if(user_config_xml == null || !user_config_xml.exists()) {
    745         // But failing that we produce a general copy
    746         XMLTools.writeXMLFile(new File(Utility.BASE_DIR + config_xml_name), general_config);
    747742    }
    748743    }
  • trunk/gli/src/org/greenstone/gatherer/Gatherer.java

    r10330 r10342  
    6969    static public boolean exit = false;
    7070
     71    static private String gli_directory_path = null;
     72    static private String gli_user_directory_path = null;
     73
    7174    /** All of the external applications that must exit before we close the Gatherer. */
    7275    public Vector apps = new Vector();
     
    131134    // Set the Greenstone path and collect directory specially when running with a remote Greenstone
    132135    if (isGsdlRemote) {
    133         go.gsdl_path = Utility.getGLIUserFolder() + File.separator;
    134         Gatherer.setCollectDirectoryPath(go.gsdl_path + "collect" + File.separator);
     136        go.gsdl_path = getGLIUserDirectoryPath();
     137        setCollectDirectoryPath(go.gsdl_path + "collect" + File.separator);
     138    }
     139    else {
     140        setGLIDirectoryPath(go.gsdl_path + "gli");
    135141    }
    136142
    137143    // Users may specify a non-standard collect directory (eg. when running one GLI in a network environment)
    138144    if (go.collect_directory_path != null) {
    139         Gatherer.setCollectDirectoryPath(go.collect_directory_path);
     145        setCollectDirectoryPath(go.collect_directory_path);
    140146    }
    141147
    142148    // Special code for running with a remote Greenstone
    143149    if (isGsdlRemote) {
    144         File gli_user_directory = Utility.getGLIUserFolder();
    145 
    146         Utility.BASE_DIR = go.gsdl_path;
    147         Utility.METADATA_DIR = Utility.BASE_DIR + "metadata" + File.separator;
    148         Utility.TMP_DIR = Utility.BASE_DIR + "tmp" + File.separator;
    149 
    150150        Configuration.TEMPLATE_CONFIG_XML = "xml/configRemote.xml";
    151151        Configuration.CONFIG_XML = "configRemote.xml";
     
    160160            //   for documented example collections so "base this on
    161161            //   existing collection" works
    162             ZipTools.unzipFromJar(Utility.COLLECT_ZIP, gli_user_directory.toString());
     162            ZipTools.unzipFromJar(Utility.COLLECT_ZIP, getGLIUserDirectoryPath());
    163163        }
    164164        else {
     
    170170        }
    171171
    172         File tmp_dir = new File(Utility.TMP_DIR);
    173         if (!tmp_dir.exists()) {
    174         if (!tmp_dir.mkdir()) {
    175             System.err.println("Warning: Unable to make directory: " + tmp_dir.toString());
    176         }
    177 
    178         String username = System.getProperty("user.name");
    179         if ((username != null) && (username != "")) {
    180             File user_tmp_dir = new File(Utility.TMP_DIR + File.separator + username);
    181             if (!user_tmp_dir.exists()) {
    182             if (!user_tmp_dir.mkdir()) {
    183                 System.err.println("Warning: Unable to make directory: " + user_tmp_dir.toString());
    184             }
    185             }
    186         }
    187         }
    188 
    189         File metadata_directory = new File(Utility.METADATA_DIR);
     172        File metadata_directory = new File(Gatherer.getGLIMetadataDirectoryPath());
    190173        if (!metadata_directory.exists()) {
    191174        // dig out metadata.zip from JAR file and unzip it
    192         ZipTools.unzipFromJar(Utility.METADATA_ZIP, gli_user_directory.toString());
    193         }
    194 
    195         File plug_dat = new File(Utility.BASE_DIR + "plugins.dat");
     175        ZipTools.unzipFromJar(Utility.METADATA_ZIP, getGLIUserDirectoryPath());
     176        }
     177
     178        File plug_dat = new File(getGLIUserDirectoryPath() + "plugins.dat");
    196179        if (!plug_dat.exists()) {
    197         JarTools.extractFromJar("plugins.dat", Utility.BASE_DIR, false);
    198         }
    199 
    200         File class_dat = new File(Utility.BASE_DIR + "classifiers.dat");
     180        JarTools.extractFromJar("plugins.dat", getGLIUserDirectoryPath(), false);
     181        }
     182
     183        File class_dat = new File(getGLIUserDirectoryPath() + "classifiers.dat");
    201184        if (!class_dat.exists()) {
    202         JarTools.extractFromJar("classifiers.dat", Utility.BASE_DIR, false);
     185        JarTools.extractFromJar("classifiers.dat", getGLIUserDirectoryPath(), false);
    203186        }
    204187    }
     
    229212
    230213        // Debug file is created in the user's GLI directory
    231         debug_file_path = Utility.getGLIUserFolder().toString() + File.separator + debug_file_path;
     214        debug_file_path = getGLIUserDirectoryPath() + debug_file_path;
    232215        DebugStream.println("Debug file path: " + debug_file_path);
    233216        DebugStream.setDebugFile(debug_file_path);
     
    541524
    542525
     526    /** Returns the path of the Greenstone "collect" directory. */
    543527    static public String getCollectDirectoryPath()
    544528    {
     
    553537        return getSitesDirectoryPath() + Configuration.site_name + File.separator + "collect" + File.separator;
    554538    }
     539    }
     540
     541
     542    /** Returns the path of the GLI directory. */
     543    static public String getGLIDirectoryPath()
     544    {
     545    return gli_directory_path;
     546    }
     547
     548
     549    /** Returns the path of the GLI "metadata" directory. */
     550    static public String getGLIMetadataDirectoryPath()
     551    {
     552    return getGLIDirectoryPath() + "metadata" + File.separator;
     553    }
     554
     555
     556    /** Returns the path of the GLI user directory. */
     557    static public String getGLIUserDirectoryPath()
     558    {
     559    return gli_user_directory_path;
     560    }
     561
     562
     563    /** Returns the path of the GLI user "cache" directory. */
     564    static public String getGLIUserCacheDirectoryPath()
     565    {
     566    return getGLIUserDirectoryPath() + "cache" + File.separator;
     567    }
     568
     569
     570    /** Returns the path of the GLI user "log" directory. */
     571    static public String getGLIUserLogDirectoryPath()
     572    {
     573    return getGLIUserDirectoryPath() + "log" + File.separator;
    555574    }
    556575
     
    568587        non_standard_collect_directory_path = non_standard_collect_directory_path + File.separator;
    569588    }
     589    }
     590
     591
     592    static public void setGLIDirectoryPath(String gli_directory_path_arg)
     593    {
     594    gli_directory_path = gli_directory_path_arg;
     595    }
     596
     597
     598    static public void setGLIUserDirectoryPath(String gli_user_directory_path_arg)
     599    {
     600    gli_user_directory_path = gli_user_directory_path_arg;
    570601    }
    571602
  • trunk/gli/src/org/greenstone/gatherer/GathererApplet.java

    r10242 r10342  
    8989    }
    9090
     91    // Determine the GLI user directory path
     92    String gli_user_directory_path = System.getProperty("user.home") + File.separator;
     93        if (Utility.isWindows()) {
     94        String windows_home_parameter = getParameter("windowsHome");
     95        if (windows_home_parameter != null && !windows_home_parameter.equals("")) {
     96        gli_user_directory_path = windows_home_parameter + File.separator + "GLI" + File.separator;
     97        }
     98        else {
     99        gli_user_directory_path += "Application Data" + File.separator + "Greenstone" + File.separator + "GLI" + File.separator;
     100        }
     101    }
     102        else {
     103            gli_user_directory_path += ".gli" + File.separator;
     104        }
     105    Gatherer.setGLIUserDirectoryPath(gli_user_directory_path);
     106    Gatherer.setGLIDirectoryPath(gli_user_directory_path);
     107
    91108    // Ensure the GLI user directory exists
    92         File gli_user_directory = Utility.setGLIUserFolder(getParameter("windowsHome"));
     109        File gli_user_directory = new File(gli_user_directory_path);
    93110    if (!gli_user_directory.exists() && !gli_user_directory.mkdirs()) {
    94111        System.err.println("Error: Unable to make directory: " + gli_user_directory.toString());
  • trunk/gli/src/org/greenstone/gatherer/GathererProg.java

    r10242 r10342  
    6161    }
    6262
     63    // Determine the GLI user directory path
     64    String gli_user_directory_path = System.getProperty("user.home") + File.separator;
     65        if (Utility.isWindows()) {
     66        gli_user_directory_path += "Application Data" + File.separator + "Greenstone" + File.separator + "GLI" + File.separator;
     67        }
     68        else {
     69            gli_user_directory_path += ".gli" + File.separator;
     70        }
     71    Gatherer.setGLIUserDirectoryPath(gli_user_directory_path);
     72
    6373    // Ensure the GLI user directory exists
    64         File gli_user_directory = Utility.setGLIUserFolder(null);  // Defaults to user's home area
     74        File gli_user_directory = new File(gli_user_directory_path);
    6575    if (!gli_user_directory.exists() && !gli_user_directory.mkdirs()) {
    6676        System.err.println("Error: Unable to make directory: " + gli_user_directory.toString());
  • trunk/gli/src/org/greenstone/gatherer/cdm/ClassifierManager.java

    r10341 r10342  
    103103
    104104    DebugStream.println("deleting classifiers.dat");
    105     File class_file = new File(Utility.getGLIUserFolder(), "classifiers.dat");
     105    File class_file = new File(Gatherer.getGLIUserDirectoryPath() + "classifiers.dat");
    106106    if (class_file.exists()) {
    107107        return Utility.delete(class_file);
     
    261261    private void saveClassifiers() {
    262262    try {
    263         File classifiers_dat_file = new File(Utility.getGLIUserFolder(), "classifiers.dat");
     263        File classifiers_dat_file = new File(Gatherer.getGLIUserDirectoryPath() + "classifiers.dat");
    264264        FileOutputStream file = new FileOutputStream(classifiers_dat_file);
    265265        ObjectOutputStream out = new ObjectOutputStream(file);
     
    369369    private void loadClassifiers() {
    370370    // Attempt to restore the cached file.
    371     File classifiers_dat_file = new File(Utility.getGLIUserFolder(), "classifiers.dat");
     371    File classifiers_dat_file = new File(Gatherer.getGLIUserDirectoryPath() + "classifiers.dat");
    372372    try {
    373373        FileInputStream file = new FileInputStream(classifiers_dat_file);
  • trunk/gli/src/org/greenstone/gatherer/cdm/MetadataSetView.java

    r9172 r10342  
    289289        public void actionPerformed(ActionEvent event)
    290290        {
    291         JFileChooser chooser = new JFileChooser(new File(Utility.METADATA_DIR));
     291        JFileChooser chooser = new JFileChooser(new File(Gatherer.getGLIMetadataDirectoryPath()));
    292292        chooser.setFileFilter(new MetadataSet.MetadataSetFileFilter());
    293293        int return_val = chooser.showDialog(Gatherer.g_man, Dictionary.get("CDM.MetadataSetManager.Add"));
  • trunk/gli/src/org/greenstone/gatherer/cdm/PluginManager.java

    r10237 r10342  
    107107
    108108    DebugStream.println("deleting plugins.dat");
    109     File plugin_file = new File(Utility.getGLIUserFolder(), "plugins.dat");
     109    File plugin_file = new File(Gatherer.getGLIUserDirectoryPath() + "plugins.dat");
    110110    if (plugin_file.exists()) {
    111111        return Utility.delete(plugin_file);
     
    359359    private void savePlugins() {
    360360    try {
    361         File plugins_dat_file = new File(Utility.getGLIUserFolder(), "plugins.dat");
     361        File plugins_dat_file = new File(Gatherer.getGLIUserDirectoryPath() + "plugins.dat");
    362362        FileOutputStream file = new FileOutputStream(plugins_dat_file);
    363363        ObjectOutputStream out = new ObjectOutputStream(file);
     
    499499    private void loadPlugins() {
    500500    // Attempt to restore the cached file.
    501     File plugins_dat_file = new File(Utility.getGLIUserFolder(), "plugins.dat");
     501    File plugins_dat_file = new File(Gatherer.getGLIUserDirectoryPath() + "plugins.dat");
    502502    try {
    503503        FileInputStream file = new FileInputStream(plugins_dat_file);
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r10263 r10342  
    317317        //check that this creation has worked - simply by checking for the existence of the collect.cfg file
    318318        String collection_directory_path = getCollectionDirectoryPath(name);
    319         File config_file = new File(Utility.getConfigFile(collection_directory_path));
    320         if (!config_file.exists()) {
     319        File collect_cfg_file = new File(collection_directory_path + "collect.cfg");
     320        if (!collect_cfg_file.exists()) {
    321321        // no point continuing
    322322        System.err.println("Error: no collect.cfg file has been created!");
     
    327327       
    328328        // ACTIVE_DIR/log/
    329         File log_dir_temp = new File(Utility.getLogDir(collection_directory_path)+"temp.dat");
    330         File log_dir = log_dir_temp.getParentFile();
     329        File log_dir = new File(collection_directory_path + "log");
    331330        log_dir.mkdirs();
    332331        progress.setNote(Dictionary.get("CollectionManager.Log_Created"));
    333332
    334333        // Make sure an import folder exists
    335         File import_directory = new File(Utility.getImportDir(collection_directory_path));
     334        File import_directory = new File(collection_directory_path + "import");
    336335        if (!import_directory.exists()) {
    337336        import_directory.mkdirs();
     
    396395        // Always import the extracted metadata set if we didn't already
    397396        if (MetadataSetManager.getMetadataSet(MetadataSetManager.EXTRACTED_METADATA_NAMESPACE) == null) {
    398         File extracted_metadata_set_file = new File(Utility.METADATA_DIR + Utility.EXTRACTED_METADATA_NAMESPACE + StaticStrings.METADATA_SET_EXTENSION);
     397        File extracted_metadata_set_file = new File(Gatherer.getGLIMetadataDirectoryPath() + Utility.EXTRACTED_METADATA_NAMESPACE + StaticStrings.METADATA_SET_EXTENSION);
    399398        importMetadataSet(new MetadataSet(extracted_metadata_set_file));
    400399        }
     
    11471146
    11481147    // Always import the extracted metadata set
    1149     File extracted_metadata_set_file = new File(Utility.METADATA_DIR + Utility.EXTRACTED_METADATA_NAMESPACE + StaticStrings.METADATA_SET_EXTENSION);
     1148    File extracted_metadata_set_file = new File(Gatherer.getGLIMetadataDirectoryPath() + Utility.EXTRACTED_METADATA_NAMESPACE + StaticStrings.METADATA_SET_EXTENSION);
    11501149    importMetadataSet(new MetadataSet(extracted_metadata_set_file));
    11511150
  • trunk/gli/src/org/greenstone/gatherer/collection/DownloadJob.java

    r8811 r10342  
    101101    // this.model = model;
    102102
    103     String log_filename = Utility.getLogDir(null) + "wget" + initial.hashCode() + ".log";
     103    String log_filename = Gatherer.getGLIUserLogDirectoryPath() + "wget" + initial.hashCode() + ".log";
    104104    File log_file = new File(log_filename);
    105105    if(log_file.exists()) {
     
    413413
    414414    // Parse arguments into array.
    415     args.add(Utility.BASE_DIR + "wget");
     415    args.add(Configuration.getWGetPath());
    416416    args.add("-d");
    417417    args.add("-o");
  • trunk/gli/src/org/greenstone/gatherer/file/FileManager.java

    r10325 r10342  
    111111
    112112        // ...except for files from the "Downloaded Files" folder
    113         String downloaded_files_folder_path = Utility.getCacheDir().getAbsolutePath();
     113        String downloaded_files_folder_path = Gatherer.getGLIUserCacheDirectoryPath();
    114114        for (int i = 0; i < source_nodes.length; i++) {
    115115        // Is this the "Downloaded Files" folder?
  • trunk/gli/src/org/greenstone/gatherer/file/FileSystem.java

    r9755 r10342  
    44import org.greenstone.gatherer.DebugStream;
    55import org.greenstone.gatherer.Dictionary;
     6import org.greenstone.gatherer.Gatherer;
    67import org.greenstone.gatherer.util.Utility;
    78
     
    5960    {
    6061    // Return a mapping to the downloaded files folder
    61     return new WorkspaceTreeNode(Utility.getCacheDir(), Dictionary.get("Tree.DownloadedFiles"));
     62    return new WorkspaceTreeNode(new File(Gatherer.getGLIUserCacheDirectoryPath()), Dictionary.get("Tree.DownloadedFiles"));
    6263    }
    6364}
  • trunk/gli/src/org/greenstone/gatherer/file/RecycleBin.java

    r10011 r10342  
    8181    setOpaque(true);
    8282
    83     this.model = new FileSystemModel(new RecycleBinNode(new File(Utility.getGLIUserFolder(), "recycle")));
     83    this.model = new FileSystemModel(new RecycleBinNode(new File(Gatherer.getGLIUserDirectoryPath() + "recycle")));
    8484    }
    8585
  • trunk/gli/src/org/greenstone/gatherer/file/WorkspaceTreeNode.java

    r9458 r10342  
    112112        ArrayTools.sort(sites);
    113113        for (int i = 0; sites != null && i < sites.length; i++) {
    114             File collect_dir = new File(sites[i], Utility.COL_DIR);
     114            File collect_dir = new File(sites[i], "collect");
    115115            if (!collect_dir.exists()) {
    116116            continue;
  • trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java

    r10330 r10342  
    197197    // Load all the core metadata sets (in the GLI "metadata" directory)
    198198    model = new GEMSModel();
    199     File metadata_directory = new File(Utility.METADATA_DIR);
     199    File metadata_directory = new File(getGLIMetadataDirectoryPath());
    200200    if (metadata_directory.exists()) {
    201201        // Load just those .mds files in this directory, and return them
     
    385385
    386386
     387    static public String getGLIDirectoryPath()
     388    {
     389    return System.getProperty("user.dir") + File.separator;
     390    }
     391
     392
     393    static public String getGLIMetadataDirectoryPath()
     394    {
     395    return getGLIDirectoryPath() + "metadata" + File.separator;
     396    }
     397
    387398   
    388399    private class GEMSMenuBar
     
    514525                //we first launch the dialog to determine where the jfilechooser should be opened
    515526                //ie: for collection specific sets - attila dec10-04
    516                 String set_directory = Utility.METADATA_DIR;
     527                String set_directory = getGLIMetadataDirectoryPath();
    517528               
    518529                SetSelectionDialog m = new SetSelectionDialog();
     
    15591570                //setup to write to filename from existing file
    15601571                try {
    1561                 out = new FileOutputStream(Utility.METADATA_DIR + File.separator+ namespace_str + ".mds");
     1572                out = new FileOutputStream(getGLIMetadataDirectoryPath() + namespace_str + ".mds");
    15621573                OutputStreamWriter pout = new OutputStreamWriter(out, "UTF8");
    15631574                p = new PrintWriter(pout);
     
    15761587                p.close();
    15771588               
    1578                 MetadataSet loadedset = msm.loadMetadataSet(new File(Utility.METADATA_DIR + File.separator + namespace_str + ".mds"));
     1589                MetadataSet loadedset = msm.loadMetadataSet(new File(getGLIMetadataDirectoryPath() + namespace_str + ".mds"));
    15791590                model.add(null, loadedset, GEMSNode.SET);
    15801591                }
     
    22442255        if(current_set != null) {
    22452256               
    2246                 //If the current_set_filename is dls or dublin or ex and in the METADATA_DIR, then do
     2257                //If the current_set_filename is dls or dublin or ex and in the GLI metadata directory, then do
    22472258                //not let anyone remove them --Attila
    22482259                File current_set_filename = current_set.getFile();
    2249                 if(current_set_filename.toString().compareTo(new String(Utility.METADATA_DIR+"dls.mds")) == 0 ||
    2250                     current_set_filename.toString().compareTo(new String(Utility.METADATA_DIR+"dublin.mds")) == 0 ||
    2251                     current_set_filename.toString().compareTo(new String(Utility.METADATA_DIR+"ex.mds")) == 0){
     2260                if(current_set_filename.toString().compareTo(new String(getGLIMetadataDirectoryPath() + "dls.mds")) == 0 ||
     2261                    current_set_filename.toString().compareTo(new String(getGLIMetadataDirectoryPath() + "dublin.mds")) == 0 ||
     2262                    current_set_filename.toString().compareTo(new String(getGLIMetadataDirectoryPath() + "ex.mds")) == 0){
    22522263                 
    22532264                    JOptionPane.showMessageDialog(self, Dictionary.get("GEMS.Cannot_Delete_Core_Sets_Error"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
  • trunk/gli/src/org/greenstone/gatherer/gems/MetadataSetManager.java

    r9170 r10342  
    8585    mds.setName(name);
    8686    // this is the location for a global metadata set
    87     File mds_file = new File(Utility.METADATA_DIR, namespace + ".mds");
     87    File mds_file = new File(GEMS.getGLIMetadataDirectoryPath() + namespace + ".mds");
    8888    mds.setFile(mds_file);
    8989    mds_hashtable.put(namespace, mds);
     
    399399
    400400    public void save() {
    401     File file = new File(Utility.METADATA_DIR);
     401    File file = new File(GEMS.getGLIMetadataDirectoryPath());
    402402       
    403403    if (!file.exists()) {
  • trunk/gli/src/org/greenstone/gatherer/gui/DownloadPane.java

    r8992 r10342  
    307307    public void actionPerformed(ActionEvent event) {
    308308        // Retrieve the cache folder and delete it.
    309         Utility.delete(Utility.getCacheDir());
     309        Utility.delete(Gatherer.getGLIUserCacheDirectoryPath());
    310310        // ...and refresh the node in the workspace tree to show it's all gone
    311311        Gatherer.g_man.refreshWorkspaceTree(WorkspaceTree.DOWNLOADED_FILES_CHANGED);
     
    369369        depth_object = null;
    370370   
    371         File destination_file = Utility.getCacheDir();
    372         destination_file.mkdirs(); // If they aren't already
    373         String destination_filename = destination_file.getAbsolutePath();
    374         if(!destination_filename.endsWith(File.separator)) {
    375         destination_filename = destination_filename + File.separator;
    376         }
     371        String destination_file_path = Gatherer.getGLIUserCacheDirectoryPath();
     372        (new File(destination_file_path)).mkdirs(); // If they aren't already
    377373
    378374        if(url != null) {
    379         getter.newDownloadJob(higher_checkbox.isSelected(), (higher_checkbox.isSelected()? false : !same_host_checkbox.isSelected()), !requisite_checkbox.isSelected(), url, depth_value, destination_filename);
     375        getter.newDownloadJob(higher_checkbox.isSelected(), (higher_checkbox.isSelected()? false : !same_host_checkbox.isSelected()), !requisite_checkbox.isSelected(), url, depth_value, destination_file_path);
    380376        }
    381377    }
  • trunk/gli/src/org/greenstone/gatherer/gui/FileAssociationDialog.java

    r9354 r10342  
    290290     */
    291291    public void actionPerformed(ActionEvent event) {
    292         JFileChooser chooser = new JFileChooser(new File(Utility.BASE_DIR));
     292        JFileChooser chooser = new JFileChooser(new File(Gatherer.getGLIUserDirectoryPath()));
    293293        OpenCollectionDialog.disableRename(chooser);
    294294        chooser.setDialogTitle(Dictionary.get("FileAssociationDialog.Browse_Title"));
  • trunk/gli/src/org/greenstone/gatherer/gui/HelpFrame.java

    r10013 r10342  
    4747import org.greenstone.gatherer.DebugStream;
    4848import org.greenstone.gatherer.Dictionary;
     49import org.greenstone.gatherer.Gatherer;
    4950import org.greenstone.gatherer.util.JarTools;
    5051import org.greenstone.gatherer.util.StaticStrings;
     
    322323        url = JarTools.getResource("/" + help_file);
    323324        if (url == null) {
    324             File file = new File(Utility.BASE_DIR + help_file);
     325            File file = new File(Gatherer.getGLIUserDirectoryPath() + help_file);
    325326            try {
    326327            url = file.toURL();
  • trunk/gli/src/org/greenstone/gatherer/gui/NewCollectionMetadataPrompt.java

    r9864 r10342  
    7070
    7171    // Show the metadata sets (except extracted!) available in the GLI "metadata" folder
    72     ArrayList metadata_sets = MetadataSetManager.listMetadataSets(new File(Utility.METADATA_DIR));
     72    ArrayList metadata_sets = MetadataSetManager.listMetadataSets(new File(Gatherer.getGLIMetadataDirectoryPath()));
    7373    ArrayList metadata_set_list_entries = new ArrayList();
    7474    for (int i = 0; i < metadata_sets.size(); i++) {
  • trunk/gli/src/org/greenstone/gatherer/gui/PreviewCommandDialog.java

    r8243 r10342  
    176176     */
    177177    public void actionPerformed(ActionEvent event) {
    178         JFileChooser chooser = new JFileChooser(new File(Utility.BASE_DIR));
     178        JFileChooser chooser = new JFileChooser(new File(Gatherer.getGLIUserDirectoryPath()));
    179179        OpenCollectionDialog.disableRename(chooser);
    180180        chooser.setDialogTitle(Dictionary.get("FileAssociationDialog.Browse_Title"));
  • trunk/gli/src/org/greenstone/gatherer/shell/GShell.java

    r10259 r10342  
    627627            progress.messageOnProgressBar("Downloading CD-ROM data from server");
    628628            }
     629
     630            // !! TO DO
    629631           
    630             //Export directory derrived from -cdname argument
    631             //This needs to be exactly the same as derrived by exportcol.pl - perhaps it should be passed in as an argument?
    632             String cd_dir = "exported_collections";
    633             for(int i=0; i<args.length-1; i++) {
    634             if(args[i] == "-cdname") {
    635                 //Remove all spaces
    636                 String cdName = args[i+1];
    637                 Pattern pattern = Pattern.compile("\\s");
    638                 Matcher matcher = pattern.matcher(cdName);
    639                 cd_dir = "exported_" + matcher.replaceAll("");
    640             }
    641             }
    642             //DebugStream.println("cd_dir is: " + cd_dir);
    643 
    644             String tmp_dir = Utility.TMP_DIR;
    645             String user_tmp_dir = "/tmp";
    646 
    647             //String username = System.getProperty("user.name");
    648             //if ((username != null) && (username != "")) {
    649             // user_cd_dir = username + File.separator + cd_dir;
    650             //user_tmp_dir = user_tmp_dir + File.separator + username;
    651             //}
    652 
    653             String full_local_cd_dir = tmp_dir + cd_dir; //Need to tell user this!
    654 
    655             Utility.delete(full_local_cd_dir); // remove current cd-rom dir, if it exists
    656             RemoteGreenstoneServer.download_url_zip(user_tmp_dir,cd_dir,this,"","");
    657 
    658             ZipTools.unzip(Configuration.gsdl_path, user_tmp_dir.substring(1));
    659 
    660             if (progress!=null) {
    661             System.err.println("Asking progress bar to be empty string");
    662             progress.messageOnProgressBar("");
    663             }
    664            
    665             //The string needs to start with exportcol.pl> otherwise it won't be displayed in the final dialog
    666             String message = "exportcol.pl>\nThese files have been copied from the server to " + full_local_cd_dir + " and are ready to written to CD-ROM";
    667             fireMessage(type, message, status, bos); //Hopefully this works
    668             System.err.println("Finished download of /tmp ...");
    669         }
    670        
     632            if (progress!=null) {
     633            progress.messageOnProgressBar("");
     634            }
     635        }
    671636        }
    672637    }
  • 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.