Changeset 18363 for gli/branches/rtl-gli
- Timestamp:
- 2009-01-12T11:19:54+13:00 (15 years ago)
- Location:
- gli/branches/rtl-gli/src/org/greenstone/gatherer
- Files:
-
- 7 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
gli/branches/rtl-gli/src/org/greenstone/gatherer/Configuration.java
r14302 r18363 67 67 /** The name of the general Gatherer configuration file. */ 68 68 static public String CONFIG_XML = "config.xml"; 69 /** The name of the general Gatherer configuration file for running with GS3. */ 70 static public String GS3_CONFIG_XML = "config3.xml"; 69 static public String FEDORA_CONFIG_PREFIX = "fedora-"; 71 70 72 71 /** The name of the root element of the subtree containing gatherer configuration options. This is required as the document itself may contain several other subtrees of settings (such as in the case of a '.col' file). */ … … 101 100 /** If we are using GLI in Greenstone 3, the path to gsdl3 src directory (== gsdl3 dir)*/ 102 101 static public String gsdl3_src_path = ""; 102 103 static public FedoraInfo fedora_info = null; 104 103 105 /** The path to the PERL executable, up to and including Perl.exe. */ 104 106 static public String perl_path = ""; … … 126 128 static public URL gliserver_url = null; 127 129 static public URL library_url = null; 128 129 130 131 130 132 /** Constructor. 131 133 * @param gsdl_path The path to the Greenstone directory as a <strong>String</strong>. … … 133 135 * @param gsdl3_src_path The path to the Greenstone 3 src directory as a <strong>String</strong>. 134 136 * @param site_name The name of the Greenstone 3 site currently in use. 137 * @param fedora_info A FedoraInfo object containing the user-provided details for creating 138 * a connection to a Fedora repository. 135 139 */ 136 public Configuration(String gli_user_directory_path, String gsdl_path, String gsdl3_path, String gsdl3_src_path, String site_name) 140 public Configuration(String gli_user_directory_path, String gsdl_path, String gsdl3_path, String gsdl3_src_path, 141 String site_name, FedoraInfo fedora_info) 137 142 { 138 143 super(); 139 self = this; 144 self = this; // allows Configuration to statically refer to itself in the static methods 140 145 141 146 this.gli_user_directory_path = gli_user_directory_path; … … 145 150 this.site_name = site_name; 146 151 152 this.fedora_info = fedora_info; 153 147 154 // Try to load the configuration file from the user specific location 148 155 String config_xml_file_name = CONFIG_XML; 149 if (gsdl3_path != null || (Gatherer.isGsdlRemote && Gatherer.GS3)) { 150 config_xml_file_name = GS3_CONFIG_XML; 156 157 if (fedora_info != null && fedora_info.isActive()) { 158 config_xml_file_name = FEDORA_CONFIG_PREFIX + config_xml_file_name; 151 159 } 152 160 153 161 // If the existing user config.xml file isn't recent enough, backup the old version and update it 154 162 File config_xml_file = new File(gli_user_directory_path + config_xml_file_name); 163 155 164 if (config_xml_file != null && config_xml_file.exists()) { 156 165 just_updated_config_xml_file = updateUserConfigXMLFileIfNecessary(config_xml_file); … … 171 180 172 181 // Read the Greenstone library URL from the config file 173 String library_url_string = getString("general.library_url" , true);182 String library_url_string = getString("general.library_url"+gliPropertyNameSuffix(), true); 174 183 if (!library_url_string.equals("")) { 175 184 try { … … 194 203 } 195 204 196 if (gsdl3_path != null || (Gatherer.GS3 && Gatherer.isGsdlRemote)) { 197 if (this.site_name == null || this.site_name.equals("")) { 198 this.site_name = getString("general.site_name", true); 199 this.servlet_path = getString("general.servlet_path", true); 200 if (this.site_name.equals("")) { 201 this.site_name = "localsite"; // can we assume these?? 202 this.servlet_path = "/library"; 203 setString("general.site_name", true, this.site_name); 204 setString("general.servlet_path", true, this.servlet_path); 205 } 206 207 } else { 208 // we set the current one in the config 209 setString("general.site_name", true, this.site_name); 210 if (this.servlet_path != null && !this.servlet_path.equals("")) { 211 setString("general.servlet_path", true, this.servlet_path); 212 } 213 } 214 } 215 } 216 205 if(gsdl3_path != null) { 206 prepareForGS3(); 207 } 208 209 } 210 211 /** @return the suffix for the the config file's library_url/open_collection propertyname. 212 * For Fedora and remote GS2 cases, there is no suffix. 213 * However, when dealing with a local Greenstone server, this returns suffix _gs2 or _gs3 214 * so it can be appended to the default library_url/open_collection propertynames. 215 * Having 2 separate library URL properties and open_collection properties for the two 216 * local versions of Greenstone allows GLI to save the library_url and last opened 217 * collection for both GS2 and GS3, in case anyone runs them alternatively. (This is useful 218 * when developing and testing across GS versions.) */ 219 static public String gliPropertyNameSuffix() { 220 if(Gatherer.isGsdlRemote) { 221 return ""; // no special suffix 222 } else if(Gatherer.GS3) { // local GS3, including FLI for GS3 223 return "_gs3"; 224 } else { // local GS2, including FLI for GS2 225 return "_gs2"; 226 } 227 } 228 229 230 // Called when (gsdl3_path != null) || (Gatherer.GS3 && Gatherer.isGsdlRemote) 231 static public void prepareForGS3() { 232 if (site_name == null || site_name.equals("")) { 233 site_name = getString("general.site_name", true); 234 servlet_path = getString("general.servlet_path", true); 235 if (site_name.equals("")) { 236 site_name = "localsite"; // can we assume these?? 237 servlet_path = "/library"; 238 setString("general.site_name", true, site_name); 239 setString("general.servlet_path", true, servlet_path); 240 } 241 242 } else { 243 // we set the current one in the config 244 setString("general.site_name", true, site_name); 245 if (servlet_path != null && !servlet_path.equals("")) { 246 setString("general.servlet_path", true, servlet_path); 247 } 248 } 249 } 217 250 218 251 static private boolean updateUserConfigXMLFileIfNecessary(File config_xml_file) … … 228 261 String new_version = new_document.getDocumentElement().getAttribute(StaticStrings.VERSION_ATTRIBUTE); 229 262 String old_version = old_document.getDocumentElement().getAttribute(StaticStrings.VERSION_ATTRIBUTE); 230 if (new_version. compareTo(old_version) <= 0) {263 if (new_version.equals(old_version)) { 231 264 // Don't need to update file 232 265 return false; 233 266 } 234 267 235 System.err.println(" Updating user config.xml from version " + old_version + " to version " + new_version + "...");268 System.err.println("Converting user config.xml from version " + old_version + " to version " + new_version + "..."); 236 269 237 270 // Build up the new user config.xml file from the template config.xml with the user's preferences added … … 254 287 // Argument found 255 288 if (old_argument_element_name.equals(new_argument_element_name)) { 256 if (!new_argument_element_name.equals("general.open_collection")) { 257 String old_argument_element_value = XMLTools.getElementTextValue(old_argument_element); 258 if (!old_argument_element_value.equals(new_argument_element_value)) { 259 XMLTools.setElementTextValue(new_argument_element, old_argument_element_value); 260 } 289 // we don't want to carry over open_collection or library_url 290 // as these may be invalid 291 if (!new_argument_element_name.equals("general.open_collection"+Configuration.gliPropertyNameSuffix()) && !new_argument_element_name.equals("general.library_url"+Configuration.gliPropertyNameSuffix())) { 292 293 String old_argument_element_value = XMLTools.getElementTextValue(old_argument_element); 294 if (!old_argument_element_value.equals(new_argument_element_value)) { 295 XMLTools.setElementTextValue(new_argument_element, old_argument_element_value); 261 296 } 262 263 // We don't care about this option any more 297 } 298 299 // We don't care about this option any more 264 300 old_argument_element.getParentNode().removeChild(old_argument_element); 265 301 break; … … 597 633 } 598 634 635 static public String getApplicationTitle() { 636 String gli_title = getString("GLI.Title", GENERAL_SETTING); 637 String title = (gli_title=="") ? Gatherer.PROGRAM_NAME : gli_title; 638 639 return title; 640 } 641 642 599 643 static public String getServletPath() { 600 644 return servlet_path; … … 688 732 File user_config_xml = null; 689 733 String config_xml_name = CONFIG_XML; 690 if (gsdl3_path!=null) { 691 config_xml_name = GS3_CONFIG_XML; 692 } 693 694 if (Gatherer.isGsdlRemote) { 695 if (Gatherer.GS3){ 696 config_xml_name = GS3_CONFIG_XML; 697 }else{ 698 config_xml_name = CONFIG_XML; 699 } 700 } 734 735 if (fedora_info != null && fedora_info.isActive()) { 736 config_xml_name = FEDORA_CONFIG_PREFIX + config_xml_name; 737 } 738 701 739 try { 702 740 user_config_xml = new File(gli_user_directory_path + config_xml_name); -
gli/branches/rtl-gli/src/org/greenstone/gatherer/GAuthenticator.java
r14567 r18363 42 42 import java.util.*; 43 43 import javax.swing.*; 44 45 44 46 import org.greenstone.gatherer.gui.GLIButton; 47 45 48 46 49 /** Provides a graphic authenticator for network password requests. … … 65 68 /** The default size of this dialog. */ 66 69 static final private Dimension SIZE = new Dimension(470,160); 67 70 71 /** For Wget downloads, we want to avoid the second automatic request for proxy authentication 72 * But the settings for that specific case will otherwise interfere with how this GAuthenticator 73 * is to function in the usual situation. For this reason, we use two modes.*/ 74 static final public int REGULAR = 0; 75 static final public int DOWNLOAD = 1; 76 static private int operationMode = REGULAR; 77 78 public static void setMode(int mode) { 79 operationMode = mode; 80 } 81 68 82 /** Constructor. */ 69 83 public GAuthenticator() { … … 75 89 * @see org.greenstone.gatherer.GAuthenticator.RequestFocusListener 76 90 */ 77 protected PasswordAuthentication getPasswordAuthentication() { 91 protected PasswordAuthentication getPasswordAuthentication(String username_str, String password_str) { 92 if(operationMode == DOWNLOAD) { // special handling of proxy authentication popup for Wget downloads 93 94 // Don't prompt if the details were already saved for the same host and port. This is necessary 95 // when running wget because wget requires proxy authentication. And without the following, the 96 // regular proxy authentication would also popup a dialog requesting the same information. 97 98 String key = getRequestingHost() + ":" + getRequestingPort(); 99 String value = (String)authentications.get(key); 100 101 if(value != null) { // authentication for this host and port was already stored 102 // Arguments may be null. If so, retrieve them from the stored value 103 if(username_str == null) { 104 username_str = value.substring(0, value.indexOf("@")); 105 } 106 if(password_str == null) { 107 password_str = value.substring(value.indexOf("@") + 1); 108 } 109 operationMode = REGULAR; // reset the state of the Authenticator to normal mode 110 return new PasswordAuthentication(username_str, password_str.toCharArray()); 111 } 112 } 113 78 114 // Component definition. 79 115 dialog = new JDialog (Gatherer.g_man, Dictionary.get("GAuthenticator.Title"), true); … … 82 118 JPanel content_pane = (JPanel) dialog.getContentPane(); 83 119 JLabel title_label = new JLabel(getMessageString()); 120 84 121 JPanel user_panel = new JPanel(); 85 122 JLabel username_label = new JLabel(Dictionary.get("GAuthenticator.Username")); 86 123 JTextField username = new JTextField(); 87 124 username.setToolTipText(Dictionary.get("GAuthenticator.Username_Tooltip")); 125 if (username_str != null) { 126 username.setText(username_str); 127 } 128 88 129 JPanel password_panel = new JPanel(); 89 130 JLabel password_label = new JLabel(Dictionary.get("GAuthenticator.Password")); … … 91 132 password.setEchoChar('*'); 92 133 password.setToolTipText(Dictionary.get("GAuthenticator.Password_Tooltip")); 134 if (password_str != null) { 135 password.setText(password_str); 136 } 137 93 138 JPanel button_panel = new JPanel(); 94 139 ok_button = new GLIButton(Dictionary.get("General.OK"), Dictionary.get("General.OK_Tooltip")); … … 134 179 } 135 180 181 protected PasswordAuthentication getPasswordAuthentication() { 182 return getPasswordAuthentication(null,null); 183 } 136 184 137 185 /** This is defined so it can be overridden by subclasses (getRequestingPrompt is final). */ -
gli/branches/rtl-gli/src/org/greenstone/gatherer/Gatherer.java
r14605 r18363 36 36 import javax.swing.plaf.*; 37 37 import javax.swing.text.*; 38 39 38 40 import org.greenstone.gatherer.Configuration; 39 41 import org.greenstone.gatherer.GAuthenticator; 42 import org.greenstone.gatherer.FedoraInfo; 40 43 import org.greenstone.gatherer.collection.CollectionManager; 41 44 import org.greenstone.gatherer.feedback.ActionRecorderDialog; … … 51 54 import org.greenstone.gatherer.gui.URLField; 52 55 import org.greenstone.gatherer.gui.WarningDialog; 56 import org.greenstone.gatherer.gui.FedoraLogin; 53 57 import org.greenstone.gatherer.remote.RemoteGreenstoneServer; 54 58 import org.greenstone.gatherer.util.JarTools; … … 74 78 * in a line which maches this java regex: 75 79 * ^(.*)String\s*PROGRAM_VERSION\s*=\s*"trunk"; 76 * If change the d aclaration and it no longer matches the regex, please80 * If change the declaration and it no longer matches the regex, please 77 81 * change the regex in the gs3-release-maker code and in this message 78 82 */ 83 79 84 static final public String PROGRAM_VERSION = "trunk"; 80 85 81 86 static private Dimension size = new Dimension(800, 540); 87 static public RemoteGreenstoneServer remoteGreenstoneServer = null; 82 88 83 89 /** Has the exit flag been set? */ … … 165 171 // We don't have a local Greenstone! 166 172 go.gsdl_path = null; 173 go.gsdl3_path=null; 174 go.gsdl3_src_path=null; 167 175 168 176 // We have to use our own collect directory since we can't use the Greenstone one 169 177 setCollectDirectoryPath(getGLIUserDirectoryPath() + "collect" + File.separator); 170 if (go.run_gsdl3){171 GS3=true;172 go.gsdl3_path=null;173 go.gsdl3_src_path=null;174 }175 178 } 176 179 // No, we have a local Greenstone … … 186 189 // More special code for running with a remote Greenstone 187 190 if (isGsdlRemote) { 188 Configuration.TEMPLATE_CONFIG_XML = "xml/configRemote.xml"; 189 if (!go.run_gsdl3){ 190 Configuration.CONFIG_XML = "configRemote.xml"; 191 }else{ 192 Configuration.GS3_CONFIG_XML = "config3Remote.xml"; 193 } 191 if (go.fedora_info.isActive()) { 192 Configuration.TEMPLATE_CONFIG_XML = "xml/" + Configuration.FEDORA_CONFIG_PREFIX + "configRemote.xml"; 193 } 194 else { 195 Configuration.TEMPLATE_CONFIG_XML = "xml/configRemote.xml"; 196 } 197 198 Configuration.CONFIG_XML = "configRemote.xml"; 194 199 195 200 File collect_directory = new File(Gatherer.getCollectDirectoryPath()); … … 198 203 } 199 204 } 200 201 init(go.gsdl_path, go.gsdl3_path, go.gsdl3_src_path, go.local_library_path, go.library_url_string, 205 else { 206 if (go.fedora_info.isActive()) { 207 Configuration.TEMPLATE_CONFIG_XML = "xml/" + Configuration.FEDORA_CONFIG_PREFIX + Configuration.CONFIG_XML; 208 } 209 // else, the CONFIG_XML uses the default config file, which is for the local GS server 210 } 211 212 init(go.gsdl_path, go.gsdl3_path, go.gsdl3_src_path, 213 go.fedora_info, 214 go.local_library_path, go.library_url_string, 202 215 go.gliserver_url_string, go.debug, go.perl_path, go.no_load, go.filename, go.site_name, 203 216 go.servlet_path); … … 205 218 206 219 207 public void init(String gsdl_path, String gsdl3_path, String gsdl3_src_path, String local_library_path, 220 public void init(String gsdl_path, String gsdl3_path, String gsdl3_src_path, 221 FedoraInfo fedora_info, 222 String local_library_path, 208 223 String library_url_string, String gliserver_url_string, boolean debug_enabled, 209 224 String perl_path, boolean no_load, String open_collection, … … 245 260 try { 246 261 // Load GLI config file 247 new Configuration(getGLIUserDirectoryPath(), gsdl_path, gsdl3_path, gsdl3_src_path, site_name); 248 262 new Configuration(getGLIUserDirectoryPath(), gsdl_path, gsdl3_path, gsdl3_src_path, site_name, 263 fedora_info); 264 249 265 // Check we know where Perl is 250 266 Configuration.perl_path = perl_path; … … 278 294 } 279 295 280 // Start up the local library server, if that's what we want 281 if (Utility.isWindows() && local_library_path != null && !isGsdlRemote && !GS3) { 282 LocalLibraryServer.start(gsdl_path, local_library_path); 283 } 284 296 if (fedora_info.isActive()) { 297 popupFedoraInfo(); 298 } 299 300 // Finally, we're ready to find out the version of the remote Greenstone server 301 if(isGsdlRemote) { 302 // instantiate the RemoteGreenstoneServer object first 303 remoteGreenstoneServer = new RemoteGreenstoneServer(); 304 305 int greenstoneVersion = 2; 306 requestGLIServerURL(); 307 gliserver_url_string = Configuration.gliserver_url.toString(); 308 309 greenstoneVersion = remoteGreenstoneServer.getGreenstoneVersion(); 310 // Display the version to make error reports a lot more useful 311 System.err.println("Remote Greenstone server version: " + greenstoneVersion); 312 if(greenstoneVersion >= 3) { 313 this.GS3 = true; 314 Configuration.prepareForGS3(); 315 } 316 317 if(fedora_info.isActive()) { 318 // when GS server is remote, FEDORA_HOME resides on the remote server side, 319 // but we know the library URL from user-provided information 320 library_url_string = fedora_info.getLibraryURL(); 321 } else { 322 library_url_string = remoteGreenstoneServer.getLibraryURL(Configuration.gliserver_url.toString()); 323 } 324 } 325 else { // local greenstone: Start up the local library server, if that's what we want 326 if (Utility.isWindows() && local_library_path != null && !GS3) { 327 LocalLibraryServer.start(gsdl_path, local_library_path); 328 } 329 } 330 285 331 // The "-library_url" option overwrites anything in the config files 286 332 if (library_url_string != null && library_url_string.length() > 0) { … … 293 339 } 294 340 } 341 295 342 296 343 // Check that we now know the Greenstone library URL, since we need this for previewing collections … … 298 345 if (Configuration.library_url == null) { 299 346 missingEXEC(); 300 if ((Configuration.library_url!=null) && isGsdlRemote && (gliserver_url_string==null)){301 if (GS3){302 default_gliserver_url = new URL(Configuration.library_url.toString() + "/cgi-bin/gliserver4gs3.pl");303 }else{304 default_gliserver_url = new URL(Configuration.library_url.toString().substring(0,Configuration.library_url.toString().lastIndexOf("/library")) + "/gliserver.pl");305 }306 missingGLIServer();307 }308 347 } 309 348 … … 321 360 // If we're using a remote Greenstone we need to know where the gliserver script is 322 361 DebugStream.println("Configuration.gliserver_url = " + Configuration.gliserver_url); 323 if (isGsdlRemote) {324 if (Configuration.gliserver_url == null) {325 if (Configuration.library_url != null) {326 if (GS3){327 default_gliserver_url = new URL(Configuration.library_url.toString() + "/cgi-bin/gliserver4gs3.pl");328 }else{329 default_gliserver_url = new URL(Configuration.library_url.toString().substring(0,Configuration.library_url.toString().lastIndexOf("/library")) + "/gliserver.pl");330 }331 }332 missingGLIServer();333 }334 if (Configuration.gliserver_url != null) {335 gliserver_url_string = Configuration.gliserver_url.toString();336 }337 }338 362 339 363 if (GS3) { … … 348 372 if (GS3 && Configuration.servlet_path == null) { 349 373 Configuration.servlet_path = servlet_config.getServletPath(Configuration.site_name); 374 } 375 376 // ensure that a directory called 'cache' exists in the GLI user directory 377 File user_cache_dir = new File(Gatherer.getGLIUserCacheDirectoryPath()); 378 System.err.println("User cache dir: " + Gatherer.getGLIUserCacheDirectoryPath()); 379 if (!user_cache_dir.exists() && !user_cache_dir.mkdir()) { 380 System.err.println("Warning: Unable to make directory: " + user_cache_dir); 350 381 } 351 382 … … 424 455 open_collection_file_path = open_collection; 425 456 if (open_collection_file_path == null) { 426 open_collection_file_path = Configuration.getString("general.open_collection", true); 457 open_collection_file_path = Configuration.getString( 458 "general.open_collection"+Configuration.gliPropertyNameSuffix(), true); 427 459 } 428 460 if (no_load || open_collection_file_path.equals("")) { … … 434 466 } 435 467 468 436 469 // Create GUI Manager (last) or else suffer the death of a thousand NPE's 437 470 g_man = new GUIManager(size); … … 443 476 // If using a remote Greenstone we need to download the collection configurations now 444 477 if (Gatherer.isGsdlRemote) { 445 if ( RemoteGreenstoneServer.downloadCollectionConfigurations().equals("")) {478 if (remoteGreenstoneServer.downloadCollectionConfigurations().equals("")) { 446 479 // !! Something went wrong downloading the collection configurations 447 480 System.err.println("Error: Could not download collection configurations."); 448 System.exit(0); 449 } 450 } 451 452 } 481 if(!Gatherer.isApplet) { // don't close the browser if it is an applet! 482 System.exit(0); 483 } 484 } 485 } 486 } 487 488 489 /** Returns the correct version of the (local or remote) Greenstone server if init() has already been called. */ 490 public static int serverVersionNumber() { 491 return GS3 ? 3 : 2; 492 } 493 494 /** Returns "Server: version number" if init() has already been called. */ 495 public static String getServerVersionAsString() { 496 return "Server: v" + serverVersionNumber(); 497 } 453 498 454 499 public void openGUI() … … 511 556 // If using a remote Greenstone we need to download the collection configurations now 512 557 if (Gatherer.isGsdlRemote) { 513 if ( RemoteGreenstoneServer.downloadCollectionConfigurations().equals("")) {558 if (remoteGreenstoneServer.downloadCollectionConfigurations().equals("")) { 514 559 // !! Something went wrong downloading the collection configurations 515 560 System.err.println("Error: Could not download collection configurations."); … … 561 606 562 607 // Get the gui to deallocate 563 g_man.destroy(); 564 g_man_built = false; 608 if(g_man != null) { 609 g_man.destroy(); 610 g_man_built = false; 611 } 565 612 566 613 // Flush debug … … 574 621 // If we're using a remote Greenstone server we need to make sure that all jobs have completed first 575 622 if (isGsdlRemote) { 576 RemoteGreenstoneServer.exit();623 remoteGreenstoneServer.exit(); 577 624 } 578 625 … … 715 762 url = null; 716 763 } 764 catch(java.net.ConnectException connectException) { 765 JOptionPane.showMessageDialog(g_man, Dictionary.get("Preferences.Connection.Library_Path_Connection_Failure", Configuration.library_url.toString()), Dictionary.get("General.Warning"), JOptionPane.WARNING_MESSAGE); 766 DebugStream.println(connectException.getMessage()); 767 } 717 768 catch (Exception exception) { 718 769 DebugStream.printStackTrace(exception); … … 767 818 static private void missingEXEC() { 768 819 WarningDialog dialog; 820 String configPropertyName = "general.library_url"+Configuration.gliPropertyNameSuffix(); 821 769 822 if (GS3) { 770 dialog = new WarningDialog("warning.MissingEXEC", Dictionary.get("MissingEXEC_GS3.Title"), Dictionary.get("MissingEXEC_GS3.Message"), "general.library_url", false); 771 }else { 772 dialog = new WarningDialog("warning.MissingEXEC", Dictionary.get("MissingEXEC.Title"), Dictionary.get("MissingEXEC.Message"), "general.library_url", false); 773 } 774 dialog.setValueField(new URLField(Configuration.getColor("coloring.editable_foreground", false), Configuration.getColor("coloring.editable_background", false))); 823 // Warning dialog with no cancel button and no "turn off warning" checkbox 824 dialog = new WarningDialog("warning.MissingEXEC", Dictionary.get("MissingEXEC_GS3.Title"), Dictionary.get("MissingEXEC_GS3.Message"), configPropertyName, false, false); 825 } else { // local case 826 dialog = new WarningDialog("warning.MissingEXEC", Dictionary.get("MissingEXEC.Title"), Dictionary.get("MissingEXEC.Message"), configPropertyName, false); 827 } 828 829 JTextField field = new URLField.Text(Configuration.getColor("coloring.editable_foreground", false), Configuration.getColor("coloring.editable_background", false)); 830 831 // Set the default library URL to the tomcat server and port number 832 // specified in the build.properties located in the gsdl3_src_path 833 if (GS3) { 834 String host = "localhost"; 835 String port = "8080"; 836 837 File buildPropsFile = new File(Configuration.gsdl3_src_path + File.separator + "build.properties"); 838 if(buildPropsFile.exists()) { 839 Properties props = new Properties(); 840 try{ 841 props.load(new FileInputStream(buildPropsFile)); 842 host = props.getProperty("tomcat.server", host); 843 port = props.getProperty("tomcat.port", port); 844 }catch(Exception e){ 845 DebugStream.println("Could not load build.properties file"); 846 System.err.println("Could not load build.properties file"); 847 } 848 props = null; 849 } 850 String defaultURL = "http://"+host+":"+port+"/"+"greenstone3/library"; 851 field.setText(defaultURL); 852 field.selectAll(); 853 } 854 dialog.setValueField(field); 775 855 dialog.display(); 776 856 dialog.dispose(); 777 857 dialog = null; 778 858 779 String library_url_string = Configuration.getString( "general.library_url", true);859 String library_url_string = Configuration.getString(configPropertyName, true); 780 860 if (!library_url_string.equals("")) { 781 861 try { 862 // WarningDialog does not allow invalid URLs, so the following is ignored: 863 // make sure the URL the user provided contains the http:// prefix 864 // and then save the corrected URL 865 if(!library_url_string.startsWith("http://") 866 && !library_url_string.startsWith("https://")) { 867 library_url_string = "http://"+library_url_string; 868 Configuration.setString(configPropertyName, true, configPropertyName); 869 } 782 870 Configuration.library_url = new URL(library_url_string); 783 871 } … … 789 877 790 878 791 static private void missingGLIServer() 879 880 /** Prints a warning message about a missing library path, which means the final collection cannot be previewed in the Gatherer. 881 */ 882 static private void popupFedoraInfo() { 883 884 FedoraLogin dialog = new FedoraLogin("Fedora Login", false); 885 886 if (Configuration.library_url == null) { 887 888 String library_url_string = dialog.getLibraryURL(); 889 if (!library_url_string.equals("")) { 890 try { 891 Configuration.library_url = new URL(library_url_string); 892 } 893 catch (MalformedURLException exception) { 894 DebugStream.printStackTrace(exception); 895 } 896 } 897 } 898 899 boolean showLogin = true; 900 do { 901 if(!dialog.loginRequested()) { // user pressed cancel to exit the FedoraLogin dialog 902 System.exit(0); 903 } else { 904 showLogin = dialog.loginRequested(); 905 String hostname = dialog.getHostname(); 906 String port = dialog.getPort(); 907 String username = dialog.getUsername(); 908 String password = dialog.getPassword(); 909 String protocol = dialog.getProtocol(); 910 911 Configuration.fedora_info.setHostname(hostname); 912 Configuration.fedora_info.setPort(port); 913 Configuration.fedora_info.setUsername(username); 914 Configuration.fedora_info.setPassword(password); 915 Configuration.fedora_info.setProtocol(protocol); 916 917 String ping_url_str = protocol + "://" + hostname + ":" + port + "/fedora"; 918 String login_str = username + ":" + password; 919 920 String login_encoding = new sun.misc.BASE64Encoder().encode(login_str.getBytes()); 921 922 try { 923 URL ping_url = new URL(ping_url_str); 924 URLConnection uc = ping_url.openConnection(); 925 uc.setRequestProperty ("Authorization", "Basic " + login_encoding); 926 // Attempt to access some content ... 927 InputStream content = (InputStream)uc.getInputStream(); 928 929 // if no exception occurred in the above, we would have come here: 930 showLogin = false; 931 dialog.dispose(); 932 } 933 catch (Exception exception) { 934 // TODO: move into dictionary 935 String[] errorMessage = {"Failed to connect to the Fedora server.", "It might not be running, or", 936 "incorrect username and/or password."}; 937 dialog.setErrorMessage(errorMessage); 938 //DebugStream.printStackTrace(exception); 939 // exception occurred, show the dialog again (do this after printing to 940 // debugStream, else the above does not get done for some reason). 941 dialog.setVisible(true); 942 } 943 } 944 } while(showLogin); 945 946 dialog = null; // no more need of the dialog 947 948 // Now we are connected. 949 } 950 951 952 953 static private void requestGLIServerURL() 792 954 { 793 955 WarningDialog dialog; 794 if (GS3) { 795 dialog = new WarningDialog("warning.MissingGLIServer", Dictionary.get("MissingGLIServer_GS3.Title"), Dictionary.get("MissingGLIServer_GS3.Message"), "general.gliserver_url", false); 796 }else { 797 dialog = new WarningDialog("warning.MissingGLIServer", Dictionary.get("MissingGLIServer.Title"), Dictionary.get("MissingGLIServer.Message"), "general.gliserver_url", false); 798 } 799 dialog.setValueField(new URLField(Configuration.getColor("coloring.editable_foreground", false), Configuration.getColor("coloring.editable_background", false))); 800 956 String[] defaultURLs = { 957 "http://localhost:8080/greenstone3/cgi-bin/gliserver.pl", 958 "http://localhost:8080/gsdl/cgi-bin/gliserver.pl" 959 }; 960 961 // Warning dialog with no cancel button and no "turn off warning" checkbox 962 // (since user-input of the gliserver script is mandatory) 963 dialog = new WarningDialog("warning.MissingGLIServer", Dictionary.get("MissingGLIServer.Title"), Dictionary.get("MissingGLIServer.Message"), "general.gliserver_url", false, false); 964 965 dialog.setValueField(new URLField.DropDown(Configuration.getColor("coloring.editable_foreground", false), 966 Configuration.getColor("coloring.editable_background", false), 967 defaultURLs, "general.gliserver_url", 968 "general.open_collection"+Configuration.gliPropertyNameSuffix(), 969 "gliserver.pl")); 970 801 971 if (Gatherer.default_gliserver_url!=null){ 802 972 dialog.setValueField(Gatherer.default_gliserver_url.toString()); 803 973 } 974 975 // A WarningDialog cannot always be made to respond (let alone to exit the program) on close. We 976 // handle the response of this particular WarningDialog here: a URL for gliserver.pl is a crucial 977 // piece of user-provided data. Therefore, if no URL was entered for gliserver.pl, it'll exit safely. 978 dialog.addWindowListener(new WindowAdapter() { 979 public void windowClosing(WindowEvent e) { 980 Gatherer.exit(); 981 } 982 }); 804 983 805 984 dialog.display(); 806 985 dialog.dispose(); 807 986 dialog = null; 987 808 988 809 989 String gliserver_url_string = Configuration.getString("general.gliserver_url", true); … … 1045 1225 //new way of detection of ImageMagick 1046 1226 InputStreamReader isr = new InputStreamReader(image_magick_process.getInputStream()); 1227 1047 1228 BufferedReader br = new BufferedReader(isr); 1048 1229 // Capture the standard output stream and seach for two particular occurances: Version and ImageMagick. 1049 String line = br.readLine().toLowerCase(); 1050 if (line.indexOf("version") != -1 || line.indexOf("imagemagick") != -1) { 1230 1231 String line = br.readLine(); 1232 if (line == null) { 1233 return false; 1234 } 1235 String lc_line = line.toLowerCase(); 1236 if (lc_line.indexOf("version") != -1 || lc_line.indexOf("imagemagick") != -1) { 1051 1237 return true; 1052 1238 } else { 1053 1239 return false; 1054 1240 } 1241 1055 1242 //return (image_magick_process.exitValue() == 0); 1056 1243 } -
gli/branches/rtl-gli/src/org/greenstone/gatherer/GathererApplet.java
r13599 r18363 87 87 // Ensure platform specific LAF 88 88 try { 89 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 89 //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 90 UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); 90 91 } 91 92 catch (Exception exception) { … … 115 116 Gatherer.isApplet = true; 116 117 String library_url_string = fullLibraryURL(getParameter("gwcgi")); 117 String gliserver_url_string = library_url_string.substring(0, library_url_string.lastIndexOf('/') + 1) + "gliserver.pl"; 118 119 String gs3 = getParameter("gsdl3"); 120 boolean isGS3 = (gs3 == null || !gs3.equals("true")) ? false : true; 121 122 String gliserver_url_string; 123 if(!isGS3) { 124 gliserver_url_string = library_url_string.substring(0, library_url_string.lastIndexOf('/') + 1) + "gliserver.pl"; 125 } else { 126 gliserver_url_string = library_url_string + "/cgi-bin/gliserver.pl"; 127 } 118 128 119 129 // String debug_param = getParameter("debug"); … … 122 132 // } 123 133 124 String[] args = { "-use_remote_greenstone", 125 "-gliserver_url", gliserver_url_string, 126 "-library_url", library_url_string, 127 // "-debug", 128 }; 129 134 String[] args; 135 if(!isGS3) { 136 String[] gs2_args = { 137 "-use_remote_greenstone", 138 "-gliserver_url", gliserver_url_string, 139 "-library_url", library_url_string, 140 // "-debug", 141 }; 142 args = gs2_args; 143 } else { // >= GS3 144 String[] gs3_args = { 145 "-use_remote_greenstone", 146 "-gliserver_url", gliserver_url_string, 147 "-library_url", library_url_string, 148 "-gsdl3", 149 //"-debug", 150 }; 151 args = gs3_args; 152 } 153 130 154 File collect_directory = new File(Gatherer.getCollectDirectoryPath()); 131 155 if (!collect_directory.exists()) { … … 178 202 System.err.println("Destroy called"); 179 203 gatherer.exit(); 204 gatherer = null; 180 205 System.err.println("Done gatherer exit."); 181 206 } … … 189 214 190 215 /** 191 * Method which unzips a given metadata resour e.216 * Method which unzips a given metadata resource. 192 217 * @param jar_zip_fname The name of the jar file as a <strong>String</strong>. 193 218 * @param dst_dir The destination directory for unzipping, also as a <strong>String</strong>. -
gli/branches/rtl-gli/src/org/greenstone/gatherer/GathererApplet4gs3.java
r14330 r18363 117 117 Gatherer.isApplet = true; 118 118 String library_url_string = fullLibraryURL(getParameter("gwcgi")); 119 String gliserver_url_string = library_url_string + "/cgi-bin/gliserver 4gs3.pl";119 String gliserver_url_string = library_url_string + "/cgi-bin/gliserver.pl"; 120 120 String[] args = { "-use_remote_greenstone", 121 121 "-gliserver_url", gliserver_url_string, … … 174 174 System.err.println("Destroy called"); 175 175 gatherer.exit(); 176 gatherer = null; 176 // bug that causes browser (Firefox to freeze) when trying to reload the applet 177 // gatherer = null; 177 178 System.err.println("Done gatherer exit."); 178 179 } -
gli/branches/rtl-gli/src/org/greenstone/gatherer/GathererProg.java
r13599 r18363 55 55 // Ensure platform specific LAF 56 56 try { 57 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 57 // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 58 UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); 58 59 } 59 60 catch (Exception exception) { -
gli/branches/rtl-gli/src/org/greenstone/gatherer/GetOpt.java
r14303 r18363 55 55 public String metadata_path = null; 56 56 57 protected FedoraInfo fedora_info = null; 58 57 59 public GetOpt(String[] args) 58 60 { 59 61 // Default dictionary. Only used for starting error messages. 60 62 Dictionary dictionary = new Dictionary(null, null); 63 64 fedora_info = new FedoraInfo(); 61 65 62 66 // Parse arguments … … 142 146 use_remote_greenstone = true; 143 147 //Use a remote Greenstone 144 145 }else if (argument_name.equals(StaticStrings.GSDL3_ARGUMENT)){148 } 149 else if (argument_name.equals(StaticStrings.GSDL3_ARGUMENT)){ 146 150 //Use a remote Greenstone3 147 151 run_gsdl3=true; … … 149 153 else if (argument_name.equals(StaticStrings.NEW_METADATASET)) { 150 154 new_set = true; 155 } 156 else if(argument_name.equals(StaticStrings.FEDORA_MODE)) { 157 // Running FLI remotely 158 fedora_info.setActive(true); 151 159 } 152 160 } … … 243 251 } 244 252 } 253 254 // Fedora home - when running Fedora locally 255 if(argument_name.equals(StaticStrings.FEDORA_HOME)) { 256 if(argument_value.endsWith(File.separator)) { 257 fedora_info.setHome(argument_value); 258 } 259 else { 260 fedora_info.setHome(argument_value + File.separator); 261 } 262 } 263 264 if(argument_name.equals(StaticStrings.FEDORA_VERSION)) { 265 fedora_info.setVersion(argument_value); 266 } 267 268 // Fedora hostname 269 if(argument_name.equals(StaticStrings.FEDORA_HOSTNAME)) { 270 if(argument_value.endsWith(File.separator)) { 271 fedora_info.setHostname(argument_value); 272 } 273 else { 274 fedora_info.setHostname(argument_value + File.separator); 275 } 276 } 277 // Fedora port 278 if(argument_name.equals(StaticStrings.FEDORA_PORT)) { 279 if(argument_value.endsWith(File.separator)) { 280 fedora_info.setPort(argument_value); 281 } 282 else { 283 fedora_info.setPort(argument_value + File.separator); 284 } 285 } 286 // Fedora username 287 if(argument_name.equals(StaticStrings.FEDORA_USERNAME)) { 288 if(argument_value.endsWith(File.separator)) { 289 fedora_info.setUsername(argument_value); 290 } 291 else { 292 fedora_info.setUsername(argument_value + File.separator); 293 } 294 } 295 // Fedora password 296 if(argument_name.equals(StaticStrings.FEDORA_PASSWORD)) { 297 if(argument_value.endsWith(File.separator)) { 298 fedora_info.setPassword(argument_value); 299 } 300 else { 301 fedora_info.setPassword(argument_value + File.separator); 302 } 303 } 304 // Fedora protocol, e.g. http or https 305 if(argument_name.equals(StaticStrings.FEDORA_PROTOCOL)) { 306 if(argument_value.endsWith(File.separator)) { 307 fedora_info.setProtocol(argument_value); 308 } 309 else { 310 fedora_info.setProtocol(argument_value + File.separator); 311 } 312 } 313 314 315 316 245 317 246 318 }
Note:
See TracChangeset
for help on using the changeset viewer.