Changeset 36110 for main


Ignore:
Timestamp:
2022-03-13T11:37:42+13:00 (2 years ago)
Author:
kjdon
Message:

need to work out servlet_path and site_name in the local (not remote) case too - use build.properties to look for greenstone_default_servlet. Also, move initCollectDir to later on, after we have worked out what the site name is

File:
1 edited

Legend:

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

    r36105 r36110  
    345345                // up fedora further below, together with the local tomcat
    346346            }
    347            
     347                       
    348348            // the no_load flag to GLI is processed at the end of handling open_collection_file_path
    349349            open_collection_file_path = open_collection;
     
    352352                "general.open_collection"+Configuration.gliPropertyNameSuffix(), true);
    353353            }
    354            
    355             initCollectDirectoryPath();
     354            // we haven't worked out site name yet, so do this step later ...
     355            //initCollectDirectoryPath();
    356356           
    357357            if (no_load || (isGsdlRemote && open_collection_file_path.equals(""))) {
     
    359359            }
    360360
    361 
     361           
    362362            // Before calling setProxy, store anything already present
    363363            // Downloading happens on the machine where GLI is running from, even with clientgli
     
    525525
    526526                if (Configuration.servlet_path == null || Configuration.servlet_path.equals("")) {
     527                    String my_servlet_path = null;
    527528                    if (isGsdlRemote) {
    528529                    System.err.println("servlet path is null, get new one from remote server");
    529                     String my_servlet_path = remoteGreenstoneServer.getDefaultServletPath().trim();
    530                     // set site name to match
    531                     String my_site_name = servlet_config.getSiteForServlet(my_servlet_path);
    532 
    533                     Configuration.setSiteAndServlet(my_site_name, my_servlet_path);
     530                    my_servlet_path = remoteGreenstoneServer.getDefaultServletPath().trim();
    534531                    } else {
    535                     // TODO - how do we work out default in local case?
    536                     Configuration.servlet_path = servlet_config.getServletPath(Configuration.site_name);
     532                    // we need to look up build.properties
     533                    System.err.println("servlet path is null, get one from build.properties");
     534                    Properties build_props = loadBuildProperties();
     535                    my_servlet_path = build_props.getProperty("greenstone.default.servlet", "/library");
     536                    build_props = null;
    537537                    }
    538                 }
    539             }
    540            
     538                    // set site name to match
     539                    String my_site_name = servlet_config.getSiteForServlet(my_servlet_path);
     540                    System.err.println("setting site and servlet to " +my_site_name+", "+my_servlet_path);
     541                    Configuration.setSiteAndServlet(my_site_name, my_servlet_path);
     542                   
     543                }
     544            }
     545
     546            initCollectDirectoryPath();
    541547            // ensure that a directory called 'cache' exists in the GLI user directory 
    542548            File user_cache_dir = new File(Gatherer.getGLIUserCacheDirectoryPath());
     
    13361342    }
    13371343
    1338 
     1344    static private Properties loadBuildProperties() {
     1345
     1346    File buildPropsFile = new File(Configuration.gsdl3_src_path + File.separator + "build.properties");
     1347    Properties props = null;
     1348    if(buildPropsFile.exists()) {
     1349        props = new Properties();
     1350        try{
     1351        props.load(new FileInputStream(buildPropsFile));
     1352        } catch (Exception e) {
     1353        System.err.println("couldn't load properties "+e.toString());
     1354        props = null;
     1355        }
     1356    }
     1357    return props;
     1358    }
    13391359
    13401360    /** Prints a warning message about a missing library path, which means the final collection cannot be previewed in the Gatherer.
Note: See TracChangeset for help on using the changeset viewer.