Changeset 34160


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.

Location:
main/trunk
Files:
4 edited

Legend:

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

    r34158 r34160  
    237237        command_parts_list.add("-library_name");
    238238        String library_servlet_name = Configuration.servlet_path;
    239         if(library_servlet_name.startsWith("/")) {
     239        if(library_servlet_name.charAt(0) == '/') {
    240240        library_servlet_name = library_servlet_name.substring(1);
    241241        }
  • main/trunk/gli/src/org/greenstone/gatherer/remote/RemoteGreenstoneServer.java

    r32923 r34160  
    605605    if (Gatherer.GS3){
    606606        cgi_args += "&site=" + Configuration.site_name;
     607        String library_servlet_name = Configuration.servlet_path;
     608        if (library_servlet_name.charAt(0) == '/') {
     609        library_servlet_name = library_servlet_name.substring(1);
     610        }
     611        cgi_args += "&servlet=" + library_servlet_name;
    607612    }
    608613
  • main/trunk/greenstone2/common-src/cgi-bin/gliserver.pl

    r34159 r34160  
    315315    my $user_password = shift(@_);
    316316    my $collection = shift(@_);
    317    
     317
     318    # this is the only subroutine here that uses library servlet name param
     319    my $library_servlet_name = $gsdl_cgi->clean_param("servlet");   
     320    #if (!defined $library_servlet_name) {
     321    #$library_servlet_name = "library";
     322    #}
     323    $gsdl_cgi->delete("servlet");
     324
     325       
    318326    my $gsdl3home = $ENV{'GSDL3HOME'};
    319327    my $java = $gsdl_cgi->get_java_path();
     
    331339    my $java_args = "\"$gsdl3home\" \"$username\" \"$user_password\"";
    332340    if ($collection ne "") {
    333     $java_args .= " \"$collection\"";
    334     }
    335    
     341    $java_args .= " -c \"$collection\"";
     342    }
     343    if (defined $library_servlet_name && $library_servlet_name !~ m/^\s*$/) {
     344    $java_args .= " -s \"$library_servlet_name\"";
     345    }
    336346    $gsdl_cgi->checked_chdir($gsdl3home);   
    337347    my $java_command="\"$java\" -classpath \"$java_classpath\" org.greenstone.gsdl3.util.ServletRealmCheck $java_args 2>&1";
  • 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.