Ignore:
Timestamp:
2020-06-13T06:50:06+12:00 (4 years ago)
Author:
ak19
Message:

Completing TODO from Kathy's commit message for 34116 for ServletRealmCheck: still todo - get servlet name from input args, can't assume library.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/ServletRealmCheck.java

    r34116 r34160  
    3939 * to see if any of these allow the user to edit that collection.
    4040 *
    41  * Run as java org.greenstone.gsdl3.util.ServletRealmCheck <GSDL3HOME> <un> <pwd> [colname]
     41 * Run as java org.greenstone.gsdl3.util.ServletRealmCheck <GSDL3HOME> <un> <pwd> [-c colname] [-s servletname]
    4242 *
    4343 * >java -classpath "greenstone3\web\WEB-INF\lib\gsdl3.jar;greenstone3\web\WEB-INF\lib\gutil.jar"
    44  *      org.greenstone.gsdl3.util.ServletRealmCheck "greenstone3\web" <un> <pw> [colname] 2>&1
     44 *      org.greenstone.gsdl3.util.ServletRealmCheck "greenstone3\web" <un> <pw> [-c colname] [-s servlet-name] 2>&1
    4545 *
    46  * Tries URL: http://hostname:port/context/library?a=s&sa=authenticated-ping&excerptid=gs_content&un=<un>&pw=<pw>[&col=colname]
     46 * Tries URL: http://hostname:port/context/servletname?a=s&sa=authenticated-ping&excerptid=gs_content&un=<un>&pw=<pw>[&col=colname]
    4747 * The &excerptid=gs_content in the URL will return just the <div id="gs_content" /> part of the
    4848 * page that we're interested in.
     
    5353 * If a collection is specified, will only print user groups if the user has access to the collection.
    5454 *
     55 * -s <servletname> to specify a specific servlet-name if different from default of "library".
     56 * This is probaly only meaningful if there is no library called "library" as all servlet-names
     57 * I think would respond identically to the ping regarding the groups a user belongs to.
    5558*/
    5659public class ServletRealmCheck
    57 {   
     60{
     61    private static void printUsageAndTerminate() {
     62    System.out.println("Run with: <GSDL3HOME> <un> <pwd> [-c collection-name] [-s servlet-name]");
     63    System.exit(0);
     64    }
     65   
    5866    public static void main(String[] args) {
    5967   
    60     if (args.length < 3 || args.length > 4){
    61         System.out.println("Run with: <GSDL3HOME> <un> <pwd> [collection-name]");       
    62         System.exit(0);
     68    if (args.length < 3 || args.length > 7){       
     69        printUsageAndTerminate();
     70    } else if(args.length % 2 == 0) { // for all args past the 3rd arg, need odd number of args:
     71        // first 3 args + (2 args for each -flag-option value combination) = odd number of args
     72        printUsageAndTerminate();
    6373    }
    6474   
     
    6676    String username = args[1];
    6777    String password = args[2];
    68     String collection = (args.length > 3) ? args[3] : null;     
     78    //String collection = (args.length > 3) ? args[3] : null;
     79    String collection = null;   
     80    String libservletname = "library"; // fallback to default library servlet
     81   
     82    for(int i = 3; i < args.length; i++) {     
     83        if(args[i].equals("-c")) {
     84        collection = args[++i];
     85        }
     86        else if(args[i].equals("-s")) {
     87        libservletname = args[++i];
     88        }
     89    }
     90
    6991   
    7092    //System.err.println("gsdl3srchome: " + gsdl3srchome);
     
    96118        String context = globalProps.getProperty("tomcat.context");
    97119        // Appending &excerptid=gs_content will get just the <div ... id="gs_content"/> from the final web page:
    98         // TODO dynamically get library name
    99         String urlSuffix = "/"+context+"/library?a=s&sa=authenticated-ping&excerptid=gs_content&un="+username+"&pw="+password;
     120        String urlSuffix = "/"+context+"/"+libservletname+"?a=s&sa=authenticated-ping&excerptid=gs_content&un="+username+"&pw="+password;
    100121        if(collection != null) {
    101122            urlSuffix = urlSuffix + "&col="+collection;
Note: See TracChangeset for help on using the changeset viewer.