Changeset 19758

Show
Ignore:
Timestamp:
08.06.2009 15:16:34 (10 years ago)
Author:
ak19
Message:

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.

Location:
gli/trunk/src/org/greenstone/gatherer
Files:
3 modified

Legend:

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

    r19678 r19758  
    121121    static public boolean isApplet = false; 
    122122    static public boolean isGsdlRemote = false; 
     123    static public boolean isLocalLibrary = false; 
    123124 
    124125    /* TODO: If we're using local GLI, collections are built locally. If we're using client-GLI 
     
    349350        } 
    350351        else { // local greenstone: Start up the local library server, if that's what we want 
    351         if (local_library_path != null && !GS3) { 
    352             LocalLibraryServer.start(gsdl_path, local_library_path); 
    353         } 
     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 
    354356        } 
    355357         
     
    369371        // It is not necessary if an independent GSI was launched and the user hasn't pressed Enter Library yet 
    370372        DebugStream.println("Configuration.library_url = " + Configuration.library_url); 
    371         if (Configuration.library_url == null && (LocalLibraryServer.isRunning() && !LocalLibraryServer.isURLPending())) { 
     373        if (Configuration.library_url == null && (isLocalLibrary && !LocalLibraryServer.isURLPending())) { 
    372374        missingEXEC();  
    373375        } 
  • gli/trunk/src/org/greenstone/gatherer/greenstone/LocalLibraryServer.java

    r19585 r19758  
    162162    } 
    163163 
    164     static public void start(String gsdl_path, String local_library_server_file_path) 
     164    static public boolean start(String gsdl_path, String local_library_server_file_path) 
    165165    { 
    166     // Check the local library server file (server.exe or gs2-server.sh) exists 
    167     local_library_server_file = new File(local_library_server_file_path); 
    168      
    169     if (!local_library_server_file.exists()) { 
    170         DebugStream.println("No local library at given file path."); 
    171      
    172         String defaultServerFilename = Utility.isWindows() ? "server.exe" : "gs2-server.sh"; 
    173         local_library_server_file = new File(gsdl_path + defaultServerFilename); 
    174         if (!local_library_server_file.exists()) { 
    175         DebugStream.println("No local library at all."); 
    176         return; 
    177         } 
    178     }    
    179  
    180166    // In the case of the Local Library Server on Linux, we need to do an extra test: 
    181167    // If GS2 was not configured with --enable-apache-httpd, then there is no apache webserver folder, 
     
    187173        DebugStream.println("The web server does not exist at "  
    188174                    + localLinuxServerFolder.getAbsolutePath() + "\nNo local library at all. Trying web library"); 
    189         return; 
    190         } 
    191     } 
     175        return false; 
     176        } 
     177    } 
     178 
     179    // Check the local library server file (server.exe or gs2-server.sh) exists 
     180    if(local_library_server_file_path == null) { 
     181        return false; 
     182    } 
     183    local_library_server_file = new File(local_library_server_file_path);    
     184    if (!local_library_server_file.exists()) { 
     185        DebugStream.println("No local library at given file path."); 
     186     
     187        String defaultServerFilename = Utility.isWindows() ? "server.exe" : "gs2-server.sh"; 
     188        local_library_server_file = new File(gsdl_path + defaultServerFilename); 
     189        if (!local_library_server_file.exists()) { 
     190        DebugStream.println("No local library at all."); 
     191        return false; 
     192        } 
     193    }    
    192194 
    193195    llssite_cfg_file = new LLSSiteConfig(local_library_server_file); 
    194          
     196    if(!llssite_cfg_file.isConfigFileSet()) { 
     197        return false; 
     198    } 
     199 
     200    // from now on return true: we're in local_library_mode (even if the server is not running) 
     201 
     202     
    195203    // If the user launched the GSI independent of GLI, but user has not pressed 
    196204    // Enter Library yet, then we will obtain the previewURL later. 
    197205    if(LocalLibraryServer.isURLPending()) { 
    198206        // running is still false when the URL is pending because only GSI is running, not the server 
    199         return; 
     207        return true; 
    200208    } else if(llssite_cfg_file.isIndependentGSI()) { 
    201209        // there is a url, it's not pending, and it is llssite.cfg: meaning GSI has started up 
    202210        running = true; 
    203         return;      
     211        return true;     
    204212    } 
    205213 
     
    219227        // Run the server interface 
    220228        Gatherer.spawnApplication(local_library_server_command, ID); 
    221         return; 
     229        return true; 
    222230        } 
    223231        catch (MalformedURLException exception) { 
     
    250258        } 
    251259    } 
     260 
     261    return true; 
    252262    } 
    253263 
     
    584594        lastModified = configFile.lastModified(); 
    585595        return true; 
     596    } 
     597 
     598    /** To test we've actually instantiated this object meaningfully. If so, then configFile is set */ 
     599    public boolean isConfigFileSet() { 
     600        return (configFile != null && configFile.exists()); 
    586601    } 
    587602     
  • gli/trunk/src/org/greenstone/gatherer/gui/PreviewButton.java

    r19752 r19758  
    8888    } 
    8989 
    90     if(!Gatherer.isGsdlRemote) { 
     90    if(Gatherer.isLocalLibrary) { 
    9191        // check that the local library server is still running  - doesn't do anything if it's not supposed to be running 
    9292        // !! Don't like this here 
    9393        LocalLibraryServer.checkServerRunning(); 
    94         if(LocalLibraryServer.isRunning() && LocalLibraryServer.isURLPending()) { 
     94        if(LocalLibraryServer.isURLPending()) { 
    9595        // Remind the user to press Enter Library, and return from this method 
    9696        JOptionPane.showMessageDialog(Gatherer.g_man,