Changeset 3682


Ignore:
Timestamp:
2003-01-17T10:45:27+13:00 (21 years ago)
Author:
kjdon
Message:

changes to cgi args: a=action, sa=subaction, s=servicename, rt=request-type (d for display, r for request, s for status) ro=request-only (dont process the page using xslt, just pass back the xml)

Location:
trunk/gsdl3/src/java/org/greenstone/gsdl3/action
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/AppletAction.java

    r3645 r3682  
    2929    Element request = (Element)GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
    3030   
    31     // subaction is display (d) or request (r)
    32     String request_type = request.getAttribute(GSXML.SUBACTION_ATT);
    33     if (!request_type.equals("d")&&!request_type.equals("r")) {
    34         System.err.println("AppletAction Error: the sa arg should be either d or r, instead it was "+request_type+"!");
    35         return null;
    36     }
    3731   
    3832    // get the collection and service param
     
    4034    HashMap params = GSXML.extractParams(cgi_param_list);
    4135
     36    // request_type is display (d) or request (r)
     37    String request_type = (String)params.get(GSCGI.REQUEST_TYPE_ARG);
     38    if (!request_type.equals("d")&&!request_type.equals("r")) {
     39        System.err.println("AppletAction Error: the rt arg should be either d or r, instead it was "+request_type+"!");
     40        return null;
     41    }
     42
    4243    String collection = (String)params.get(GSCGI.COLLECTION_ARG);
    4344    String service_name=(String)params.get(GSCGI.SERVICE_ARG);
    44     service_name+= "Applet";
    4545   
    4646    String to=null;
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/BrowseAction.java

    r3645 r3682  
    1414public class BrowseAction extends Action {
    1515   
     16    public static final String CLASSIFIER_ARG = "cl";
     17
     18    /* add the action specific args to the cgi param list
     19     */
     20    public void addCGIParams() {
     21    cgi_.addStaticParam(CLASSIFIER_ARG);
     22    }
     23
     24    /** process the request */
    1625    public Element process (Element message) {
    1726
     
    2837
    2938   
    30     // the browse type is the subaction
    31     String browse_type = request.getAttribute(GSXML.SUBACTION_ATT);
     39    // the browse type is the subaction - ignore for now
     40    //String browse_type = request.getAttribute(GSXML.SUBACTION_ATT);
    3241   
    33     if (browse_type.equals("Classifier")) {
    34         return classifierBrowse(page, request);
    35     }
    36     return unknownBrowse(page, request, browse_type);
     42    //if (browse_type.equals("classifier")) {
     43    return classifierBrowse(page, request);
     44    //}
     45    //return unknownBrowse(page, request, browse_type);
    3746
    3847   
     
    5463    HashMap params = GSXML.extractParams(cgi_paramList);
    5564
     65    String service_name = (String)params.get(GSCGI.SERVICE_ARG);
    5666    String collection = (String)params.get(GSCGI.COLLECTION_ARG);
    5767    if (collection == null || collection.equals("")) {
     
    7181
    7282    String to = collection;
    73     to = GSPath.appendLink(to, "ClassifierBrowse");
     83    to = GSPath.appendLink(to, service_name);
    7484    mr_info_request.setAttribute(GSXML.TO_ATT, to);
    7585
     
    8898   
    8999    // if there is a cl field in the cgi params, get the classifier info
    90     String node = (String)params.get("cl");
     100    String node = (String)params.get(CLASSIFIER_ARG);
    91101   
    92102    if (node!=null && !node.equals("")) {
     
    121131       
    122132        Element response = (Element)GSXML.getChildByTagName(mr_query_response, GSXML.RESPONSE_ELEM);
    123         Node new_style = GSXML.getChildByTagName(response, "stylesheet");
     133        Node new_style = GSXML.getChildByTagName(response, GSXML.STYLESHEET_ELEM);
    124134        if (new_style !=null) {
    125135        GSXSLT.mergeStylesheets(style_doc, (Element)new_style);
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/ProcessAction.java

    r3645 r3682  
    1616public class ProcessAction extends Action {
    1717   
    18     public static final String PROCESS_ONLY_ARG="p";
    19 
    20     /** add the action specific args to the GSCGI object */
    21     protected void addCGIParams() {
    22     cgi_.addStaticParam(PROCESS_ONLY_ARG);
    23    
    24     }
    2518    /** process a request */
    2619    public Element process (Element message) {
     
    2821    // assume only one request
    2922    Element request = (Element)GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
    30     String subaction = request.getAttribute(GSXML.SUBACTION_ATT);
     23
     24    // we ignore the subaction for now - all types are processed by the same method
     25    //String subaction = request.getAttribute(GSXML.SUBACTION_ATT);
    3126    // get the param list
    3227    Element cgi_param_list = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     
    3429    String service_name = (String) params.get(GSCGI.SERVICE_ARG);
    3530    String cluster_name = (String) params.get(GSCGI.CLUSTER_ARG);
    36     String process_p = (String)params.get(PROCESS_ONLY_ARG);
    37     boolean process_only = false;
    38     if (process_p!=null) {
    39         process_only = (((String)params.get(PROCESS_ONLY_ARG)).equals("1")?true:false);
     31    String request_only_p = (String)params.get(GSCGI.REQUEST_ONLY_ARG);
     32    boolean request_only = false;
     33    if (request_only_p!=null) {
     34        request_only = (request_only_p.equals("1")?true:false);
    4035    }
     36    String request_type = (String) params.get(GSCGI.REQUEST_TYPE_ARG);
    4137    // the return page
    4238    Element page = doc_.createElement(GSXML.PAGE_ELEM);
    4339    page.setAttribute(GSXML.LANG_ATT, request.getAttribute(GSXML.LANG_ATT));
    4440
    45     // what is carried out depends on the subaction
    46     // if sa=d, then a describe request is done,
    47     // is sa=r, a request and then a describe request is done
    48     // if sa=s, a status request is done.
     41    // what is carried out depends on the request_type
     42    // if rt=d, then a describe request is done,
     43    // is rt=r, a request and then a describe request is done
     44    // if rt=s, a status request is done.
    4945
    50     // if p=1, then this calls for a process only page - we do the request
    51     // (sa should be r or s) and just give the response straight back
     46    // if ro=1, then this calls for a process only page - we do the request
     47    // (rt should be r or s) and just give the response straight back
    5248    // without any page processing
    5349
     
    5551    String stylesheet = GSFile.stylesheetFile(config_, "process.xsl");
    5652   
    57     if (!process_only) {
     53    if (!request_only) {
    5854        // check that the stylesheet is present
    5955        if (stylesheet==null) {
    60         System.err.println("ProcessAction Error: build stylesheet not found!");
     56        System.err.println("ProcessAction Error: process stylesheet not found!");
    6157        return null;
    6258        }
     
    6763    to = GSPath.appendLink(to, service_name);
    6864
    69     if (!subaction.equals("d")) {
    70         // if sa=s or sa=r, do the request
     65    if (!request_type.equals("d")) {
     66        // if rt=s or rt=r, do the request
    7167       
    7268        Element mr_query_message = doc_.createElement(GSXML.MESSAGE_ELEM);
     
    7470        mr_query_message.appendChild(mr_query_request);
    7571       
    76         if (subaction.equals("s")) { // status
     72        if (request_type.equals("s")) { // status
    7773        mr_query_request.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_STATUS);
    7874        } else {
     
    8985        Element result_response = (Element)GSXML.getChildByTagName(mr_query_response, GSXML.RESPONSE_ELEM);
    9086       
    91         if (process_only) {
     87        if (request_only) {
    9288        // just send the reponse as is
    9389        return result_response;
     
    147143    page.appendChild(cgi_request);
    148144   
    149     System.out.println("process action, page=");
    150     System.out.println(converter_.getString(page));
    151145    // now process the page and return the result
    152146    Document style_doc = converter_.getDOM(new File(stylesheet));
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/QueryAction.java

    r3645 r3682  
    3333       page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.CONFIGURATION_ELEM), true));
    3434
    35     // query type is the subaction
    36     String query_type = request.getAttribute(GSXML.SUBACTION_ATT) + "Query";
    37    
    38     // for now assume all queries can be handled by basic query
    39     return basicQuery(page, request, query_type);
    40    
     35       // if want to have a different type of query here, check the subaction att of request
     36
     37       // for now assume all queries can be handled by basic query
     38       return basicQuery(page, request);
     39       
    4140    }
    4241   
     
    4544     * params to the service, then gets the titles for any results
    4645     */
    47     protected Element basicQuery(Element page, Element request, String service_name) {
     46    protected Element basicQuery(Element page, Element request) {
    4847
    4948    // check that the stylesheet is present - cant output the page without one.
     
    5857   
    5958    HashMap params = GSXML.extractParams(cgi_param_list);
    60 
     59   
     60    String request_type = (String)params.get(GSCGI.REQUEST_TYPE_ARG);
     61    String service_name = (String)params.get(GSCGI.SERVICE_ARG);
    6162    String collection = (String)params.get(GSCGI.COLLECTION_ARG);
    6263    if (collection == null || collection.equals("")) {
     
    122123    page.appendChild(description);
    123124
    124     // now we always do the query - we have no way of knowing whether
    125     // a query was specified or not cos we cant assume that q is the
    126     // query string - maybe we could check that any required params have
    127     // a value??
    128    
     125    // just a display request
     126    if (request_type.equals("d")) {
     127        // output the page
     128        // process using the stylesheet
     129        Document style_doc = converter_.getDOM(new File(stylesheet));
     130        GSXSLT.absoluteIncludePaths(style_doc, config_);
     131        return (Element)transformer_.transform(style_doc, page);   
     132    }
     133       
     134    // do the query
    129135    Element mr_query_message = doc_.createElement(GSXML.MESSAGE_ELEM);
    130136    Element mr_query_request = doc_.createElement(GSXML.REQUEST_ELEM);
Note: See TracChangeset for help on using the changeset viewer.