Changeset 8232
- Timestamp:
- 2004-10-07T16:56:41+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/Gatherer.java
r8231 r8232 96 96 /** A public reference to the CollectionManager. */ 97 97 static public CollectionManager c_man; 98 /** A public reference to the Gatherer's configuration. */99 static public Configuration config;100 98 /** a reference to the Servlet Configuration is GS3 */ 101 99 static public ServletConfiguration servlet_config; … … 213 211 // now set the user specified one 214 212 if (feedback_enabled && feedback_dialog != null) { 215 feedback_dialog.setLocale( config.getLocale("general.locale", true));213 feedback_dialog.setLocale(Configuration.getLocale("general.locale", true)); 216 214 } 217 215 218 216 // Read Dictionary 219 dictionary = new Dictionary( config.getLocale("general.locale", true), config.getFont("general.font", true));217 dictionary = new Dictionary(Configuration.getLocale("general.locale", true), Configuration.getFont("general.font", true)); 220 218 221 219 … … 225 223 226 224 // If we were given a server run it if neccessary. 227 if (!GS3 && config.exec_file != null) {225 if (!GS3 && Configuration.exec_file != null) { 228 226 startServerEXE(); 229 227 } 230 228 231 229 // 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. 232 if (config.exec_file == null && config.exec_address == null) { 233 if (config.exec_file == null) { 234 Gatherer.println("config.exec_file is null"); 235 } 236 if (config.exec_address == null) { 237 Gatherer.println("config.exec_address is null"); 238 } 230 if (Configuration.exec_file == null && Configuration.exec_address == null) { 231 Gatherer.println("config.exec_file is null"); 232 Gatherer.println("config.exec_address is null"); 239 233 missingEXEC(); 240 234 } … … 247 241 // start the Gatherer without providing a perl path 248 242 boolean found_perl = false; 249 if ( config.perl_path != null) {243 if (Configuration.perl_path != null) { 250 244 // See if the file pointed to actually exists 251 File perl_file = new File( config.perl_path);245 File perl_file = new File(Configuration.perl_path); 252 246 found_perl = perl_file.exists(); 253 247 perl_file = null; 254 248 } 255 if ( config.perl_path == null || !found_perl) {249 if (Configuration.perl_path == null || !found_perl) { 256 250 // Run test to see if we can run perl as is. 257 251 PerlTest perl_test = new PerlTest(); … … 259 253 // If so replace the perl path with the system 260 254 // default (or null for unix). 261 config.perl_path = perl_test.toString();255 Configuration.perl_path = perl_test.toString(); 262 256 found_perl = true; 263 257 } … … 270 264 271 265 // also check for wget 272 boolean mirror_workflow = config.get(StaticStrings.WORKFLOW_MIRROR, false);266 boolean mirror_workflow = Configuration.get(StaticStrings.WORKFLOW_MIRROR, false); 273 267 if (mirror_workflow) { 274 268 wget_version_str = StaticStrings.NO_WGET_STR; … … 305 299 306 300 // tell the config the new values 307 config.setWGetPath(wget_path);308 config.setWGetVersion(wget_version_str);301 Configuration.setWGetPath(wget_path); 302 Configuration.setWGetVersion(wget_version_str); 309 303 } 310 304 311 305 // Set default font 312 setUIFont( config.getFont("general.font", true), config.getFont("general.tooltip_font", true));306 setUIFont(Configuration.getFont("general.font", true), Configuration.getFont("general.tooltip_font", true)); 313 307 // Set up proxy 314 308 setProxy(); … … 324 318 if (GS3) { 325 319 if (site_name==null) { 326 site_name = config.site_name;320 site_name = Configuration.site_name; 327 321 servlet_path = null; // need to reset this 328 322 } 329 323 if (servlet_path == null) { 330 servlet_path = config.getServletPath();324 servlet_path = Configuration.getServletPath(); 331 325 } 332 326 } … … 334 328 // If there was an open collection last session, reopen it. 335 329 if (open_collection == null) { 336 open_collection = config.getString("general.open_collection", true);330 open_collection = Configuration.getString("general.open_collection", true); 337 331 } 338 332 if (!no_load && open_collection.length() > 0) { … … 356 350 { 357 351 // Size and place the frame on the screen 358 Rectangle bounds = config.getBounds("general.bounds", true);352 Rectangle bounds = Configuration.getBounds("general.bounds", true); 359 353 if (bounds == null) { 360 354 // Choose a sensible default value … … 367 361 size.width = 640; 368 362 } 369 else if (size.width > config.screen_size.width) {370 size.width = config.screen_size.width;363 else if (size.width > Configuration.screen_size.width) { 364 size.width = Configuration.screen_size.width; 371 365 } 372 366 if (size.height < 480) { 373 367 size.height = 480; 374 368 } 375 else if (size.height > config.screen_size.height) {376 size.height = config.screen_size.height;369 else if (size.height > Configuration.screen_size.height) { 370 size.height = Configuration.screen_size.height; 377 371 } 378 372 … … 429 423 exit = true; 430 424 // If we have an open collection make note of it. 431 config.setString("general.open_collection", true, null);425 Configuration.setString("general.open_collection", true, null); 432 426 if(c_man.ready()) { 433 427 ///ystem.err.println("Collection open."); 434 428 if(c_man.saved()) { 435 429 ///ystem.err.println("Collection has been recently saved, so I'll remember it for next time."); 436 config.setString("general.open_collection", true, c_man.getCollectionFilename());430 Configuration.setString("general.open_collection", true, c_man.getCollectionFilename()); 437 431 } 438 432 c_man.closeCollection(); … … 445 439 // Store the current position and size (if reasonable) of the Gatherer for next time 446 440 Rectangle bounds = g_man.getBounds(); 447 config.setBounds("general.bounds", true, bounds);441 Configuration.setBounds("general.bounds", true, bounds); 448 442 449 443 // Save configuration. … … 493 487 { 494 488 try { 495 String raw_url = config.exec_address.toString() + command;489 String raw_url = Configuration.exec_address.toString() + command; 496 490 URL url = new URL(raw_url); 497 491 Gatherer.println("Action: " + raw_url); … … 517 511 try { 518 512 // need to add the servlet name to the exec address 519 String raw_url = config.exec_address.toString() + config.getServletPath() + command;513 String raw_url = Configuration.exec_address.toString() + Configuration.getServletPath() + command; 520 514 URL url = new URL(raw_url); 521 515 Gatherer.println("Action: " + raw_url); … … 723 717 private void loadConfig(String gsdl_path, String gsdl3_path, String exec_path, String perl_path, boolean mirroring_enabled, String site_name) { 724 718 try { 725 config =new Configuration(gsdl_path, gsdl3_path, exec_path, perl_path, mirroring_enabled, site_name);719 new Configuration(gsdl_path, gsdl3_path, exec_path, perl_path, mirroring_enabled, site_name); 726 720 } 727 721 catch (Exception error) { … … 741 735 private void saveConfig() { 742 736 try { 743 config.save();737 Configuration.save(); 744 738 } catch (Exception error) { 745 739 Gatherer.printStackTrace(error); … … 748 742 749 743 private void startServerEXE() { 750 if( config.exec_file != null && config.exec_address == null && Utility.isWindows() && !GS3) {744 if(Configuration.exec_file != null && Configuration.exec_address == null && Utility.isWindows() && !GS3) { 751 745 // First of all we create a GSDLSiteCFG object and check if a URL is already present, in which case the server is already running. 752 gsdlsite_cfg = new GSDLSiteConfig( config.exec_file);746 gsdlsite_cfg = new GSDLSiteConfig(Configuration.exec_file); 753 747 String url = gsdlsite_cfg.getURL(); 754 748 // If its already running then set exec address. 755 749 if(url != null) { 756 750 try { 757 config.exec_address = new URL(url);751 Configuration.exec_address = new URL(url); 758 752 } 759 753 catch(Exception error) { … … 761 755 } 762 756 // Otherwise its time to run the server in a spawned process. 763 if( config.exec_address == null && config.exec_file.exists()) {757 if(Configuration.exec_address == null && Configuration.exec_file.exists()) { 764 758 // Configure for immediate entry. Note that this only works if the gsdlsite.cfg file exists. 765 759 gsdlsite_cfg.set(); 766 760 // Spawn server 767 String command = config.exec_file.getAbsolutePath() + " " + gsdlsite_cfg.getSiteConfigFilename();761 String command = Configuration.exec_file.getAbsolutePath() + " " + gsdlsite_cfg.getSiteConfigFilename(); 768 762 server = new ExternalApplication(command); 769 763 server.start(); … … 793 787 if((url = gsdlsite_cfg.getURL()) != null) { 794 788 // Ta-da. Now the url should be available. 795 config.exec_address = new URL(url);789 Configuration.exec_address = new URL(url); 796 790 797 791 // A quick test involves opening a connection to get the home page for this collection. If this fails then we try changing the url to be localhost. 798 792 try { 799 Gatherer.println("Try connecting to server on config url: '" + config.exec_address + "'");800 URLConnection connection = config.exec_address.openConnection();793 Gatherer.println("Try connecting to server on config url: '" + Configuration.exec_address + "'"); 794 URLConnection connection = Configuration.exec_address.openConnection(); 801 795 connection.getContent(); 802 796 } … … 804 798 try { 805 799 Gatherer.println("Try connecting to server on local host: '" + gsdlsite_cfg.getLocalHostURL() + "'"); 806 config.exec_address = new URL(gsdlsite_cfg.getLocalHostURL ());807 URLConnection connection = config.exec_address.openConnection();800 Configuration.exec_address = new URL(gsdlsite_cfg.getLocalHostURL ()); 801 URLConnection connection = Configuration.exec_address.openConnection(); 808 802 connection.getContent(); 809 803 } 810 804 catch(IOException worse_url_connection) { 811 805 Gatherer.println("Can't connect to server on either address."); 812 config.exec_address = null;813 config.exec_file = null;806 Configuration.exec_address = null; 807 Configuration.exec_file = null; 814 808 } 815 809 } … … 826 820 // Can't do a damb thing. 827 821 } 828 Gatherer.println("Having started server.exe, exec_address is: " + config.exec_address);822 Gatherer.println("Having started server.exe, exec_address is: " + Configuration.exec_address); 829 823 } 830 824 831 825 private void stopServerEXE() { 832 if(server != null && config.exec_address != null) {826 if(server != null && Configuration.exec_address != null) { 833 827 // See if its already exited for some reason. 834 828 gsdlsite_cfg.load();
Note:
See TracChangeset
for help on using the changeset viewer.