Changeset 14974 for gli/trunk/src/org/greenstone/gatherer/Gatherer.java
- Timestamp:
- 2008-02-12T16:13:13+13:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/trunk/src/org/greenstone/gatherer/Gatherer.java
r14605 r14974 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; … … 77 81 * change the regex in the gs3-release-maker code and in this message 78 82 */ 79 static final public String PROGRAM_VERSION = " trunk";83 static final public String PROGRAM_VERSION = "1.0"; 80 84 81 85 static private Dimension size = new Dimension(800, 540); … … 186 190 // More special code for running with a remote Greenstone 187 191 if (isGsdlRemote) { 188 Configuration.TEMPLATE_CONFIG_XML = "xml/configRemote.xml"; 192 if (go.fedora_info.isActive()) { 193 Configuration.TEMPLATE_CONFIG_XML = "xml/" + Configuration.FEDORA_CONFIG_PREFIX + "configRemote.xml"; 194 } 195 else { 196 Configuration.TEMPLATE_CONFIG_XML = "xml/configRemote.xml"; 197 } 198 189 199 if (!go.run_gsdl3){ 190 200 Configuration.CONFIG_XML = "configRemote.xml"; … … 198 208 } 199 209 } 200 201 init(go.gsdl_path, go.gsdl3_path, go.gsdl3_src_path, go.local_library_path, go.library_url_string, 210 else { 211 if (go.fedora_info.isActive()) { 212 Configuration.TEMPLATE_CONFIG_XML = "xml/" + Configuration.FEDORA_CONFIG_PREFIX + Configuration.CONFIG_XML; 213 214 } 215 } 216 217 init(go.gsdl_path, go.gsdl3_path, go.gsdl3_src_path, 218 go.fedora_info, 219 go.local_library_path, go.library_url_string, 202 220 go.gliserver_url_string, go.debug, go.perl_path, go.no_load, go.filename, go.site_name, 203 221 go.servlet_path); … … 205 223 206 224 207 public void init(String gsdl_path, String gsdl3_path, String gsdl3_src_path, String local_library_path, 225 public void init(String gsdl_path, String gsdl3_path, String gsdl3_src_path, 226 FedoraInfo fedora_info, 227 String local_library_path, 208 228 String library_url_string, String gliserver_url_string, boolean debug_enabled, 209 229 String perl_path, boolean no_load, String open_collection, … … 245 265 try { 246 266 // Load GLI config file 247 new Configuration(getGLIUserDirectoryPath(), gsdl_path, gsdl3_path, gsdl3_src_path, site_name); 267 new Configuration(getGLIUserDirectoryPath(), gsdl_path, gsdl3_path, gsdl3_src_path, site_name, 268 fedora_info); 248 269 249 270 // Check we know where Perl is … … 278 299 } 279 300 301 if (fedora_info.isActive()) { 302 popupFedoraInfo(); 303 } 304 305 280 306 // Start up the local library server, if that's what we want 281 307 if (Utility.isWindows() && local_library_path != null && !isGsdlRemote && !GS3) { … … 298 324 if (Configuration.library_url == null) { 299 325 missingEXEC(); 326 300 327 if ((Configuration.library_url!=null) && isGsdlRemote && (gliserver_url_string==null)){ 301 328 if (GS3){ 302 329 default_gliserver_url = new URL(Configuration.library_url.toString() + "/cgi-bin/gliserver4gs3.pl"); 303 330 }else{ 304 default_gliserver_url = new URL(Configuration.library_url.toString().substring(0,Configuration.library_url.toString().lastIndexOf("/library")) + "/gliserver.pl"); 331 String default_gliserver_str = ""; 332 String library_url_str = Configuration.library_url.toString(); 333 int cut_pos = library_url_str.lastIndexOf("/library"); 334 335 if (cut_pos>0) { 336 default_gliserver_str = library_url_str.substring(0,cut_pos) + "/gliserver.pl"; 337 } 338 else { 339 cut_pos = library_url_str.lastIndexOf("/"); 340 if (cut_pos>0) { 341 default_gliserver_str = library_url_str.substring(0,cut_pos) + "/gliserver.pl"; 342 } 343 else { 344 default_gliserver_str = library_url_str + "/gliserver.pl"; 345 } 346 } 347 348 default_gliserver_url = new URL(default_gliserver_str); 305 349 } 306 350 missingGLIServer(); … … 327 371 default_gliserver_url = new URL(Configuration.library_url.toString() + "/cgi-bin/gliserver4gs3.pl"); 328 372 }else{ 329 default_gliserver_url = new URL(Configuration.library_url.toString().substring(0,Configuration.library_url.toString().lastIndexOf("/library")) + "/gliserver.pl"); 373 String library_url = Configuration.library_url.toString(); 374 default_gliserver_url = new URL(library_url.substring(0,library_url.lastIndexOf("/library")) + "/gliserver.pl"); 330 375 } 331 376 } … … 787 832 } 788 833 } 834 835 836 837 /** Prints a warning message about a missing library path, which means the final collection cannot be previewed in the Gatherer. 838 */ 839 static private void popupFedoraInfo() { 840 841 FedoraLogin dialog = new FedoraLogin("Fedora Login", false); 842 843 if (Configuration.library_url == null) { 844 845 String library_url_string = dialog.getLibraryURL(); 846 if (!library_url_string.equals("")) { 847 try { 848 Configuration.library_url = new URL(library_url_string); 849 } 850 catch (MalformedURLException exception) { 851 DebugStream.printStackTrace(exception); 852 } 853 } 854 } 855 856 if (dialog.loginRequested()) { 857 858 String hostname = dialog.getHostname(); 859 String port = dialog.getPort(); 860 String username = dialog.getUsername(); 861 String password = dialog.getPassword(); 862 String protocol = dialog.getProtocol(); 863 864 Configuration.fedora_info.setHostname(hostname); 865 Configuration.fedora_info.setPort(port); 866 Configuration.fedora_info.setUsername(username); 867 Configuration.fedora_info.setPassword(password); 868 Configuration.fedora_info.setProtocol(protocol); 869 870 String ping_url_str = protocol + "://" + hostname + ":" + port + "/fedora"; 871 String login_str = username + ":" + password; 872 873 String login_encoding = new sun.misc.BASE64Encoder().encode(login_str.getBytes()); 874 875 876 try { 877 URL ping_url = new URL(ping_url_str); 878 URLConnection uc = ping_url.openConnection(); 879 uc.setRequestProperty ("Authorization", "Basic " + login_encoding); 880 // Attempt to access some content ... 881 InputStream content = (InputStream)uc.getInputStream(); 882 883 } 884 catch (Exception exception) { 885 System.err.println("****"); 886 System.err.println("* Failed to connect to Fedora server."); 887 System.err.println("* Server might not be running, or incorrect username and/or password."); 888 System.err.println("***"); 889 DebugStream.printStackTrace(exception); 890 System.exit(1); 891 } 892 } 893 else { 894 System.exit(0); 895 } 896 897 898 dialog.dispose(); 899 dialog = null; 900 901 902 } 903 789 904 790 905
Note:
See TracChangeset
for help on using the changeset viewer.