Changeset 10461


Ignore:
Timestamp:
2005-08-10T14:56:20+12:00 (19 years ago)
Author:
mdewsnip
Message:

Fixed a bug where the GEMS didn't know the GLI user directory, so updates to the config.xml file would fail.

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

Legend:

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

    r10370 r10461  
    9494
    9595    static public Configuration self = null;
     96    static private String gli_user_directory_path = null;
    9697
    9798    static public boolean just_updated_config_xml_file = false;
     
    137138     * @param site_name The name of the Greenstone 3 site currently in use.
    138139     */
    139     public Configuration(String gsdl_path, String gsdl3_path, String gsdl3_src_path, String site_name)
     140    public Configuration(String gli_user_directory_path, String gsdl_path, String gsdl3_path, String gsdl3_src_path, String site_name)
    140141    {
    141142    super();
    142143    self = this;
    143144
     145    this.gli_user_directory_path = gli_user_directory_path;
    144146    this.gsdl_path = gsdl_path;
    145147    this.gsdl3_path = gsdl3_path;
     
    154156
    155157    // If the existing user config.xml file isn't recent enough, backup the old version and update it
    156     File config_xml_file = new File(Gatherer.getGLIUserDirectoryPath() + config_xml_file_name);
     158    File config_xml_file = new File(gli_user_directory_path + config_xml_file_name);
    157159    if (config_xml_file != null && config_xml_file.exists()) {
    158160        just_updated_config_xml_file = updateUserConfigXMLFileIfNecessary(config_xml_file);
     
    392394        }
    393395    }
    394     catch(Exception error) {
     396    catch (Exception exception) {
     397        DebugStream.printStackTrace(exception);
    395398    }
    396399    return properties;
     
    421424        document_element = null;
    422425    }
    423     catch(Exception error) {
     426    catch (Exception exception) {
     427        DebugStream.printStackTrace(exception);
    424428    }
    425429    return argument_element;
     
    451455        result = new Rectangle(x, y, width, height);
    452456    }
    453     catch(Exception error) {
    454         DebugStream.printStackTrace(error);
     457    catch (Exception exception) {
     458        DebugStream.printStackTrace(exception);
    455459    }
    456460    return result;
     
    469473        result = new Color(red, green, blue);
    470474    }
    471     catch(Exception error) {
    472         error.printStackTrace();
     475    catch (Exception exception) {
     476        DebugStream.printStackTrace(exception);
    473477    }
    474478    return result;
     
    496500        mappings = null;
    497501    }
    498     catch(Exception exception) {
     502    catch (Exception exception) {
    499503        DebugStream.printStackTrace(exception);
    500504    }
     
    537541        result = new FontUIResource(face, style, size);
    538542    }
    539     catch(Exception error) {
    540         DebugStream.printStackTrace(error);
     543    catch (Exception exception) {
     544        DebugStream.printStackTrace(exception);
    541545    }
    542546    return result;
     
    550554        result = Integer.parseInt(raw);
    551555    }
    552     catch(Exception error) {
    553         DebugStream.printStackTrace(error);
     556    catch (Exception exception) {
     557        DebugStream.printStackTrace(exception);
    554558    }
    555559    return result;
     
    582586        }
    583587    }
    584     catch(Exception error) {
    585         DebugStream.printStackTrace(error);
     588    catch (Exception exception) {
     589        DebugStream.printStackTrace(exception);
    586590    }
    587591    return result;
     
    664668        }
    665669    }
    666     catch (Exception error) {
    667         error.printStackTrace();
     670    catch (Exception exception) {
     671        DebugStream.printStackTrace(exception);
    668672    }
    669673    // If we still have no result, and the search was made in the collection configuration, retrieve the general one instead.
     
    707711        mappings = null;
    708712    }
    709     catch(Exception error) {
    710         DebugStream.printStackTrace(error);
     713    catch (Exception exception) {
     714        DebugStream.printStackTrace(exception);
    711715    }
    712716    return file;
     
    723727    }
    724728    try {
    725         user_config_xml = new File(Gatherer.getGLIUserDirectoryPath() + config_xml_name);
     729        user_config_xml = new File(gli_user_directory_path + config_xml_name);
    726730        ///ystem.err.println("Trying to save to: " + user_config_xml.getAbsolutePath());
    727731        ///ystem.err.println("Writing.");
     
    729733        XMLTools.writeXMLFile(new File(user_config_xml.getAbsolutePath()), general_config);
    730734    }
    731     catch(Exception exception) {
     735    catch (Exception exception) {
     736        DebugStream.printStackTrace(exception);
    732737        user_config_xml = null;
    733738    }
     
    768773        document_element = null;
    769774    }
    770     catch (Exception error) {
    771         DebugStream.println("Error in Configuration.setArguments(): " + error);
    772         DebugStream.printStackTrace(error);
     775    catch (Exception exception) {
     776        DebugStream.println("Error in Configuration.setArguments(): " + exception);
     777        DebugStream.printStackTrace(exception);
    773778    }
    774779    }
     
    926931        }
    927932    }
    928     catch (Exception error) {
     933    catch (Exception exception) {
     934        DebugStream.printStackTrace(exception);
    929935    }
    930936    }
  • trunk/gli/src/org/greenstone/gatherer/Gatherer.java

    r10396 r10461  
    209209    try {
    210210        // Load GLI config file
    211         new Configuration(gsdl_path, gsdl3_path, gsdl3_src_path, site_name);
     211        new Configuration(getGLIUserDirectoryPath(), gsdl_path, gsdl3_path, gsdl3_src_path, site_name);
    212212        if (Configuration.just_updated_config_xml_file) {
    213213        // Delete the plugins.dat and classifiers.dat files
  • trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java

    r10447 r10461  
    6666import org.greenstone.gatherer.util.Codec;
    6767import org.greenstone.gatherer.util.JarTools;
     68import org.greenstone.gatherer.util.Utility;
    6869import org.greenstone.gatherer.util.XMLTools;
    6970import org.w3c.dom.*;
     
    172173    public GEMS(String gsdl_path)
    173174    {
     175    // Determine the GLI user directory path
     176    String gli_user_directory_path = System.getProperty("user.home") + File.separator;
     177        if (Utility.isWindows()) {
     178        gli_user_directory_path += "Application Data" + File.separator + "Greenstone" + File.separator + "GLI" + File.separator;
     179        }
     180        else {
     181            gli_user_directory_path += ".gli" + File.separator;
     182        }
     183
    174184    //Load configuration file
    175185    this.self = this;
    176186    JarTools.initialise(this);
    177     config = new Configuration(gsdl_path, null, null, null);
     187    config = new Configuration(gli_user_directory_path, gsdl_path, null, null, null);
    178188
    179189    // Read Dictionary
  • trunk/gli/src/org/greenstone/gatherer/gems/GEMSLanguageManager.java

    r10345 r10461  
    4848import org.greenstone.gatherer.DebugStream;
    4949import org.greenstone.gatherer.Dictionary;
    50 import org.greenstone.gatherer.Gatherer;
    5150import org.greenstone.gatherer.gui.GLIButton;
    5251import org.w3c.dom.*;
Note: See TracChangeset for help on using the changeset viewer.