Changeset 37330


Ignore:
Timestamp:
2023-02-19T23:52:08+13:00 (14 months ago)
Author:
davidb
Message:

GLI code updated to better support webswing: a specific configWebswing.xml file introduced, and Gatherer/GathererProg updated so the area for the user GLI config files is set as <GLIHOME>/webswing-users, with the logged in username then used to form a subdirectory within this area

Location:
main/trunk/gli
Files:
1 added
2 edited

Legend:

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

    r37328 r37330  
    170170    static private URL default_gliserver_url=null;
    171171   
    172     public Gatherer(String[] args)
     172    public Gatherer(GetOpt go)
    173173    {
    174174        // Display the version to make error reports a lot more useful
     
    177177        JarTools.initialise(this);
    178178
    179         GetOpt go = new GetOpt(args);
     179        //GetOpt go = new GetOpt(args);
    180180
    181181        // Remember the GSDLOS value
     
    246246        }
    247247        else if (isWebswing) {
     248            Configuration.template_config_xml = Configuration.TEMPLATE_CONFIG_PREFIX +  Configuration.CONFIG_WEBSWING_XML;
    248249            Configuration.config_xml = Configuration.CONFIG_WEBSWING_XML;
    249250        }
     
    266267    }
    267268
     269        public Gatherer(String[] args)
     270        {
     271        this(new GetOpt(args));
     272    }
    268273
    269274    public void init(String gsdl_path, String gsdl3_path, String gsdl3_src_path,
     
    287292            System.exit(0);
    288293        }
     294
     295        String username = webswingAuthenticator.getUsername();
     296
     297        // In webswing case, GathererProg does not have a username when it was initializing this
     298        String gli_no_username_dir_path = Gatherer.getGLIUserDirectoryPath();
     299
     300        String gli_user_directory_path = gli_no_username_dir_path  + username + File.separator;
     301       
     302        File gli_user_directory = new File(gli_user_directory_path);
     303        if (!gli_user_directory.exists() && !gli_user_directory.mkdir()) {
     304            System.err.println("Warning: Unable to make directory: " + gli_user_directory_path);
     305        }
     306        else {
     307            Gatherer.setGLIUserDirectoryPath(gli_user_directory_path);
     308        }
     309       
    289310        }
    290311        // Create the debug stream if required
     
    19761997        }
    19771998
     1999        public String getUsername() {
     2000        return username;
     2001        }
     2002
     2003
    19782004        public boolean authenticate(String library_url_string) {
    19792005        PasswordAuthentication pa = getPasswordAuthentication();
  • main/trunk/gli/src/org/greenstone/gatherer/GathererProg.java

    r32926 r37330  
    6161    }
    6262
     63    GetOpt go = new GetOpt(args);
     64           
    6365    // Determine the GLI user directory path
    64     String gli_user_directory_path = System.getProperty("user.home") + File.separator;
    65         if (Utility.isWindows()) {
    66         gli_user_directory_path += "Application Data" + File.separator + "Greenstone" + File.separator + "GLI" + File.separator;
    67         }
    68         else {
    69             gli_user_directory_path += ".gli" + File.separator;
    70         }
     66    String gli_user_directory_path = null;
     67    if (go.webswing) {
     68        if (go.gsdl3_src_path != null) {
     69        // above is a (albeit a crude) test at this early stage of running,
     70        // that makes sure we're running GS3
     71
     72        // "user.dir" resolves to the user's current-working-directory
     73        // which is engineered through webswing.config to be the GLI home directory     
     74       
     75        gli_user_directory_path = System.getProperty("user.dir") + File.separator + "webswing-users" + File.separator;
     76       
     77        //gli_user_directory_path = go.gsdl3_src_path + File.separator;
     78       
     79        // or GSDL3SRCHOME ???
     80        //gli_user_directory_path = System.getProperty("user.dir") + File.separator;
     81        //gli_user_directory_path = System.getenv("GSDL3SRCHOME") + File.separator;
     82
     83        File gli_user_directory = new File(gli_user_directory_path);
     84       
     85        if (!gli_user_directory.exists() && !gli_user_directory.mkdir()) {
     86            System.err.println("Warning: Unable to make directory: " + gli_user_directory_path);
     87        }
     88        }
     89        else {
     90        System.err.println("Webswing for Greenstone2 not supported");
     91        System.exit(1);
     92        }
     93    }
     94    else {
     95        gli_user_directory_path = System.getProperty("user.home") + File.separator;
     96
     97   
     98        if (Utility.isWindows()) {
     99        gli_user_directory_path += "Application Data" + File.separator + "Greenstone" + File.separator + "GLI" + File.separator;
     100        }
     101        else {
     102        gli_user_directory_path += ".gli" + File.separator;
     103        }
     104    }
     105   
    71106    Gatherer.setGLIUserDirectoryPath(gli_user_directory_path);
    72107
     
    75110   
    76111    // Create an instance of the Gatherer class, which will parse the args and prepare the rest of the GLI
    77     final Gatherer gatherer = new Gatherer(args);
     112    final Gatherer gatherer = new Gatherer(go);
    78113       
    79114    // TESTING circumventing the old GUI event dispatch thread exceptions in GLI. Follows
Note: See TracChangeset for help on using the changeset viewer.