Changeset 38796


Ignore:
Timestamp:
2024-02-26T18:50:57+13:00 (3 months ago)
Author:
anupama
Message:
  1. I've now got the new JPhind class, when run as an application, behaving the same way as the JPhind class behaves when run as an applet, by allowing more params to be passed in through the command line as key value pairs, and setting the test input xtraParams (new commandline arg to main) to be the same as hardcoded params in service/PhindPhraseBrowse. The difference is that the window is slightly bigger due to the addition of the status bar and lack of Applet menu, thus allowing more search results to be visible at the end. 2. Updated the class comment to use this example commandline way to launch the JPhind class as an application. 3. JPhind swing JApplet is now used in place of Phind awt Applet in service/PhindPhraseBrowse. I still need to carefully compare the Phind awt Applet with the JPhind swing JApplet to make sure JPhind really can replace Phind.
Location:
main/trunk/greenstone3/src/java/org/greenstone
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/applet/phind/JPhind.java

    r38795 r38796  
    3333To run this applet as an application, for which purpose this class has a main() method, run as:
    3434
    35 java -cp ./web/WEB-INF/lib/gsdl3.jar:./web/WEB-INF/lib/gutil.jar:./web/applet/phind.jar:./web/applet/xercesImpl.jar:./web/applet/xml-apis.jar:./web/WEB-INF/lib/log4j-1.2.8.jar:./web/WEB-INF/classes org.greenstone.applet.phind.JPhind "http://localhost:8383/greenstone3/library" --collection tudor --classifier 1 --phindcgi "?a=a&rt=r&s=PhindApplet&o=xml&ro=1" --library "gs2-library" --backdrop "interfaces/default/images/phindbg1.jpg"
     35java -cp ./web/WEB-INF/lib/gsdl3.jar:./web/WEB-INF/lib/gutil.jar:./web/applet/phind.jar:./web/applet/xercesImpl.jar:./web/applet/xml-apis.jar:./web/WEB-INF/lib/log4j-1.2.8.jar:./web/WEB-INF/classes org.greenstone.applet.phind.JPhind "http://localhost:8383/greenstone3/library?a=a&rt=d&s=PhindApplet&c=tudor" --collection tudor --classifier 1 --phindcgi "?a=a&rt=r&s=PhindApplet&o=xml&ro=1" --library "library" --backdrop "interfaces/default/images/phindbg1.jpg" --xtraParams "orientation=vertical&depth=2&resultorder=L,l,E,e,D,d&fontsize=10&blocksize=10"
     36
     37Basic version:
     38java -cp ./web/WEB-INF/lib/gsdl3.jar:./web/WEB-INF/lib/gutil.jar:./web/applet/phind.jar:./web/applet/xercesImpl.jar:./web/applet/xml-apis.jar:./web/WEB-INF/lib/log4j-1.2.8.jar:./web/WEB-INF/classes org.greenstone.applet.phind.JPhind "http://localhost:8383/greenstone3/gs2-library" --collection tudor --classifier 1 --phindcgi "?a=a&rt=r&s=PhindApplet&o=xml&ro=1" --library "gs2-library" --backdrop "interfaces/default/images/phindbg1.jpg"
    3639
    3740To print very basic usage, run this as an application so:
     
    238241        if(i%2==1) {
    239242        key = args[i].substring(2); // remove -- prefix of paramname
    240         System.err.println("got key: " + key);
     243        //System.err.println("got key: " + key);
    241244        } else {
    242245        value = args[i];
    243246        appParams.put(key, value);
    244         System.err.println("got value: " + value);
     247        //System.err.println("got value: " + value);
     248
     249
     250        // HttpUtils.parseQueryString() deprecated, so hacking decode xtra key-value pairs
     251        // https://stackoverflow.com/questions/13592236/parse-a-uri-string-into-name-value-collection?page=1&tab=scoredesc#tab-top
     252        // String.split() is preferred over Tokenizer but 2nd parameter behaves differently
     253        // than I expected.
     254        // https://docs.oracle.com/javase/6/docs/api/java/lang/String.html#split%28java.lang.String,%20int%29
     255        if(key.equals("xtraParams")) {
     256            value = value.replace("&", "&"); // just in case we have html entities
     257            String[] param_list = value.split("&", 0); // 0 for all occurrences
     258            for(String key_val : param_list) {         
     259            String[] paramPair = key_val.split("=", 2); // get first 2 strings, key and val
     260            //System.err.println("key_val: " + key_val);
     261            if(paramPair.length == 2) {
     262                String xtraParamsKey = paramPair[0];
     263                String xtraParamsVal = paramPair[1];
     264                //System.err.println("key - val: " + xtraParamsKey + " - " + xtraParamsVal);
     265                appParams.put(xtraParamsKey, xtraParamsVal);
     266            }
     267            }
     268        }
     269       
    245270        key = value = null;
    246271        }
     
    602627    public URL getDocumentBase() {
    603628    if(!isRunAsApplet) { // launched as application
     629        //System.err.println("*** docBaseURL: " + docBaseURL);
    604630        return this.docBaseURL;
    605631    } else {
     
    10621088    public static void main(String args[]) {
    10631089    if(args.length < 9) {
    1064         System.err.println("Need minimum --params: <baseURL> --collection <collection> --classifier <classifier> --phindcgi <URL> --library <libURL> [--backdrop <ImgURL>]");
     1090        System.err.println("Need minimum --params: <baseURL> --collection <collection> --classifier <classifier> --phindcgi <URL> --library <libURL> [--backdrop <ImgURL>] [--xtraParams <key1=value1&key2=value2&...]");
    10651091    }
    10661092    else { // collection fao.org, classifier 1, phindcgi url, library url, backdrop imgurl
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/PhindPhraseBrowse.java

    r29309 r38796  
    102102    // this is left blank at this end, and must be filled in by applet action - if the library name is not needed, this param is left out
    103103    // phindcgi param now is not complete - library must be prepended to it.
    104     String app_info = "<"+GSXML.APPLET_ELEM+" CODEBASE='applet' CODE='org.greenstone.applet.phind.Phind.class' ARCHIVE='phind.jar, xercesImpl.jar, xml-apis.jar' WIDTH='500' HEIGHT='400'><PARAM NAME='library' VALUE=''/> <PARAM NAME='phindcgi' VALUE='?";
     104    String app_info = "<"+GSXML.APPLET_ELEM+" CODEBASE='applet' CODE='org.greenstone.applet.phind.JPhind.class' ARCHIVE='phind.jar, xercesImpl.jar, xml-apis.jar' WIDTH='500' HEIGHT='400'><PARAM NAME='library' VALUE=''/> <PARAM NAME='phindcgi' VALUE='?";
    105105    app_info += GSParams.ACTION +"=a&amp;"+GSParams.REQUEST_TYPE +"=r&amp;"+GSParams.SERVICE+"="+PHIND_SERVICE+"&amp;"+GSParams.OUTPUT+"=xml&amp;"+GSParams.RESPONSE_ONLY+"=1'/>";
    106106    app_info +="<PARAM NAME='collection'   VALUE='";
Note: See TracChangeset for help on using the changeset viewer.