Changeset 18363

Show
Ignore:
Timestamp:
12.01.2009 11:19:54 (10 years ago)
Author:
kjdon
Message:

updated the rtl-gli branch with files from trunk. Result of a merge 14807:18318

Location:
gli/branches/rtl-gli/src/org/greenstone/gatherer
Files:
7 modified
1 copied

Legend:

Unmodified
Added
Removed
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/Configuration.java

    r14302 r18363  
    6767    /** The name of the general Gatherer configuration file. */ 
    6868    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-"; 
    7170 
    7271    /** 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). */ 
     
    101100    /** If we are using GLI in Greenstone 3, the path to gsdl3 src directory (== gsdl3 dir)*/ 
    102101    static public String gsdl3_src_path = ""; 
     102 
     103    static public FedoraInfo fedora_info = null; 
     104     
    103105    /** The path to the PERL executable, up to and including Perl.exe. */ 
    104106    static public String perl_path = ""; 
     
    126128    static public URL gliserver_url = null; 
    127129    static public URL library_url = null; 
    128  
    129  
     130     
     131     
    130132    /** Constructor. 
    131133     * @param gsdl_path The path to the Greenstone directory as a <strong>String</strong>. 
     
    133135     * @param gsdl3_src_path The path to the Greenstone 3 src directory as a <strong>String</strong>. 
    134136     * @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. 
    135139     */ 
    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)  
    137142    { 
    138143    super(); 
    139     self = this; 
     144    self = this; // allows Configuration to statically refer to itself in the static methods 
    140145 
    141146    this.gli_user_directory_path = gli_user_directory_path; 
     
    145150    this.site_name = site_name; 
    146151 
     152    this.fedora_info = fedora_info; 
     153 
    147154    // Try to load the configuration file from the user specific location 
    148155    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; 
    151159    } 
    152160 
    153161    // If the existing user config.xml file isn't recent enough, backup the old version and update it 
    154162    File config_xml_file = new File(gli_user_directory_path + config_xml_file_name); 
     163 
    155164    if (config_xml_file != null && config_xml_file.exists()) { 
    156165        just_updated_config_xml_file = updateUserConfigXMLFileIfNecessary(config_xml_file); 
     
    171180 
    172181    // 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); 
    174183    if (!library_url_string.equals("")) { 
    175184        try { 
     
    194203    } 
    195204     
    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    } 
    217250 
    218251    static private boolean updateUserConfigXMLFileIfNecessary(File config_xml_file) 
     
    228261    String new_version = new_document.getDocumentElement().getAttribute(StaticStrings.VERSION_ATTRIBUTE); 
    229262    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)) { 
    231264        // Don't need to update file 
    232265        return false; 
    233266    } 
    234267 
    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 + "..."); 
    236269 
    237270    // Build up the new user config.xml file from the template config.xml with the user's preferences added 
     
    254287        // Argument found 
    255288        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); 
    261296            } 
    262  
    263             // We don't care about this option any more 
     297          } 
     298           
     299          // We don't care about this option any more 
    264300            old_argument_element.getParentNode().removeChild(old_argument_element); 
    265301            break; 
     
    597633    } 
    598634 
     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 
    599643    static public String getServletPath() { 
    600644    return servlet_path; 
     
    688732    File user_config_xml = null; 
    689733    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 
    701739    try { 
    702740        user_config_xml = new File(gli_user_directory_path + config_xml_name); 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/GAuthenticator.java

    r14567 r18363  
    4242import java.util.*; 
    4343import javax.swing.*; 
     44 
     45 
    4446import org.greenstone.gatherer.gui.GLIButton; 
     47 
    4548 
    4649/** Provides a graphic authenticator for network password requests. 
     
    6568    /** The default size of this dialog. */ 
    6669    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     
    6882    /** Constructor. */ 
    6983    public GAuthenticator() { 
     
    7589     * @see org.greenstone.gatherer.GAuthenticator.RequestFocusListener 
    7690     */ 
    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     
    78114    // Component definition. 
    79115    dialog = new JDialog (Gatherer.g_man, Dictionary.get("GAuthenticator.Title"), true); 
     
    82118    JPanel content_pane = (JPanel) dialog.getContentPane(); 
    83119    JLabel title_label = new JLabel(getMessageString()); 
     120 
    84121    JPanel user_panel = new JPanel(); 
    85122    JLabel username_label = new JLabel(Dictionary.get("GAuthenticator.Username")); 
    86123    JTextField username = new JTextField(); 
    87124    username.setToolTipText(Dictionary.get("GAuthenticator.Username_Tooltip")); 
     125    if (username_str != null) { 
     126        username.setText(username_str); 
     127    } 
     128 
    88129    JPanel password_panel = new JPanel(); 
    89130    JLabel password_label = new JLabel(Dictionary.get("GAuthenticator.Password")); 
     
    91132    password.setEchoChar('*'); 
    92133    password.setToolTipText(Dictionary.get("GAuthenticator.Password_Tooltip")); 
     134    if (password_str != null) { 
     135        password.setText(password_str); 
     136    } 
     137 
    93138    JPanel button_panel = new JPanel(); 
    94139    ok_button = new GLIButton(Dictionary.get("General.OK"), Dictionary.get("General.OK_Tooltip")); 
     
    134179    } 
    135180 
     181    protected PasswordAuthentication getPasswordAuthentication() { 
     182    return getPasswordAuthentication(null,null); 
     183    } 
    136184 
    137185    /** 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  
    3636import javax.swing.plaf.*; 
    3737import javax.swing.text.*; 
     38 
     39 
    3840import org.greenstone.gatherer.Configuration; 
    3941import org.greenstone.gatherer.GAuthenticator; 
     42import org.greenstone.gatherer.FedoraInfo; 
    4043import org.greenstone.gatherer.collection.CollectionManager; 
    4144import org.greenstone.gatherer.feedback.ActionRecorderDialog; 
     
    5154import org.greenstone.gatherer.gui.URLField; 
    5255import org.greenstone.gatherer.gui.WarningDialog; 
     56import org.greenstone.gatherer.gui.FedoraLogin; 
    5357import org.greenstone.gatherer.remote.RemoteGreenstoneServer; 
    5458import org.greenstone.gatherer.util.JarTools; 
     
    7478        * in a line which maches this java regex: 
    7579        * ^(.*)String\s*PROGRAM_VERSION\s*=\s*"trunk"; 
    76         * If change the daclaration and it no longer matches the regex, please 
     80        * If change the declaration and it no longer matches the regex, please 
    7781        * change the regex in the gs3-release-maker code and in this message 
    7882        */ 
     83 
    7984    static final public String PROGRAM_VERSION = "trunk"; 
    8085 
    8186    static private Dimension size = new Dimension(800, 540); 
     87    static public RemoteGreenstoneServer remoteGreenstoneServer = null; 
    8288 
    8389    /** Has the exit flag been set? */ 
     
    165171        // We don't have a local Greenstone! 
    166172        go.gsdl_path = null; 
     173        go.gsdl3_path=null; 
     174        go.gsdl3_src_path=null; 
    167175 
    168176        // We have to use our own collect directory since we can't use the Greenstone one 
    169177        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         } 
    175178    } 
    176179    // No, we have a local Greenstone 
     
    186189    // More special code for running with a remote Greenstone 
    187190    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";  
    194199 
    195200        File collect_directory = new File(Gatherer.getCollectDirectoryPath()); 
     
    198203        } 
    199204    } 
    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,  
    202215         go.gliserver_url_string, go.debug, go.perl_path, go.no_load, go.filename, go.site_name, 
    203216         go.servlet_path); 
     
    205218 
    206219 
    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, 
    208223             String library_url_string, String gliserver_url_string, boolean debug_enabled, 
    209224             String perl_path, boolean no_load, String open_collection,  
     
    245260    try { 
    246261        // 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         
    249265        // Check we know where Perl is 
    250266        Configuration.perl_path = perl_path; 
     
    278294        } 
    279295 
    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         
    285331        // The "-library_url" option overwrites anything in the config files 
    286332        if (library_url_string != null && library_url_string.length() > 0) { 
     
    293339        } 
    294340        } 
     341   
    295342 
    296343        // Check that we now know the Greenstone library URL, since we need this for previewing collections 
     
    298345        if (Configuration.library_url == null) { 
    299346        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         } 
    308347        } 
    309348 
     
    321360        // If we're using a remote Greenstone we need to know where the gliserver script is 
    322361        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         } 
    338362 
    339363        if (GS3) { 
     
    348372        if (GS3 && Configuration.servlet_path == null) { 
    349373        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); 
    350381        } 
    351382 
     
    424455        open_collection_file_path = open_collection; 
    425456        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); 
    427459        } 
    428460        if (no_load || open_collection_file_path.equals("")) { 
     
    434466    } 
    435467 
     468     
    436469    // Create GUI Manager (last) or else suffer the death of a thousand NPE's 
    437470    g_man = new GUIManager(size); 
     
    443476    // If using a remote Greenstone we need to download the collection configurations now 
    444477    if (Gatherer.isGsdlRemote) { 
    445         if (RemoteGreenstoneServer.downloadCollectionConfigurations().equals("")) { 
     478        if (remoteGreenstoneServer.downloadCollectionConfigurations().equals("")) { 
    446479        // !! Something went wrong downloading the collection configurations 
    447480        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    }  
    453498 
    454499    public void openGUI() 
     
    511556    // If using a remote Greenstone we need to download the collection configurations now 
    512557    if (Gatherer.isGsdlRemote) { 
    513         if (RemoteGreenstoneServer.downloadCollectionConfigurations().equals("")) { 
     558        if (remoteGreenstoneServer.downloadCollectionConfigurations().equals("")) { 
    514559        // !! Something went wrong downloading the collection configurations 
    515560        System.err.println("Error: Could not download collection configurations."); 
     
    561606 
    562607    // 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    } 
    565612 
    566613    // Flush debug 
     
    574621    // If we're using a remote Greenstone server we need to make sure that all jobs have completed first 
    575622    if (isGsdlRemote) { 
    576         RemoteGreenstoneServer.exit(); 
     623        remoteGreenstoneServer.exit(); 
    577624    } 
    578625 
     
    715762        url = null; 
    716763    } 
     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    } 
    717768    catch (Exception exception) {             
    718769        DebugStream.printStackTrace(exception); 
     
    767818    static private void missingEXEC() { 
    768819    WarningDialog dialog; 
     820    String configPropertyName = "general.library_url"+Configuration.gliPropertyNameSuffix(); 
     821 
    769822    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); 
    775855    dialog.display(); 
    776856    dialog.dispose(); 
    777857    dialog = null; 
    778858 
    779     String library_url_string = Configuration.getString("general.library_url", true); 
     859    String library_url_string = Configuration.getString(configPropertyName, true); 
    780860    if (!library_url_string.equals("")) { 
    781861        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        } 
    782870        Configuration.library_url = new URL(library_url_string); 
    783871        } 
     
    789877 
    790878 
    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() 
    792954    { 
    793955    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 
    801971    if (Gatherer.default_gliserver_url!=null){ 
    802972        dialog.setValueField(Gatherer.default_gliserver_url.toString()); 
    803973    } 
     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        }); 
    804983     
    805984    dialog.display(); 
    806985    dialog.dispose(); 
    807986    dialog = null; 
     987 
    808988     
    809989    String gliserver_url_string = Configuration.getString("general.gliserver_url", true); 
     
    10451225        //new way of detection of ImageMagick 
    10461226        InputStreamReader isr = new InputStreamReader(image_magick_process.getInputStream()); 
     1227 
    10471228            BufferedReader br = new BufferedReader(isr); 
    10481229            // 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) { 
    10511237            return true; 
    10521238        } else { 
    10531239                return false; 
    10541240        } 
     1241 
    10551242        //return (image_magick_process.exitValue() == 0); 
    10561243        } 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/GathererApplet.java

    r13599 r18363  
    8787    // Ensure platform specific LAF 
    8888    try { 
    89         UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 
     89        //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 
     90        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); 
    9091    } 
    9192    catch (Exception exception) { 
     
    115116    Gatherer.isApplet = true; 
    116117    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    } 
    118128 
    119129        // String debug_param = getParameter("debug"); 
     
    122132        // } 
    123133 
    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     
    130154    File collect_directory = new File(Gatherer.getCollectDirectoryPath()); 
    131155    if (!collect_directory.exists()) { 
     
    178202    System.err.println("Destroy called"); 
    179203    gatherer.exit(); 
     204    gatherer = null; 
    180205    System.err.println("Done gatherer exit."); 
    181206    } 
     
    189214 
    190215    /**  
    191      * Method which unzips a given metadata resoure. 
     216     * Method which unzips a given metadata resource. 
    192217     * @param jar_zip_fname The name of the jar file as a <strong>String</strong>. 
    193218     * @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  
    117117    Gatherer.isApplet = true; 
    118118    String library_url_string = fullLibraryURL(getParameter("gwcgi")); 
    119     String gliserver_url_string = library_url_string + "/cgi-bin/gliserver4gs3.pl"; 
     119    String gliserver_url_string = library_url_string + "/cgi-bin/gliserver.pl"; 
    120120    String[] args = { "-use_remote_greenstone", 
    121121              "-gliserver_url", gliserver_url_string, 
     
    174174    System.err.println("Destroy called"); 
    175175    gatherer.exit(); 
    176     gatherer = null; 
     176    // bug that causes browser (Firefox to freeze) when trying to reload the applet 
     177    // gatherer = null; 
    177178    System.err.println("Done gatherer exit."); 
    178179    } 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/GathererProg.java

    r13599 r18363  
    5555    // Ensure platform specific LAF 
    5656    try { 
    57         UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 
     57        // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 
     58        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); 
    5859    } 
    5960    catch (Exception exception) { 
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/GetOpt.java

    r14303 r18363  
    5555    public String metadata_path = null; 
    5656 
     57    protected FedoraInfo fedora_info = null; 
     58     
    5759    public GetOpt(String[] args) 
    5860    { 
    5961    // Default dictionary. Only used for starting error messages. 
    6062    Dictionary dictionary = new Dictionary(null, null);  
     63 
     64    fedora_info = new FedoraInfo(); 
    6165 
    6266    // Parse arguments 
     
    142146            use_remote_greenstone = true; 
    143147            //Use a remote Greenstone 
    144          
    145             }else if (argument_name.equals(StaticStrings.GSDL3_ARGUMENT)){ 
     148            } 
     149            else if (argument_name.equals(StaticStrings.GSDL3_ARGUMENT)){ 
    146150            //Use a remote Greenstone3 
    147151            run_gsdl3=true; 
     
    149153            else if (argument_name.equals(StaticStrings.NEW_METADATASET)) { 
    150154            new_set = true; 
     155            } 
     156            else if(argument_name.equals(StaticStrings.FEDORA_MODE)) { 
     157            // Running FLI remotely 
     158            fedora_info.setActive(true); 
    151159            } 
    152160        } 
     
    243251            } 
    244252            } 
     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 
    245317                   
    246318        }