source: gli/trunk/src/org/greenstone/gatherer/Gatherer.java@ 19758

Last change on this file since 19758 was 19758, checked in by ak19, 15 years ago

Created new variable in Gatherer.java called isLocalLibrary that defaults to false and gets initialised upon calling LocalLibraryServer.start(). This variable is now also used in PreviewButton.java so that the Local Library Server is still working with a GSI interface launched either via GLI or independently, and still works with an external apache-web server.

  • Property svn:keywords set to Author Date Id Revision
File size: 48.3 KB
Line 
1/**
2 *#########################################################################
3 *
4 * A component of the Gatherer application, part of the Greenstone digital
5 * library suite from the New Zealand Digital Library Project at the
6 * University of Waikato, New Zealand.
7 *
8 * Author: John Thompson, Greenstone Digital Library, University of Waikato
9 *
10 * Copyright (C) 1999 New Zealand Digital Library Project
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *########################################################################
26 */
27package org.greenstone.gatherer;
28
29import java.awt.*;
30import java.awt.event.*;
31import java.io.*;
32import java.lang.*;
33import java.net.*;
34import java.util.*;
35import javax.swing.*;
36import javax.swing.plaf.*;
37import javax.swing.text.*;
38
39
40import org.greenstone.gatherer.Configuration;
41import org.greenstone.gatherer.GAuthenticator;
42import org.greenstone.gatherer.FedoraInfo;
43import org.greenstone.gatherer.collection.CollectionManager;
44import org.greenstone.gatherer.feedback.ActionRecorderDialog;
45import org.greenstone.gatherer.feedback.Base64;
46import org.greenstone.gatherer.file.FileManager;
47import org.greenstone.gatherer.file.FileAssociationManager;
48import org.greenstone.gatherer.file.RecycleBin;
49import org.greenstone.gatherer.greenstone.Classifiers;
50import org.greenstone.gatherer.greenstone.LocalGreenstone;
51import org.greenstone.gatherer.greenstone.LocalLibraryServer;
52import org.greenstone.gatherer.greenstone.Plugins;
53import org.greenstone.gatherer.greenstone3.ServletConfiguration;
54import org.greenstone.gatherer.gui.GUIManager;
55import org.greenstone.gatherer.gui.URLField;
56import org.greenstone.gatherer.gui.WarningDialog;
57import org.greenstone.gatherer.gui.FedoraLogin;
58import org.greenstone.gatherer.remote.RemoteGreenstoneServer;
59import org.greenstone.gatherer.util.JarTools;
60import org.greenstone.gatherer.util.StaticStrings;
61import org.greenstone.gatherer.util.Utility;
62
63
64/** Containing the top-level "core" for the Gatherer, this class is the
65 * common core for the GLI application and applet. It first parses the
66 * command line arguments, preparing to update the configuration as
67 * required. Next it loads several important support classes such as the
68 * Configuration and Dictionary. Finally it creates the other important
69 * managers and sends them on their way.
70 * @author John Thompson, Greenstone Digital Library, University of Waikato
71 * @version 2.3
72 */
73public class Gatherer
74{
75 /** The name of the GLI. */
76 static final public String PROGRAM_NAME = "Greenstone Librarian Interface";
77 /** The current version of the GLI.
78 * Note: the gs3-release-maker relies on this variable being declared
79 * in a line which maches this java regex:
80 * ^(.*)String\s*PROGRAM_VERSION\s*=\s*"trunk";
81 * If change the declaration and it no longer matches the regex, please
82 * change the regex in the gs3-release-maker code and in this message
83 */
84
85 static final public String PROGRAM_VERSION = "trunk";
86
87 static private Dimension size = new Dimension(800, 540);
88 static public RemoteGreenstoneServer remoteGreenstoneServer = null;
89
90 /** Has the exit flag been set? */
91 static final public int EXIT_THEN_RESTART= 2;
92 static public boolean exit = false;
93 static public int exit_status = 0;
94
95 static private String gli_directory_path = null;
96 static private String gli_user_directory_path = null;
97
98 static public String client_operating_system = null;
99
100 /** All of the external applications that must exit before we close the Gatherer. */
101 static private Vector apps = new Vector();
102 static private String non_standard_collect_directory_path = null;
103 static public String open_collection_file_path = null;
104 /** A public reference to the FileAssociationManager. */
105 static public FileAssociationManager assoc_man;
106 /** A public reference to the CollectionManager. */
107 static public CollectionManager c_man;
108 /** A public reference to the RecycleBin. */
109 static public RecycleBin recycle_bin;
110 /** a reference to the Servlet Configuration is GS3 */
111 static public ServletConfiguration servlet_config;
112 /** A public reference to the FileManager. */
113 static public FileManager f_man;
114 /** A public reference to the GUIManager. */
115 static public GUIManager g_man = null;
116 static private boolean g_man_built = false;
117
118 /** We are using the GLI for GS3 */
119 static public boolean GS3 = false;
120
121 static public boolean isApplet = false;
122 static public boolean isGsdlRemote = false;
123 static public boolean isLocalLibrary = false;
124
125 /* TODO: If we're using local GLI, collections are built locally. If we're using client-GLI
126 * and it contains a gs2build folder in it, then localBuild will also be true (if this is not
127 * turned off in Preferences). If we're remote and this is turned off in Prefs, build remotely. */
128 /*static public boolean buildingLocally = true;*/
129 /** If we're using local GLI, we can always download. If we're using client-GLI, we can only
130 * download if we have a gs2build folder inside it. And if we don't turn off downloadEnabling
131 * in the preferences.
132 */
133 static public boolean isDownloadEnabled = true;
134
135 // feedback stuff
136 /** is the feedback feature enabled? */
137 static public boolean feedback_enabled = true;
138 /** the action recorder dialog */
139 static public ActionRecorderDialog feedback_dialog = null;
140
141 // Refresh reasons
142 static public final int COLLECTION_OPENED = 0;
143 static public final int COLLECTION_CLOSED = 1;
144 static public final int COLLECTION_REBUILT = 2;
145 static public final int PREFERENCES_CHANGED = 3;
146
147 //////kk added////////
148 static public String cgiBase="";
149 /////////////////
150
151 /** Magic to allow Enter to fire the default button. */
152 static {
153 KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
154 Keymap map = JTextComponent.getKeymap(JTextComponent.DEFAULT_KEYMAP);
155 map.removeKeyStrokeBinding(enter);
156 }
157
158 static private URL default_gliserver_url=null;
159
160 public Gatherer(String[] args)
161 {
162 // Display the version to make error reports a lot more useful
163 System.err.println("Version: " + PROGRAM_VERSION + "\n");
164
165 JarTools.initialise(this);
166
167 GetOpt go = new GetOpt(args);
168
169 // Remember the GSDLOS value
170 client_operating_system = go.client_operating_system;
171
172 // If feedback is enabled, set up the recorder dialog
173 if (go.feedback_enabled) {
174 // Use the default locale for now - this will be changed by the Gatherer run method
175 feedback_enabled = true;
176 feedback_dialog = new ActionRecorderDialog(Locale.getDefault());
177 }
178
179 // Are we using a remote Greenstone?
180 if (go.use_remote_greenstone) {
181 isGsdlRemote = true;
182
183 // We don't have a local Greenstone!
184 go.gsdl3_path=null;
185 go.gsdl3_src_path=null;
186
187 // Don't set go.gsdl_path to null, since gdsl_path may still be set
188 // if we have a client-gli containing gs2build folder.
189 // However, keep track of whether we can download.
190 if(go.gsdl_path == null) {
191 isDownloadEnabled = false;
192 }
193
194 // We have to use our own collect directory since we can't use the Greenstone one
195 setCollectDirectoryPath(getGLIUserDirectoryPath() + "collect" + File.separator);
196 }
197 // We have a local Greenstone. OR we have a gs2build folder inside
198 // the client-GLI folder (with which the Download panel becomes enabled)
199 if(isDownloadEnabled) {
200 LocalGreenstone.setDirectoryPath(go.gsdl_path);
201 }
202
203 // Users may specify a non-standard collect directory (eg. when running one GLI in a network environment)
204 if (go.collect_directory_path != null) {
205 setCollectDirectoryPath(go.collect_directory_path);
206 }
207
208 // More special code for running with a remote Greenstone
209 if (isGsdlRemote) {
210 if (go.fedora_info.isActive()) {
211 Configuration.TEMPLATE_CONFIG_XML = "xml/" + Configuration.FEDORA_CONFIG_PREFIX + "configRemote.xml";
212 }
213 else {
214 Configuration.TEMPLATE_CONFIG_XML = "xml/configRemote.xml";
215 }
216
217 Configuration.CONFIG_XML = "configRemote.xml";
218
219 File collect_directory = new File(Gatherer.getCollectDirectoryPath());
220 if (!collect_directory.exists() && !collect_directory.mkdir()) {
221 System.err.println("Warning: Unable to make directory: " + collect_directory);
222 }
223 }
224 else {
225 if (go.fedora_info.isActive()) {
226 Configuration.TEMPLATE_CONFIG_XML = "xml/" + Configuration.FEDORA_CONFIG_PREFIX + Configuration.CONFIG_XML;
227 }
228 // else, the CONFIG_XML uses the default config file, which is for the local GS server
229 }
230
231 init(go.gsdl_path, go.gsdl3_path, go.gsdl3_src_path,
232 go.fedora_info,
233 go.local_library_path, go.library_url_string,
234 go.gliserver_url_string, go.debug, go.perl_path, go.no_load, go.filename, go.site_name,
235 go.servlet_path);
236 }
237
238
239 public void init(String gsdl_path, String gsdl3_path, String gsdl3_src_path,
240 FedoraInfo fedora_info,
241 String local_library_path,
242 String library_url_string, String gliserver_url_string, boolean debug_enabled,
243 String perl_path, boolean no_load, String open_collection,
244 String site_name, String servlet_path)
245 {
246 if (gsdl3_path != null && !gsdl3_path.equals("")) {
247 this.GS3 = true;
248 } else {
249 gsdl3_path = null;
250 gsdl3_src_path = null;
251 }
252
253 // Create the debug stream if required
254 if (debug_enabled) {
255 DebugStream.enableDebugging();
256
257 Calendar now = Calendar.getInstance();
258 String debug_file_path = "debug" + now.get(Calendar.DATE) + "-" + now.get(Calendar.MONTH) + "-" + now.get(Calendar.YEAR) + ".txt";
259
260 // Debug file is created in the user's GLI directory
261 debug_file_path = getGLIUserDirectoryPath() + debug_file_path;
262 DebugStream.println("Debug file path: " + debug_file_path);
263 DebugStream.setDebugFile(debug_file_path);
264 DebugStream.print(System.getProperties());
265 }
266
267 // Delete plugins.dat and classifiers.dat files from previous versions of the GLI (no longer used)
268 File plugins_dat_file = new File(Gatherer.getGLIUserDirectoryPath() + "plugins.dat");
269 if (plugins_dat_file.exists()) {
270 System.err.println("Deleting plugins.dat file...");
271 Utility.delete(plugins_dat_file);
272 }
273 File classifiers_dat_file = new File(Gatherer.getGLIUserDirectoryPath() + "classifiers.dat");
274 if (classifiers_dat_file.exists()) {
275 System.err.println("Deleting classifiers.dat file...");
276 Utility.delete(classifiers_dat_file);
277 }
278
279 try {
280 // Load GLI config file
281 new Configuration(getGLIUserDirectoryPath(), gsdl_path, gsdl3_path, gsdl3_src_path, site_name,
282 fedora_info);
283
284 // Check we know where Perl is
285 Configuration.perl_path = perl_path;
286 if (isGsdlRemote && !isDownloadEnabled && Utility.isWindows() && Configuration.perl_path != null) {
287 if (Configuration.perl_path.toLowerCase().endsWith("perl.exe")) {
288 Configuration.perl_path = Configuration.perl_path.substring(0, Configuration.perl_path.length() - "perl.exe".length());
289 }
290 if (Configuration.perl_path.endsWith(File.separator)) {
291 Configuration.perl_path = Configuration.perl_path.substring(0, Configuration.perl_path.length() - File.separator.length());
292 }
293 }
294
295 // the feedback dialog has been loaded with a default locale,
296 // now set the user specified one
297 if (feedback_enabled && feedback_dialog != null) {
298 feedback_dialog.setLocale(Configuration.getLocale("general.locale", true));
299 }
300
301 // Read Dictionary
302 new Dictionary(Configuration.getLocale("general.locale", true), Configuration.getFont("general.font", true));
303
304 // check that we are using Sun Java
305 String java_vendor = System.getProperty("java.vendor");
306 if (!java_vendor.equals("Sun Microsystems Inc.")) {
307 System.err.println(Dictionary.get("General.NotSunJava", java_vendor));
308 }
309
310 // Unless we're using remote building, we need to know where the local Greenstone is
311 if (!isGsdlRemote && gsdl_path == null) {
312 missingGSDL();
313 }
314
315 if (fedora_info.isActive()) {
316 popupFedoraInfo();
317 }
318
319 // Finally, we're ready to find out the version of the remote Greenstone server
320 if(isGsdlRemote) {
321 // instantiate the RemoteGreenstoneServer object first
322 remoteGreenstoneServer = new RemoteGreenstoneServer();
323
324 // Set up proxy
325 setProxy();
326 // Now we set up an Authenticator
327 Authenticator.setDefault(new GAuthenticator());
328
329 int greenstoneVersion = 2;
330 requestGLIServerURL();
331 gliserver_url_string = Configuration.gliserver_url.toString();
332
333 greenstoneVersion = remoteGreenstoneServer.getGreenstoneVersion();
334 // Display the version to make error reports a lot more useful
335 System.err.println("Remote Greenstone server version: " + greenstoneVersion);
336 if(greenstoneVersion >= 3) {
337 this.GS3 = true;
338 Configuration.prepareForGS3();
339 }
340
341 if(fedora_info.isActive()) {
342 // when GS server is remote, FEDORA_HOME resides on the remote server side,
343 // but we know the library URL from user-provided information
344 library_url_string = fedora_info.getLibraryURL();
345 } else {
346 library_url_string = remoteGreenstoneServer.getLibraryURL(Configuration.gliserver_url.toString());
347 }
348 // write it into the config file
349 Configuration.setString("general.library_url", true, library_url_string);
350 }
351 else { // local greenstone: Start up the local library server, if that's what we want
352 if (!GS3) {
353 isLocalLibrary = LocalLibraryServer.start(gsdl_path, local_library_path);
354 }
355 // else web library: GS server is local, but doesn't use the webserver included with GS2
356 }
357
358 // The "-library_url" option overwrites anything in the config files
359 if (library_url_string != null && library_url_string.length() > 0) {
360 try {
361 System.err.println("Setting library_url to " + library_url_string + "...");
362 Configuration.library_url = new URL(library_url_string);
363 }
364 catch (MalformedURLException error) {
365 DebugStream.printStackTrace(error);
366 }
367 }
368
369
370 // Check that we now know the Greenstone library URL, since we need this for previewing collections
371 // It is not necessary if an independent GSI was launched and the user hasn't pressed Enter Library yet
372 DebugStream.println("Configuration.library_url = " + Configuration.library_url);
373 if (Configuration.library_url == null && (isLocalLibrary && !LocalLibraryServer.isURLPending())) {
374 missingEXEC();
375 }
376
377 // The "-gliserver_url" option overwrites anything in the config files
378 if (gliserver_url_string != null && gliserver_url_string.length() > 0) {
379 try {
380 System.err.println("Setting gliserver_url to " + gliserver_url_string + "...");
381 Configuration.gliserver_url = new URL(gliserver_url_string);
382 }
383 catch (MalformedURLException error) {
384 DebugStream.printStackTrace(error);
385 }
386 }
387
388 // If we're using a remote Greenstone we need to know where the gliserver script is
389 DebugStream.println("Configuration.gliserver_url = " + Configuration.gliserver_url);
390
391 if (GS3) {
392 // Load Greenstone 3 servlet configuration
393 if (isGsdlRemote){
394 servlet_config = new ServletConfiguration(Configuration.gli_user_directory_path);
395 }else{
396 servlet_config= new ServletConfiguration(gsdl3_path);
397 }
398 }
399
400 if (GS3 && Configuration.servlet_path == null) {
401 Configuration.servlet_path = servlet_config.getServletPath(Configuration.site_name);
402 }
403
404 // ensure that a directory called 'cache' exists in the GLI user directory
405 File user_cache_dir = new File(Gatherer.getGLIUserCacheDirectoryPath());
406 System.err.println("User cache dir: " + Gatherer.getGLIUserCacheDirectoryPath());
407 if (!user_cache_dir.exists() && !user_cache_dir.mkdir()) {
408 System.err.println("Warning: Unable to make directory: " + user_cache_dir);
409 }
410
411 // Check for ImageMagick
412 if (Gatherer.isGsdlRemote) {
413 DebugStream.println("Not checking for ImageMagick.");
414 }
415 else if (!(new ImageMagickTest()).found()) {
416 // Time for a warning message
417 missingImageMagick();
418 }
419
420 if (Gatherer.isGsdlRemote) {
421 DebugStream.println("Not checking for perl path/exe");
422 }
423 else {
424 // Perl path is a little different as it is perfectly ok to
425 // start the GLI without providing a perl path
426 boolean found_perl = false;
427 if (Configuration.perl_path != null) {
428 // See if the file pointed to actually exists
429 File perl_file = new File(Configuration.perl_path);
430 found_perl = perl_file.exists();
431 perl_file = null;
432 }
433 if (Configuration.perl_path == null || !found_perl) {
434 // Run test to see if we can run perl as is.
435 PerlTest perl_test = new PerlTest();
436 if (perl_test.found()) {
437 // If so replace the perl path with the system
438 // default (or null for unix).
439 Configuration.perl_path = perl_test.toString();
440 found_perl = true;
441 }
442 }
443 if (!found_perl) {
444 // Time for an error message.
445 missingPERL();
446 }
447 }
448
449 // Set the default font for all Swing components.
450 FontUIResource default_font = Configuration.getFont("general.font", true);
451 Enumeration keys = UIManager.getDefaults().keys();
452 while (keys.hasMoreElements()) {
453 Object key = keys.nextElement();
454 Object value = UIManager.get(key);
455 if (value instanceof FontUIResource) {
456 UIManager.put(key, default_font);
457 }
458 }
459
460 // At this point (which is where this code originally used to be), we can set up the proxy for the
461 // non-remote case. The remote Greenstone server would already have setup its proxy when required.
462 if(!isGsdlRemote) {
463 setProxy();
464 // Now we set up an Authenticator
465 Authenticator.setDefault(new GAuthenticator());
466 }
467 assoc_man = new FileAssociationManager();
468 // Create File Manager
469 f_man = new FileManager();
470 // Create Collection Manager
471 c_man = new CollectionManager();
472 // Create Recycle Bin
473 recycle_bin = new RecycleBin();
474
475 if (GS3) {
476 if (site_name==null) {
477 site_name = Configuration.site_name;
478 servlet_path = null; // need to reset this
479 }
480 if (servlet_path == null) {
481 servlet_path = Configuration.getServletPath();
482 }
483 }
484
485 open_collection_file_path = open_collection;
486 if (open_collection_file_path == null) {
487 open_collection_file_path = Configuration.getString(
488 "general.open_collection"+Configuration.gliPropertyNameSuffix(), true);
489 }
490 if (no_load || open_collection_file_path.equals("")) {
491 open_collection_file_path = null;
492 }
493 }
494 catch (Exception exception) {
495 DebugStream.printStackTrace(exception);
496 }
497
498
499 // Create GUI Manager (last) or else suffer the death of a thousand NPE's
500 g_man = new GUIManager(size);
501
502 // Get a list of the core Greenstone classifiers and plugins
503 Classifiers.loadClassifiersList(null);
504 Plugins.loadPluginsList(null);
505
506 // If using a remote Greenstone we need to download the collection configurations now
507 if (Gatherer.isGsdlRemote) {
508 if (remoteGreenstoneServer.downloadCollectionConfigurations().equals("")) {
509 // !! Something went wrong downloading the collection configurations
510 System.err.println("Error: Could not download collection configurations.");
511 if(!Gatherer.isApplet) { // don't close the browser if it is an applet!
512 System.exit(0);
513 }
514 }
515 }
516 }
517
518
519 /** Returns the correct version of the (local or remote) Greenstone server if init() has already been called. */
520 public static int serverVersionNumber() {
521 return GS3 ? 3 : 2;
522 }
523
524 /** Returns "Server: version number" if init() has already been called. */
525 public static String getServerVersionAsString() {
526 return "Server: v" + serverVersionNumber();
527 }
528
529 public void openGUI()
530 {
531 // Size and place the frame on the screen
532 Rectangle bounds = Configuration.getBounds("general.bounds", true);
533 if (bounds == null) {
534 // Choose a sensible default value
535 bounds = new Rectangle(0, 0, 640, 480);
536 }
537
538 // Ensure width and height are reasonable
539 size = bounds.getSize();
540 if (size.width < 640) {
541 size.width = 640;
542 }
543 else if (size.width > Configuration.screen_size.width && Configuration.screen_size.width > 0) {
544 size.width = Configuration.screen_size.width;
545 }
546 if (size.height < 480) {
547 size.height = 480;
548 }
549 else if (size.height > Configuration.screen_size.height && Configuration.screen_size.height > 0) {
550 size.height = Configuration.screen_size.height;
551 }
552
553 if (!g_man_built) {
554
555 g_man.display();
556
557 // Place the window in the desired location on the screen, if this is do-able (not under most linux window managers apparently. In fact you're lucky if they listen to any of your screen size requests).
558 g_man.setLocation(bounds.x, bounds.y);
559 g_man.setVisible(true);
560
561 // After the window has been made visible, check that it is in the correct place
562 // sometimes java places a window not in the correct place,
563 // but with an offset. If so, we work out what the offset is
564 // and change the desired location to take that into account
565 Point location = g_man.getLocation();
566 int x_offset = bounds.x - location.x;
567 int y_offset = bounds.y - location.y;
568 // If not, offset the window to move it into the correct location
569 if (x_offset > 0 || y_offset > 0) {
570 ///ystem.err.println("changing the location to "+(bounds.x + x_offset)+" "+ (bounds.y + y_offset));
571 g_man.setLocation(bounds.x + x_offset, bounds.y + y_offset);
572 }
573
574 // The 'after-display' triggers several events which don't occur until after the visual components are actually available on screen. Examples of these would be the various html renderings, as they can't happen offscreen.
575 g_man.afterDisplay();
576 g_man_built = true;
577 }
578 else {
579 g_man.setVisible(true);
580 }
581
582 // Get a list of the core Greenstone classifiers and plugins
583 /*Classifiers.loadClassifiersList(null);
584 Plugins.loadPluginsList(null);
585
586 // If using a remote Greenstone we need to download the collection configurations now
587 if (Gatherer.isGsdlRemote) {
588 if (remoteGreenstoneServer.downloadCollectionConfigurations().equals("")) {
589 // !! Something went wrong downloading the collection configurations
590 System.err.println("Error: Could not download collection configurations.");
591 System.exit(0);
592 }
593 }*/
594
595 // If there was a collection left open last time, reopen it
596 if (open_collection_file_path == null) {
597
598 //the menu bar items, file and edit, are disabled from the moment of their creation. if there is no left-over collection from the last session, enable them; otherwise it is untill the collection finishes loading, will they be enabled in collectionManager.java
599 setMenuBarEnabled(true);
600 } else {
601
602 // If there was a collection left open last time, reopen it
603 c_man.openCollectionFromLastTime();
604 }
605 }
606
607 public static void setMenuBarEnabled(boolean enabled) {
608 g_man.menu_bar.file.setEnabled(enabled);
609 g_man.menu_bar.edit.setEnabled(enabled);
610 }
611
612 /** Exits the Gatherer after ensuring that things needing saving are saved.
613 * @see java.io.FileOutputStream
614 * @see java.io.PrintStream
615 * @see java.lang.Exception
616 * @see javax.swing.JOptionPane
617 * @see org.greenstone.gatherer.Configuration
618 * @see org.greenstone.gatherer.collection.CollectionManager
619 * @see org.greenstone.gatherer.gui.GUIManager
620 */
621 static public void exit(int new_exit_status)
622 {
623 DebugStream.println("In Gatherer.exit()...");
624 exit = true;
625 if (new_exit_status != 0) {
626 // default exit_status is already 0
627 // only remember a new exit status if it is non-trivial
628 exit_status = new_exit_status;
629 }
630
631 // Save the file associations
632 if (assoc_man != null) {
633 assoc_man.save();
634 assoc_man = null;
635 }
636
637 // Get the gui to deallocate
638 if(g_man != null) {
639 g_man.destroy();
640 g_man_built = false;
641 }
642
643 // Flush debug
644 DebugStream.closeDebugStream();
645
646 // If we started a server, we should try to stop it.
647 if (LocalLibraryServer.isRunning() == true) {
648 LocalLibraryServer.stop();
649 }
650
651 // If we're using a remote Greenstone server we need to make sure that all jobs have completed first
652 if (isGsdlRemote) {
653 remoteGreenstoneServer.exit();
654 }
655
656 // Make sure we haven't started up any processes that are still running
657 if (apps.size() == 0) {
658 // If we're running as an applet we don't actually quit (just hide the main GLI window)
659 if (!Gatherer.isApplet) {
660 // This is the end...
661 System.exit(exit_status);
662 }
663 }
664 else {
665 JOptionPane.showMessageDialog(g_man, Dictionary.get("General.Outstanding_Processes"), Dictionary.get("General.Outstanding_Processes_Title"), JOptionPane.ERROR_MESSAGE);
666 g_man.setVisible(false);
667 }
668 }
669
670 static public void exit()
671 {
672 exit(0);
673 }
674
675 /** Returns the path of the Greenstone "collect" directory. */
676 static public String getCollectDirectoryPath()
677 {
678 if (non_standard_collect_directory_path != null) {
679 return non_standard_collect_directory_path;
680 }
681
682 if (!GS3) {
683 return Configuration.gsdl_path + "collect" + File.separator;
684 }
685 else {
686 return getSitesDirectoryPath() + Configuration.site_name + File.separator + "collect" + File.separator;
687 }
688 }
689
690
691 /** Returns the path of the GLI directory. */
692 static public String getGLIDirectoryPath()
693 {
694 return gli_directory_path;
695 }
696
697
698 /** Returns the path of the GLI "metadata" directory. */
699 static public String getGLIMetadataDirectoryPath()
700 {
701 return getGLIDirectoryPath() + "metadata" + File.separator;
702 }
703
704
705 /** Returns the path of the GLI user directory. */
706 static public String getGLIUserDirectoryPath()
707 {
708 return gli_user_directory_path;
709 }
710
711
712 /** Returns the path of the GLI user "cache" directory. */
713 static public String getGLIUserCacheDirectoryPath()
714 {
715 return getGLIUserDirectoryPath() + "cache" + File.separator;
716 }
717
718
719 /** Returns the path of the GLI user "log" directory. */
720 static public String getGLIUserLogDirectoryPath()
721 {
722 return getGLIUserDirectoryPath() + "log" + File.separator;
723 }
724
725
726 static public String getSitesDirectoryPath()
727 {
728 return Configuration.gsdl3_path + "sites" + File.separator;
729 }
730
731
732 static public void setCollectDirectoryPath(String collect_directory_path)
733 {
734 non_standard_collect_directory_path = collect_directory_path;
735 if (!non_standard_collect_directory_path.endsWith(File.separator)) {
736 non_standard_collect_directory_path = non_standard_collect_directory_path + File.separator;
737 }
738 }
739
740
741 static public void setGLIDirectoryPath(String gli_directory_path_arg)
742 {
743 gli_directory_path = gli_directory_path_arg;
744 }
745
746
747 static public void setGLIUserDirectoryPath(String gli_user_directory_path_arg)
748 {
749 gli_user_directory_path = gli_user_directory_path_arg;
750
751 // Ensure the GLI user directory exists
752 File gli_user_directory = new File(gli_user_directory_path);
753 if (!gli_user_directory.exists() && !gli_user_directory.mkdirs()) {
754 System.err.println("Error: Unable to make directory: " + gli_user_directory);
755 }
756 }
757
758
759 static public void refresh(int refresh_reason)
760 {
761 if (g_man != null) {
762
763 g_man.refresh(refresh_reason, c_man.ready());
764 }
765
766 // Now is a good time to force a garbage collect
767 System.gc();
768 }
769
770
771 // used to send reload coll messages to the tomcat server
772 static public void configGS3Server(String site, String command) {
773 if (Configuration.library_url == null){
774 System.out.println("Error: you have not provide the Greenstone Library address.");
775 return;
776
777 }
778
779 try {
780 // need to add the servlet name to the exec address
781 String raw_url = Configuration.library_url.toString() + Configuration.getServletPath() + command;
782 URL url = new URL(raw_url);
783 DebugStream.println("Action: " + raw_url);
784 HttpURLConnection library_connection = (HttpURLConnection) url.openConnection();
785 int response_code = library_connection.getResponseCode();
786 if(HttpURLConnection.HTTP_OK <= response_code && response_code < HttpURLConnection.HTTP_MULT_CHOICE) {
787 DebugStream.println("200 - Complete.");
788 }
789 else {
790 DebugStream.println("404 - Failed.");
791 }
792 url = null;
793 }
794 catch(java.net.ConnectException connectException) {
795 JOptionPane.showMessageDialog(g_man, Dictionary.get("Preferences.Connection.Library_Path_Connection_Failure", Configuration.library_url.toString()), Dictionary.get("General.Warning"), JOptionPane.WARNING_MESSAGE);
796 DebugStream.println(connectException.getMessage());
797 }
798 catch (Exception exception) {
799 DebugStream.printStackTrace(exception);
800 }
801 }
802
803
804 /** Used to 'spawn' a new child application when a file is double clicked.
805 * @param file The file to open
806 * @see org.greenstone.gatherer.Gatherer.ExternalApplication
807 */
808 static public void spawnApplication(File file) {
809 String [] commands = assoc_man.getCommand(file);
810 if(commands != null) {
811 ExternalApplication app = new ExternalApplication(commands);
812 apps.add(app);
813 app.start();
814 }
815 else {
816 ///ystem.err.println("No open command available.");
817 }
818 }
819
820
821 static public void spawnApplication(String command)
822 {
823 ExternalApplication app = new ExternalApplication(command);
824 apps.add(app);
825 app.start();
826 }
827
828 static public void spawnApplication(String command, String ID)
829 {
830 ExternalApplication app = new ExternalApplication(command, ID);
831 apps.add(app);
832 app.start();
833 }
834
835 static public void terminateApplication(String ID) {
836 for(int i = 0; i < apps.size(); i++) {
837 ExternalApplication app = (ExternalApplication)apps.get(i);
838 if(app.getID() != null && app.getID().equals(ID)) {
839 app.stopExternalApplication();
840 apps.remove(app);
841 }
842 }
843 }
844
845
846 /** Used to 'spawn' a new browser application or reset an existing one when the preview button is clicked
847 * @param url The url to open the browser at
848 * @see org.greenstone.gatherer.Gatherer.BrowserApplication
849 */
850 static public void spawnBrowser(String url) {
851 String command = assoc_man.getBrowserCommand(url);
852 if (command != null) {
853 BrowserApplication app = new BrowserApplication(command, url);
854 apps.add(app);
855 app.start();
856 }
857 else {
858 ///ystem.err.println("No browser command available.");
859 }
860 }
861
862
863 /** Prints a warning message about a missing library path, which means the final collection cannot be previewed in the Gatherer.
864 */
865 static private void missingEXEC() {
866 WarningDialog dialog;
867 String configPropertyName = "general.library_url"+Configuration.gliPropertyNameSuffix();
868
869 if (GS3) {
870 // Warning dialog with no cancel button and no "turn off warning" checkbox
871 dialog = new WarningDialog("warning.MissingEXEC", Dictionary.get("MissingEXEC_GS3.Title"), Dictionary.get("MissingEXEC_GS3.Message"), configPropertyName, false, false);
872 } else { // local case
873 dialog = new WarningDialog("warning.MissingEXEC", Dictionary.get("MissingEXEC.Title"), Dictionary.get("MissingEXEC.Message"), configPropertyName, false);
874 }
875
876 JTextField field = new URLField.Text(Configuration.getColor("coloring.editable_foreground", false), Configuration.getColor("coloring.editable_background", false));
877
878 // Set the default library URL to the tomcat server and port number
879 // specified in the build.properties located in the gsdl3_src_path
880 if (GS3) {
881 String host = "localhost";
882 String port = "8080";
883
884 File buildPropsFile = new File(Configuration.gsdl3_src_path + File.separator + "build.properties");
885 if(buildPropsFile.exists()) {
886 Properties props = new Properties();
887 try{
888 props.load(new FileInputStream(buildPropsFile));
889 host = props.getProperty("tomcat.server", host);
890 port = props.getProperty("tomcat.port", port);
891 }catch(Exception e){
892 DebugStream.println("Could not load build.properties file");
893 System.err.println("Could not load build.properties file");
894 }
895 props = null;
896 }
897 String defaultURL = "http://"+host+":"+port+"/"+"greenstone3/library";
898 field.setText(defaultURL);
899 field.selectAll();
900 }
901 dialog.setValueField(field);
902 dialog.display();
903 dialog.dispose();
904 dialog = null;
905
906 String library_url_string = Configuration.getString(configPropertyName, true);
907 if (!library_url_string.equals("")) {
908 try {
909 // WarningDialog does not allow invalid URLs, so the following is ignored:
910 // make sure the URL the user provided contains the http:// prefix
911 // and then save the corrected URL
912 if(!library_url_string.startsWith("http://")
913 && !library_url_string.startsWith("https://")) {
914 library_url_string = "http://"+library_url_string;
915 Configuration.setString(configPropertyName, true, configPropertyName);
916 }
917 Configuration.library_url = new URL(library_url_string);
918 }
919 catch (MalformedURLException exception) {
920 DebugStream.printStackTrace(exception);
921 }
922 }
923 }
924
925
926
927 /** Prints a warning message about a missing library path, which means the final collection cannot be previewed in the Gatherer.
928 */
929 static private void popupFedoraInfo() {
930
931 FedoraLogin dialog = new FedoraLogin("Fedora Login", false);
932
933 if (Configuration.library_url == null) {
934
935 String library_url_string = dialog.getLibraryURL();
936 if (!library_url_string.equals("")) {
937 try {
938 Configuration.library_url = new URL(library_url_string);
939 }
940 catch (MalformedURLException exception) {
941 DebugStream.printStackTrace(exception);
942 }
943 }
944 }
945
946 boolean showLogin = true;
947 do {
948 if(!dialog.loginRequested()) { // user pressed cancel to exit the FedoraLogin dialog
949 System.exit(0);
950 } else {
951 showLogin = dialog.loginRequested();
952 String hostname = dialog.getHostname();
953 String port = dialog.getPort();
954 String username = dialog.getUsername();
955 String password = dialog.getPassword();
956 String protocol = dialog.getProtocol();
957
958 Configuration.fedora_info.setHostname(hostname);
959 Configuration.fedora_info.setPort(port);
960 Configuration.fedora_info.setUsername(username);
961 Configuration.fedora_info.setPassword(password);
962 Configuration.fedora_info.setProtocol(protocol);
963
964 String ping_url_str = protocol + "://" + hostname + ":" + port + "/fedora";
965 String login_str = username + ":" + password;
966
967 String login_encoding = Base64.encodeBytes(login_str.getBytes());
968
969 try {
970 URL ping_url = new URL(ping_url_str);
971 URLConnection uc = ping_url.openConnection();
972 uc.setRequestProperty ("Authorization", "Basic " + login_encoding);
973 // Attempt to access some content ...
974 InputStream content = (InputStream)uc.getInputStream();
975
976 // if no exception occurred in the above, we would have come here:
977 showLogin = false;
978 dialog.dispose();
979 }
980 catch (Exception exception) {
981 // TODO: move into dictionary
982 String[] errorMessage = {"Failed to connect to the Fedora server.", "It might not be running, or",
983 "incorrect username and/or password."};
984 dialog.setErrorMessage(errorMessage);
985 //DebugStream.printStackTrace(exception);
986 // exception occurred, show the dialog again (do this after printing to
987 // debugStream, else the above does not get done for some reason).
988 dialog.setVisible(true);
989 }
990 }
991 } while(showLogin);
992
993 dialog = null; // no more need of the dialog
994
995 // Now we are connected.
996 }
997
998
999
1000 static private void requestGLIServerURL()
1001 {
1002 WarningDialog dialog;
1003 String[] defaultURLs = {
1004 "http://localhost:8080/greenstone3/cgi-bin/gliserver.pl",
1005 "http://localhost:8080/gsdl/cgi-bin/gliserver.pl"
1006 };
1007
1008 // Warning dialog with no cancel button and no "turn off warning" checkbox
1009 // (since user-input of the gliserver script is mandatory)
1010 dialog = new WarningDialog("warning.MissingGLIServer", Dictionary.get("MissingGLIServer.Title"), Dictionary.get("MissingGLIServer.Message"), "general.gliserver_url", false, false);
1011
1012 dialog.setValueField(new URLField.DropDown(Configuration.getColor("coloring.editable_foreground", false),
1013 Configuration.getColor("coloring.editable_background", false),
1014 defaultURLs, "general.gliserver_url",
1015 "general.open_collection"+Configuration.gliPropertyNameSuffix(),
1016 "gliserver.pl"));
1017
1018 if (Gatherer.default_gliserver_url!=null){
1019 dialog.setValueField(Gatherer.default_gliserver_url.toString());
1020 }
1021
1022 // A WarningDialog cannot always be made to respond (let alone to exit the program) on close. We
1023 // handle the response of this particular WarningDialog here: a URL for gliserver.pl is a crucial
1024 // piece of user-provided data. Therefore, if no URL was entered for gliserver.pl, it'll exit safely.
1025 dialog.addWindowListener(new WindowAdapter() {
1026 public void windowClosing(WindowEvent e) {
1027 Gatherer.exit();
1028 }
1029 });
1030
1031 dialog.display();
1032 dialog.dispose();
1033 dialog = null;
1034
1035
1036 String gliserver_url_string = Configuration.getString("general.gliserver_url", true);
1037 if (!gliserver_url_string.equals("")) {
1038 try {
1039 Configuration.gliserver_url = new URL(gliserver_url_string);
1040 Configuration.setString("general.gliserver_url", true, gliserver_url_string);
1041 }
1042 catch (MalformedURLException exception) {
1043 DebugStream.printStackTrace(exception);
1044 }
1045 }
1046 }
1047
1048
1049 /** Prints a warning message about a missing GSDL path, which although not fatal pretty much ensures nothing will work properly in the GLI.
1050 */
1051 static private void missingGSDL() {
1052 WarningDialog dialog = new WarningDialog("warning.MissingGSDL", Dictionary.get("MissingGSDL.Title"), Dictionary.get("MissingGSDL.Message"), null, false);
1053 dialog.display();
1054 dialog.dispose();
1055 dialog = null;
1056 }
1057
1058 /** Prints a warning message about missing a valid ImageMagick path, which although not fatal means building image collections won't work */
1059 static private void missingImageMagick() {
1060 WarningDialog dialog = new WarningDialog("warning.MissingImageMagick", Dictionary.get("MissingImageMagick.Title"), Dictionary.get("MissingImageMagick.Message"), null, false);
1061 dialog.display();
1062 dialog.dispose();
1063 dialog = null;
1064 }
1065
1066 /** Prints a warning message about missing a valid PERL path, which although not fatal pretty much ensures no collection creation/building will work properly in the GLI. */
1067 static private void missingPERL() {
1068 WarningDialog dialog = new WarningDialog("warning.MissingPERL", Dictionary.get("MissingPERL.Title"), Dictionary.get("MissingPERL.Message"), null, false);
1069 dialog.display();
1070 dialog.dispose();
1071 dialog = null;
1072 }
1073
1074
1075 /** Sets up the proxy connection by setting JVM Environment flags and creating a new Authenticator.
1076 * @see java.lang.Exception
1077 * @see java.lang.System
1078 * @see java.net.Authenticator
1079 * @see org.greenstone.gatherer.Configuration
1080 * @see org.greenstone.gatherer.GAuthenticator
1081 */
1082 static public void setProxy() {
1083 try {// Can throw several exceptions
1084 if(Configuration.get("general.use_proxy", true)) {
1085 System.setProperty("http.proxyType", "4");
1086 System.setProperty("http.proxyHost", Configuration.getString("general.proxy_host", true));
1087 System.setProperty("http.proxyPort", Configuration.getString("general.proxy_port", true));
1088 System.setProperty("http.proxySet", "true");
1089 } else {
1090 System.setProperty("http.proxyHost", "");
1091 System.setProperty("http.proxyPort", "");
1092 System.setProperty("http.proxySet", "false");
1093 }
1094 } catch (Exception error) {
1095 DebugStream.println("Error in Gatherer.initProxy(): " + error);
1096 DebugStream.printStackTrace(error);
1097 }
1098 }
1099
1100
1101 /** This private class contains an instance of an external application running within a JVM shell. It is important that this process sits in its own thread, but its more important that when we exit the Gatherer we don't actually System.exit(0) the Gatherer object until the user has volunteerily ended all of these child processes. Otherwise when we quit the Gatherer any changes the users may have made in external programs will be lost and the child processes are automatically deallocated. */
1102 static private class ExternalApplication
1103 extends Thread {
1104 private Process process = null;
1105 /** The initial command string given to this sub-process. */
1106 private String command = null;
1107 private String[] commands = null;
1108
1109 private String ID = null;
1110
1111 /** Constructor.
1112 * @param command The initial command <strong>String</strong>.
1113 */
1114 public ExternalApplication(String command) {
1115 this.command = command;
1116 }
1117
1118 public ExternalApplication(String[] commands) {
1119 this.commands = commands;
1120 }
1121
1122 public ExternalApplication(String command, String ID) {
1123 this.command = command;
1124 this.ID = ID;
1125 }
1126
1127 public String getID() {
1128 return ID;
1129 }
1130
1131 /** We start the child process inside a new thread so it doesn't block the rest of Gatherer.
1132 * @see java.lang.Exception
1133 * @see java.lang.Process
1134 * @see java.lang.Runtime
1135 * @see java.lang.System
1136 * @see java.util.Vector
1137 */
1138 public void run() {
1139 // Call an external process using the args.
1140 try {
1141 if(commands != null) {
1142 StringBuffer whole_command = new StringBuffer();
1143 for(int i = 0; i < commands.length; i++) {
1144 whole_command.append(commands[i]);
1145 whole_command.append(" ");
1146 }
1147 DebugStream.println("Running " + whole_command.toString());
1148 Runtime rt = Runtime.getRuntime();
1149 process = rt.exec(commands);
1150 process.waitFor();
1151 }
1152 else {
1153 DebugStream.println("Running " + command);
1154 Runtime rt = Runtime.getRuntime();
1155 process = rt.exec(command);
1156 process.waitFor();
1157 }
1158 }
1159 catch (Exception exception) {
1160 DebugStream.printStackTrace(exception);
1161 }
1162 // Remove ourself from Gatherer list of threads.
1163 apps.remove(this);
1164 // Call exit if we were the last outstanding child process thread.
1165 if (apps.size() == 0 && exit == true) {
1166 // In my opinion (DB) there is no need to exit here,
1167 // the 'run' method ending naturally brings this
1168 // thread to an end. In fact it is potentially
1169 // dangerous to exit here, as the main thread in the
1170 // Gatherer class may be stopped prematurely. As it so
1171 // happens the point at which the ExternalApplication thread
1172 // is asked to stop (Back in the main Gatherer thread) is after
1173 // various configuration files have been saved.
1174 //
1175 // A similar argument holds for BrowserApplication thread below.
1176 System.exit(exit_status);
1177 }
1178 }
1179 public void stopExternalApplication() {
1180 if(process != null) {
1181 process.destroy();
1182 }
1183 }
1184 }
1185 /** This private class contains an instance of an external application running within a JVM shell. It is important that this process sits in its own thread, but its more important that when we exit the Gatherer we don't actually System.exit(0) the Gatherer object until the user has volunteerily ended all of these child processes. Otherwise when we quit the Gatherer any changes the users may have made in external programs will be lost and the child processes are automatically deallocated. */
1186 static private class BrowserApplication
1187 extends Thread {
1188 private Process process = null;
1189 /** The initial command string given to this sub-process. */
1190 private String command = null;
1191 private String url = null;
1192 private String[] commands = null;
1193
1194 public BrowserApplication(String command, String url) {
1195 StringTokenizer st = new StringTokenizer(command);
1196 int num_tokens = st.countTokens();
1197 this.commands = new String [num_tokens];
1198 int i=0;
1199 while (st.hasMoreTokens()) {
1200 commands[i] = st.nextToken();
1201 i++;
1202 }
1203 //this.commands = commands;
1204 this.url = url;
1205 }
1206 /** We start the child process inside a new thread so it doesn't block the rest of Gatherer.
1207 * @see java.lang.Exception
1208 * @see java.lang.Process
1209 * @see java.lang.Runtime
1210 * @see java.lang.System
1211 * @see java.util.Vector
1212 */
1213 public void run() {
1214 // Call an external process using the args.
1215 if(commands == null) {
1216 apps.remove(this);
1217 return;
1218 }
1219 try {
1220 String prog_name = commands[0];
1221 String lower_name = prog_name.toLowerCase();
1222 if (lower_name.indexOf("mozilla") != -1 || lower_name.indexOf("netscape") != -1) {
1223 DebugStream.println("found mozilla or netscape, trying remote it");
1224 // mozilla and netscape, try using a remote command to get things in the same window
1225 String [] new_commands = new String[] {prog_name, "-raise", "-remote", "openURL("+url+",new-tab)"};
1226 printArray(new_commands);
1227
1228 Runtime rt = Runtime.getRuntime();
1229 process = rt.exec(new_commands);
1230 int exitCode = process.waitFor();
1231 if (exitCode != 0) { // if Netscape or mozilla was not open
1232 DebugStream.println("couldn't do remote, trying original command");
1233 printArray(commands);
1234 process = rt.exec(commands); // try the original command
1235 }
1236 } else {
1237 // just run what we have been given
1238 StringBuffer whole_command = new StringBuffer();
1239 for(int i = 0; i < commands.length; i++) {
1240 whole_command.append(commands[i]);
1241 whole_command.append(" ");
1242 }
1243 DebugStream.println("Running " + whole_command.toString());
1244 Runtime rt = Runtime.getRuntime();
1245 process = rt.exec(commands);
1246 process.waitFor();
1247 }
1248 }
1249
1250 catch (Exception exception) {
1251 DebugStream.printStackTrace(exception);
1252 }
1253 // Remove ourself from Gatherer list of threads.
1254 apps.remove(this);
1255 // Call exit if we were the last outstanding child process thread.
1256 if (apps.size() == 0 && exit == true) {
1257 System.exit(exit_status);
1258 }
1259 }
1260 public void printArray(String [] array) {
1261 for(int i = 0; i < array.length; i++) {
1262 DebugStream.print(array[i]+" ");
1263 System.err.println(array[i]+" ");
1264 }
1265 }
1266 public void stopBrowserApplication() {
1267 if(process != null) {
1268 process.destroy();
1269 }
1270 }
1271 }
1272
1273
1274 private class ImageMagickTest
1275 {
1276 public boolean found()
1277 {
1278 try {
1279 String[] command = new String[2];
1280 command[0] = (Utility.isWindows() ? "identify.exe" : "identify");
1281 command[1] = "-version";
1282 Process image_magick_process = Runtime.getRuntime().exec(command);
1283 image_magick_process.waitFor();
1284
1285 //new way of detection of ImageMagick
1286 InputStreamReader isr = new InputStreamReader(image_magick_process.getInputStream());
1287
1288 BufferedReader br = new BufferedReader(isr);
1289 // Capture the standard output stream and seach for two particular occurances: Version and ImageMagick.
1290
1291 String line = br.readLine();
1292 if (line == null) {
1293 return false;
1294 }
1295 String lc_line = line.toLowerCase();
1296 if (lc_line.indexOf("version") != -1 || lc_line.indexOf("imagemagick") != -1) {
1297 return true;
1298 } else {
1299 return false;
1300 }
1301
1302 //return (image_magick_process.exitValue() == 0);
1303 }
1304 catch (IOException exception) {
1305 return false;
1306 }
1307 catch (InterruptedException exception) {
1308 return false;
1309 }
1310 }
1311 }
1312
1313
1314 private class PerlTest
1315 {
1316 private String[] command = new String[2];
1317
1318 public PerlTest()
1319 {
1320 command[0] = (Utility.isWindows() ? Utility.PERL_EXECUTABLE_WINDOWS : Utility.PERL_EXECUTABLE_UNIX);
1321 command[1] = "-version";
1322 }
1323
1324 public boolean found()
1325 {
1326 try {
1327 Process perl_process = Runtime.getRuntime().exec(command);
1328 perl_process.waitFor();
1329 return (perl_process.exitValue() == 0);
1330 }
1331 catch (Exception exception) {
1332 return false;
1333 }
1334 }
1335
1336 public String toString() {
1337 return command[0];
1338 }
1339 }
1340}
Note: See TracBrowser for help on using the repository browser.