Changeset 16329 for gli

Show
Ignore:
Timestamp:
10.07.2008 12:26:44 (12 years ago)
Author:
ak19
Message:

Changes to work with the remote GS server knowing the server version and informing the GLI client application. 1. Changes to work with gliserver.pl's get-greenstone-server-version rather than being passed this from the client-gli scripts. Now the server will tell the client what version of Greenstone it is running (GS2 or GS3). However, this has made it compulsory now for the gliserver URL request dialog to always be displayed upon startup. It will remember upto 5 URLs entered previously along with the collection that was left open last time GLI ran against that gliserver URL. These changes have been made possible by merging config3.xml into config.xml and configRemote3.xml into configRemote.xml. 2. Minor bugfix: previously g_man was called to destroy itself even though it could be (and was occasionally) null.

Files:
1 modified

Legend:

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

    r15506 r16329  
    170170        // We don't have a local Greenstone! 
    171171        go.gsdl_path = null; 
     172        go.gsdl3_path=null; 
     173        go.gsdl3_src_path=null; 
    172174 
    173175        // We have to use our own collect directory since we can't use the Greenstone one 
    174176        setCollectDirectoryPath(getGLIUserDirectoryPath() + "collect" + File.separator); 
    175         if (go.run_gsdl3){    
    176         GS3=true; 
    177         go.gsdl3_path=null; 
    178         go.gsdl3_src_path=null; 
    179         } 
    180177    } 
    181178    // No, we have a local Greenstone 
     
    198195        } 
    199196 
    200         if (!go.run_gsdl3){   
    201         Configuration.CONFIG_XML = "configRemote.xml"; 
    202         }else{ 
    203         Configuration.GS3_CONFIG_XML = "config3Remote.xml"; 
    204         } 
     197        Configuration.CONFIG_XML = "configRemote.xml";  
    205198 
    206199        File collect_directory = new File(Gatherer.getCollectDirectoryPath()); 
     
    212205        if (go.fedora_info.isActive()) { 
    213206        Configuration.TEMPLATE_CONFIG_XML = "xml/" + Configuration.FEDORA_CONFIG_PREFIX + Configuration.CONFIG_XML; 
    214  
    215         } 
     207        } 
     208        // else, the CONFIG_XML uses the default config file, which is for the local GS server 
    216209    } 
    217210 
     
    268261        new Configuration(getGLIUserDirectoryPath(), gsdl_path, gsdl3_path, gsdl3_src_path, site_name, 
    269262                  fedora_info); 
    270  
     263         
    271264        // Check we know where Perl is 
    272265        Configuration.perl_path = perl_path; 
     
    304297        } 
    305298 
     299        // Finally, we're ready to find out the version of the remote Greenstone server  
     300        if(isGsdlRemote) { 
     301        int greenstoneVersion = 2; 
     302        requestGLIServerURL(); 
     303        gliserver_url_string = Configuration.gliserver_url.toString(); 
     304         
     305        greenstoneVersion = RemoteGreenstoneServer.getGreenstoneVersion(); 
     306        // Display the version to make error reports a lot more useful 
     307        System.err.println("Remote Greenstone server version: " + greenstoneVersion); 
     308        if(greenstoneVersion >= 3) { 
     309            this.GS3 = true; 
     310            Configuration.prepareForGS3(); 
     311        }  
     312         
     313        library_url_string = RemoteGreenstoneServer.getLibraryURL(Configuration.gliserver_url.toString()); 
     314        } 
    306315 
    307316        // Start up the local library server, if that's what we want 
     
    309318        LocalLibraryServer.start(gsdl_path, local_library_path); 
    310319        } 
    311  
     320         
    312321        // The "-library_url" option overwrites anything in the config files 
    313322        if (library_url_string != null && library_url_string.length() > 0) { 
     
    320329        } 
    321330        } 
     331   
    322332 
    323333        // Check that we now know the Greenstone library URL, since we need this for previewing collections 
     
    325335        if (Configuration.library_url == null) { 
    326336        missingEXEC();  
    327  
    328         if ((Configuration.library_url!=null) && isGsdlRemote && (gliserver_url_string==null)){ 
    329             if (GS3){ 
    330             default_gliserver_url = new URL(Configuration.library_url.toString() + "/cgi-bin/gliserver4gs3.pl"); 
    331             }else{ 
    332             String default_gliserver_str = ""; 
    333             String library_url_str = Configuration.library_url.toString();           
    334             int cut_pos = library_url_str.lastIndexOf("/library"); 
    335  
    336             if (cut_pos>0) { 
    337                 default_gliserver_str = library_url_str.substring(0,cut_pos) + "/gliserver.pl"; 
    338             } 
    339             else { 
    340                 cut_pos = library_url_str.lastIndexOf("/"); 
    341                 if (cut_pos>0) { 
    342                 default_gliserver_str = library_url_str.substring(0,cut_pos) + "/gliserver.pl"; 
    343                 } 
    344                 else { 
    345                 default_gliserver_str = library_url_str + "/gliserver.pl"; 
    346                 } 
    347             } 
    348  
    349             default_gliserver_url = new URL(default_gliserver_str); 
    350             } 
    351             missingGLIServer(); 
    352         } 
    353337        } 
    354338 
     
    366350        // If we're using a remote Greenstone we need to know where the gliserver script is 
    367351        DebugStream.println("Configuration.gliserver_url = " + Configuration.gliserver_url); 
    368         if (isGsdlRemote) { 
    369         if (Configuration.gliserver_url == null) { 
    370             if (Configuration.library_url != null) { 
    371             if (GS3){ 
    372                 default_gliserver_url = new URL(Configuration.library_url.toString() + "/cgi-bin/gliserver4gs3.pl"); 
    373             }else{ 
    374                 String library_url = Configuration.library_url.toString(); 
    375                 default_gliserver_url = new URL(library_url.substring(0,library_url.lastIndexOf("/library")) + "/gliserver.pl"); 
    376             } 
    377             } 
    378             missingGLIServer(); 
    379         } 
    380         if (Configuration.gliserver_url != null) { 
    381             gliserver_url_string = Configuration.gliserver_url.toString(); 
    382         } 
    383         } 
    384352 
    385353        if (GS3) { 
     
    480448    } 
    481449 
     450     
    482451    // Create GUI Manager (last) or else suffer the death of a thousand NPE's 
    483452    g_man = new GUIManager(size); 
     
    497466 
    498467    } 
     468 
     469     
     470    /** Returns the correct version of the (local or remote) Greenstone server if init() has already been called. */ 
     471    public static int serverVersionNumber() {  
     472    return GS3 ? 3 : 2; 
     473    }  
     474 
     475    /** Returns "Server: version number" if init() has already been called. */ 
     476    public static String getServerVersionAsString() {  
     477    return "Server: v" + serverVersionNumber(); 
     478    }  
    499479 
    500480    public void openGUI() 
     
    607587 
    608588    // Get the gui to deallocate 
    609     g_man.destroy(); 
    610     g_man_built = false; 
     589    if(g_man != null) { 
     590        g_man.destroy(); 
     591        g_man_built = false; 
     592    } 
    611593 
    612594    // Flush debug 
     
    818800        dialog = new WarningDialog("warning.MissingEXEC", Dictionary.get("MissingEXEC.Title"), Dictionary.get("MissingEXEC.Message"), "general.library_url", false); 
    819801    } 
    820     dialog.setValueField(new URLField(Configuration.getColor("coloring.editable_foreground", false), Configuration.getColor("coloring.editable_background", false))); 
     802    dialog.setValueField(new URLField.Text(Configuration.getColor("coloring.editable_foreground", false), Configuration.getColor("coloring.editable_background", false))); 
    821803    dialog.display(); 
    822804    dialog.dispose(); 
     
    891873        } 
    892874        catch (Exception exception) { 
     875            // TODO: move into dictionary 
    893876            String[] errorMessage = {"Failed to connect to the Fedora server.", "It might not be running, or", 
    894877                         "incorrect username and/or password."}; 
     
    909892 
    910893 
    911     static private void missingGLIServer() 
     894    static private void requestGLIServerURL() 
    912895    { 
    913896    WarningDialog dialog; 
    914     if (GS3) { 
    915         dialog = new WarningDialog("warning.MissingGLIServer", Dictionary.get("MissingGLIServer_GS3.Title"), Dictionary.get("MissingGLIServer_GS3.Message"), "general.gliserver_url", false); 
    916     }else { 
    917         dialog = new WarningDialog("warning.MissingGLIServer", Dictionary.get("MissingGLIServer.Title"), Dictionary.get("MissingGLIServer.Message"), "general.gliserver_url", false); 
    918     } 
    919     dialog.setValueField(new URLField(Configuration.getColor("coloring.editable_foreground", false), Configuration.getColor("coloring.editable_background", false))); 
    920      
     897    String[] defaultURLs = { 
     898        "http://localhost:8080/greenstone3/cgi-bin/gliserver.pl",  
     899        "http://localhost:8080/gsdl/cgi-bin/gliserver.pl" 
     900    }; 
     901 
     902    // Warning dialog with no cancel button and no "turn off warning" checkbox  
     903    // (since user-input of the gliserver script is mandatory) 
     904    dialog = new WarningDialog("warning.MissingGLIServer", Dictionary.get("MissingGLIServer.Title"), Dictionary.get("MissingGLIServer.Message"), "general.gliserver_url", false, false);  
     905 
     906    dialog.setValueField(new URLField.DropDown(Configuration.getColor("coloring.editable_foreground", false),  
     907                           Configuration.getColor("coloring.editable_background", false),  
     908                           defaultURLs, "general.gliserver_url", "general.open_collection",   
     909                           "gliserver.pl")); 
     910 
    921911    if (Gatherer.default_gliserver_url!=null){ 
    922912        dialog.setValueField(Gatherer.default_gliserver_url.toString()); 
    923913    } 
     914 
     915    // A WarningDialog cannot always be made to respond (let alone to exit the program) on close. We 
     916    // handle the response of this particular WarningDialog here: a URL for gliserver.pl is a crucial 
     917    // piece of user-provided data. Therefore, if no URL was entered for gliserver.pl, it'll exit safely. 
     918    dialog.addWindowListener(new WindowAdapter() { 
     919        public void windowClosing(WindowEvent e) { 
     920            Gatherer.exit(); 
     921        } 
     922        }); 
    924923     
    925924    dialog.display(); 
    926925    dialog.dispose(); 
    927926    dialog = null; 
     927 
    928928     
    929929    String gliserver_url_string = Configuration.getString("general.gliserver_url", true);