Changeset 34161

Show
Ignore:
Timestamp:
13.06.2020 08:43:50 (4 weeks ago)
Author:
ak19
Message:

Fixed last of the client-gli/remoe GS3 bugs discovered yesterday. When client-gli connects to many different remote GS3 servers, the previously stored site in configRemote.xml may not exist in the next remote GS3 server that the same client-gli will connect to. client-gli must not terminate, as it ends up being an infinite loop of client-GLI terminating. Instead, print a warning and fallback on known sites, which then ends up savin a known site name into configRemot.xml for next time.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/remote/RemoteGreenstoneServerAction.java

    r24915 r34161  
    251251        download_collection_configurations_command += "&lr=" + remote.lang_region; 
    252252        String zip_file_path = Gatherer.getCollectDirectoryPath() + "collections.zip"; 
    253         action_output = remote.downloadFile(download_collection_configurations_command, zip_file_path); 
    254  
     253 
     254        // In the case of GS3, one of the causes the following may throw an exception is because 
     255        // there was no such site by the name stored in configRemote.xml under general.site_name 
     256        // from the previous client-gli connection session. 
     257        // The previous session may have connected to a different remote GS for instance, 
     258        // or it's a since deleted site. 
     259        // Need to handle this exception here if it happens the first time, else client-GLI will 
     260        // never open, but keep closing with the error msg that the collect directory within the 
     261        // unknown site does not exist, unless and until general.site_name's value is removed by 
     262        // hand from configRemote.xml. 
     263        try { 
     264        action_output = remote.downloadFile(download_collection_configurations_command, zip_file_path); 
     265         
     266        } catch(Exception e) { 
     267        if(!Gatherer.GS3) { 
     268            throw(e); // rethrow, as no site in GS2 
     269        } 
     270         
     271        if(e.getMessage().contains("Directory") && e.getMessage().contains("does not exist")) { 
     272            System.err.println("*** Warning: The stored GS3 site '" + Configuration.site_name 
     273                       + "' from the previous session did not exist."); 
     274            System.err.println("    Swapping to known site and attempting to download" 
     275                       + " its collection configurations."); 
     276             
     277            // The result of cmd=get-site-names store by servlet_config before 
     278            // download-collection-configurations gets called. 
     279            ArrayList sites = Gatherer.servlet_config.getSites(); 
     280            // Let's go with the first if there is one, else rethrow 
     281            if(sites.size() > 0) { 
     282 
     283            // Use a known site and one of its servlets this time. 
     284            String site = (String)sites.get(0); 
     285            String servlet = (String)Gatherer.servlet_config.getServletsForSite(site).get(0); 
     286            Configuration.setSiteAndServlet(site, servlet); // these values will into configRemote.xml 
     287 
     288            // Now try downloading coll configurations again, for a known site this time 
     289            action_output = remote.downloadFile(download_collection_configurations_command, zip_file_path); 
     290             
     291            } 
     292            else { 
     293            throw(e); 
     294            } 
     295        } else { 
     296            throw(e); 
     297        } 
     298 
     299        } 
     300 
     301        // if we made it here, we downloaded the collection configs zip for an extant site 
     302        // and can continue. 
    255303        // Unzip the collection configurations just downloaded 
    256304        UnzipTools.unzipFile(zip_file_path, Gatherer.getCollectDirectoryPath()); 
     305 
    257306    } 
    258307    }