Changeset 8626
- Timestamp:
- 2004-11-23T13:35:05+13:00 (19 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/Configuration.java
r8625 r8626 113 113 /** The servlet path if we are using GS3 */ 114 114 static public String servlet_path = ""; 115 /** If true, overrides the mirroring enabled setting in the config.xml file. */116 static private boolean mirroring_enabled = false;117 115 /** Collection level configuration (which in some cases overrides general configuration. */ 118 116 static private Document collection_config; 119 117 /** The general configuration settings. */ 120 118 static private Document general_config; 121 119 122 120 /** The element, from glis config file, that contains the various directory mappings. */ 123 121 static private Element directory_mappings_element; … … 135 133 * @param library_url A <strong>String</strong> containing the url of the Greenstone webserver. 136 134 * @param perl_path The path to the PERL executable, as a <strong>String</strong>. 137 * @param mirroring_enabled If true will override the config.xml fiel setting for mirroring.138 135 * @param site_name The name of the Greenstone 3 site currently in use. 139 136 */ 140 public Configuration(String gsdl_path, String gsdl3_path, String library_url, String perl_path, boolean mirroring_enabled, String site_name) { 137 public Configuration(String gsdl_path, String gsdl3_path, String library_url, String perl_path, String site_name) 138 { 141 139 super(); 142 140 self = this; … … 144 142 this.gsdl_path = gsdl_path; 145 143 this.gsdl3_path = gsdl3_path; 146 this.mirroring_enabled = mirroring_enabled;147 144 this.site_name = site_name; 148 145 … … 166 163 } 167 164 168 // Try to reload the configuration. The first place we look isthe user specific location169 String config_xml_ name = CONFIG_XML;165 // Try to load the configuration file, first looking in the user specific location 166 String config_xml_file_name = CONFIG_XML; 170 167 if (gsdl3_path != null) { 171 config_xml_ name = GS3_CONFIG_XML;172 } 173 File config_xml = new File(Utility.getGLIUserFolder(), config_xml_name);174 if (config_xml != null && config_xml.exists()) {175 general_config = Utility.parse(config_xml .getAbsolutePath(), false);168 config_xml_file_name = GS3_CONFIG_XML; 169 } 170 File config_xml_file = new File(Utility.getGLIUserFolder(), config_xml_file_name); 171 if (config_xml_file != null && config_xml_file.exists()) { 172 general_config = Utility.parse(config_xml_file.getAbsolutePath(), false); 176 173 } 177 174 178 175 // We then try within the gli directory itself 179 if (general_config == null) {180 config_xml = new File(config_xml_name);181 if (config_xml.exists()) {182 general_config = Utility.parse(config_xml_ name, true);176 if (general_config == null) { 177 config_xml_file = new File(config_xml_file_name); 178 if (config_xml_file.exists()) { 179 general_config = Utility.parse(config_xml_file_name, true); 183 180 } 184 181 } 185 182 186 183 // 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. 187 if (general_config != null) {184 if (general_config != null) { 188 185 Element configuration_element = general_config.getDocumentElement(); 189 186 String configuration_version = configuration_element.getAttribute(StaticStrings.VERSION_ATTRIBUTE); 190 if(!configuration_version.equals(CURRENT_CONFIGURATION_VERSION)) { 191 /** @todo - reenable this once we can change the dictionary. */ 192 //JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("Configuration.Obsolete_Config"), Dictionary.get("Configuration.Obsolete_Config_Title"), JOptionPane.ERROR_MESSAGE); 187 if (!configuration_version.equals(CURRENT_CONFIGURATION_VERSION)) { 188 // !!! JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("Configuration.Obsolete_Config"), Dictionary.get("Configuration.Obsolete_Config_Title"), JOptionPane.ERROR_MESSAGE); 189 File backup = new File(config_xml_file.getAbsolutePath() + ".bak"); 190 config_xml_file.renameTo(backup); 193 191 general_config = null; 194 configuration_element = null; 195 File backup = new File(config_xml.getAbsolutePath() + ".bak"); 196 config_xml.renameTo(backup); 197 backup = null; 198 } 199 else { 200 configuration_element = null; 201 } 202 configuration_version = null; 203 } 204 205 // And if that fails retrieve the default configuration file from our xml library, which I'll personally guarantee to work. 206 if(general_config == null) { 192 } 193 } 194 195 // And if that fails retrieve the default configuration file from our xml library 196 if (general_config == null) { 207 197 general_config = Utility.parse(TEMPLATE_CONFIG_XML, true); 208 DebugStream.println("Loaded default Gatherer configuration template.");209 }210 else {211 DebugStream.println("Loaded current Gatherer configuration.");212 198 } 213 199 … … 287 273 /** The default get action retrieves the named property from the desired configuration, and returns a true or false. */ 288 274 static public boolean get(String property, boolean general) { 289 if(general && mirroring_enabled && property.equals(StaticStrings.WORKFLOW_MIRROR)) {290 return mirroring_enabled;291 }292 275 String raw = getString(property, general); 293 276 return (raw != null && raw.equalsIgnoreCase("true")); -
trunk/gli/src/org/greenstone/gatherer/Gatherer.java
r8625 r8626 121 121 boolean no_load, String open_collection, 122 122 String site_name, String servlet_path, 123 boolean mirroring_enabled, String wget_version_str, 124 String wget_path) 123 String wget_version_str, String wget_path) 125 124 { 126 125 // This will hopefully catch ctrl-c and terminate, and exit gracefully. However it is platform specific, and may not be supported by some JVMs. … … 153 152 try { 154 153 // Load Config 155 loadConfig(gsdl_path, gsdl3_path, library_url, perl_path, mirroring_enabled,site_name);154 loadConfig(gsdl_path, gsdl3_path, library_url, perl_path, site_name); 156 155 157 156 // I don't really know what this is for but I've moved it here from Configuration … … 611 610 * @param library_url The path to the library executable, gathered from the startup arguments, and presented as a <strong>String</strong>. 612 611 * @param perl_path The path to the PERL compiler as a <strong>String</strong>. Necessary for windows platform versions. 613 * @param mirroring_enabled614 * @param wget_version_str615 * @param wget_path616 612 * @see java.io.FileInputStream 617 613 * @see java.io.ObjectInputStream … … 619 615 * @see org.greenstone.gatherer.Configuration 620 616 */ 621 private void loadConfig(String gsdl_path, String gsdl3_path, String library_url, String perl_path, boolean mirroring_enabled,String site_name) {617 private void loadConfig(String gsdl_path, String gsdl3_path, String library_url, String perl_path, String site_name) { 622 618 try { 623 new Configuration(gsdl_path, gsdl3_path, library_url, perl_path, mirroring_enabled,site_name);619 new Configuration(gsdl_path, gsdl3_path, library_url, perl_path, site_name); 624 620 } 625 621 catch (Exception error) { -
trunk/gli/src/org/greenstone/gatherer/GathererApplet.java
r8625 r8626 174 174 go.library_url, go.debug, go.perl_path, 175 175 go.no_load, go.filename, go.site_name, 176 go.servlet_path, go.mirroring_enabled, 177 go.wget_version_str, go.wget_path); 176 go.servlet_path, go.wget_version_str, go.wget_path); 178 177 179 178 -
trunk/gli/src/org/greenstone/gatherer/GathererProg.java
r8625 r8626 93 93 go.library_url, go.debug, go.perl_path, 94 94 go.no_load, go.filename, go.site_name, 95 go.servlet_path, go.mirroring_enabled, 96 go.wget_version_str, go.wget_path); 95 go.servlet_path, go.wget_version_str, go.wget_path); 97 96 gatherer.run(size,splash,g_man); 98 97 } -
trunk/gli/src/org/greenstone/gatherer/GetOpt.java
r8625 r8626 36 36 public boolean debug = false; 37 37 public boolean feedback_enabled = false; 38 public boolean mirroring_enabled = false;39 38 public boolean no_load = false; 40 39 … … 134 133 filename = null; 135 134 } 136 // Run the GLI with mirroring enabled137 else if(argument_name.equals(StaticStrings.MIRROR_ARGUMENT)) {138 mirroring_enabled = true;139 }140 135 /* I've got a sneak suspicion Aqua look and feel is not free domain 141 136 // Specify the use of Greenstone LAF. -
trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java
r8625 r8626 190 190 try { 191 191 192 config = new Configuration(go.gsdl_path, null, null, go.perl_path, false,null);192 config = new Configuration(go.gsdl_path, null, null, go.perl_path, null); 193 193 } 194 194 catch (Exception exception) { -
trunk/gli/src/org/greenstone/gatherer/util/StaticStrings.java
r8625 r8626 172 172 static final public String MGPP_ATTRIBUTE = "mgpp_enabled"; 173 173 static final public String MINUS_CHARACTER = "-"; 174 static final public String MIRROR_ARGUMENT = "-mirror";175 174 static final public String MODE_STR = "Mode: "; 176 175 static final public String MODEGLI_ELEMENT = "ModeGLI";
Note:
See TracChangeset
for help on using the changeset viewer.