Changeset 36229


Ignore:
Timestamp:
2022-05-31T10:15:53+12:00 (2 years ago)
Author:
kjdon
Message:

I find it annoying when switching between gs2 and 3 that the gli config file (in .gli/config.xml) gets changed back and forth. In the same way we now have configRemote.xml for when we are running remotely, now locally, config.xml gets saved as config2.xml or config3.xml. they use the same config.xml template though. added final static strings for the filenames, and always use these, so only Configuration now contains the actual text strings. made Configuration.CONFIG_XML and Configuration.TEMPLATE_CONFIG_XML lowercase as they are not final Strings, they get changed by Gatherer.

Location:
main/trunk/gli/src/org/greenstone/gatherer
Files:
2 edited

Legend:

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

    r36102 r36229  
    6363    static final public int EXPERT_MODE    = 3;
    6464
     65  // Gs2 and 3 use the same config file format - same template - but will save in user folder as config2/3 so you can
     66  // save settings for version 2 and 3.
     67  static final public String CONFIG_XML_TEMPLATE = "config.xml";
     68  static final public String CONFIG_XML_2 = "config2.xml";
     69  static final public String CONFIG_XML_3 = "config3.xml";
     70  static final public String CONFIG_REMOTE_XML = "configRemote.xml";
     71
     72    static final public String TEMPLATE_CONFIG_PREFIX = "xml/";
     73     static final public String FEDORA_CONFIG_PREFIX = "fedora-";
     74 
    6575    /** The string identifying an argument's name attribute. */
    6676    static final private String ARGUMENT_NAME = "name";
    67     /** The name of the general Gatherer configuration file.
    68      Gatherer will change this to configRemote if isGsdlRemote */
    69     static public String CONFIG_XML = "config.xml";
    70     static public String FEDORA_CONFIG_PREFIX = "fedora-";
    7177
    7278    /** The name of the root element of the subtree containing gatherer configuration options. This is required as the document itself may contain several other subtrees of settings (such as in the case of a '.col' file). */
     
    8288    /** The name of the other arguments element. */
    8389    static final private String OTHER = "Other";
    84     /** The name of the general Gatherer configuration template.
    85     Gatherer will change this to xml/configRemote.xml if isGSDLRemote */
    86     static public String TEMPLATE_CONFIG_XML = "xml/config.xml";
    8790    /** The first of three patterns used during tokenization, this pattern handles a comma separated list. */
    8891    static final private String TOKENIZER_PATTERN1 = " ,\n\t";
     
    9497    static public Configuration self = null;
    9598    static public String gli_user_directory_path = null;
     99    /** The name of the general Gatherer configuration file.
     100     Gatherer will set this to configRemote/2/3 as necessary */
     101  static public String config_xml = CONFIG_XML_2;
     102    /** The name of the general Gatherer configuration template.
     103    Gatherer will change this to xml/configRemote.xml if isGSDLRemote */
     104  static public String template_config_xml = TEMPLATE_CONFIG_PREFIX + CONFIG_XML_TEMPLATE;
    96105
    97106    static public boolean just_updated_config_xml_file = false;
     
    156165
    157166    // Try to load the configuration file from the user specific location
    158     String config_xml_file_name = CONFIG_XML;
    159 
    160     if (fedora_info != null && fedora_info.isActive()) {
    161         config_xml_file_name = FEDORA_CONFIG_PREFIX + config_xml_file_name;
    162     }
     167    String config_xml_file_name = this.config_xml;
     168
     169        // I think this has already been set by Gatherer
     170    // if (fedora_info != null && fedora_info.isActive()) {
     171    //     config_xml_file_name = FEDORA_CONFIG_PREFIX + config_xml_file_name;
     172    // }
    163173
    164174    // If the existing user config.xml file isn't recent enough, backup the old version and update it
     
    172182    // Create a new config from the default configuration file from our xml library
    173183    if (general_config == null) {
    174         general_config = XMLTools.parseXMLFile(TEMPLATE_CONFIG_XML, true);
     184        general_config = XMLTools.parseXMLFile(this.template_config_xml, true);
    175185        just_updated_config_xml_file = true;
    176186    }
     
    248258    {
    249259    // Check if the configuration file actually needs updating by looking at the version numbers
    250     Document new_document = XMLTools.parseXMLFile(TEMPLATE_CONFIG_XML, true);
     260    Document new_document = XMLTools.parseXMLFile(template_config_xml, true);
    251261    Document old_document = XMLTools.parseXMLFile(config_xml_file);
    252262    if (new_document == null || old_document == null) {
     
    736746    // We first try exporting to a user specific place
    737747    File user_config_xml = null;
    738     String config_xml_name = CONFIG_XML;
    739 
    740     if (fedora_info != null && fedora_info.isActive()) {
    741         config_xml_name = FEDORA_CONFIG_PREFIX + config_xml_name;
    742     }
     748    String config_xml_name = config_xml;
     749
     750        // this should have been set already
     751    // if (fedora_info != null && fedora_info.isActive()) {
     752    //     config_xml_name = FEDORA_CONFIG_PREFIX + config_xml_name;
     753    // }
    743754
    744755    try {
  • main/trunk/gli/src/org/greenstone/gatherer/Gatherer.java

    r36110 r36229  
    186186        }
    187187
     188                // Are we greenstone 2 or 3?
     189                if (go.gsdl3_path != null && !go.gsdl3_path.equals("")) {
     190                  this.GS3 = true;
     191                  Configuration.config_xml = Configuration.CONFIG_XML_3;
     192        } else {
     193                  go.gsdl3_path = null;
     194                  go.gsdl3_src_path = null;
     195        }
     196               
    188197        // Are we using a remote Greenstone?
    189198        if (go.use_remote_greenstone) {
     
    217226        if (isGsdlRemote) {
    218227            if (go.fedora_info.isActive()) {
    219                 Configuration.TEMPLATE_CONFIG_XML = "xml/" + Configuration.FEDORA_CONFIG_PREFIX + "configRemote.xml";
     228                          Configuration.template_config_xml = Configuration.TEMPLATE_CONFIG_PREFIX + Configuration.FEDORA_CONFIG_PREFIX + Configuration.CONFIG_REMOTE_XML;
    220229            }
    221230            else {
    222                 Configuration.TEMPLATE_CONFIG_XML = "xml/configRemote.xml";
    223             }
    224 
    225             Configuration.CONFIG_XML = "configRemote.xml";
     231                          Configuration.template_config_xml = Configuration.TEMPLATE_CONFIG_PREFIX +  Configuration.CONFIG_REMOTE_XML;
     232            }
     233
     234            Configuration.config_xml = Configuration.CONFIG_REMOTE_XML;
    226235
    227236            File collect_directory = new File(Gatherer.getCollectDirectoryPath());
     
    232241        else {     
    233242            if (go.fedora_info.isActive()) {
    234                 Configuration.TEMPLATE_CONFIG_XML = "xml/" + Configuration.FEDORA_CONFIG_PREFIX + Configuration.CONFIG_XML;
     243                Configuration.template_config_xml = Configuration.TEMPLATE_CONFIG_PREFIX + Configuration.FEDORA_CONFIG_PREFIX + Configuration.config_xml;
    235244            }
    236245            // else, the CONFIG_XML uses the default config file, which is for the local GS server
     
    256265    String site_name, String servlet_path, String collect_directory_path)
    257266    {
    258         if (gsdl3_path != null && !gsdl3_path.equals("")) {
    259             this.GS3 = true;
    260         } else {
    261             gsdl3_path = null;
    262             gsdl3_src_path = null;
    263         }
     267   
    264268
    265269        // Create the debug stream if required
Note: See TracChangeset for help on using the changeset viewer.