Changeset 7326
- Timestamp:
- 2004-05-13T17:08:42+12:00 (20 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 1 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/Configuration.java
r7182 r7326 68 68 /** The name of the general Gatherer configuration file. */ 69 69 static final private String CONFIG_XML = "config.xml"; 70 /** The name of the general Gatherer configuration file for running with GS3. */ 71 static final private String GS3_CONFIG_XML = "config3.xml"; 70 72 71 73 static final private String CURRENT_CONFIGURATION_VERSION = "2.50"; … … 98 100 /** The path to the Greenstone Suite installation directory. */ 99 101 public String gsdl_path = ""; 102 /** If we are using GLI in Greenstone 3, the path to gsdl3 directory */ 103 public String gsdl3_path = ""; 100 104 /** The path to the PERL executable, up to and including Perl.exe. */ 101 105 public String perl_path = ""; … … 106 110 /** The screen size of the desktop the Gatherer will be displayed on. */ 107 111 public Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize(); 108 112 /** The site name if we are using GS3 */ 113 public String site_name = ""; 114 /** The servlet path if we are using GS3 */ 115 private String servlet_path = ""; 109 116 /** If true, overrides the mirroring enabled setting in the config.xml file. */ 110 117 private boolean mirroring_enabled = false; … … 130 137 * @param perl_path The path to the PERL executable, as a <strong>String</strong>. 131 138 */ 132 public Configuration(String gsdl_path, String exec_path, String perl_path, boolean mirroring_enabled, String wget_version_str, String wget_path) {139 public Configuration(String gsdl_path, String gsdl3_path, String exec_path, String perl_path, boolean mirroring_enabled, String wget_version_str, String wget_path, String site_name) { 133 140 super(); 134 141 this.gsdl_path = gsdl_path; 142 this.gsdl3_path = gsdl3_path; 135 143 this.exec_path = exec_path; 136 144 this.mirroring_enabled = mirroring_enabled; 137 145 this.wget_version_str = wget_version_str; 138 146 this.wget_path = wget_path; 147 this.site_name = site_name; 139 148 140 149 // The exec_path may contain an url address, in which case we blindly use that and leave it up to the user to worry about settings and resetting. … … 164 173 // All sorts of errors might be thrown by a bogus file path. 165 174 catch (Exception error) { 166 Gatherer.println("Lib rary url does not indicate the server.exe file.");175 Gatherer.println("Libary url does not indicate the server.exe file."); 167 176 ///atherer.printStackTrace(error); 168 177 } … … 193 202 194 203 // Try to reload the configuration. The first place we look is the user specific location 195 File config_xml = new File(Utility.getGLIUserFolder(), CONFIG_XML); 204 String config_xml_name = CONFIG_XML; 205 if (gsdl3_path != null) { 206 config_xml_name = GS3_CONFIG_XML; 207 } 208 File config_xml = new File(Utility.getGLIUserFolder(), config_xml_name); 196 209 if(config_xml != null && config_xml.exists()) { 197 210 general_config = Utility.parse(config_xml.getAbsolutePath(), false); … … 200 213 // We then try within the gli directory itself 201 214 if(general_config == null) { 202 config_xml = new File( CONFIG_XML);215 config_xml = new File(config_xml_name); 203 216 if(config_xml.exists()) { 204 general_config = Utility.parse( CONFIG_XML, false);217 general_config = Utility.parse(config_xml_name, false); 205 218 } 206 219 } … … 253 266 } 254 267 268 if (Gatherer.GS3) { 269 if (this.site_name == null || this.site_name.equals("")) { 270 this.site_name = getString("general.site_name", true); 271 this.servlet_path = getString("general.servlet_path", true); 272 if (this.site_name.equals("")) { 273 this.site_name = "localsite"; // can we assume these?? 274 this.servlet_path = "/library"; 275 setString("general.site_name", true, this.site_name); 276 setString("general.servlet_path", true, this.servlet_path); 277 } 278 279 } else { 280 // we set the current one in the config 281 setString("general.site_name", true, this.site_name); 282 if (this.servlet_path != null && !this.servlet_path.equals("")) { 283 setString("general.servlet_path", true, this.servlet_path); 284 } 285 } 286 } 255 287 Gatherer.println("EXEC_FILE = " + exec_file); 256 288 Gatherer.println("EXEC_ADDRESS = " + exec_address); … … 569 601 } 570 602 603 public String getServletPath() { 604 if (servlet_path == null) { 605 servlet_path = Gatherer.servlet_config.getServletPath(site_name); 606 } 607 return servlet_path; 608 } 571 609 /** Retrieve the value of the named property, and noting whether we consult the general or collection specific configuration. */ 572 610 public String getString(String property, boolean general) { … … 626 664 } 627 665 666 public String getGS3ScriptPath() { 667 return gsdl3_path + "bin" + File.separator + "script" + File.separator; 668 } 669 628 670 629 671 public String getWGetPath() { … … 667 709 // We first try exporting to a user specific place 668 710 File user_config_xml = null; 669 try { 670 user_config_xml = new File(Utility.getGLIUserFolder(), CONFIG_XML); 711 String config_xml_name = CONFIG_XML; 712 if (gsdl3_path!=null) { 713 config_xml_name = GS3_CONFIG_XML; 714 } 715 try { 716 user_config_xml = new File(Utility.getGLIUserFolder(), config_xml_name); 671 717 ///ystem.err.println("Trying to save to: " + user_config_xml.getAbsolutePath()); 672 718 ///ystem.err.println("Writing."); … … 680 726 if(user_config_xml == null || !user_config_xml.exists()) { 681 727 // But failing that we produce a general copy 682 Utility.export(general_config, Utility.BASE_DIR + CONFIG_XML);728 Utility.export(general_config, Utility.BASE_DIR + config_xml_name); 683 729 } 684 730 } … … 830 876 } 831 877 878 public void setSiteAndServlet(String site, String servlet) { 879 this.site_name = site; 880 this.servlet_path = servlet; 881 setString("general.site_name", GENERAL_SETTING, site); 882 setString("general.servlet_path", GENERAL_SETTING, servlet); 883 884 } 832 885 /** Sets the value of the named property argument using the given string. */ 833 886 public void setString(String property, boolean general, String value) { … … 928 981 pane.updateUI(); 929 982 // Also update all of the tabs according to workflow. 930 Gatherer.g_man.workflowUpdate("Hunt", get("workflow.browse", false));983 //Gatherer.g_man.workflowUpdate("Hunt", get("workflow.browse", false)); 931 984 Gatherer.g_man.workflowUpdate("Mirror", get("workflow.mirror", false)); 932 985 Gatherer.g_man.workflowUpdate("Gather", get("workflow.gather", false)); … … 935 988 Gatherer.g_man.workflowUpdate("Export", get("workflow.export", false)); 936 989 Gatherer.g_man.workflowUpdate("Create", get("workflow.create", false)); 937 Gatherer.g_man.workflowUpdate("Preview", get("workflow.preview", false));990 //Gatherer.g_man.workflowUpdate("Preview", get("workflow.preview", false)); 938 991 } 939 992 } -
trunk/gli/src/org/greenstone/gatherer/Gatherer.java
r7314 r7326 111 111 /** A public reference to the Gatherer's configuration. */ 112 112 static public Configuration config; 113 /** a reference to the Servlet Configuration is GS3 */ 114 static public ServletConfiguration servlet_config; 113 115 /** The current modal dialog being shown on screen, if any. */ 114 116 static public ModalDialog current_modal = null; … … 123 125 /** The debug print stream. */ 124 126 static public PrintStream debug; 127 /** We are using the GLI for GS3 */ 128 static public boolean GS3 = false; 125 129 /** The name of the necessary environment variable to check for in the programs environment. */ 126 130 static public String KEY = "GSDLPATH"; … … 153 157 * @param size The desired size of the Gatherer window as a <strong>Dimension</strong>. 154 158 * @param gsdl_path The path to the gsdl directory, gathered from the startup arguments, and presented as a <strong>String</strong>. 159 * @param gsdl3_path The path to the gsdl3 directory, gathered from the startup arguments, and presented as a <strong>String</strong>. 155 160 * @param exec_path The path to the library executable, gathered from the startup arguments, and presented as a <strong>String</strong>. 156 161 * @param debug_enabled <i>true</i> to print verbose debug messages to "debug.txt", <i>false</i> otherwise. … … 176 181 * @see org.greenstone.gatherer.gui.Splash 177 182 */ 178 public void run(Dimension size, String gsdl_path, String exec_path, boolean debug_enabled, String perl_path, boolean no_load, Splash splash, String open_collection, boolean mirroring_enabled, String wget_version_str, String wget_path) {183 public void run(Dimension size, String gsdl_path, String gsdl3_path, String exec_path, boolean debug_enabled, String perl_path, boolean no_load, Splash splash, String open_collection, String site_name, String servlet_path, boolean mirroring_enabled, String wget_version_str, String wget_path) { 179 184 180 185 // This will hopefully catch ctrl-c and terminate, and exit gracefully. However it is platform specific, and may not be supported by some JVMs. … … 185 190 handler = null; 186 191 */ 192 193 if (gsdl3_path != null && !gsdl3_path.equals("")) { 194 this.GS3 = true; 195 } else { 196 gsdl3_path = null; 197 } 187 198 // Create the debug stream only if required. 188 199 if(debug_enabled) { … … 210 221 try { 211 222 // Load Config 212 loadConfig(gsdl_path, exec_path, perl_path, mirroring_enabled, wget_version_str, wget_path);223 loadConfig(gsdl_path, gsdl3_path, exec_path, perl_path, mirroring_enabled, wget_version_str, wget_path, site_name); 213 224 214 225 // the feedback dialog has been loaded with a default locale, … … 223 234 224 235 if (gsdl_path == null) { 225 missingGSDL( dictionary);236 missingGSDL(); 226 237 } 227 238 228 239 // If we were given a server run it if neccessary. 229 if ( config.exec_file != null) {240 if (!GS3 && config.exec_file != null) { 230 241 startServerEXE(); 231 242 } … … 239 250 Gatherer.println("config.exec_address is null"); 240 251 } 241 missingEXEC( dictionary);252 missingEXEC(); 242 253 } 243 254 … … 261 272 if (!found_perl) { 262 273 // Time for an error message. 263 missingPERL( dictionary);274 missingPERL(); 264 275 } 265 276 … … 298 309 c_man = new CollectionManager(); 299 310 // If there was an open collection last session, reopen it. 311 312 if (GS3) { 313 if (site_name==null) { 314 site_name = config.site_name; 315 servlet_path = null; // need to reset this 316 } 317 if (servlet_path == null) { 318 servlet_path = config.getServletPath(); 319 } 320 } 300 321 if(open_collection == null) { 301 322 open_collection = config.getString("general.open_collection", true); … … 351 372 // If we have an open collection make note of it. 352 373 config.setString("general.open_collection", true, null); 374 config.setString("general.site_name", true, null); 353 375 if(c_man.ready()) { 354 376 ///ystem.err.println("Collection open."); … … 390 412 391 413 // If we started a server, we should try to stop it. 392 if( gsdlsite_cfg != null) {414 if(!GS3 && gsdlsite_cfg != null) { 393 415 stopServerEXE(); 394 416 } … … 425 447 } 426 448 449 } 450 451 // used to send reload coll messages to the tomcat server 452 public void configGS3Server(String site, String command) { 453 454 try { 455 // need to add the servlet name to the exec address 456 String raw_url = config.exec_address.toString() + config.getServletPath() + command; 457 URL url = new URL(raw_url); 458 Gatherer.println("Action: " + raw_url); 459 HttpURLConnection library_connection = (HttpURLConnection) url.openConnection(); 460 int response_code = library_connection.getResponseCode(); 461 if(HttpURLConnection.HTTP_OK <= response_code && response_code < HttpURLConnection.HTTP_MULT_CHOICE) { 462 Gatherer.println("200 - Complete."); 463 } 464 else { 465 Gatherer.println("404 - Failed."); 466 } 467 url = null; 468 } 469 catch(Exception exception) { 470 Gatherer.printStackTrace(exception); 471 ///ystem.err.println("Bad URL."); 472 } 427 473 } 428 474 … … 528 574 String filename = null; 529 575 String gsdl_path = null; 576 String gsdl3_path = null; 530 577 String perl_path = null; 578 String site_name = null; // for GS3 579 String servlet_path = null; 531 580 String wget_path = null; 532 581 String wget_version_str = StaticStrings.NO_WGET_STR; … … 621 670 gsdl_path = argument_value + File.separator; 622 671 } 672 } 673 // GSDL3 path 674 if(argument_name.equals(StaticStrings.GSDL3_ARGUMENT)) { 675 if(argument_value.endsWith(File.separator)) { 676 gsdl3_path = argument_value; 677 } 678 else { 679 gsdl3_path = argument_value + File.separator; 680 } 681 } 682 else if (argument_name.equals(StaticStrings.SITE_ARGUMENT)) { 683 site_name = argument_value; 684 } 685 else if (argument_name.equals(StaticStrings.SERVLET_ARGUMENT)) { 686 servlet_path = argument_value; 623 687 } 624 688 // Specify a collection to load initially. Could be used for file associations. … … 690 754 Splash splash = new Splash(); 691 755 // dictionary.destroy(); 692 gatherer.run(size, gsdl_path, exec_path, debug, perl_path, no_load, splash, filename, mirroring_enabled, wget_version_str, wget_path);756 gatherer.run(size, gsdl_path, gsdl3_path, exec_path, debug, perl_path, no_load, splash, filename, site_name, servlet_path, mirroring_enabled, wget_version_str, wget_path); 693 757 } 694 758 695 759 /** Prints a warning message about a missing library path, which means the final collection cannot be previewed in the Gatherer. 696 760 */ 697 static public void missingEXEC( Dictionary dictionary) {761 static public void missingEXEC() { 698 762 WarningDialog dialog = new WarningDialog("warning.MissingEXEC", "general.exec_address"); 699 763 dialog.setValueField(new URLField(Gatherer.config.getColor("coloring.editable_foreground", false), Gatherer.config.getColor("coloring.editable_background", false), Gatherer.config.getColor("coloring.error_foreground", false), Gatherer.config.getColor("coloring.error_background", false))); … … 711 775 } 712 776 } 713 714 ///ystem.out.println(Dictionary.get("General.Missing_EXEC")); 715 } 777 } 716 778 717 779 /** Prints a warning message about a missing GSDL path, which although not fatal pretty much ensures nothing will work properly in the Gatherer. 718 780 */ 719 static public void missingGSDL( Dictionary dictionary) {781 static public void missingGSDL() { 720 782 WarningDialog dialog = new WarningDialog("warning.MissingGSDL", false); 721 783 dialog.display(); 722 784 dialog.dispose(); 723 785 dialog = null; 724 ///ystem.out.println(Dictionary.get("General.Missing_GSDL")); 725 } 786 } 726 787 727 788 /** Prints a warning message about a missing PERL path, which although not fatal pretty much ensures no collection creation/building will work properly in the Gatherer. */ 728 static public void missingPERL( Dictionary dictionary) {789 static public void missingPERL() { 729 790 WarningDialog dialog = new WarningDialog("warning.MissingPERL", false); 730 791 dialog.display(); 731 792 dialog.dispose(); 732 793 dialog = null; 733 ///ystem.out.println(Dictionary.get("General.Missing_PERL"));734 794 } 735 795 … … 819 879 * @see org.greenstone.gatherer.Configuration 820 880 */ 821 private void loadConfig(String gsdl_path, String exec_path, String perl_path, boolean mirroring_enabled, String wget_version_str, String wget_path) {881 private void loadConfig(String gsdl_path, String gsdl3_path, String exec_path, String perl_path, boolean mirroring_enabled, String wget_version_str, String wget_path, String site_name) { 822 882 try { 823 config = new Configuration(gsdl_path, exec_path, perl_path, mirroring_enabled, wget_version_str, wget_path);883 config = new Configuration(gsdl_path, gsdl3_path, exec_path, perl_path, mirroring_enabled, wget_version_str, wget_path, site_name); 824 884 } 825 885 catch (Exception error) { … … 827 887 Gatherer.printStackTrace(error); 828 888 } 889 if (GS3) { 890 try { 891 servlet_config = new ServletConfiguration(gsdl3_path); 892 } catch (Exception error) { 893 error.printStackTrace(); 894 } 895 } 896 829 897 } 830 898 … … 839 907 840 908 private void startServerEXE() { 841 if(config.exec_file != null && config.exec_address == null && Utility.isWindows() ) {909 if(config.exec_file != null && config.exec_address == null && Utility.isWindows() && !GS3) { 842 910 // First of all we create a GSDLSiteCFG object and check if a URL is already present, in which case the server is already running. 843 911 gsdlsite_cfg = new GSDLSiteConfig(config.exec_file); … … 908 976 // Unable to start local library. Show appropriate message. 909 977 else { 910 missingEXEC( dictionary);978 missingEXEC(); 911 979 } 912 980 } -
trunk/gli/src/org/greenstone/gatherer/cdm/SuperCollectionManager.java
r7275 r7326 191 191 // We start by building a model of the installed collections. 192 192 collection_checklist_model = new ArrayList(); 193 File gsdl_collection_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl_path)); 193 File gsdl_collection_directory; 194 if (Gatherer.GS3) { 195 gsdl_collection_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name)); 196 } else { 197 gsdl_collection_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl_path)); 198 } 194 199 current_coll_name = Gatherer.c_man.getCollection().getName(); 195 200 File[] possible_collections = gsdl_collection_directory.listFiles(); -
trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java
r7281 r7326 46 46 import org.greenstone.gatherer.Dictionary; 47 47 import org.greenstone.gatherer.Gatherer; 48 import org.greenstone.gatherer.ServletConfiguration; 48 49 import org.greenstone.gatherer.cdm.CollectionDesignManager; 49 50 import org.greenstone.gatherer.cdm.CollectionMeta; … … 153 154 building = true; 154 155 String lang = Gatherer.config.getLanguage(); 156 String collect_dir = getCollectDirectory(); 157 155 158 String args[]; 156 159 if(Utility.isWindows()) { 157 args = new String[ 7];160 args = new String[9]; 158 161 args[0] = Gatherer.config.perl_path; 159 162 args[1] = "-S"; … … 162 165 args[4] = "-language"; 163 166 args[5] = lang; 164 args[6] = collection.getName(); 167 args[6] = "-collectdir"; 168 args[7] = collect_dir; 169 args[8] = collection.getName(); 165 170 } 166 171 else { 167 args = new String[ 5];172 args = new String[7]; 168 173 args[0] = Gatherer.config.getScriptPath() + "buildcol.pl"; 169 174 args[1] = "-gli"; 170 175 args[2] = "-language"; 171 176 args[3] = lang; 172 args[4] = collection.getName(); 177 args[4] = "-collectdir"; 178 args[5] = collect_dir; 179 args[6] = collection.getName(); 173 180 } 174 181 args = ArrayTools.add(args, collection.build_options.getBuildValues()); … … 214 221 closing_thread = Thread.currentThread(); 215 222 // Remove the lock on this file, then remove the collection. 216 File lock_file = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName()) + LOCK_FILE); 223 String collection_dir; 224 if (Gatherer.GS3) { 225 collection_dir = Utility.getCollectionDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name, collection.getName()); 226 } else { 227 collection_dir = Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName()); 228 229 } 230 File lock_file = new File(collection_dir + LOCK_FILE); 217 231 lock_file.delete(); 218 232 if(lock_file.exists()) { … … 239 253 } 240 254 255 public void convertToGS3Collection() { 256 // Run the mkcol command. 257 String command[]; 258 String collect_dir = getCollectDirectory(); 259 260 if(Utility.isWindows()) { 261 command = new String[6]; 262 command[0] = Gatherer.config.perl_path; 263 command[1] = "-S"; 264 command[2] = Gatherer.config.getGS3ScriptPath() + "convert_coll_from_gs2.pl"; 265 command[3] = "-collectdir"; 266 command[4] = collect_dir; 267 command[5] = collection.getName(); 268 } else { 269 command = new String[4]; 270 command[0] = Gatherer.config.getGS3ScriptPath() + "convert_coll_from_gs2.pl"; 271 command[1] = "-collectdir"; 272 command[2] = collect_dir; 273 command[3] = collection.getName(); 274 } 275 Gatherer.println("running command "+command); 276 GShell process = new GShell(command, GShell.CONVERT, COLLECT, this, null, GShell.GSHELL_CONVERT); 277 process.addGShellListener(this); 278 process.run(); // Don't bother threading this... yet 279 280 } 281 241 282 /** Used to set the current collection to the given collection. Note that this call should -always- be proceeded by a ready call, and if the colection is ready and the saved flag is unset then the user should be prompted to save. Also note that this method creates yet another GShell to run buildcol.pl. 242 283 * @param description a description of the collection as a String … … 256 297 makeCollection(description, email, name, title); 257 298 progress.setProgress(1); 258 String a_dir = Utility.getCollectionDir(Gatherer.config.gsdl_path, name); 259 299 // *******************8 300 String a_dir; 301 if (Gatherer.GS3) { 302 a_dir = Utility.getCollectionDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name, name); 303 } else { 304 a_dir = Utility.getCollectionDir(Gatherer.config.gsdl_path, name); 305 } 260 306 // ACTIVE_DIR/log/ 261 307 File log_dir_temp = new File(Utility.getLogDir(a_dir)+"temp.dat"); … … 490 536 */ 491 537 public String getCollectionArchive() { 492 return Utility.getArchiveDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName())); 538 if (Gatherer.GS3) { 539 return Utility.getArchiveDir(Utility.getCollectionDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name, collection.getName())); 540 } else { 541 return Utility.getArchiveDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName())); 542 } 493 543 } 494 544 /** Constructs the absolute filename of the collection building directory, which should resemble "$GSDLHOME/collect/<col_name>/building/" … … 500 550 */ 501 551 public String getCollectionBuild() { 502 return Utility.getBuildDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName())); 503 } 504 552 if (Gatherer.GS3) { 553 return Utility.getBuildDir(Utility.getCollectionDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name, collection.getName())); 554 } else { 555 return Utility.getBuildDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName())); 556 } 557 } 505 558 /** Constructs the absolute filename of the collection config file, which should resemble "$GSDLHOME/collect/<col_name>/etc/collect.cfg" 506 559 * @return A <strong>String</strong> containing the filename. … … 511 564 */ 512 565 public String getCollectionConfig() { 566 if (Gatherer.GS3) { 567 return Utility.getConfigFile(Utility.getCollectionDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name, collection.getName())); 568 } else { 513 569 return Utility.getConfigFile(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName())); 570 } 514 571 } 515 572 … … 522 579 */ 523 580 public String getCollectionDirectory() { 524 return Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName()); 581 if (Gatherer.GS3) { 582 return Utility.getCollectionDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name, collection.getName()); 583 } else { 584 return Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName()); 585 } 525 586 } 526 587 … … 533 594 */ 534 595 public String getCollectionEtc() { 596 if (Gatherer.GS3) { 597 return Utility.getEtcDir(Utility.getCollectionDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name, collection.getName())); 598 } else { 535 599 return Utility.getEtcDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName())); 600 } 536 601 } 537 602 /** Constructs the absolute filename of the collection file, which should resemble "$GSDLHOME/collect/<col_name>/<col_name>.col" … … 543 608 */ 544 609 public String getCollectionFilename() { 610 if (Gatherer.GS3) { 611 return Utility.getCollectionDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name, collection.getName()) + collection.getName() + ".col"; 612 } else { 545 613 return Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName()) + collection.getName() + ".col"; 614 } 546 615 } 547 616 /** Constructs the absolute filename of the collection images directory, which should resemble "$GSDLHOME/collect/<col_name>/images/" … … 553 622 */ 554 623 public String getCollectionImages() { 624 if (Gatherer.GS3) { 625 return Utility.getImagesDir(Utility.getCollectionDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name, collection.getName())); 626 } else { 555 627 return Utility.getImagesDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName())); 628 } 556 629 } 557 630 /** Constructs the absolute filename of the collection import directory, which should resemble "$GSDLHOME/collect/<col_name>/import/" … … 563 636 */ 564 637 public String getCollectionImport() { 565 return Utility.getImportDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName())); 638 if (Gatherer.GS3) { 639 return Utility.getImportDir(Utility.getCollectionDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name, collection.getName())); 640 } else { 641 return Utility.getImportDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName())); 642 } 566 643 } 567 644 /** Constructs the absolute filename of the collection index directory, which should resemble "$GSDLHOME/collect/<col_name>/index/" … … 573 650 */ 574 651 public String getCollectionIndex() { 575 return Utility.getIndexDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName())); 652 if (Gatherer.GS3) { 653 return Utility.getIndexDir(Utility.getCollectionDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name, collection.getName())); 654 } else { 655 return Utility.getIndexDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName())); 656 } 576 657 } 577 658 /** Constructs the absolute filename of the collection log directory, which should resemble "$GSDLHOME/collect/<col_name>/log/" … … 583 664 */ 584 665 public String getCollectionLog() { 585 return Utility.getLogDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName())); 666 if (Gatherer.GS3) { 667 return Utility.getLogDir(Utility.getCollectionDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name, collection.getName())); 668 } else { 669 return Utility.getLogDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName())); 670 } 586 671 } 587 672 /** Constructs the absolute filename of the collection metadata directory, which should resemble "$GSDLHOME/collect/<col_name>/metadata/" … … 593 678 */ 594 679 public String getCollectionMetadata() { 595 return Utility.getMetadataDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName())); 680 if (Gatherer.GS3) { 681 return Utility.getMetadataDir(Utility.getCollectionDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name, collection.getName())); 682 } else { 683 return Utility.getMetadataDir(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getName())); 684 } 596 685 } 597 686 … … 691 780 } 692 781 693 // Remove erroneous file windows file separator as it causes problems when running import.pl 694 String collection_import = getCollectionImport(); 695 if(collection_import.length() > 2 && collection_import.endsWith("\\")) { 696 collection_import = collection_import.substring(0, collection_import.length() - 1); 697 } 782 String collect_dir = getCollectDirectory(); 783 698 784 String args[]; 699 785 String lang = Gatherer.config.getLanguage(); … … 706 792 args[4] = "-language"; 707 793 args[5] = lang; 708 args[6] = "- importdir";709 args[7] = collect ion_import;794 args[6] = "-collectdir"; 795 args[7] = collect_dir; 710 796 args[8] = collection.getName(); 711 797 } … … 716 802 args[2] = "-language"; 717 803 args[3] = lang; 718 args[4] = "- importdir";719 args[5] = collect ion_import;804 args[4] = "-collectdir"; 805 args[5] = collect_dir; 720 806 args[6] = collection.getName(); 721 807 } 722 collect ion_import= null;808 collect_dir = null; 723 809 args = ArrayTools.add(args, collection.build_options.getImportValues()); 724 810 GShell shell = new GShell(args, GShell.IMPORT, BUILDING, this, import_monitor, GShell.GSHELL_IMPORT); … … 822 908 } 823 909 // Open the collection file 824 collection = new Collection(collection_file);910 this.collection = new Collection(collection_file); 825 911 if (collection.error) { 826 912 collection = null; … … 835 921 msm = collection.msm; // Legacy 836 922 collection.msm.load(); 837 838 923 // if non-gatherer collection, need to add some metadata sets 839 924 if (non_gatherer_collection) { … … 856 941 lci = null; 857 942 } 858 859 943 // Whether the collection is legacy or not, we should now be able to prepare the MetadataXMLFileManager 860 944 collection.gdm = new MetadataXMLFileManager(); … … 872 956 } 873 957 result = true; 874 ///ystem.err.println("Done loadCollection().");875 958 } catch (Exception error) { 876 System.err.println("Exception occurred!");877 error.printStackTrace();878 959 // There is obviously no existing collection present. 879 960 Gatherer.printStackTrace(error); … … 897 978 } 898 979 899 /** I started giving the user the choice of using an existing meta set or creating a new one. The second option being so that they didn't have to add/merge/ignore each element, they could all be added automatically. However, I am not sure where the merge prompt gets called from, and it is not essential, so I am leaving it for now - it shoudl be added back in and finished. [kjdon] */ 980 981 public void makeCollection(String description, String email, String name, String title) { 982 // Encode the description so it is safe to write to shell 983 if(Utility.isWindows()) { 984 description = Codec.transform(description, Codec.TEXT_TO_SHELL_WINDOWS); 985 } 986 else { 987 description = Codec.transform(description, Codec.TEXT_TO_SHELL_UNIX); 988 } 989 String collect_dir = getCollectDirectory(); 990 // Run the mkcol command. 991 String command[]; 992 if(Utility.isWindows()) { 993 if(description == null || title == null) { 994 command = new String[6]; 995 command[0] = Gatherer.config.perl_path; 996 command[1] = "-S"; 997 command[2] = Gatherer.config.getScriptPath() + "mkcol.pl"; 998 command[3] = "-collectdir"; 999 command[4] = collect_dir; 1000 command[5] = name; 1001 } 1002 // Users are no longer required to supply an email 1003 else if(email == null) { 1004 command = new String[10]; 1005 command[0] = Gatherer.config.perl_path; 1006 command[1] = "-S"; 1007 command[2] = Gatherer.config.getScriptPath() + "mkcol.pl"; 1008 command[3] = "-collectdir"; 1009 command[4] = collect_dir; 1010 command[5] = "-title"; 1011 command[6] = title; 1012 command[7] = "-about"; 1013 command[8] = description; 1014 command[9] = name; 1015 } 1016 else { 1017 command = new String[12]; 1018 command[0] = Gatherer.config.perl_path; 1019 command[1] = "-S"; 1020 command[2] = Gatherer.config.getScriptPath() + "mkcol.pl"; 1021 command[3] = "-collectdir"; 1022 command[4] = collect_dir; 1023 command[5] = "-title"; 1024 command[6] = title; 1025 command[7] = "-creator"; 1026 command[8] = email; 1027 command[9] = "-about"; 1028 command[10] = description; 1029 command[11] = name; 1030 } 1031 } 1032 else { 1033 if(description == null || title == null) { 1034 command = new String[4]; 1035 command[0] = "mkcol.pl"; 1036 command[1] = "-collectdir"; 1037 command[2] = collect_dir; 1038 command[3] = name; 1039 } 1040 else if(email == null) { 1041 command = new String[8]; 1042 command[0] = "mkcol.pl"; 1043 command[1] = "-collectdir"; 1044 command[2] = collect_dir; 1045 command[3] = "-title"; 1046 command[4] = title; 1047 command[5] = "-about"; 1048 command[6] = description; 1049 command[7] = name; 1050 } 1051 else { 1052 command = new String[10]; 1053 command[0] = "mkcol.pl"; 1054 command[1] = "-collectdir"; 1055 command[2] = collect_dir; 1056 command[3] = "-title"; 1057 command[4] = title; 1058 command[5] = "-creator"; 1059 command[6] = email; 1060 command[7] = "-about"; 1061 command[8] = description; 1062 command[9] = name; 1063 } 1064 } 1065 GShell process = new GShell(command, GShell.NEW, COLLECT, this, null, GShell.GSHELL_NEW); 1066 process.addGShellListener(this); 1067 process.run(); // Don't bother threading this... yet 1068 1069 } 1070 1071 /** Any implementation of GShellListener must include this method to allow the GShell to send messages to listeners. However in this case the CollectionManager is in no way interested in what the messages are, just the import events which have a specific type and are handled elsewhere. Thus we can safely ignore this event. 1072 * @param event A <strong>GShellEvent</strong> which contains a the message. 1073 */ 1074 public synchronized void message(GShellEvent event) { 1075 } 1076 /** Called whenever the metadata value changes in some way, such as the addition of a new value. We want to mark the collection so that it needs saving again. 1077 * @param event A <strong>MSMEvent</strong> containing details of the event that caused this message to be fired. 1078 * @see org.greenstone.gatherer.collection.Collection 1079 */ 1080 public void metadataChanged(MSMEvent event) { 1081 // Again this change means we need to save the collection again. 1082 collection.setSaved(false); 1083 } 1084 /** This call is fired whenever a process within a GShell created by this class begins. 1085 * @param event A <strong>GShellEvent</strong> containing information about the GShell process. 1086 * @see org.greenstone.gatherer.Gatherer 1087 * @see org.greenstone.gatherer.gui.GUIManager 1088 * @see org.greenstone.gatherer.shell.GShell 1089 */ 1090 public synchronized void processBegun(GShellEvent event) { 1091 Gatherer.println("CollectionManager.processBegun(" + event.getType() + ")"); 1092 ///ystem.err.println("ProcessBegun " + event.getType()); 1093 // If this is one of the types where we wish to lock user control 1094 Gatherer.g_man.lockCollection((event.getType() == GShell.IMPORT), true); 1095 } 1096 /** This call is fired whenever a process within a GShell created by this class ends. 1097 * @param event A <strong>GShellEvent</strong> containing information about the GShell process. 1098 * @see org.greenstone.gatherer.Gatherer 1099 * @see org.greenstone.gatherer.gui.GUIManager 1100 * @see org.greenstone.gatherer.shell.GShell 1101 */ 1102 public synchronized void processComplete(GShellEvent event) { 1103 Gatherer.println("CollectionManager.processComplete(" + event.getType() + ")"); 1104 Gatherer.g_man.lockCollection((event.getType() == GShell.IMPORT), false); 1105 ///ystem.err.println("Recieved process complete event - " + event); 1106 // If we were running an import, now run a build. 1107 if(event.getType() == GShell.IMPORT && event.getStatus() == GShell.OK) { 1108 // Finish import. 1109 collection.setImported(true); 1110 buildCollection(); 1111 } 1112 // If we were running a build, now is when we move files across. 1113 else if(event.getType() == GShell.BUILD && event.getStatus() == GShell.OK) { 1114 if(installCollection()) { 1115 // If we have a local library running (that we know about) then we ask it to add our newly create collection 1116 if(Gatherer.config.exec_file != null) { 1117 Gatherer.self.configServer(GSDLSiteConfig.ADD_COMMAND + collection.getName()); 1118 } else if (Gatherer.GS3) { 1119 convertToGS3Collection(); 1120 Gatherer.self.configGS3Server(Gatherer.config.site_name, ServletConfiguration.ADD_COMMAND + collection.getName()); 1121 } 1122 1123 // Fire a collection changed first to update the preview etc buttons 1124 Gatherer.g_man.collectionChanged(ready()); 1125 1126 // Now display a message dialog saying its all built 1127 WarningDialog collection_built_warning_dialog = new WarningDialog("warning.CollectionBuilt", false); 1128 collection_built_warning_dialog.setMessageOnly(true); // Not a warning 1129 collection_built_warning_dialog.display(); 1130 collection_built_warning_dialog.dispose(); 1131 collection_built_warning_dialog = null; 1132 } 1133 else { 1134 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready_Failed"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE); 1135 Gatherer.g_man.collectionChanged(ready()); 1136 } 1137 } 1138 else if(event.getStatus() == GShell.ERROR || event.getStatus() == GShell.CANCELLED) { 1139 Gatherer.println("There was an error in the gshell:"+ event.getMessage()); 1140 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready_Failed"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE); 1141 Gatherer.g_man.collectionChanged(ready()); 1142 Gatherer.g_man.repaint(); // It appears Java's own dialogs have the same not always painting correct area bug that I suffer from. Well I don't suffer from it personally, but my ModalDialog components do. 1143 } 1144 } 1145 /** Determine if the manager is ready for actions apon its collection. 1146 * @return A <i>boolean</i> which is <i>true</i> to indicate a collection has been loaded and thus the collection is ready for editing, <i>false</i> otherwise. 1147 */ 1148 static public synchronized boolean ready() { 1149 if(collection != null) { 1150 return true; 1151 } 1152 else { 1153 return false; 1154 } 1155 } 1156 1157 public synchronized boolean reallyReady() { 1158 // If the closing thread is non-null we should only allow that thread to see the collection as closed. 1159 if(closing_thread != null) { 1160 // Only the closing thread sees the truth 1161 if(Thread.currentThread() == closing_thread) { 1162 return (collection == null); 1163 } 1164 // All other threads are told a lie. 1165 else { 1166 return true; 1167 } 1168 } 1169 else { 1170 if(collection != null) { 1171 return true; 1172 } 1173 else { 1174 return false; 1175 } 1176 } 1177 } 1178 1179 /** This method associates the collection build monitor with the build monitor created in CreatePane. 1180 * @param monitor A <strong>GShellProgressMonitor</strong> which we will use as the build monitor. 1181 */ 1182 public void registerBuildMonitor(GShellProgressMonitor monitor) { 1183 build_monitor = monitor; 1184 } 1185 /** This method associates the collection import monitor with the import monitor created in CreatePane. 1186 * @param monitor A <strong>GShellProgressMonitor</strong> which we will use as the import monitor. 1187 */ 1188 public void registerImportMonitor(GShellProgressMonitor monitor) { 1189 import_monitor = monitor; 1190 } 1191 /** Remove a previously assigned special directory mapping. 1192 * @param target The <string>FileNode</strong> representing the special directory mapping to remove as a <strong>String</strong>. 1193 * @return The <strong>File</strong> of the mapping removed. 1194 * @see org.greenstone.gatherer.file.FileNode 1195 */ 1196 public File removeDirectoryMapping(FileNode target) { 1197 // Remove from config, remembering file 1198 File file = Gatherer.config.removeDirectoryMapping(target.toString()); 1199 // Update tree. 1200 Gatherer.g_man.gather_pane.refreshWorkspaceTree(WorkspaceTree.MAPPED_DIRECTORIES_CHANGED); 1201 return file; 1202 } 1203 /** Used to check whether all open collections have a 'saved' state. 1204 * @return A <i>boolean</i> which is <i>true</i> if the collection has been saved. 1205 * @see org.greenstone.gatherer.collection.Collection 1206 */ 1207 public boolean saved() { 1208 boolean result = true; 1209 if(collection != null) { 1210 result = collection.getSaved(); 1211 } 1212 return result; 1213 } 1214 /** Saves a collection by serializing it to file. 1215 * @param close_after <i>true</i> to cause the Gatherer to close the collection once save is complete, <i>false</i> otherwise. 1216 * @param exit_after <i>true</i> to cause the Gatherer to exit once save is complete, <i>false</i> otherwise. 1217 * @see org.greenstone.gatherer.Gatherer 1218 * @see org.greenstone.gatherer.gui.GUIManager 1219 * @see org.greenstone.gatherer.collection.Collection 1220 */ 1221 public void saveCollection(boolean close_after, boolean exit_after) { 1222 Gatherer.println("Save collection: " + collection.getName()); 1223 try { 1224 SaveCollectionTask save_task = new SaveCollectionTask(collection, close_after, exit_after); 1225 save_task.start(); 1226 // Run this in the same thread 1227 //save_task.run(); 1228 } 1229 catch(Exception error) { 1230 Gatherer.printStackTrace(error); 1231 } 1232 } 1233 /** Saves the current collection to a new filename, then restores the original collection. Finally opens the collection copy. 1234 * @param name The name collection name. 1235 */ 1236 public void saveCollectionAs(String name) { 1237 // We need to do this in a separate thread so create a SaveCollectionAsTask 1238 try { 1239 SaveCollectionTask save_task = new SaveCollectionTask(collection, name); 1240 save_task.start(); 1241 } 1242 catch(Exception error) { 1243 Gatherer.printStackTrace(error); 1244 } 1245 } 1246 1247 /** Method that is called whenever the metadata set collection changes in some way, such as the addition of a new set or the merging of two sets. We want to mark the collection so that it needs saving again. 1248 * @param event A <strong>MSMEvent</strong> containing details of the event that caused this message to be fired. 1249 * @see org.greenstone.gatherer.collection.Collection 1250 */ 1251 public void setChanged(MSMEvent event) { 1252 // Invalidate saved 1253 collection.setSaved(false); 1254 } 1255 1256 public void setClosingThread(boolean set) { 1257 if(set) { 1258 closing_thread = Thread.currentThread(); 1259 } 1260 else { 1261 closing_thread = null; 1262 } 1263 } 1264 1265 /** Updates the given workspace tree model to reference the private cache of the currently loaded collection. */ 1266 /* private void updatePrivateWorkspace(DefaultTreeModel model) { 1267 // Add Private workspace if a collection has been loaded. 1268 if(ready() && !Gatherer.config.get("workflow.mirror", true)) { 1269 FileNode root = (FileNode)model.getRoot(); 1270 // Remove old private workspace 1271 FileNode old = (FileNode)model.getChild(root, 2); 1272 model.removeNodeFromParent(old); 1273 // Create and insert new. 1274 FileNode private_workspace = new FileNode(new File(getCollectionCache()), Dictionary.get("Tree.Private")); 1275 model.insertNodeInto(private_workspace, root, 2); 1276 } 1277 } */ 1278 /** Called whenever the value tree of an metadata element changes in some way, such as the addition of a new value. We want to mark the collection so that it needs saving again. 1279 * @param event A <strong>MSMEvent</strong> containing details of the event that caused this message to be fired. 1280 * @see org.greenstone.gatherer.collection.Collection 1281 */ 1282 public void valueChanged(MSMEvent event) { 1283 collection.setSaved(false); 1284 } 1285 1286 /** I started giving the user the choice of using an existing meta set or creating a new one. The second option being so that they didn't have to add/merge/ignore each element, they could all be added automatically. However, I am not sure where the merge prompt gets called from, and it is not essential, so I am leaving it for now - it should be added back in and finished. [kjdon] */ 900 1287 private boolean addSomeMetadataSets(File collection_dir) { 901 1288 … … 951 1338 // } 952 1339 953 954 private boolean searchForMetadata(TreeModel collection_tree, FileNode current_node) { 955 File source_file = current_node.getFile(); 956 String source_file_name = source_file.getName(); 957 if (source_file_name.equals(Utility.METADATA_XML) || source_file_name.equals("CVS")) { 958 return true; 959 } 960 if (collection.msm.searchForMetadata(current_node, current_node, false)== false) { 961 return false; 962 } 963 int num_children = collection_tree.getChildCount(current_node); 964 for (int i=0; i<num_children; i++) { 965 FileNode child = (FileNode)collection_tree.getChild(current_node, i); 966 if (searchForMetadata(collection_tree, child)==false) { 967 return false; 968 } 969 } 970 return true; 971 } 972 973 public void makeCollection(String description, String email, String name, String title) { 974 // Encode the description so it is safe to write to shell 975 if(Utility.isWindows()) { 976 description = Codec.transform(description, Codec.TEXT_TO_SHELL_WINDOWS); 977 } 978 else { 979 description = Codec.transform(description, Codec.TEXT_TO_SHELL_UNIX); 980 } 981 // Run the mkcol command. 982 String command[]; 983 if(Utility.isWindows()) { 984 if(description == null || title == null) { 985 command = new String[4]; 986 command[0] = Gatherer.config.perl_path; 987 command[1] = "-S"; 988 command[2] = Gatherer.config.getScriptPath() + "mkcol.pl"; 989 command[3] = name; 990 } 991 // Users are no longer required to supply an email 992 else if(email == null) { 993 command = new String[8]; 994 command[0] = Gatherer.config.perl_path; 995 command[1] = "-S"; 996 command[2] = Gatherer.config.getScriptPath() + "mkcol.pl"; 997 command[3] = "-title"; 998 command[4] = title; 999 command[5] = "-about"; 1000 command[6] = description; 1001 command[7] = name; 1002 } 1003 else { 1004 command = new String[10]; 1005 command[0] = Gatherer.config.perl_path; 1006 command[1] = "-S"; 1007 command[2] = Gatherer.config.getScriptPath() + "mkcol.pl"; 1008 command[3] = "-title"; 1009 command[4] = title; 1010 command[5] = "-creator"; 1011 command[6] = email; 1012 command[7] = "-about"; 1013 command[8] = description; 1014 command[9] = name; 1015 } 1016 } 1017 else { 1018 if(description == null || title == null) { 1019 command = new String[2]; 1020 command[0] = "mkcol.pl"; 1021 command[1] = name; 1022 } 1023 else if(email == null) { 1024 command = new String[6]; 1025 command[0] = "mkcol.pl"; 1026 command[1] = "-title"; 1027 command[2] = title; 1028 command[3] = "-about"; 1029 command[4] = description; 1030 command[5] = name; 1031 } 1032 else { 1033 command = new String[8]; 1034 command[0] = "mkcol.pl"; 1035 command[1] = "-title"; 1036 command[2] = title; 1037 command[3] = "-creator"; 1038 command[4] = email; 1039 command[5] = "-about"; 1040 command[6] = description; 1041 command[7] = name; 1042 } 1043 } 1044 GShell process = new GShell(command, GShell.NEW, COLLECT, this, null, GShell.GSHELL_NEW); 1045 process.addGShellListener(this); 1046 process.run(); // Don't bother threading this... yet 1047 1048 } 1049 1050 /** Any implementation of GShellListener must include this method to allow the GShell to send messages to listeners. However in this case the CollectionManager is in no way interested in what the messages are, just the import events which have a specific type and are handled elsewhere. Thus we can safely ignore this event. 1051 * @param event A <strong>GShellEvent</strong> which contains a the message. 1052 */ 1053 public synchronized void message(GShellEvent event) { 1054 } 1055 /** Called whenever the metadata value changes in some way, such as the addition of a new value. We want to mark the collection so that it needs saving again. 1056 * @param event A <strong>MSMEvent</strong> containing details of the event that caused this message to be fired. 1057 * @see org.greenstone.gatherer.collection.Collection 1058 */ 1059 public void metadataChanged(MSMEvent event) { 1060 // Again this change means we need to save the collection again. 1061 collection.setSaved(false); 1062 } 1063 /** This call is fired whenever a process within a GShell created by this class begins. 1064 * @param event A <strong>GShellEvent</strong> containing information about the GShell process. 1065 * @see org.greenstone.gatherer.Gatherer 1066 * @see org.greenstone.gatherer.gui.GUIManager 1067 * @see org.greenstone.gatherer.shell.GShell 1068 */ 1069 public synchronized void processBegun(GShellEvent event) { 1070 Gatherer.println("CollectionManager.processBegun(" + event.getType() + ")"); 1071 ///ystem.err.println("ProcessBegun " + event.getType()); 1072 // If this is one of the types where we wish to lock user control 1073 Gatherer.g_man.lockCollection((event.getType() == GShell.IMPORT), true); 1074 } 1075 /** This call is fired whenever a process within a GShell created by this class ends. 1076 * @param event A <strong>GShellEvent</strong> containing information about the GShell process. 1077 * @see org.greenstone.gatherer.Gatherer 1078 * @see org.greenstone.gatherer.gui.GUIManager 1079 * @see org.greenstone.gatherer.shell.GShell 1080 */ 1081 public synchronized void processComplete(GShellEvent event) { 1082 Gatherer.println("CollectionManager.processComplete(" + event.getType() + ")"); 1083 ///ystem.err.println("ProcessComplete " + event.getType()); 1084 Gatherer.g_man.lockCollection((event.getType() == GShell.IMPORT), false); 1085 ///ystem.err.println("Recieved process complete event - " + event); 1086 // If we were running an import, now run a build. 1087 if(event.getType() == GShell.IMPORT && event.getStatus() == GShell.OK) { 1088 // Finish import. 1089 collection.setImported(true); 1090 buildCollection(); 1091 } 1092 // If we were running a build, now is when we move files across. 1093 else if(event.getType() == GShell.BUILD && event.getStatus() == GShell.OK) { 1094 if(installCollection()) { 1095 // If we have a local library running (that we know about) then we ask it to add our newly create collection 1096 if(Gatherer.config.exec_file != null) { 1097 Gatherer.self.configServer(GSDLSiteConfig.ADD_COMMAND + collection.getName()); 1098 } 1099 1100 // Fire a collection changed first to update the preview etc buttons 1101 Gatherer.g_man.collectionChanged(ready()); 1102 1103 // Now display a message dialog saying its all built 1104 WarningDialog collection_built_warning_dialog = new WarningDialog("warning.CollectionBuilt", false); 1105 collection_built_warning_dialog.setMessageOnly(true); // Not a warning 1106 collection_built_warning_dialog.display(); 1107 collection_built_warning_dialog.dispose(); 1108 collection_built_warning_dialog = null; 1109 } 1110 else { 1111 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready_Failed"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE); 1112 Gatherer.g_man.collectionChanged(ready()); 1113 } 1114 } 1115 else if(event.getStatus() == GShell.ERROR || event.getStatus() == GShell.CANCELLED) { 1116 Gatherer.println("There was an error in the gshell:"+ event.getMessage()); 1117 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready_Failed"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE); 1118 Gatherer.g_man.collectionChanged(ready()); 1119 Gatherer.g_man.repaint(); // It appears Java's own dialogs have the same not always painting correct area bug that I suffer from. Well I don't suffer from it personally, but my ModalDialog components do. 1120 } 1121 } 1122 /** Determine if the manager is ready for actions apon its collection. 1123 * @return A <i>boolean</i> which is <i>true</i> to indicate a collection has been loaded and thus the collection is ready for editing, <i>false</i> otherwise. 1124 */ 1125 static public synchronized boolean ready() { 1126 if(collection != null) { 1127 return true; 1128 } 1129 else { 1130 return false; 1131 } 1132 } 1133 1134 public synchronized boolean reallyReady() { 1135 // If the closing thread is non-null we should only allow that thread to see the collection as closed. 1136 if(closing_thread != null) { 1137 // Only the closing thread sees the truth 1138 if(Thread.currentThread() == closing_thread) { 1139 return (collection == null); 1140 } 1141 // All other threads are told a lie. 1142 else { 1143 return true; 1144 } 1145 } 1146 else { 1147 if(collection != null) { 1148 return true; 1149 } 1150 else { 1151 return false; 1152 } 1153 } 1154 } 1155 1156 /** This method associates the collection build monitor with the build monitor created in CreatePane. 1157 * @param monitor A <strong>GShellProgressMonitor</strong> which we will use as the build monitor. 1158 */ 1159 public void registerBuildMonitor(GShellProgressMonitor monitor) { 1160 build_monitor = monitor; 1161 } 1162 /** This method associates the collection import monitor with the import monitor created in CreatePane. 1163 * @param monitor A <strong>GShellProgressMonitor</strong> which we will use as the import monitor. 1164 */ 1165 public void registerImportMonitor(GShellProgressMonitor monitor) { 1166 import_monitor = monitor; 1167 } 1168 /** Remove a previously assigned special directory mapping. 1169 * @param target The <string>FileNode</strong> representing the special directory mapping to remove as a <strong>String</strong>. 1170 * @return The <strong>File</strong> of the mapping removed. 1171 * @see org.greenstone.gatherer.file.FileNode 1172 */ 1173 public File removeDirectoryMapping(FileNode target) { 1174 // Remove from config, remembering file 1175 File file = Gatherer.config.removeDirectoryMapping(target.toString()); 1176 // Update tree. 1177 Gatherer.g_man.gather_pane.refreshWorkspaceTree(WorkspaceTree.MAPPED_DIRECTORIES_CHANGED); 1178 return file; 1179 } 1180 /** Used to check whether all open collections have a 'saved' state. 1181 * @return A <i>boolean</i> which is <i>true</i> if the collection has been saved. 1182 * @see org.greenstone.gatherer.collection.Collection 1183 */ 1184 public boolean saved() { 1185 boolean result = true; 1186 if(collection != null) { 1187 result = collection.getSaved(); 1188 } 1189 return result; 1190 } 1191 /** Saves a collection by serializing it to file. 1192 * @param close_after <i>true</i> to cause the Gatherer to close the collection once save is complete, <i>false</i> otherwise. 1193 * @param exit_after <i>true</i> to cause the Gatherer to exit once save is complete, <i>false</i> otherwise. 1194 * @see org.greenstone.gatherer.Gatherer 1195 * @see org.greenstone.gatherer.gui.GUIManager 1196 * @see org.greenstone.gatherer.collection.Collection 1197 */ 1198 public void saveCollection(boolean close_after, boolean exit_after) { 1199 Gatherer.println("Save collection: " + collection.getName()); 1200 try { 1201 SaveCollectionTask save_task = new SaveCollectionTask(collection, close_after, exit_after); 1202 save_task.start(); 1203 // Run this in the same thread 1204 //save_task.run(); 1205 } 1206 catch(Exception error) { 1207 Gatherer.printStackTrace(error); 1208 } 1209 } 1210 /** Saves the current collection to a new filename, then restores the original collection. Finally opens the collection copy. 1211 * @param name The name collection name. 1212 */ 1213 public void saveCollectionAs(String name) { 1214 // We need to do this in a separate thread so create a SaveCollectionAsTask 1215 try { 1216 SaveCollectionTask save_task = new SaveCollectionTask(collection, name); 1217 save_task.start(); 1218 } 1219 catch(Exception error) { 1220 Gatherer.printStackTrace(error); 1221 } 1222 } 1223 1224 /** Method that is called whenever the metadata set collection changes in some way, such as the addition of a new set or the merging of two sets. We want to mark the collection so that it needs saving again. 1225 * @param event A <strong>MSMEvent</strong> containing details of the event that caused this message to be fired. 1226 * @see org.greenstone.gatherer.collection.Collection 1227 */ 1228 public void setChanged(MSMEvent event) { 1229 // Invalidate saved 1230 collection.setSaved(false); 1231 } 1232 1233 public void setClosingThread(boolean set) { 1234 if(set) { 1235 closing_thread = Thread.currentThread(); 1236 } 1237 else { 1238 closing_thread = null; 1239 } 1240 } 1241 1242 /** Updates the given workspace tree model to reference the private cache of the currently loaded collection. */ 1243 /* private void updatePrivateWorkspace(DefaultTreeModel model) { 1244 // Add Private workspace if a collection has been loaded. 1245 if(ready() && !Gatherer.config.get("workflow.mirror", true)) { 1246 FileNode root = (FileNode)model.getRoot(); 1247 // Remove old private workspace 1248 FileNode old = (FileNode)model.getChild(root, 2); 1249 model.removeNodeFromParent(old); 1250 // Create and insert new. 1251 FileNode private_workspace = new FileNode(new File(getCollectionCache()), Dictionary.get("Tree.Private")); 1252 model.insertNodeInto(private_workspace, root, 2); 1253 } 1254 } */ 1255 /** Called whenever the value tree of an metadata element changes in some way, such as the addition of a new value. We want to mark the collection so that it needs saving again. 1256 * @param event A <strong>MSMEvent</strong> containing details of the event that caused this message to be fired. 1257 * @see org.greenstone.gatherer.collection.Collection 1258 */ 1259 public void valueChanged(MSMEvent event) { 1260 collection.setSaved(false); 1340 // used as arg in the perl scripts 1341 private String getCollectDirectory() { 1342 String collect_dir; 1343 if (Gatherer.GS3) { 1344 collect_dir = Utility.getCollectDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name); 1345 } else { 1346 collect_dir = Utility.getCollectDir(Gatherer.config.gsdl_path); 1347 } 1348 1349 // Remove erroneous file windows file separator as it causes problems when running import.pl 1350 if(collect_dir.length() > 2 && collect_dir.endsWith("\\")) { 1351 collect_dir = collect_dir.substring(0, collect_dir.length() - 1); 1352 } 1353 1354 return collect_dir; 1261 1355 } 1262 1356 … … 1270 1364 try { 1271 1365 // We have to ensure that the local library 1272 if( Gatherer.config.exec_file != null) {1366 if(!Gatherer.GS3 && Gatherer.config.exec_file != null) { 1273 1367 ///ystem.err.println("Local Library Found!"); 1274 1368 //Gatherer.g_man./review_pane.configServer(GSDLSiteConfig.RELEASE_COMMAND + collection.getName()); … … 1333 1427 } 1334 1428 } 1429 1335 1430 } 1336 1431 catch (Exception exception) { … … 1361 1456 } 1362 1457 1458 private boolean searchForMetadata(TreeModel collection_tree, FileNode current_node) { 1459 File source_file = current_node.getFile(); 1460 String source_file_name = source_file.getName(); 1461 if (source_file_name.equals(Utility.METADATA_XML) || source_file_name.equals("CVS")) { 1462 return true; 1463 } 1464 if (collection.msm.searchForMetadata(current_node, current_node, false)== false) { 1465 return false; 1466 } 1467 int num_children = collection_tree.getChildCount(current_node); 1468 for (int i=0; i<num_children; i++) { 1469 FileNode child = (FileNode)collection_tree.getChild(current_node, i); 1470 if (searchForMetadata(collection_tree, child)==false) { 1471 return false; 1472 } 1473 } 1474 return true; 1475 } 1476 1363 1477 private void updateCollectionCFG(File base_cfg, File new_cfg, String description, String email, String title) { 1364 1478 boolean first_name = true; -
trunk/gli/src/org/greenstone/gatherer/collection/DeleteCollectionPrompt.java
r7281 r7326 217 217 private void scanForCollections() { 218 218 // Start at the collect dir. 219 String collect_directory_name = Utility.getCollectDir(Gatherer.config.gsdl_path); 220 File collect_directory = new File(collect_directory_name); 219 File collect_directory; 220 if (Gatherer.GS3) { 221 collect_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name)); 222 } else { 223 collect_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl_path)); 224 } 221 225 if(collect_directory.exists()) { 222 226 // Now for each child directory see if it contains a .col file and … … 310 314 } 311 315 312 File delete_me = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getShortName())); 316 File delete_me; 317 if (Gatherer.GS3) { 318 delete_me = new File(Utility.getCollectionDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name, collection.getShortName())); 319 } else { 320 delete_me = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path, collection.getShortName())); 321 } 313 322 if(Utility.delete(delete_me)) { 314 323 if (Gatherer.c_man.getCollection() != null && collection.getShortName().equals(Gatherer.c_man.getCollection().getName())) { -
trunk/gli/src/org/greenstone/gatherer/collection/ExportCollectionPrompt.java
r7281 r7326 345 345 private void scanForCollections() { 346 346 // Start at the collect dir. 347 String collect_directory_name = Utility.getCollectDir(Gatherer.config.gsdl_path); 348 File collect_directory = new File(collect_directory_name); 347 File collect_directory; 348 if (Gatherer.GS3) { 349 collect_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name)); 350 } else { 351 collect_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl_path)); 352 } 349 353 if(collect_directory.exists()) { 350 354 // Now for each child directory see if it contains a .col file and -
trunk/gli/src/org/greenstone/gatherer/collection/SaveCollectionTask.java
r7224 r7326 163 163 ArrayList files = new ArrayList(); 164 164 File collection_file = new File(Gatherer.c_man.getCollectionFilename()); 165 File copied_dir = new File(Utility.getCollectDir(Gatherer.config.gsdl_path) + name); 165 File copied_dir; 166 if (Gatherer.GS3) { 167 copied_dir = new File(Utility.getCollectionDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name, name)); 168 } else { 169 copied_dir = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path, name)); 170 } 166 171 files.add(collection_file.getParentFile()); 167 172 while(files.size() > 0) { -
trunk/gli/src/org/greenstone/gatherer/file/FileNode.java
r7281 r7326 34 34 private MutableTreeNode parent; 35 35 private String title; 36 private boolean gs3_site = false; 36 37 37 38 public FileNode(File file) { … … 267 268 268 269 public void map() { 269 if(children == null) { 270 children = new ArrayList(); 271 // Super Special Case: if the name of this node is the Tree.World string, then we actually map the collections installed in greenstone. The file in this case will actually be the collect directory of greenstone. 272 if(file == null && title.equals(Dictionary.get("Tree.World"))) { 270 if(children != null) { 271 return; 272 } 273 children = new ArrayList(); 274 // Super Special Case: if the name of this node is the Tree.World string, then we actually map the collections installed in greenstone. The file in this case will actually be the collect directory of greenstone. 275 if(file == null) { // a special mapping folder 276 if (title.equals(Dictionary.get("Tree.World")) && Gatherer.GS3) { 277 // the Greenstone collections folder for GS3 - this contains a 278 // folder for each site 279 File start = new File(Utility.getSitesDir(Gatherer.config.gsdl3_path)); 280 File sites[] = start.listFiles(); 281 ArrayTools.sort(sites); 282 for (int i=0; sites != null && i < sites.length; i++) { 283 //File site = sites[i]; 284 File collect_dir = new File(sites[i], Utility.COL_DIR); 285 if(!collect_dir.exists()) { 286 continue; 287 } 288 289 FileNode child = new FileNode(sites[i].getName()); 290 child.setGS3Site(true); 291 child.unmap(); 292 child.setParent(this); 293 child.setModel(model); 294 child.map(); 295 children.add(child); 296 } 297 298 } else if (title.equals(Dictionary.get("Tree.World")) || gs3_site) { 299 // the collect dir for gs2 or a site dir for gs3 273 300 ///atherer.println("Map the 'Greenstone Collections' node."); 274 301 // For each of the children directories, which are collections... 275 File start = new File(Utility.getCollectDir(Gatherer.config.gsdl_path)); 302 File start; 303 if (gs3_site) { 304 start = new File(Utility.getCollectDir(Gatherer.config.gsdl3_path, title)); 305 } else { 306 start = new File(Utility.getCollectDir(Gatherer.config.gsdl_path)); 307 } 276 308 File cols[] = start.listFiles(); 277 309 ArrayTools.sort(cols); … … 279 311 for(int i = 0; cols != null && i < cols.length; i++) { 280 312 if (!cols[i].getName().equals(StaticStrings.MODEL_COLLECTION_NAME)) { 281 File dirs[] = cols[i].listFiles();282 ArrayTools.sort(dirs);313 //File dirs[] = cols[i].listFiles(); 314 //ArrayTools.sort(dirs); 283 315 File import_dir = new File(cols[i], StaticStrings.IMPORT_FOLDER); 284 if(import_dir.exists()) { 285 // we don't care if there is no config file 286 BasicCollectionConfiguration collect_cfg = new BasicCollectionConfiguration(new File(cols[i], Utility.CONFIG_FILE)); 287 FileNode collection_root = new FileNode(import_dir, collect_cfg.toString(), true); 288 collection_root.setParent(this); 289 collection_root.setModel(model); 290 // One last piece of magic so we can determine the current collection 291 Collection collection = Gatherer.c_man.getCollection(); 292 if(collection != null) { 293 collection_root.setCurrentCollection(cols[i].getName().equals(collection.getName())); 294 } 295 children.add(collection_root); 296 collection_root = null; 316 if(!import_dir.exists()) { 317 continue; 297 318 } 319 // we don't care if there is no config file 320 BasicCollectionConfiguration collect_cfg = new BasicCollectionConfiguration(new File(cols[i], Utility.CONFIG_FILE)); 321 FileNode collection_root = new FileNode(import_dir, collect_cfg.toString(), true); 322 collection_root.setParent(this); 323 collection_root.setModel(model); 324 // One last piece of magic so we can determine the current collection 325 Collection collection = Gatherer.c_man.getCollection(); 326 if(collection != null) { 327 collection_root.setCurrentCollection(cols[i].getName().equals(collection.getName())); 328 } 329 children.add(collection_root); 330 collection_root = null; 298 331 import_dir = null; 299 dirs = null;300 } 301 } 332 //dirs = null; 333 } 334 } // for each coll 302 335 cols = null; 303 336 model.nodeStructureChanged(this); 304 337 } 305 // General case: Only map if there are no children. 306 else if(file != null && getAllowsChildren()) { 338 } // if file == null 339 // General case: Only map if there are no children. 340 else { // file !=null 341 if(getAllowsChildren()) { 307 342 File[] files = file.listFiles(); 308 343 if(files != null && files.length > 0) { … … 318 353 raw_children.add(child); 319 354 } 320 355 321 356 // Apply the filters set in the model. 322 357 //if(model != null) { … … 326 361 } 327 362 //} 328 363 329 364 // Now add them to children. 330 365 for(int i = 0; i < files.length; i++) { … … 343 378 } 344 379 } 380 345 381 } 346 382 … … 376 412 public void setFile(File file) { 377 413 this.file = file; 414 } 415 416 public void setGS3Site(boolean is_site) { 417 this.gs3_site = is_site; 378 418 } 379 419 … … 426 466 public void unmap() { 427 467 // You cannot unmap nodes that have no file basis. 428 if(file != null || title.equals(Dictionary.get("Tree.World")) ) {468 if(file != null || title.equals(Dictionary.get("Tree.World")) || gs3_site) { 429 469 ///atherer.println("Unmap: " + this); 430 470 children = null; -
trunk/gli/src/org/greenstone/gatherer/gui/CreatePane.java
r7161 r7326 578 578 // set up the home page for the current collection 579 579 Collection current_collection = Gatherer.c_man.getCollection(); 580 String site = Gatherer.config.site_name; // for GS3 colls 580 581 String extra_args = ""; 581 582 SearchTypeManager st_man = current_collection.cdm.searchtype_manager; 582 if ( st_man.isMGPPEnabled()) {583 if (!Gatherer.GS3 && st_man.isMGPPEnabled()) { 583 584 // we need some more args on the url 584 585 String search_types = st_man.getSearchTypes(); … … 596 597 } 597 598 // Remember to add unique timestamp 598 homepage = Gatherer.config.exec_address.toString() + "?a=p&p=about&c=" + current_collection.getName()+"&l="+Gatherer.config.getLanguage()+extra_args + StaticStrings.TIMESTAMP_ARGUMENT + System.currentTimeMillis(); 599 599 if (Gatherer.GS3) { 600 homepage = Gatherer.config.exec_address.toString() + Gatherer.config.getServletPath()+ "?a=p&sa=about&c=" + current_collection.getName()+"&l="+Gatherer.config.getLanguage(); //+extra_args + StaticStrings.TIMESTAMP_ARGUMENT + System.currentTimeMillis(); 601 } else { 602 homepage = Gatherer.config.exec_address.toString() + "?a=p&p=about&c=" + current_collection.getName()+"&l="+Gatherer.config.getLanguage()+extra_args + StaticStrings.TIMESTAMP_ARGUMENT + System.currentTimeMillis(); 603 } 600 604 } 601 605 -
trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java
r7314 r7326 369 369 enrich_pane.afterDisplay(); 370 370 } 371 public void closeCurrentCollection() { 372 373 boolean cont = showSaveCollectionBox(true, false); 374 375 if(cont) { 376 tab_pane.setSelectedComponent(gather_pane); 377 } 378 379 } 371 380 /** Once a collection has been made available to Gatherer, either by its creation or by it being reloaded, we need to inform all the visual components to update necessary data components (such as tree models), enable certain controls that depend on a collection being accessible, and refresh themselves. 372 381 * @param ready <i>true</i> if the collection is ready for editing, <i>false</i> otherwise. … … 716 725 else if(user_choice == SimpleOpenCollectionDialog.BROWSE_OPTION) { 717 726 File file; 718 if(Gatherer.config.gsdl_path != null) { 719 file = new File(Utility.getCollectDir(Gatherer.config.gsdl_path)); 720 } 721 else { 722 file = new File(Utility.BASE_DIR); 727 if (Gatherer.GS3) { 728 if (Gatherer.config.gsdl3_path != null) { 729 file = new File(Utility.getSitesDir(Gatherer.config.gsdl3_path)); 730 } else { 731 file = new File(Utility.BASE_DIR); 732 } 733 734 } else { 735 736 if(Gatherer.config.gsdl_path != null) { 737 file = new File(Utility.getCollectDir(Gatherer.config.gsdl_path)); 738 } 739 else { 740 file = new File(Utility.BASE_DIR); 741 } 723 742 } 724 743 OpenCollectionDialog chooser = new OpenCollectionDialog(file); … … 748 767 } 749 768 } 769 750 770 result = Gatherer.c_man.loadCollection(filename); 751 771 filename = null; -
trunk/gli/src/org/greenstone/gatherer/gui/NewCollectionDetailsPrompt.java
r7280 r7326 51 51 return false; 52 52 } 53 File collection_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl_path)); 53 File collection_directory; 54 if (Gatherer.GS3) { 55 collection_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name)); 56 } else { 57 collection_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl_path)); 58 } 54 59 File children[] = collection_directory.listFiles(); 55 60 for(int i = 0; children != null && i < children.length; i++) { … … 97 102 // Model building. Build a model of all of the collections in the gsdl collect directory with the appropriate directories. 98 103 Vector base_collection_model = new Vector(); 99 File gsdl_collection_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl_path)); 104 // need to modify this to base a coll on any collection from any site 105 File gsdl_collection_directory; 106 if (Gatherer.GS3) { 107 gsdl_collection_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name)); 108 } else { 109 gsdl_collection_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl_path)); 110 } 100 111 File[] possible_collections = gsdl_collection_directory.listFiles(); 101 112 for (int i = 0; possible_collections != null && i < possible_collections.length; i++) { … … 258 269 259 270 private boolean filenameClashes(String filename) { 260 File collection_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl_path)); 271 File collection_directory; 272 if (Gatherer.GS3) { 273 collection_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name)); 274 } else { 275 collection_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl_path)); 276 } 277 261 278 File children[] = collection_directory.listFiles(); 262 279 for(int i = 0; children != null && i < children.length; i++) { … … 271 288 return title_final; 272 289 } 273 290 274 291 private class CancelListener 275 292 implements ActionListener { -
trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java
r7205 r7326 48 48 import org.greenstone.gatherer.gui.SimpleMenuBar; 49 49 import org.greenstone.gatherer.gui.tree.DragTree; 50 import org.greenstone.gatherer.util.ArrayTools; // just for debug 50 51 import org.greenstone.gatherer.util.StaticStrings; 51 52 import org.greenstone.gatherer.util.Utility; … … 82 83 private JCheckBox workflow_preview; 83 84 private JComboBox language_combobox; 85 private JComboBox servlet_combobox; // GS3 86 private JComboBox site_combobox; // GS3 84 87 private JLabel email_label; 85 88 private JLabel language_label; … … 91 94 //private JLabel recursion_depth_label; 92 95 private JLabel title_label; 96 private JPanel servlet_pane; 93 97 private JRadioButton assistant_mode_radio_button; 94 98 private JRadioButton expert_mode_radio_button; … … 104 108 private Preferences self; 105 109 110 private String current_site_selection; 106 111 public Preferences() { 107 112 this(GENERAL_PREFS); … … 198 203 library_path_label = new JLabel(); 199 204 library_path_label.setPreferredSize(LABEL_SIZE); 200 Dictionary.registerText(library_path_label, "Preferences.Connection.Library_Path");201 205 library_path_field = new JTextField(Gatherer.config.getString("general.exec_address", true)); 202 206 library_path_field.setCaretPosition(0); 203 Dictionary.registerTooltip(library_path_field, "Preferences.Connection.Library_Path_Tooltip"); 204 207 if (Gatherer.GS3) { 208 Dictionary.registerText(library_path_label, "Preferences.Connection.Library_Path_GS3"); 209 Dictionary.registerTooltip(library_path_field, "Preferences.Connection.Library_Path_Tooltip_GS3"); 210 } else { 211 Dictionary.registerText(library_path_label, "Preferences.Connection.Library_Path"); 212 Dictionary.registerTooltip(library_path_field, "Preferences.Connection.Library_Path_Tooltip"); 213 } 214 215 216 JPanel site_pane = null; 217 JLabel site_label = null; 218 JLabel servlet_label = null; 219 if (Gatherer.GS3) { 220 site_pane = new JPanel(); 221 site_pane.setPreferredSize(ROW_SIZE); 222 site_label = new JLabel(); 223 Dictionary.registerText(site_label, "Preferences.Connection.Site"); 224 site_label.setPreferredSize(LABEL_SIZE); 225 site_combobox = new JComboBox(Gatherer.servlet_config.getSites().toArray()); 226 Dictionary.registerTooltip(site_combobox, "Preferences.Connection.Site_Tooltip"); 227 servlet_pane = new JPanel(); 228 servlet_pane.setPreferredSize(ROW_SIZE); 229 servlet_label = new JLabel(); 230 Dictionary.registerText(servlet_label, "Preferences.Connection.Servlet"); 231 servlet_label.setPreferredSize(LABEL_SIZE); 232 servlet_combobox = new JComboBox(); 233 // try to locate and select the current site 234 String this_site = Gatherer.config.site_name; 235 for(int b = 0; b < site_combobox.getItemCount(); b++) { 236 String entry = (String) site_combobox.getItemAt(b); 237 if(this_site.equals(entry)) { 238 site_combobox.setSelectedIndex(b); 239 break; 240 } 241 } 242 243 // just in case its not the current one? 244 current_site_selection = (String)site_combobox.getSelectedItem(); 245 246 ArrayList servlet_options = Gatherer.servlet_config.getServletsForSite(current_site_selection); 247 if (servlet_options == null) { 248 //servlet_combobox.setModel(new DefaultComboBoxModel()); 249 Dictionary.registerTooltip(servlet_combobox, "Preferences.Connection.Servlet_Tooltip2"); 250 servlet_combobox.setEnabled(false); 251 } else { 252 System.err.println(ArrayTools.objectArrayToString(servlet_options.toArray())); 253 254 servlet_combobox.setModel(new DefaultComboBoxModel(servlet_options.toArray())); 255 Dictionary.registerTooltip(servlet_combobox, "Preferences.Connection.Servlet_Tooltip"); 256 servlet_combobox.setEnabled(true); 257 // try to locate and select the current servlet 258 String this_servlet = Gatherer.config.getServletPath(); 259 for(int b = 0; b < servlet_combobox.getItemCount(); b++) { 260 String entry = (String) servlet_combobox.getItemAt(b); 261 if(this_servlet.equals(entry)) { 262 servlet_combobox.setSelectedIndex(b); 263 break; 264 } 265 } 266 267 } 268 } 269 205 270 boolean currently_enabled = Gatherer.config.get("general.use_proxy", true); 206 271 // Creation … … 240 305 use_proxy_checkbox.addActionListener(new UseProxyListener()); 241 306 clear_cache_button.addActionListener(new ClearCacheListener()); 307 site_combobox.addActionListener(new SiteComboboxListener()); 242 308 243 309 // Layout … … 250 316 library_path_pane.add(library_path_field, BorderLayout.CENTER); 251 317 318 if (Gatherer.GS3) { 319 site_pane.setLayout(new BorderLayout()); 320 site_pane.add(site_label, BorderLayout.WEST); 321 site_pane.add(site_combobox, BorderLayout.CENTER); 322 323 servlet_pane.setLayout(new BorderLayout()); 324 servlet_pane.add(servlet_label, BorderLayout.WEST); 325 servlet_pane.add(servlet_combobox, BorderLayout.CENTER); 326 } 252 327 proxy_host_pane.setLayout(new BorderLayout()); 253 328 proxy_host_pane.add(proxy_host_label, BorderLayout.WEST); … … 262 337 connection_pane.add(program_pane); 263 338 connection_pane.add(library_path_pane); 339 if (Gatherer.GS3) { 340 connection_pane.add(site_pane); 341 connection_pane.add(servlet_pane); 342 } 264 343 connection_pane.add(use_proxy_checkbox); 265 344 connection_pane.add(proxy_host_pane); … … 638 717 } 639 718 } 719 boolean site_changed = false; 720 if (Gatherer.GS3) { 721 String current_site = Gatherer.config.site_name; 722 String new_site =(String)site_combobox.getSelectedItem() ; 723 if (!new_site.equals(current_site)) { 724 site_changed = true; 725 } 726 Gatherer.config.setSiteAndServlet(new_site, (String)servlet_combobox.getSelectedItem()); 727 } 728 640 729 Gatherer.config.set("general.use_proxy", true, use_proxy_checkbox.isSelected()); 641 730 Gatherer.config.setString("general.proxy_host", true, proxy_host_field.getText()); … … 691 780 Gatherer.config.set(entry.getProperty(), true, entry.isSelected()); 692 781 } 782 783 if (Gatherer.GS3 && site_changed) { 784 // shut down the collection 785 System.err.println("shutting down teh collection"); 786 Gatherer.g_man.closeCurrentCollection(); 787 } 788 693 789 // Workflow preferences 694 790 // Gatherer.config.set("workflow.browse", false, workflow_browse.isSelected()); … … 823 919 } 824 920 921 private class SiteComboboxListener 922 implements ActionListener { 923 private boolean ignore_event=false; 924 public void actionPerformed(ActionEvent event) { 925 System.err.println("event occurred "+event.paramString()); 926 String site = (String) site_combobox.getSelectedItem(); 927 System.err.println("new site = "+site); 928 if (!site.equals(current_site_selection)) { 929 current_site_selection = site; 930 System.err.println("changed the current selection"); 931 ArrayList servlet_options = Gatherer.servlet_config.getServletsForSite(current_site_selection); 932 if (servlet_options == null) { 933 System.err.println("no servlets for this site"); 934 servlet_combobox.setModel(new DefaultComboBoxModel()); 935 Dictionary.registerTooltip(servlet_combobox, "Preferences.Connection.Servlet_Tooltip2"); 936 servlet_combobox.setEnabled(false); 937 938 } else { 939 System.err.println(ArrayTools.objectArrayToString(servlet_options.toArray())); 940 servlet_combobox.setModel(new DefaultComboBoxModel(servlet_options.toArray())); 941 Dictionary.registerTooltip(servlet_combobox, "Preferences.Connection.Servlet_Tooltip"); 942 servlet_combobox.setEnabled(true); 943 } 944 } 945 } 946 /* if (!ignore_event) { 947 ignore_event=true; 948 // Retrieve the entry 949 String site = (String) site_combobox.getSelectedItem(); 950 if (!site.equals(current_site_selection)) { 951 current_site_selection = site; 952 System.err.println("current selection ="+current_site_selection); 953 ArrayList servlet_options = Gatherer.servlet_config.getServletsForSite(current_site_selection); 954 System.err.println(ArrayTools.objectArrayToString(servlet_options.toArray())); 955 956 servlet_combobox.setModel(new DefaultComboBoxModel(servlet_options.toArray())); 957 servlet_pane.updateUI(); 958 }*/ 959 //DictionaryEntry entry = (DictionaryEntry) language_combobox.getSelectedItem(); 960 //if(entry != null) { 961 //Gatherer.dictionary.changeDictionary(entry.getLocale()); 962 // Display message 963 //JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("Preferences.General.Restart_Required"), Dictionary.get("General.Warning"), JOptionPane.WARNING_MESSAGE); 964 // } 965 //ignore_event=false; 966 //} 967 968 } 969 825 970 private class UseProxyListener 826 971 implements ActionListener { -
trunk/gli/src/org/greenstone/gatherer/gui/SimpleOpenCollectionDialog.java
r7281 r7326 77 77 Dictionary.setText(collection_list_label, "OpenCollectionDialog.Available_Collections"); 78 78 collection_list = new JList(new CollectionListModel()); 79 80 79 description_pane = new JPanel(); 81 80 card_layout = new CardLayout(); … … 151 150 152 151 public String getFileName() { 153 return filename; 154 } 155 152 return this.filename; 153 } 156 154 private class AdvancedListener 157 155 implements ActionListener { … … 202 200 } 203 201 202 // use this if we ever go back to viewing all colls at once 203 /* private class GS3CollectionListModel 204 extends AbstractListModel { 205 206 private TreeSet data; 207 208 public GS3CollectionListModel() { 209 data = new TreeSet(); 210 File sites_folder = new File(Utility.getSitesDir(Gatherer.config.gsdl3_path)); 211 File sites[] = sites_folder.listFiles(); 212 for (int s=0; s<sites.length; s++) { 213 String site_name = sites[s].getName(); 214 System.err.println("found site "+site_name); 215 File collect_folder = new File(Utility.getCollectDir(Gatherer.config.gsdl3_path, site_name) ); 216 if (!collect_folder.exists()) { 217 continue; 218 } 219 File[] collection_folders = collect_folder.listFiles(); 220 for(int i = 0; i < collection_folders.length; i++) { 221 File collection_folder = collection_folders[i]; 222 String collection_foldername = collection_folder.getName(); 223 if(!collection_folder.isFile() && !collection_foldername.equals(StaticStrings.MODEL_COLLECTION_NAME)) { 224 BasicCollectionConfiguration collection_configuration = new BasicCollectionConfiguration(new File(collection_folder, Utility.CONFIG_FILE), site_name); 225 if(!collection_configuration.getName().equals(StaticStrings.ERROR_STR)) { 226 data.add(collection_configuration); 227 } 228 } 229 collection_foldername = null; 230 collection_folder = null; 231 } // for each collection 232 collection_folders = null; 233 collect_folder = null; 234 } // for each site 235 sites_folder = null; 236 sites = null; 237 } 238 239 public Object getElementAt(int index) { 240 Iterator iterator = data.iterator(); 241 for(int i = 0; iterator.hasNext(); i++) { 242 Object object = iterator.next(); 243 if(i == index) { 244 iterator = null; 245 return object; 246 } 247 object = null; 248 } 249 iterator = null; 250 return null; 251 } 252 253 public int getSize() { 254 return data.size(); 255 } 256 } 257 */ 204 258 private class CollectionListModel 205 259 extends AbstractListModel { … … 209 263 public CollectionListModel() { 210 264 data = new TreeSet(); 211 File collect_folder = new File(Gatherer.config.gsdl_path + Utility.COL_DIR); 265 File collect_folder; 266 if (Gatherer.GS3) { 267 collect_folder = new File(Utility.getCollectDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name) ); 268 } else { 269 collect_folder = new File(Utility.getCollectDir(Gatherer.config.gsdl_path)); 270 } 212 271 File[] collection_folders = collect_folder.listFiles(); 213 272 for(int i = 0; i < collection_folders.length; i++) { … … 253 312 public void actionPerformed(ActionEvent event) { 254 313 result = OK_OPTION; 255 BasicCollectionConfiguration collection_configuration = (BasicCollectionConfiguration) collection_list.getSelectedValue(); 256 File collect_cfg_file = collection_configuration.getFile(); 257 File etc_folder = collect_cfg_file.getParentFile(); 258 File collection_folder = etc_folder.getParentFile(); 259 filename = collection_folder.getAbsolutePath() + File.separator + collection_folder.getName() + Utility.GLI_EXTENSION; 260 collection_folder = null; 261 etc_folder = null; 262 collect_cfg_file = null; 263 collection_configuration = null; 264 SimpleOpenCollectionDialog.this.dispose(); 314 Object selected_object = collection_list.getSelectedValue(); 315 if (selected_object instanceof BasicCollectionConfiguration) { 316 BasicCollectionConfiguration collection_configuration = (BasicCollectionConfiguration)selected_object; //(BasicCollectionConfiguration) collection_list.getSelectedValue(); 317 //*************888 318 File collect_cfg_file = collection_configuration.getFile(); // returns the collect.cfg file 319 File etc_folder = collect_cfg_file.getParentFile(); 320 File collection_folder = etc_folder.getParentFile(); 321 filename = collection_folder.getAbsolutePath() + File.separator + collection_folder.getName() + Utility.GLI_EXTENSION; 322 collection_folder = null; 323 etc_folder = null; 324 collect_cfg_file = null; 325 collection_configuration = null; 326 SimpleOpenCollectionDialog.this.dispose(); 327 } 265 328 } 266 329 } -
trunk/gli/src/org/greenstone/gatherer/mem/MEMNode.java
r7281 r7326 149 149 boolean is_descendant = false; 150 150 File source_path = new File((String)userObject); 151 File collect_path = new File(Utility.getCollectDir(Gatherer.config.gsdl_path)); 151 File collect_path; 152 if (Gatherer.GS3) { 153 collect_path = new File(Utility.getCollectDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name)); 154 } else { 155 collect_path = new File(Utility.getCollectDir(Gatherer.config.gsdl_path)); 156 } 152 157 File current_path = source_path; 153 158 while(!is_descendant && current_path != null) {
Note:
See TracChangeset
for help on using the changeset viewer.