Changeset 8627


Ignore:
Timestamp:
2004-11-23T14:28:53+13:00 (19 years ago)
Author:
mdewsnip
Message:

Replaced exec_address with library_url, which is much more descriptive (in my mind, anyway). Also tidied up a few things related to this.

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/Configuration.java

    r8626 r8627  
    7171    static public String GS3_CONFIG_XML = "config3.xml";
    7272
    73     static final private String CURRENT_CONFIGURATION_VERSION = "2.52";
     73    static final private String CURRENT_CONFIGURATION_VERSION = "2.52a";
    7474    /** 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). */
    7575    static final private String GATHERER_CONFIG = "GathererConfig";
     
    127127    static private String wget_version_str = StaticStrings.NO_WGET_STR;
    128128
    129     static public URL exec_address = null;
     129    static public URL library_url = null;
     130
    130131
    131132    /** Constructor.
    132133     * @param gsdl_path The path to the Greenstone directory as a <strong>String</strong>.
    133      * @param library_url A <strong>String</strong> containing the url of the Greenstone webserver.
    134      * @param perl_path The path to the PERL executable, as a <strong>String</strong>.
     134     * @param gsdl3_path The path to the Greenstone 3 directory as a <strong>String</strong>.
    135135     * @param site_name The name of the Greenstone 3 site currently in use.
    136136     */
    137     public Configuration(String gsdl_path, String gsdl3_path, String library_url, String perl_path, String site_name)
     137    public Configuration(String gsdl_path, String gsdl3_path, String site_name)
    138138    {
    139139    super();
     
    143143    this.gsdl3_path = gsdl3_path;
    144144    this.site_name = site_name;
    145 
    146     DebugStream.println("Library URL = " + library_url);
    147     if (library_url != null && library_url.length() > 0) {
    148         try {
    149         exec_address = new URL(library_url);
    150         }
    151         catch (MalformedURLException error) {
    152         DebugStream.printStackTrace(error);
    153         }
    154     }
    155 
    156     this.perl_path = perl_path;
    157     // Ensure the perl path includes exe under windoze
    158     if (Utility.isWindows() && !perl_path.toLowerCase().endsWith(".exe")) {
    159         if (!perl_path.endsWith(File.separator)) {
    160         perl_path = perl_path + File.separator;
    161         }
    162         perl_path = perl_path + "perl.exe";
    163     }
    164145
    165146    // Try to load the configuration file, first looking in the user specific location
     
    204185    updateUI();
    205186
    206     // If we have no exec_address, see if one was specified in the config file
    207     if (exec_address == null) {
    208         String exec_address_string = getString("general.exec_address", true);
    209         if (!exec_address_string.equals("")) {
    210         try {
    211             exec_address = new URL(exec_address_string);
    212         }
    213         catch (MalformedURLException error) {
    214             ///ystem.err.println("Error: Bad address: " + exec_address_string);
    215         }
     187    // Read the Greenstone library URL from the config file
     188    String library_url_string = getString("general.library_url", true);
     189    if (!library_url_string.equals("")) {
     190        try {
     191        library_url = new URL(library_url_string);
     192        }
     193        catch (MalformedURLException exception) {
     194        DebugStream.printStackTrace(exception);
    216195        }
    217196    }
     
    236215        }
    237216    }
    238 
    239     DebugStream.println("EXEC_ADDRESS = " + exec_address);
    240     }
     217    }
     218
    241219
    242220    /** Add a special directory mapping. */
  • trunk/gli/src/org/greenstone/gatherer/Gatherer.java

    r8626 r8627  
    118118
    119119    public GUIManager init(Dimension size, String gsdl_path, String gsdl3_path, String local_library_path,
    120                String library_url, boolean debug_enabled, String perl_path,
     120               String library_url_string, boolean debug_enabled, String perl_path,
    121121               boolean no_load, String open_collection,
    122122               String site_name, String servlet_path,
     
    152152    try {
    153153        // Load Config
    154         loadConfig(gsdl_path, gsdl3_path, library_url, perl_path, site_name);
    155 
    156         // I don't really know what this is for but I've moved it here from Configuration
     154        loadConfig(gsdl_path, gsdl3_path, site_name);
     155
     156        // Check we know where Perl is
     157        Configuration.perl_path = perl_path;
    157158        if (isGsdlRemote && Utility.isWindows() && Configuration.perl_path != null) {
    158159        if (Configuration.perl_path.toLowerCase().endsWith("perl.exe")) {
     
    173174        feedback_dialog.setLocale(Configuration.getLocale("general.locale", true));
    174175        }
    175        
     176
    176177        // Read Dictionary
    177178        new Dictionary(Configuration.getLocale("general.locale", true), Configuration.getFont("general.font", true));
     
    184185        if (Utility.isWindows() && local_library_path != null && !GS3) {
    185186        LocalLibraryServer.start(gsdl_path, local_library_path);
    186         DebugStream.println("Having started server.exe, exec_address is: " + Configuration.exec_address);
    187         }
    188 
    189         // Having loaded the configuration (necessary to determine if certain warnings have been disabled) and dictionary, we now check if the necessary path variables have been provided.
    190         if (Configuration.exec_address == null) {
    191         DebugStream.println("config.exec_address is null");
     187        }
     188
     189        // The "-library_url" option overwrites anything in the config files
     190        if (library_url_string != null && library_url_string.length() > 0) {
     191        try {
     192            System.err.println("Setting library_url to " + library_url_string + "...");
     193            Configuration.library_url = new URL(library_url_string);
     194        }
     195        catch (MalformedURLException error) {
     196            DebugStream.printStackTrace(error);
     197        }
     198        }
     199
     200        // Check that we now know the Greenstone library URL, since we need this for previewing collections
     201        DebugStream.println("Configuration.library_url = " + Configuration.library_url);
     202        if (Configuration.library_url == null) {
    192203        missingEXEC();
    193204        }
     
    432443    try {
    433444        // need to add the servlet name to the exec address
    434         String raw_url = Configuration.exec_address.toString() + Configuration.getServletPath() + command;
     445        String raw_url = Configuration.library_url.toString() + Configuration.getServletPath() + command;
    435446        URL url = new URL(raw_url);
    436447        DebugStream.println("Action: " + raw_url);
     
    502513    }
    503514
     515
    504516    /** Prints a warning message about a missing library path, which means the final collection cannot be previewed in the Gatherer.
    505517     */
     
    511523        message_name = "warning.MissingEXEC";
    512524    }
    513     WarningDialog dialog = new WarningDialog(message_name, "general.exec_address", false);
     525    WarningDialog dialog = new WarningDialog(message_name, "general.library_url", false);
    514526    dialog.setValueField(new URLField(Configuration.getColor("coloring.editable_foreground", false), Configuration.getColor("coloring.editable_background", false), Configuration.getColor("coloring.error_foreground", false), Configuration.getColor("coloring.error_background", false)));
    515527    dialog.display();
     
    517529    dialog = null;
    518530
    519     String library_path_string = Configuration.getString("general.exec_address", true);
    520     if (!library_path_string.equals("")) {
     531    String library_url_string = Configuration.getString("general.library_url", true);
     532    if (!library_url_string.equals("")) {
    521533        try {
    522         Configuration.exec_address = new URL(library_path_string);
    523         }
    524         catch (MalformedURLException error) {
    525         ///ystem.err.println("Error: Bad address: " + exec_address_string);
    526         }
    527     }
    528    }
     534        Configuration.library_url = new URL(library_url_string);
     535        }
     536        catch (MalformedURLException exception) {
     537        DebugStream.printStackTrace(exception);
     538        }
     539    }
     540    }
     541
    529542
    530543    /** Prints a warning message about a missing GSDL path, which although not fatal pretty much ensures nothing will work properly in the Gatherer.
     
    609622     * @param gsdl_path The path to the gsdl directory, gathered from the startup arguments, and presented as a <strong>String</strong>.
    610623     * @param library_url The path to the library executable, gathered from the startup arguments, and presented as a <strong>String</strong>.
    611      * @param perl_path The path to the PERL compiler as a <strong>String</strong>. Necessary for windows platform versions.
    612      * @see java.io.FileInputStream
    613      * @see java.io.ObjectInputStream
    614      * @see java.lang.Exception
    615624     * @see org.greenstone.gatherer.Configuration
    616625     */
    617     private void loadConfig(String gsdl_path, String gsdl3_path, String library_url, String perl_path, String site_name) {
     626    private void loadConfig(String gsdl_path, String gsdl3_path, String site_name) {
    618627    try {
    619         new Configuration(gsdl_path, gsdl3_path, library_url, perl_path, site_name);
     628        new Configuration(gsdl_path, gsdl3_path, site_name);
    620629    }
    621630    catch (Exception error) {
  • trunk/gli/src/org/greenstone/gatherer/LocalLibraryServer.java

    r8624 r8627  
    6060    {
    6161    try {
    62         URL url = new URL(Configuration.exec_address.toString() + command);
     62        URL url = new URL(Configuration.library_url.toString() + command);
    6363        HttpURLConnection library_connection = (HttpURLConnection) url.openConnection();
    6464        int response_code = library_connection.getResponseCode();
     
    110110        // If it is already running then set the Greenstone web server address and we're done
    111111        try {
    112         Configuration.exec_address = new URL(url);
     112        Configuration.library_url = new URL(url);
    113113        running = true;
    114114        return;
     
    146146    // Ta-da. Now the url should be available
    147147    try {
    148         Configuration.exec_address = new URL(gsdlsite_cfg_file.getURL());
     148        Configuration.library_url = new URL(gsdlsite_cfg_file.getURL());
    149149    }
    150150    catch (MalformedURLException exception) {
     
    154154    // A quick test involves opening a connection to get the home page for this collection
    155155    try {
    156         DebugStream.println("Try connecting to server on config url: '" + Configuration.exec_address + "'");
    157         URLConnection connection = Configuration.exec_address.openConnection();
     156        DebugStream.println("Try connecting to server on config url: '" + Configuration.library_url+ "'");
     157        URLConnection connection = Configuration.library_url.openConnection();
    158158        connection.getContent();
    159159    }
     
    161161        try {
    162162        // If this fails then we try changing the url to be localhost
    163         Configuration.exec_address = new URL(gsdlsite_cfg_file.getLocalHostURL());
    164         DebugStream.println("Try connecting to server on local host: '" + Configuration.exec_address + "'");
    165         URLConnection connection = Configuration.exec_address.openConnection();
     163        Configuration.library_url = new URL(gsdlsite_cfg_file.getLocalHostURL());
     164        DebugStream.println("Try connecting to server on local host: '" + Configuration.library_url + "'");
     165        URLConnection connection = Configuration.library_url.openConnection();
    166166        connection.getContent();
    167167        }
    168168        catch (IOException worse_url_connection) {
    169169        DebugStream.println("Can't connect to server on either address.");
    170         Configuration.exec_address = null;
     170        Configuration.library_url = null;
    171171        return;
    172172        }
  • trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java

    r8626 r8627  
    189189    // Load configuration file
    190190    try {
    191            
    192         config = new Configuration(go.gsdl_path, null, null, go.perl_path, null);
     191        config = new Configuration(go.gsdl_path, null, null);
    193192    }
    194193    catch (Exception exception) {
  • trunk/gli/src/org/greenstone/gatherer/gems/GEMSPreferences.java

    r8601 r8627  
    423423        Configuration.setPreviewCommand(program_str);
    424424
    425         String library_path_string = library_path_field.getText();
    426         Configuration.setString("general.exec_address", true, library_path_string);
    427         if (!library_path_string.equals("")) {
    428         try {
    429             Configuration.exec_address = new URL(library_path_string);
    430         }
    431         catch (MalformedURLException error) {
    432             ///ystem.err.println("Error: Bad address: " + exec_address_string);
    433         }
    434         }
    435425        boolean site_changed = false;
    436426        if (Gatherer.GS3) {
  • trunk/gli/src/org/greenstone/gatherer/gui/CreatePane.java

    r8590 r8627  
    544544   
    545545    // now do the preview stuff
    546     if (!Gatherer.c_man.built() || Configuration.exec_address == null) {
     546    if (!Gatherer.c_man.built() || Configuration.library_url == null) {
    547547        preview_button.setEnabled(false);
    548548        simple_preview_button.setEnabled(false);
     
    577577    // Remember to add unique timestamp
    578578    if (Gatherer.GS3) {
    579         homepage = Configuration.exec_address.toString() + Configuration.getServletPath()+ "?a=p&sa=about&c=" + current_collection.getName()+"&l="+Configuration.getLanguage(); //+extra_args + StaticStrings.TIMESTAMP_ARGUMENT + System.currentTimeMillis();
     579        homepage = Configuration.library_url.toString() + Configuration.getServletPath()+ "?a=p&sa=about&c=" + current_collection.getName()+"&l="+Configuration.getLanguage(); //+extra_args + StaticStrings.TIMESTAMP_ARGUMENT + System.currentTimeMillis();
    580580    } else {
    581         homepage = Configuration.exec_address.toString() + "?a=p&p=about&c=" + current_collection.getName()+"&l="+Configuration.getLanguage()+extra_args + StaticStrings.TIMESTAMP_ARGUMENT + System.currentTimeMillis();
     581        homepage = Configuration.library_url.toString() + "?a=p&p=about&c=" + current_collection.getName()+"&l="+Configuration.getLanguage()+extra_args + StaticStrings.TIMESTAMP_ARGUMENT + System.currentTimeMillis();
    582582    }
    583583    }
  • trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java

    r8601 r8627  
    3535import javax.swing.event.*;
    3636import org.greenstone.gatherer.Configuration;
     37import org.greenstone.gatherer.DebugStream;
    3738import org.greenstone.gatherer.Dictionary;
    3839import org.greenstone.gatherer.Gatherer;
     
    190191    library_path_label = new JLabel();
    191192    library_path_label.setPreferredSize(LABEL_SIZE);
    192     library_path_field = new JTextField(Configuration.getString("general.exec_address", true));
     193    library_path_field = new JTextField(Configuration.library_url.toString());
    193194    library_path_field.setCaretPosition(0);
    194195    if (Gatherer.GS3) {
     
    608609        Configuration.setPreviewCommand(program_str);
    609610
    610         String library_path_string = library_path_field.getText();
    611         Configuration.setString("general.exec_address", true, library_path_string);
    612         if (!library_path_string.equals("")) {
     611        String library_url_string = library_path_field.getText();
     612        if (!library_url_string.equals("")) {
    613613        try {
    614             Configuration.exec_address = new URL(library_path_string);
     614            Configuration.library_url = new URL(library_url_string);
     615            // Configuration.setString("general.library_url", true, library_url_string);
    615616        }
    616         catch (MalformedURLException error) {
    617             ///ystem.err.println("Error: Bad address: " + exec_address_string);
     617        catch (MalformedURLException exception) {
     618            DebugStream.printStackTrace(exception);
    618619        }
    619620        }
Note: See TracChangeset for help on using the changeset viewer.