Changeset 6630 for trunk/gli/src/org/greenstone/gatherer/Configuration.java
- Timestamp:
- 2004-01-28T14:37:50+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/Configuration.java
r6622 r6630 68 68 /** The name of the general Gatherer configuration file. */ 69 69 static final private String CONFIG_XML = "config.xml"; 70 71 static final private String CURRENT_CONFIGURATION_VERSION = "2.4"; 70 72 /** 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). */ 71 73 static final private String GATHERER_CONFIG = "GathererConfig"; … … 189 191 190 192 // Try to reload the configuration. The first place we look is the user specific location 191 File user_config_xml = new File(Utility.getGLIUserFolder(), CONFIG_XML);192 if( user_config_xml != null && user_config_xml.exists()) {193 general_config = Utility.parse( user_config_xml.getAbsolutePath(), false);193 File config_xml = new File(Utility.getGLIUserFolder(), CONFIG_XML); 194 if(config_xml != null && config_xml.exists()) { 195 general_config = Utility.parse(config_xml.getAbsolutePath(), false); 194 196 } 195 197 196 198 // We then try within the gli directory itself 197 199 if(general_config == null) { 198 Fileconfig_xml = new File(CONFIG_XML);200 config_xml = new File(CONFIG_XML); 199 201 if(config_xml.exists()) { 200 202 general_config = Utility.parse(CONFIG_XML, false); 201 203 } 204 } 205 206 // Check the version of the config we have loaded, and if it isn't recent enough, backup the old version, and then create a new config. 207 if(general_config != null) { 208 Element configuration_element = general_config.getDocumentElement(); 209 String configuration_version = configuration_element.getAttribute(StaticStrings.VERSION_ATTRIBUTE); 210 if(!configuration_version.equals(CURRENT_CONFIGURATION_VERSION)) { 211 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("Configuration.Obsolete_Config"), Dictionary.get("Configuration.Obsolete_Config_Title"), JOptionPane.ERROR_MESSAGE); 212 general_config = null; 213 configuration_element = null; 214 File backup = new File(config_xml.getAbsolutePath() + ".bak"); 215 config_xml.renameTo(backup); 216 backup = null; 217 } 218 else { 219 configuration_element = null; 220 } 221 configuration_version = null; 202 222 } 203 223 … … 422 442 String email = getString(GENERAL_EMAIL_SETTING, true); 423 443 return (email.length() > 0 ? email : null); 444 } 445 446 public Element getFileAssociations() { 447 NodeList file_association_elements = general_config.getDocumentElement().getElementsByTagName(StaticStrings.ASSOCIATIONS_ELEMENT); 448 return (Element) file_association_elements.item(0); 424 449 } 425 450
Note:
See TracChangeset
for help on using the changeset viewer.