Changeset 8627
- Timestamp:
- 2004-11-23T14:28:53+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
r8626 r8627 71 71 static public String GS3_CONFIG_XML = "config3.xml"; 72 72 73 static final private String CURRENT_CONFIGURATION_VERSION = "2.52 ";73 static final private String CURRENT_CONFIGURATION_VERSION = "2.52a"; 74 74 /** 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). */ 75 75 static final private String GATHERER_CONFIG = "GathererConfig"; … … 127 127 static private String wget_version_str = StaticStrings.NO_WGET_STR; 128 128 129 static public URL exec_address = null; 129 static public URL library_url = null; 130 130 131 131 132 /** Constructor. 132 133 * @param gsdl_path The path to the Greenstone directory as a <strong>String</strong>. 133 * @param library_url A <strong>String</strong> containing the url of the Greenstone webserver. 134 * @param perl_path The path to the PERL executable, as a <strong>String</strong>. 134 * @param gsdl3_path The path to the Greenstone 3 directory as a <strong>String</strong>. 135 135 * @param site_name The name of the Greenstone 3 site currently in use. 136 136 */ 137 public Configuration(String gsdl_path, String gsdl3_path, String library_url, String perl_path, Stringsite_name)137 public Configuration(String gsdl_path, String gsdl3_path, String site_name) 138 138 { 139 139 super(); … … 143 143 this.gsdl3_path = gsdl3_path; 144 144 this.site_name = site_name; 145 146 DebugStream.println("Library URL = " + library_url);147 if (library_url != null && library_url.length() > 0) {148 try {149 exec_address = new URL(library_url);150 }151 catch (MalformedURLException error) {152 DebugStream.printStackTrace(error);153 }154 }155 156 this.perl_path = perl_path;157 // Ensure the perl path includes exe under windoze158 if (Utility.isWindows() && !perl_path.toLowerCase().endsWith(".exe")) {159 if (!perl_path.endsWith(File.separator)) {160 perl_path = perl_path + File.separator;161 }162 perl_path = perl_path + "perl.exe";163 }164 145 165 146 // Try to load the configuration file, first looking in the user specific location … … 204 185 updateUI(); 205 186 206 // If we have no exec_address, see if one was specified in the config file 207 if (exec_address == null) { 208 String exec_address_string = getString("general.exec_address", true); 209 if (!exec_address_string.equals("")) { 210 try { 211 exec_address = new URL(exec_address_string); 212 } 213 catch (MalformedURLException error) { 214 ///ystem.err.println("Error: Bad address: " + exec_address_string); 215 } 187 // Read the Greenstone library URL from the config file 188 String library_url_string = getString("general.library_url", true); 189 if (!library_url_string.equals("")) { 190 try { 191 library_url = new URL(library_url_string); 192 } 193 catch (MalformedURLException exception) { 194 DebugStream.printStackTrace(exception); 216 195 } 217 196 } … … 236 215 } 237 216 } 238 239 DebugStream.println("EXEC_ADDRESS = " + exec_address); 240 } 217 } 218 241 219 242 220 /** Add a special directory mapping. */ -
trunk/gli/src/org/greenstone/gatherer/Gatherer.java
r8626 r8627 118 118 119 119 public GUIManager init(Dimension size, String gsdl_path, String gsdl3_path, String local_library_path, 120 String library_url , boolean debug_enabled, String perl_path,120 String library_url_string, boolean debug_enabled, String perl_path, 121 121 boolean no_load, String open_collection, 122 122 String site_name, String servlet_path, … … 152 152 try { 153 153 // Load Config 154 loadConfig(gsdl_path, gsdl3_path, library_url, perl_path, site_name); 155 156 // I don't really know what this is for but I've moved it here from Configuration 154 loadConfig(gsdl_path, gsdl3_path, site_name); 155 156 // Check we know where Perl is 157 Configuration.perl_path = perl_path; 157 158 if (isGsdlRemote && Utility.isWindows() && Configuration.perl_path != null) { 158 159 if (Configuration.perl_path.toLowerCase().endsWith("perl.exe")) { … … 173 174 feedback_dialog.setLocale(Configuration.getLocale("general.locale", true)); 174 175 } 175 176 176 177 // Read Dictionary 177 178 new Dictionary(Configuration.getLocale("general.locale", true), Configuration.getFont("general.font", true)); … … 184 185 if (Utility.isWindows() && local_library_path != null && !GS3) { 185 186 LocalLibraryServer.start(gsdl_path, local_library_path); 186 DebugStream.println("Having started server.exe, exec_address is: " + Configuration.exec_address); 187 } 188 189 // Having loaded the configuration (necessary to determine if certain warnings have been disabled) and dictionary, we now check if the necessary path variables have been provided. 190 if (Configuration.exec_address == null) { 191 DebugStream.println("config.exec_address is null"); 187 } 188 189 // The "-library_url" option overwrites anything in the config files 190 if (library_url_string != null && library_url_string.length() > 0) { 191 try { 192 System.err.println("Setting library_url to " + library_url_string + "..."); 193 Configuration.library_url = new URL(library_url_string); 194 } 195 catch (MalformedURLException error) { 196 DebugStream.printStackTrace(error); 197 } 198 } 199 200 // Check that we now know the Greenstone library URL, since we need this for previewing collections 201 DebugStream.println("Configuration.library_url = " + Configuration.library_url); 202 if (Configuration.library_url == null) { 192 203 missingEXEC(); 193 204 } … … 432 443 try { 433 444 // need to add the servlet name to the exec address 434 String raw_url = Configuration. exec_address.toString() + Configuration.getServletPath() + command;445 String raw_url = Configuration.library_url.toString() + Configuration.getServletPath() + command; 435 446 URL url = new URL(raw_url); 436 447 DebugStream.println("Action: " + raw_url); … … 502 513 } 503 514 515 504 516 /** Prints a warning message about a missing library path, which means the final collection cannot be previewed in the Gatherer. 505 517 */ … … 511 523 message_name = "warning.MissingEXEC"; 512 524 } 513 WarningDialog dialog = new WarningDialog(message_name, "general. exec_address", false);525 WarningDialog dialog = new WarningDialog(message_name, "general.library_url", false); 514 526 dialog.setValueField(new URLField(Configuration.getColor("coloring.editable_foreground", false), Configuration.getColor("coloring.editable_background", false), Configuration.getColor("coloring.error_foreground", false), Configuration.getColor("coloring.error_background", false))); 515 527 dialog.display(); … … 517 529 dialog = null; 518 530 519 String library_ path_string = Configuration.getString("general.exec_address", true);520 if (!library_ path_string.equals("")) {531 String library_url_string = Configuration.getString("general.library_url", true); 532 if (!library_url_string.equals("")) { 521 533 try { 522 Configuration.exec_address = new URL(library_path_string); 523 } 524 catch (MalformedURLException error) { 525 ///ystem.err.println("Error: Bad address: " + exec_address_string); 526 } 527 } 528 } 534 Configuration.library_url = new URL(library_url_string); 535 } 536 catch (MalformedURLException exception) { 537 DebugStream.printStackTrace(exception); 538 } 539 } 540 } 541 529 542 530 543 /** Prints a warning message about a missing GSDL path, which although not fatal pretty much ensures nothing will work properly in the Gatherer. … … 609 622 * @param gsdl_path The path to the gsdl directory, gathered from the startup arguments, and presented as a <strong>String</strong>. 610 623 * @param library_url The path to the library executable, gathered from the startup arguments, and presented as a <strong>String</strong>. 611 * @param perl_path The path to the PERL compiler as a <strong>String</strong>. Necessary for windows platform versions.612 * @see java.io.FileInputStream613 * @see java.io.ObjectInputStream614 * @see java.lang.Exception615 624 * @see org.greenstone.gatherer.Configuration 616 625 */ 617 private void loadConfig(String gsdl_path, String gsdl3_path, String library_url, String perl_path, Stringsite_name) {626 private void loadConfig(String gsdl_path, String gsdl3_path, String site_name) { 618 627 try { 619 new Configuration(gsdl_path, gsdl3_path, library_url, perl_path,site_name);628 new Configuration(gsdl_path, gsdl3_path, site_name); 620 629 } 621 630 catch (Exception error) { -
trunk/gli/src/org/greenstone/gatherer/LocalLibraryServer.java
r8624 r8627 60 60 { 61 61 try { 62 URL url = new URL(Configuration. exec_address.toString() + command);62 URL url = new URL(Configuration.library_url.toString() + command); 63 63 HttpURLConnection library_connection = (HttpURLConnection) url.openConnection(); 64 64 int response_code = library_connection.getResponseCode(); … … 110 110 // If it is already running then set the Greenstone web server address and we're done 111 111 try { 112 Configuration. exec_address= new URL(url);112 Configuration.library_url = new URL(url); 113 113 running = true; 114 114 return; … … 146 146 // Ta-da. Now the url should be available 147 147 try { 148 Configuration. exec_address= new URL(gsdlsite_cfg_file.getURL());148 Configuration.library_url = new URL(gsdlsite_cfg_file.getURL()); 149 149 } 150 150 catch (MalformedURLException exception) { … … 154 154 // A quick test involves opening a connection to get the home page for this collection 155 155 try { 156 DebugStream.println("Try connecting to server on config url: '" + Configuration. exec_address+ "'");157 URLConnection connection = Configuration. exec_address.openConnection();156 DebugStream.println("Try connecting to server on config url: '" + Configuration.library_url+ "'"); 157 URLConnection connection = Configuration.library_url.openConnection(); 158 158 connection.getContent(); 159 159 } … … 161 161 try { 162 162 // If this fails then we try changing the url to be localhost 163 Configuration. exec_address= new URL(gsdlsite_cfg_file.getLocalHostURL());164 DebugStream.println("Try connecting to server on local host: '" + Configuration. exec_address+ "'");165 URLConnection connection = Configuration. exec_address.openConnection();163 Configuration.library_url = new URL(gsdlsite_cfg_file.getLocalHostURL()); 164 DebugStream.println("Try connecting to server on local host: '" + Configuration.library_url + "'"); 165 URLConnection connection = Configuration.library_url.openConnection(); 166 166 connection.getContent(); 167 167 } 168 168 catch (IOException worse_url_connection) { 169 169 DebugStream.println("Can't connect to server on either address."); 170 Configuration. exec_address= null;170 Configuration.library_url = null; 171 171 return; 172 172 } -
trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java
r8626 r8627 189 189 // Load configuration file 190 190 try { 191 192 config = new Configuration(go.gsdl_path, null, null, go.perl_path, null); 191 config = new Configuration(go.gsdl_path, null, null); 193 192 } 194 193 catch (Exception exception) { -
trunk/gli/src/org/greenstone/gatherer/gems/GEMSPreferences.java
r8601 r8627 423 423 Configuration.setPreviewCommand(program_str); 424 424 425 String library_path_string = library_path_field.getText();426 Configuration.setString("general.exec_address", true, library_path_string);427 if (!library_path_string.equals("")) {428 try {429 Configuration.exec_address = new URL(library_path_string);430 }431 catch (MalformedURLException error) {432 ///ystem.err.println("Error: Bad address: " + exec_address_string);433 }434 }435 425 boolean site_changed = false; 436 426 if (Gatherer.GS3) { -
trunk/gli/src/org/greenstone/gatherer/gui/CreatePane.java
r8590 r8627 544 544 545 545 // now do the preview stuff 546 if (!Gatherer.c_man.built() || Configuration. exec_address== null) {546 if (!Gatherer.c_man.built() || Configuration.library_url == null) { 547 547 preview_button.setEnabled(false); 548 548 simple_preview_button.setEnabled(false); … … 577 577 // Remember to add unique timestamp 578 578 if (Gatherer.GS3) { 579 homepage = Configuration. exec_address.toString() + Configuration.getServletPath()+ "?a=p&sa=about&c=" + current_collection.getName()+"&l="+Configuration.getLanguage(); //+extra_args + StaticStrings.TIMESTAMP_ARGUMENT + System.currentTimeMillis();579 homepage = Configuration.library_url.toString() + Configuration.getServletPath()+ "?a=p&sa=about&c=" + current_collection.getName()+"&l="+Configuration.getLanguage(); //+extra_args + StaticStrings.TIMESTAMP_ARGUMENT + System.currentTimeMillis(); 580 580 } else { 581 homepage = Configuration. exec_address.toString() + "?a=p&p=about&c=" + current_collection.getName()+"&l="+Configuration.getLanguage()+extra_args + StaticStrings.TIMESTAMP_ARGUMENT + System.currentTimeMillis();581 homepage = Configuration.library_url.toString() + "?a=p&p=about&c=" + current_collection.getName()+"&l="+Configuration.getLanguage()+extra_args + StaticStrings.TIMESTAMP_ARGUMENT + System.currentTimeMillis(); 582 582 } 583 583 } -
trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java
r8601 r8627 35 35 import javax.swing.event.*; 36 36 import org.greenstone.gatherer.Configuration; 37 import org.greenstone.gatherer.DebugStream; 37 38 import org.greenstone.gatherer.Dictionary; 38 39 import org.greenstone.gatherer.Gatherer; … … 190 191 library_path_label = new JLabel(); 191 192 library_path_label.setPreferredSize(LABEL_SIZE); 192 library_path_field = new JTextField(Configuration. getString("general.exec_address", true));193 library_path_field = new JTextField(Configuration.library_url.toString()); 193 194 library_path_field.setCaretPosition(0); 194 195 if (Gatherer.GS3) { … … 608 609 Configuration.setPreviewCommand(program_str); 609 610 610 String library_path_string = library_path_field.getText(); 611 Configuration.setString("general.exec_address", true, library_path_string); 612 if (!library_path_string.equals("")) { 611 String library_url_string = library_path_field.getText(); 612 if (!library_url_string.equals("")) { 613 613 try { 614 Configuration.exec_address = new URL(library_path_string); 614 Configuration.library_url = new URL(library_url_string); 615 // Configuration.setString("general.library_url", true, library_url_string); 615 616 } 616 catch (MalformedURLException e rror) {617 ///ystem.err.println("Error: Bad address: " + exec_address_string);617 catch (MalformedURLException exception) { 618 DebugStream.printStackTrace(exception); 618 619 } 619 620 }
Note:
See TracChangeset
for help on using the changeset viewer.