Changeset 4257


Ignore:
Timestamp:
2003-05-08T16:11:22+12:00 (21 years ago)
Author:
kjdon
Message:

simplified actions, the receptionist does a lot more of teh work now. actions have no knowledge of transformations, whether they are in a cgi context, and only get the info that they need - eg the collection info which is needed by the xslt is now gathered by the receptionist

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

Legend:

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

    r3944 r4257  
    55// XML classes
    66import org.w3c.dom.Node;
     7import org.w3c.dom.NodeList;
    78import org.w3c.dom.Element;
    89import org.w3c.dom.Document;
     
    1011// other java stuff
    1112import java.io.File;
    12 
     13import java.util.Vector;
    1314/** base class for Actions */
    1415abstract public class Action {
     
    2021    /** a converter class to parse XML and create Docs */
    2122    protected XMLConverter converter_=null;
    22     /** cgi args converter */
    23     protected GSCGI cgi_ = null;
    24     /** a transformer class to transform xml using xslt */
    25     protected XMLTransformer transformer_=null;
    2623    /** a reference to the message router that it must talk to to
    2724     * get info. it may be a communicator acting as a proxy, but it
     
    3128    public Action() {
    3229    converter_ = new XMLConverter();
    33     transformer_ = new XMLTransformer();
    3430    doc_ = converter_.newDOM();
    3531    }
     
    4238       mr_ = m;
    4339    }
    44     /** sets the GSCGI object - used to convert between short and long names
    45      * of params */
    46     public void setCGI(GSCGI cgi) {
    47     cgi_ = cgi;
    48     // add in any action specific params
    49     addCGIParams();
    50     }
    5140    public void configure() {
    5241    // does nothing yet
    5342    }
    54     /** any action specific cgi params should be added to the GSCGI object-
    55      * overwrite this if a new action has its own params
    56      * using cgi_.addStaticParam(param-name) */
    57     protected void addCGIParams() {
    58    
    59     }
     43   
    6044    /** process takes an xml representation of cgi args
    6145     * and returns the page of results - may be in html/xml/other
     
    6852    return converter_.getString(result);
    6953    }
    70    
     54   
    7155    /** the main process method - must be implemented in subclass */
    7256    abstract public Element process(Element xml_in);
    7357
    74     /** locates the format element, transforms it with config_format.xsl, then
    75      * returns the transformed element */
    76     protected Element getAndTransformFormat(Element format_response) {
    77    
    78     Element format_elem = (Element)GSXML.getChildByTagName(format_response, GSXML.FORMAT_ELEM);
    79     if (format_elem == null) {
    80         return null;
    81     }
    82     // transform it to proper xsl
    83     String stylesheet_file = GSFile.stylesheetFile(config_, "config_format.xsl");
    84     Document stylesheet = converter_.getDOM(new File(stylesheet_file));
    85     Element new_format = (Element)transformer_.transform(stylesheet, format_elem);
    86 
    87     return new_format;
    88 
    89     }
    90 
     58//      protected Vector getMetadata(Element format) {
     59//      NodeList nodes = format.getElementsByTagName("gsf:metadata");
     60//          Vector meta_names = new Vector();
     61//          for (int i=0; i<nodes.getLength(); i++) {
     62//              meta_names.add(((Element)nodes.item(i)).getAttribute("name"));
     63//          }
     64//          return meta_names;
     65//      }
    9166}
    9267
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/AppletAction.java

    r4144 r4257  
    1919   
    2020    Element request = (Element)GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
    21    
     21    Element result = doc_.createElement(GSXML.MESSAGE_ELEM);
     22    Element page_response = doc_.createElement(GSXML.RESPONSE_ELEM);
     23    result.appendChild(page_response);
     24
    2225    // get the collection and service params
    2326    Element cgi_param_list = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     
    2831    if (!request_type.equals("d")&&!request_type.equals("r")) {
    2932        System.err.println("AppletAction Error: the rt arg should be either d or r, instead it was "+request_type+"!");
    30         return null;
     33        return result;
    3134    }
    3235   
     
    6164    }
    6265   
    63     // else request type  = 'd'
    64     // find the stylesheet
    65     String stylesheet = GSFile.stylesheetFile(config_, "applet.xsl");
    66    
    67     if (stylesheet==null) {
    68         System.err.println("AppletAction Error: applet stylesheet not found!");
    69         return null;
    70     }
    71  
    72     // we are just displaying the applet - get the description from
    73     // the service, and process using xslt
    74    
    75    
    76     // create the return page tree
    77     Element page = doc_.createElement(GSXML.PAGE_ELEM);
    78     page.setAttribute(GSXML.LANG_ATT, lang);
    79     // add the page extra stuff from message
    80     page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.PAGE_EXTRA_ELEM), true));
    81 
    82     // add in the page Request
    83     Element page_request = GSXML.duplicateWithNewName(doc_, request, "pageRequest", true);
    84     page.appendChild(page_request);
    8566
    8667    // get the applet description, and the collection info if a collection is specified
    87 
     68   
    8869    Element mr_message = doc_.createElement(GSXML.MESSAGE_ELEM);
    8970    Element applet_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_DESCRIBE, to, lang);
    9071    mr_message.appendChild(applet_request);
    9172
    92     if (coll_specified) {
    93         Element coll_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_DESCRIBE, collection, lang);
    94         mr_message.appendChild(coll_request);
    95     }
    9673   
    9774    Element mr_response = (Element)mr_.process(mr_message);
    98        
    99     Element page_response = doc_.createElement(GSXML.PAGE_RESPONSE_ELEM);
    100     page.appendChild(page_response);
     75
    10176    // add in the applet info
    10277    String path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.SERVICE_ELEM);
     
    10580    // must handle any params that have values that are not
    10681    // necessarily known by the service
     82    // should this be done here or by web receptionist??
     83    // cant really have an applet without web?
    10784    editLocalParams(app_desc, config_.library_name_, collection);
    10885    page_response.appendChild(app_desc);
    10986   
    110     if (coll_specified) {
    111         Element coll_response = (Element) mr_response.getElementsByTagName(GSXML.RESPONSE_ELEM).item(1);
    112         Element coll_elem = (Element)GSXML.getChildByTagName(coll_response, GSXML.COLLECTION_ELEM);
    113         page_response.appendChild(doc_.importNode(coll_elem, true));
    114     }
    115    
    116     // process using the stylesheet
    117     Document style_doc = converter_.getDOM(new File(stylesheet));
    118     GSXSLT.absoluteIncludePaths(style_doc, config_);
    119     return (Element)transformer_.transform(style_doc, page);   
     87    return result;
    12088   
    12189    }
     
    12492     * 'library' or 'collection'. If found, the params are set to 
    12593     * the appropriate values
     94     * should this be done here or in the receptionist?
    12695     */
    12796    protected void editLocalParams(Element description, String library_name,
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/BrowseAction.java

    r4189 r4257  
    1818    public static final String CLASSIFIER_ARG = "cl";
    1919    public static final String SIBLING_ARG = "sib";
    20     /* add the action specific args to the cgi param list
    21      */
    22     public void addCGIParams() {
    23     cgi_.addStaticParam(CLASSIFIER_ARG);
    24     }
    2520
    2621    /** process the request */
     
    2924    // get the request - assume only one
    3025    Element request = (Element)GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
    31    
    32     // create the return page tree
    33     Element page = doc_.createElement(GSXML.PAGE_ELEM);
    34     page.setAttribute(GSXML.LANG_ATT, request.getAttribute(GSXML.LANG_ATT));
    35     // add the page extra stuff from message
    36     page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.PAGE_EXTRA_ELEM), true));
    37 
    38     return classifierBrowse(page, request);
    39    
     26
     27    // the result
     28    Element result = doc_.createElement(GSXML.MESSAGE_ELEM);
     29    Element response = classifierBrowse(request);
     30    result.appendChild(response);
     31    return result;
    4032    }
    4133   
    4234
    43     protected Element classifierBrowse(Element page, Element request) {
    44 
    45     // check that the stylesheet is present - cant output a page without one. we may adapt this to use unknownquery stylesheet? - or ask for one from the MR
    46     String stylesheet = GSFile.stylesheetFile(config_, "classifier.xsl");
    47     if (stylesheet==null) {
    48         System.err.println("BrowseAction Error: classifier stylesheet not found!");
    49         return null;
    50     }
    51     Document style_doc = converter_.getDOM(new File(stylesheet));
    52 
    53     // the first part of the data for the page is the cgi-params
    54     Element page_request = GSXML.duplicateWithNewName(doc_, request, GSXML.PAGE_REQUEST_ELEM, true);
    55     page.appendChild(page_request);
    56    
     35    protected Element classifierBrowse(Element request) {
     36
     37    Element page_response = doc_.createElement(GSXML.RESPONSE_ELEM);
     38
    5739    // extract the params from the cgi-request, and check that we have a coll specified
    5840    Element cgi_paramList = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     
    6244    String collection = (String)params.get(GSCGI.COLLECTION_ARG);
    6345    if (collection == null || collection.equals("")) {
    64         System.err.println("BrowseAction Error:classifierbrowse, need to specify a collection!");
    65         return null;
     46        System.err.println("BrowseAction Error:classifierBrowse, need to specify a collection!");
     47        return page_response;
    6648       
    6749    }
     
    7456    }
    7557
    76     // the main response for the page is in a pageResponse element
    77     Element page_response = doc_.createElement(GSXML.PAGE_RESPONSE_ELEM);
    78     page.appendChild(page_response);
    79 
    8058    String lang = request.getAttribute(GSXML.LANG_ATT);
    8159    String to = GSPath.appendLink(collection, service_name);
    8260   
    83     // the second part of the page is the service description
     61    // the first part of the response is the service description
    8462    // for now get this again from the service.
    85     // this will probably need to be cached somehow later on.
     63    // this should be cached somehow later on.
    8664   
    8765    Element info_message = doc_.createElement(GSXML.MESSAGE_ELEM);
     
    8967    info_message.appendChild(info_request);
    9068   
    91     // also get the collection description (should be just metadata?) for the http address stuff
    92     Element coll_info_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_DESCRIBE, collection, lang);
    93     info_message.appendChild(coll_info_request);
    9469    // also get the format stuff now if there is some
    9570    Element format_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_FORMAT, to, lang);
     
    9974    Element info_response = (Element) mr_.process(info_message);
    10075
    101     // the three responses
     76    // the two responses
    10277    NodeList responses = info_response.getElementsByTagName(GSXML.RESPONSE_ELEM);
    10378    Element service_response = (Element)responses.item(0);
    104     Element coll_response = (Element)responses.item(1);
    105     Element format_response = (Element)responses.item(2);
     79    Element format_response = (Element)responses.item(1);
    10680
    10781    Element service_description = (Element)GSXML.getChildByTagName(service_response, GSXML.SERVICE_ELEM);
    10882    page_response.appendChild(doc_.importNode(service_description, true));
    10983   
    110     Element coll_description = (Element)GSXML.getChildByTagName(coll_response, GSXML.COLLECTION_ELEM);
    111     page_response.appendChild(doc_.importNode(coll_description, true));
    112    
    113        
     84    // if rt=d, then we are just displaying the service
     85    String request_type = (String)params.get(GSCGI.REQUEST_TYPE_ARG);
     86    if (request_type.equals("d")) {
     87        //return the page that we have so far
     88        return page_response;
     89    }
     90   
    11491    // get the node that the user has clicked on
    11592    String classifier_node = (String)params.get(CLASSIFIER_ARG);
     
    11794    // if the node is not defined, return the page that we have so far
    11895    if (classifier_node ==null || classifier_node.equals("")) {
    119         GSXSLT.absoluteIncludePaths(style_doc, config_);
    120         return (Element)transformer_.transform(style_doc, page);
     96        return page_response;
    12197    }
    12298   
     
    124100    String top_id = OID.getTop(classifier_node);
    125101
    126     // add in the format info into the stylesheet
    127     //System.out.println("transforming format:"+converter_.getString(format_response));
    128     Element format_elem = getAndTransformFormat(format_response);
    129     //System.out.println("transformed format:"+converter_.getString(format_elem));
     102    // add the format info into the response
     103    Element format_elem = (Element)GSXML.getChildByTagName(format_response, GSXML.FORMAT_ELEM);
    130104    if (format_elem != null) {
     105        // find the one for the classifier we are in
    131106        Element this_format = GSXML.getNamedElement(format_elem, GSXML.CLASSIFIER_ELEM, GSXML.NAME_ATT, top_id);
    132107        if (this_format != null) {
    133         GSXSLT.mergeStylesheets(style_doc, this_format);
    134         }
    135     }
    136            
     108        Element new_format = GSXML.duplicateWithNewName(doc_, this_format, GSXML.FORMAT_ELEM, false);
     109        page_response.appendChild(new_format);
     110        }
     111    }
     112   
    137113    // get the browse structure for the selected node
    138114    Element classify_message = doc_.createElement(GSXML.MESSAGE_ELEM);
     
    183159    if (cl_structure ==null) {
    184160        System.err.println("BrowseAction: classifier structure request returned no structure");
    185        
    186         // return the page so far
    187         GSXSLT.absoluteIncludePaths(style_doc, config_);
    188         return (Element)transformer_.transform(style_doc, page);
     161        return page_response;
    189162    }   
    190163   
     
    226199        }
    227200
    228         // create and add in the param list
    229         Vector classifier_metadata = GSXSLT.extractWantedMetadata(style_doc, GSXML.CLASS_NODE_ELEM);
    230         if (classifier_metadata.isEmpty()) {
    231         System.err.println("BrowseAction: no classifier metadata specified!!");
    232         did_classifier = false;
    233         metadata_message.removeChild(cl_meta_request);
    234         } else {
    235         Element meta_param_list = GSXML.createMetadataParamList(doc_, classifier_metadata);
    236         cl_meta_request.appendChild(meta_param_list);
    237         }
    238 
     201        // create and add in the param list - for now get all the metadata
     202        // should be based on info sent in from the recept, and the
     203        // format stuff
     204        Element cl_param_list  = doc_.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     205        Element p = doc_.createElement(GSXML.PARAM_ELEM);
     206        cl_param_list.appendChild(p);
     207        p.setAttribute(GSXML.NAME_ATT, "metadata");
     208        p.setAttribute(GSXML.VALUE_ATT, "all");
     209        cl_meta_request.appendChild(cl_param_list);
     210       
    239211    }
    240212
     
    261233        }
    262234
    263         // create and add in the param list
    264         Vector doc_metadata = GSXSLT.extractWantedMetadata(style_doc, GSXML.DOC_NODE_ELEM);
    265         if (doc_metadata.isEmpty()) {
    266         System.err.println("BrowseAction: no document metadata specified!!");
    267         did_documents = false;
    268         metadata_message.removeChild(doc_meta_request);
    269         } else {
    270         Element meta_param_list = GSXML.createMetadataParamList(doc_, doc_metadata);
    271         doc_meta_request.appendChild(meta_param_list);
    272         }
    273 
     235        // create and add in the param list - add all for now
     236        Element doc_param_list  = doc_.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     237        Element p = doc_.createElement(GSXML.PARAM_ELEM);
     238        doc_param_list.appendChild(p);
     239        p.setAttribute(GSXML.NAME_ATT, "metadata");
     240        p.setAttribute(GSXML.VALUE_ATT, "all");
     241        doc_meta_request.appendChild(doc_param_list);
    274242
    275243    }
     
    305273       
    306274
    307     System.out.println("(BrowseAction) Page:\n" + converter_.getPrettyString(page));
    308 
    309     // transform the page
    310     GSXSLT.absoluteIncludePaths(style_doc, config_);
    311     return (Element)transformer_.transform(style_doc, page);
     275    System.out.println("(BrowseAction) Page:\n" + converter_.getPrettyString(page_response));
     276    return page_response;
    312277    }
    313278
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/DocumentAction.java

    r4144 r4257  
    4343    /** if this is set to true, when a document is displayed, any annotation
    4444     * type services (enrich) will be offered to the user as well */
    45     protected static final boolean provide_annotations = true;
    46 
    47     /* add the action specific args to the cgi param list
    48      */
    49     public void addCGIParams() {
    50     cgi_.addStaticParam(SIBLING_ARG);
    51     }
    52 
     45    protected static final boolean provide_annotations = false; //true;
    5346
    5447    public Element process (Element message)
     
    5649    // for now, no subaction eventually we may want to have subactions such as text assoc or something ?
    5750   
    58     // check that  the stylesheet is present
    59     String stylesheet = GSFile.stylesheetFile(config_, "document.xsl");
    60     if (stylesheet == null) {
    61         System.err.println("DocumentAction Error: document stylesheet not found!");
    62         return null;
    63     }
     51    // the response
     52    Element result = doc_.createElement(GSXML.MESSAGE_ELEM);
     53    Element page_response = doc_.createElement(GSXML.RESPONSE_ELEM);
     54    result.appendChild(page_response);
    6455
    6556    // get the request - assume only one
     
    7364    if (document_name == null || document_name.equals("")) {
    7465        System.err.println("DocumentAction Error: no document specified!");
    75         return null;
     66        return result;
    7667    }
    7768
     
    8374    }
    8475   
    85     // Create the return page tree
    86     Element page = doc_.createElement(GSXML.PAGE_ELEM);
    87     page.setAttribute(GSXML.LANG_ATT, lang);
    88 
    89     // Add the page extra element,  and original request from the message
    90     page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.PAGE_EXTRA_ELEM), true));
    91     Element page_request = GSXML.duplicateWithNewName(doc_, request, GSXML.PAGE_REQUEST_ELEM, true);
    92     page.appendChild(page_request);
    93     // the element for all the response data
    94     Element page_response = doc_.createElement(GSXML.PAGE_RESPONSE_ELEM);
    95     page.appendChild(page_response);
    96 
    9776    // get the additional data needed for the page
    9877    getBackgroundData(page_response, collection, lang);
    9978
    10079    // the_document is where all the doc info - structure and metadata etc
    101     //- is added into, to be returned in the page
     80    // is added into, to be returned in the page
    10281    Element the_document = doc_.createElement(GSXML.DOCUMENT_ELEM);
    10382    page_response.appendChild(the_document);
     
    127106        ds_param.setAttribute(GSXML.VALUE_ATT, "siblings");
    128107    }
     108
     109    // put these in for now, but we should really decide what to do on basis of type, eg get structure for toc, get info for paged navigation etc
     110   
     111    // add in the info params to test them
     112    ds_param = doc_.createElement(GSXML.PARAM_ELEM);
     113    ds_param_list.appendChild(ds_param);
     114    ds_param.setAttribute(GSXML.NAME_ATT, "info");
     115    ds_param.setAttribute(GSXML.VALUE_ATT, "numSiblings");
     116    ds_param = doc_.createElement(GSXML.PARAM_ELEM);
     117    ds_param_list.appendChild(ds_param);
     118    ds_param.setAttribute(GSXML.NAME_ATT, "info");
     119    ds_param.setAttribute(GSXML.VALUE_ATT, "numChildren");
     120    ds_param = doc_.createElement(GSXML.PARAM_ELEM);
     121    ds_param_list.appendChild(ds_param);
     122    ds_param.setAttribute(GSXML.NAME_ATT, "info");
     123    ds_param.setAttribute(GSXML.VALUE_ATT, "siblingPosition");
     124   
    129125    // create a doc_node_list and put in the doc_node that we are interested in
    130126    Element ds_doc_list = doc_.createElement(GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
     
    135131   
    136132    // Process the document structure retrieve message
    137     // System.out.println("(DocumentAction) Structure request:\n" + converter_.getString(ds_message));
    138133    Element ds_response_message = (Element) mr_.process(ds_message);
    139     // System.out.println("(DocumentAction) Structure response:\n" + converter_.getString(ds_response_message));
    140 
     134
     135    // get the info and print out
     136    String path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
     137    path = GSPath.appendLink(path, GSXML.DOC_NODE_ELEM);
     138    path = GSPath.appendLink(path, "nodeStructureInfo");
     139    Element ds_response_struct_info = (Element) GSXML.getNodeByPath(ds_response_message, path);
    141140    // get the doc_node bit
    142     String path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
     141    the_document.appendChild(doc_.importNode(ds_response_struct_info, true));
     142    path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
    143143    path = GSPath.appendLink(path, GSXML.DOC_NODE_ELEM);
    144144    path = GSPath.appendLink(path, GSXML.NODE_STRUCTURE_ELEM);
     
    202202    doc_node.setAttribute(GSXML.NODE_ID_ATT, document_name+".rt");
    203203    doc_list.appendChild(doc_node);
    204     // System.out.println("(DocumentAction) Metadata request:\n" + converter_.getString(dm_request));
    205204    Element dm_response_message = (Element) mr_.process(dm_message);
    206     // System.out.println("(DocumentAction) Metadata response:\n" + converter_.getString(dm_response));
    207205
    208206    path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
     
    273271    }
    274272
    275 
    276     Document style_doc = converter_.getDOM(new File(stylesheet));
    277     GSXSLT.absoluteIncludePaths(style_doc, config_);
    278     return (Element) transformer_.transform(style_doc, page);   
     273    System.out.println("(DocumentAction) Page:\n" + converter_.getPrettyString(result));
     274    return result;
    279275    }
    280276
     
    307303    Element info_message = doc_.createElement(GSXML.MESSAGE_ELEM);
    308304
    309     // the collection request
    310     Element coll_about_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_DESCRIBE,  collection, lang);
    311     info_message.appendChild(coll_about_request);
    312 
    313305    // the format request - ignore for now, where does this request go to??
    314306    //Element format_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_FORMAT, ???, lang);
     
    327319    // the collection is the first response
    328320    NodeList responses = info_response.getElementsByTagName(GSXML.RESPONSE_ELEM);
    329     Element coll_resp = (Element)responses.item(0);
    330     page_response.appendChild(doc_.importNode(GSXML.getChildByTagName(coll_resp, GSXML.COLLECTION_ELEM), true));
    331    
    332321    //Element format_resp = (Element) responses.item(1);
    333322    //page_reponse.appendChild(doc_.importNode(GSXML.getChildByTagName(format_resp, GSXML.FORMAT_ELEM), true));
     
    335324
    336325    if (provide_annotations) {
    337         Element services_resp = (Element)responses.item(1); // change when format request added in
     326        Element services_resp = (Element)responses.item(0); // change when format request added in
    338327
    339328        // a new message for the mr
     
    358347            Element e_service = (Element)doc_.importNode(GSXML.getChildByTagName(e_resp, GSXML.SERVICE_ELEM), true);
    359348            e_service.setAttribute(GSXML.NAME_ATT, e_resp.getAttribute(GSXML.FROM_ATT));
    360             Element pl = (Element)GSXML.getChildByTagName(e_service, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    361             if (pl != null) {
    362             // add short names to the params in the param list
    363             cgi_.paramListAddShortNames(pl);
    364             }
    365349            service_list.appendChild(e_service);
    366350        }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/PageAction.java

    r4155 r4257  
    1414public class PageAction extends Action {
    1515
    16     public static final String SHORT_ACTION_NAME = "p";
    1716    public static final String HOME_PAGE = "home";
    1817    public static final String ABOUT_PAGE = "about";
     
    2625        page_name = HOME_PAGE;
    2726    }
     27    Element result = doc_.createElement(GSXML.MESSAGE_ELEM);
     28    Element response;
     29    if (page_name.equals(HOME_PAGE)) {
     30        response = homePage(request);
     31    } else if (page_name.equals(ABOUT_PAGE)) {
     32        response = aboutPage(request);
     33    } else { // unknown page
    2834   
    29     // create the return page tree
    30     Element page = doc_.createElement(GSXML.PAGE_ELEM);
    31     page.setAttribute(GSXML.LANG_ATT, request.getAttribute(GSXML.LANG_ATT));
    32     // add the page extra stuff from message
    33     page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.PAGE_EXTRA_ELEM), true));
    34     // add the cgi args request
    35     Element page_request = GSXML.duplicateWithNewName(doc_, request, "pageRequest", true);
    36     page.appendChild(page_request);
     35        System.err.println("PageAction Error: unknown page specified!");
     36        response =  unknownPage(request);
     37    }
    3738
    38     if (page_name.equals(HOME_PAGE)) {
    39         return homePage(page, request);
    40     } else if (page_name.equals(ABOUT_PAGE)) {
    41         return aboutPage(page, request);
    42     }
    43    
    44     System.err.println("PageAction Error: unknown page specified!");
    45     return unknownPage(page, request);
    46    
     39    result.appendChild(doc_.importNode(response, true));
     40    return result;
    4741    }
    4842
    4943
    50     protected Element homePage(Element page, Element orig_message) {
     44    protected Element homePage(Element request) {
    5145   
    52     String lang = page.getAttribute(GSXML.LANG_ATT);
     46    String lang = request.getAttribute(GSXML.LANG_ATT);
     47   
    5348    // first, get the message router info
    5449    Element coll_list_message = doc_.createElement(GSXML.MESSAGE_ELEM);
     
    8782        if (c1.getAttribute(GSXML.NAME_ATT).equals(c2.getAttribute(GSXML.FROM_ATT))) {
    8883            // add the metadata to the original response   
    89             GSXML.mergeMetadataLists(c1, GSXML.getChildByTagName(c2, GSXML.COLLECTION_ELEM)); // add the metadata to the original response 
     84            GSXML.mergeMetadataLists(c1, GSXML.getChildByTagName(c2, GSXML.COLLECTION_ELEM));
    9085        } else {
    9186            System.err.println("PageAction Error: response does not correspond to request!");
     
    9590    }
    9691
    97     //now the full response is in coll_list_response
    98 
    99     // add it in to the page xml tree
     92    //now the full response message is in coll_list_response
     93    // return the response element
    10094    Element response = (Element) GSXML.getChildByTagName(coll_list_response, GSXML.RESPONSE_ELEM);
    101     Element page_response = GSXML.duplicateWithNewName(doc_, response, "pageResponse", false);
    102     page.appendChild(page_response);
    103 
    104     String stylesheet = GSFile.stylesheetFile(config_, "home.xsl");
    105     Document style_doc = converter_.getDOM(new File(stylesheet));
    106     GSXSLT.absoluteIncludePaths(style_doc, config_);
    107     return (Element)transformer_.transform(style_doc, page);       
     95    return response;
    10896   
    10997    } // homePage
    11098
    111     protected Element aboutPage(Element page, Element request) {
     99    protected Element aboutPage(Element request) {
     100
     101    String lang = request.getAttribute(GSXML.LANG_ATT);
     102    // extract the params from the cgi-request,
     103    Element cgi_paramList = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     104    HashMap params = GSXML.extractParams(cgi_paramList, false);
     105   
     106    String coll_name = (String)params.get(GSCGI.COLLECTION_ARG);
     107    if (coll_name == null || coll_name.equals("")) {
     108        System.err.println("PageAction Error: about page requested with no collection or cluster specified!");
     109        // return an empty response
     110        return doc_.createElement(GSXML.RESPONSE_ELEM);
     111    }
     112   
     113    // get the collection or cluster description
     114    Element coll_about_message = doc_.createElement(GSXML.MESSAGE_ELEM);
     115   
     116    Element coll_about_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_DESCRIBE,  coll_name, lang);
     117    coll_about_message.appendChild(coll_about_request);
     118   
     119    Element coll_about_response = (Element)mr_.process(coll_about_message);
     120
     121    // get the response element and return it
     122    Element response = (Element) GSXML.getChildByTagName(coll_about_response, GSXML.RESPONSE_ELEM);
     123    return response;
     124   
     125    }
     126
     127    /** if we dont know the page type, use this method */
     128    protected Element unknownPage(Element request) {
     129   
     130    String lang = request.getAttribute(GSXML.LANG_ATT);
     131    String page_name = request.getAttribute(GSXML.SUBACTION_ATT);
    112132
    113133    // extract the params from the cgi-request,
     
    117137    String coll_name = (String)params.get(GSCGI.COLLECTION_ARG);
    118138    if (coll_name == null || coll_name.equals("")) {
    119         System.err.println("PageAction Error: about page requested with no collection or cluster specified!");
    120         return null;
     139        // just return an empty response
     140        return doc_.createElement(GSXML.RESPONSE_ELEM);
    121141    }
    122142   
    123     // get the collection or cluster description
    124     Element coll_about_message = doc_.createElement(GSXML.MESSAGE_ELEM);
    125    
    126     Element coll_about_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_DESCRIBE,  coll_name, page.getAttribute(GSXML.LANG_ATT));
    127     coll_about_message.appendChild(coll_about_request);
    128    
    129     Element coll_about_response = (Element)mr_.process(coll_about_message);
    130 
    131     // add the response to the page
    132     Element response = (Element) GSXML.getChildByTagName(coll_about_response, GSXML.RESPONSE_ELEM);
    133     Element page_response = GSXML.duplicateWithNewName(doc_, response, "pageResponse", false);
    134     page.appendChild(page_response);
    135 
    136     // process using the stylesheet
    137     String stylesheet = GSFile.stylesheetFile(config_, "about.xsl");
    138     Document style_doc = converter_.getDOM(new File(stylesheet));
    139     GSXSLT.absoluteIncludePaths(style_doc, config_);
    140     return (Element)transformer_.transform(style_doc, page);   
    141 
    142    
    143     }
    144 
    145     /** if we dont know the page type, use this method */
    146     protected Element unknownPage(Element page, Element request) {
    147 
    148     String page_name = request.getAttribute(GSXML.SUBACTION_ATT);
    149 
    150     String stylesheet = GSFile.stylesheetFile(config_, page_name+".xsl");
    151     if (stylesheet==null) {
    152         // return the home page instead
    153         return homePage(page, request);
    154     }
    155 
    156     // extract the params from the cgi-request,
    157     Element cgi_paramList = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    158     HashMap params = GSXML.extractParams(cgi_paramList, false);
    159    
    160     String coll_name = (String)params.get(GSCGI.COLLECTION_ARG);
    161     if (coll_name == null || coll_name.equals("")) {
    162         // just process an empty page using the stylesheet
    163         Element page_response = doc_.createElement(GSXML.PAGE_RESPONSE_ELEM);
    164         page.appendChild(page_response);
    165    
    166         Document style_doc = converter_.getDOM(new File(stylesheet));
    167         GSXSLT.absoluteIncludePaths(style_doc, config_);
    168         return (Element)transformer_.transform(style_doc, page);   
    169        
    170     }
    171143    // else get the coll description - actually this is the same as for the about page - should we merge these two methods??
    172144   
     
    175147    Element coll_about_message = doc_.createElement(GSXML.MESSAGE_ELEM);
    176148   
    177     Element coll_about_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_DESCRIBE,  coll_name, page.getAttribute(GSXML.LANG_ATT));
     149    Element coll_about_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_DESCRIBE,  coll_name, lang);
    178150    coll_about_message.appendChild(coll_about_request);
    179151   
    180152    Element coll_about_response = (Element)mr_.process(coll_about_message);
    181153
    182     // add the response to the page
     154    // add the response to the page get teh response element and return it
    183155    Element response = (Element) GSXML.getChildByTagName(coll_about_response, GSXML.RESPONSE_ELEM);
    184     Element page_response = GSXML.duplicateWithNewName(doc_, response, "pageResponse", false);
    185     page.appendChild(page_response);
    186 
    187 
    188     Document style_doc = converter_.getDOM(new File(stylesheet));
    189     GSXSLT.absoluteIncludePaths(style_doc, config_);
    190     return (Element)transformer_.transform(style_doc, page);   
     156    return response;
    191157   
    192158    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/ProcessAction.java

    r4154 r4257  
    1919    public Element process (Element message) {
    2020
     21    // the result
     22    Element result = doc_.createElement(GSXML.MESSAGE_ELEM);
     23    Element page_response = doc_.createElement(GSXML.RESPONSE_ELEM);
     24    result.appendChild(page_response);
     25
    2126    // assume only one request
    2227    Element request = (Element)GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
    2328
    24     // we ignore the subaction for now - all types are processed by the same method
    25     //String subaction = request.getAttribute(GSXML.SUBACTION_ATT);
    2629    // get the param list
    2730    Element cgi_param_list = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     
    3538    }
    3639    String request_type = (String) params.get(GSCGI.REQUEST_TYPE_ARG);
    37     // the return page
    38     Element page = doc_.createElement(GSXML.PAGE_ELEM);
    39     page.setAttribute(GSXML.LANG_ATT, request.getAttribute(GSXML.LANG_ATT));
    40 
    41     // the page response goes into a pageResponse elem
    42     Element page_response = doc_.createElement(GSXML.PAGE_RESPONSE_ELEM);
    43     page.appendChild(page_response);
     40    String lang = request.getAttribute(GSXML.LANG_ATT);
    4441    // what is carried out depends on the request_type
    4542    // if rt=d, then a describe request is done,
     
    5148    // without any page processing
    5249
    53     //the stylesheet
    54     String stylesheet = GSFile.stylesheetFile(config_, "process.xsl");
    55    
    56     if (!request_only) {
    57         // check that the stylesheet is present
    58         if (stylesheet==null) {
    59         System.err.println("ProcessAction Error: process stylesheet not found!");
    60         return null;
    61         }
    62     }
    6350
    6451    // where to send requests
     
    7057       
    7158        Element mr_query_message = doc_.createElement(GSXML.MESSAGE_ELEM);
    72         Element mr_query_request = doc_.createElement(GSXML.REQUEST_ELEM);
    73         mr_query_message.appendChild(mr_query_request);
    74        
    75         mr_query_request.setAttribute(GSXML.LANG_ATT, page.getAttribute(GSXML.LANG_ATT));
    76         mr_query_request.setAttribute(GSXML.TO_ATT, to);
    77        
     59        String request_type_att;
    7860        Element param_list;
    7961        if (request_type.equals("s")) { // status
    80         mr_query_request.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_STATUS);
    81         // only need the handle param
     62        request_type_att = GSXML.REQUEST_TYPE_STATUS;
    8263        param_list = doc_.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    8364        Element param = doc_.createElement(GSXML.PARAM_ELEM);
     
    8667        param_list.appendChild(param);
    8768        } else {
    88         mr_query_request.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
     69        request_type_att = GSXML.REQUEST_TYPE_PROCESS;
    8970        // add in the params - except the ones only used by the action
    9071        param_list = getServiceParamList(cgi_param_list);
    9172       
    9273        }
     74        Element mr_query_request = GSXML.createBasicRequest(doc_, request_type_att, to, lang);
    9375        mr_query_request.appendChild(param_list);
    94    
     76        mr_query_message.appendChild(mr_query_request);
    9577       
    9678        Element mr_query_response = (Element)mr_.process(mr_query_message);
     
    10789    }
    10890   
    109     // add the page extra stuff from message
    110     page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.PAGE_EXTRA_ELEM), true));
    11191
    11292    // another part of the page is the service description
     
    11494    // request the service info for the selected service - should be cached
    11595    Element mr_info_message = doc_.createElement(GSXML.MESSAGE_ELEM);
    116     Element mr_info_request = doc_.createElement(GSXML.REQUEST_ELEM);
     96    Element mr_info_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_DESCRIBE, to, lang); //.createElement(GSXML.REQUEST_ELEM);
    11797    mr_info_message.appendChild(mr_info_request);
    118     mr_info_request.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_DESCRIBE);
    119     mr_info_request.setAttribute(GSXML.LANG_ATT, page.getAttribute(GSXML.LANG_ATT));
    120 
    121     mr_info_request.setAttribute(GSXML.TO_ATT, to);
    122    
    12398    Element mr_info_response = (Element) mr_.process(mr_info_message);
    12499
     
    127102    Element description = (Element)doc_.importNode(GSXML.getNodeByPath(mr_info_response, path), true);
    128103
    129     Element pl = (Element)GSXML.getChildByTagName(description, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    130    
    131     if (pl !=null) {
    132         // add short names to the params in the param list
    133         cgi_.paramListAddShortNames(pl);
    134 
    135         // for each param in the description, overwrite the default value with the currently set value if present
    136         Element param = (Element)pl.getFirstChild();
    137         while (param !=null) {
    138         if (param.getNodeName().equals(GSXML.PARAM_ELEM)) { // just in case
    139             String name = param.getAttribute(GSXML.NAME_ATT);
    140             String current = (String)params.get(name);
    141             if (current !=null && !current.equals("")) {
    142             param.setAttribute(GSXML.DEFAULT_ATT, current);
    143             }
    144         }
    145         param = (Element)param.getNextSibling();
    146         }
    147     }
    148104    page_response.appendChild(description);
    149105
    150     // part of the data for the page is the cgi-params
    151     // if we have this here, do we need to do the previous step?
    152     Element page_request = GSXML.duplicateWithNewName(doc_, request, GSXML.PAGE_REQUEST_ELEM, true);
    153     page.appendChild(page_request);
    154        
    155     // now process the page and return the result
    156     Document style_doc = converter_.getDOM(new File(stylesheet));
    157    
    158     GSXSLT.absoluteIncludePaths(style_doc, config_);
    159     return (Element)transformer_.transform(style_doc, page);   
     106    return result;
    160107    }
    161108
     
    171118        continue;
    172119        }
    173         // esle add it in to the list
     120        // else add it in to the list
    174121        new_param_list.appendChild(doc_.importNode(p, true));
    175122    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/QueryAction.java

    r4144 r4257  
    2626    Element request = (Element)GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
    2727
    28     // create the return page tree
    29     Element page = doc_.createElement(GSXML.PAGE_ELEM);
    30     page.setAttribute(GSXML.LANG_ATT, request.getAttribute(GSXML.LANG_ATT));
    31     // add the page extra stuff from message
    32     page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.PAGE_EXTRA_ELEM), true));
    33 
    34     // part of the data for the page is the cgi-params
    35     // if we have this here, do we need to overwrite default values in the
    36     // param list down below??
    37     Element page_request = GSXML.duplicateWithNewName(doc_, request, "pageRequest", true);
    38     page.appendChild(page_request);
    39 
    40        // if want to have a different type of query here, check the subaction att of request
    41 
    42        // for now assume all queries can be handled by basic query
    43        return basicQuery(page, request);
    44        
     28    // create the return message
     29    Element result = doc_.createElement(GSXML.MESSAGE_ELEM);
     30    // for now we only have one type of query - subaction not used
     31    Element response = basicQuery(request);
     32    result.appendChild(doc_.importNode(response, true));
     33    return result;
    4534    }
    4635   
     
    4938     * params to the service, then gets the titles for any results
    5039     */
    51     protected Element basicQuery(Element page, Element request) {
    52 
    53     // check that the stylesheet is present - cant output the page without one.
    54     String stylesheet = GSFile.stylesheetFile(config_, "basicquery.xsl");
    55     if (stylesheet==null) {
    56         System.err.println("QueryAction Error: basicquery stylesheet not found!");
    57         return null;
    58     }
    59     Document style_doc = converter_.getDOM(new File(stylesheet));
    60 
    61 
     40    protected Element basicQuery(Element request) {
     41   
     42    // the result
     43    Element page_response = doc_.createElement(GSXML.RESPONSE_ELEM);
     44   
    6245    // extract the params from the cgi-request, and check that we have a coll specified
    6346    Element cgi_param_list = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     
    6750    String service_name = (String)params.get(GSCGI.SERVICE_ARG);
    6851    String collection = (String)params.get(GSCGI.COLLECTION_ARG);
     52   
    6953    if (collection == null || collection.equals("")) {
    7054        System.err.println("QueryAction Error: no collection was specified!");
    71         return null;
     55        return page_response; // an empty response
    7256    }
    7357   
    7458    String lang = request.getAttribute(GSXML.LANG_ATT);
    7559    String to = GSPath.appendLink(collection, service_name);
    76 
    77     //create the pageResponse
    78     Element page_response = doc_.createElement(GSXML.PAGE_RESPONSE_ELEM);
    79     page.appendChild(page_response);
    8060   
    81     // the second part of the page is the service description
     61    // part of the response is the service description
    8262    // for now get this again from the service.
    8363    // this will probably need to be cached somehow later on.
     
    9070    mr_info_message.appendChild(format_request);
    9171
    92     // also get the coll description
    93     Element coll_about_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_DESCRIBE,  collection, lang);
    94     mr_info_message.appendChild(coll_about_request);
    95 
    9672    // process the messages
    9773    Element mr_info_response = (Element) mr_.process(mr_info_message);
    9874   
    99     // the three responses
     75    // the two responses
    10076    NodeList responses = mr_info_response.getElementsByTagName(GSXML.RESPONSE_ELEM);
    10177    Element service_response = (Element)responses.item(0);
    10278    Element format_response = (Element)responses.item(1);
    103     Element coll_response = (Element)responses.item(2);
    10479   
    10580    Element service_description = (Element)doc_.importNode(GSXML.getChildByTagName(service_response, GSXML.SERVICE_ELEM), true);
    10681    page_response.appendChild(service_description);
    10782   
    108     Element pl = (Element)GSXML.getChildByTagName(service_description, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    109    
    110     if (pl !=null) {
    111         // add short names to the params in the param list
    112         cgi_.paramListAddShortNames(pl);
    113         // for each param in the description, overwrite teh default value with the currently set value if present
    114         Element param = (Element)pl.getFirstChild();
    115         while (param !=null) {
    116         if (param.getNodeName().equals(GSXML.PARAM_ELEM)) { // just in case
    117             if (param.getAttribute(GSXML.TYPE_ATT).equals(GSXML.PARAM_TYPE_MULTI)) {
    118             // get the values for each sub param
    119             NodeList subparams = param.getElementsByTagName(GSXML.PARAM_ELEM);
    120             for (int i=0; i<subparams.getLength(); i++) {
    121                 String name = ((Element)subparams.item(i)).getAttribute(GSXML.NAME_ATT);
    122                 String current = (String)params.get(name);
    123                 if (current !=null && !current.equals("")) {
    124                 Element e = GSXML.createTextElement(pl.getOwnerDocument(), GSXML.DEFAULT_ELEM, current);
    125                 e.setAttribute(GSXML.NAME_ATT, name);
    126                 param.appendChild(e);
    127                 }
    128             }
    129             } else {
    130            
    131             String name = param.getAttribute(GSXML.NAME_ATT);
    132             String current = (String)params.get(name);
    133             if (current !=null && !current.equals("")) {
    134                 param.setAttribute(GSXML.DEFAULT_ATT, current);
    135             }
    136             }
    137         }
    138         param = (Element)param.getNextSibling();
    139         }
    140     }
    141 
    142    
    143     // add the coll-response to the page
    144     Element coll_description = (Element)GSXML.getChildByTagName(coll_response, GSXML.COLLECTION_ELEM);
    145     page_response.appendChild(doc_.importNode(coll_description, true));
    146 
    147 
    148     // just a display request
    149     if (request_type.equals("d")) {
    150         System.out.println("(QueryAction) Finished page:\n" + converter_.getPrettyString(page));
    151         // output the page
    152         // process using the stylesheet
    153         GSXSLT.absoluteIncludePaths(style_doc, config_);
    154         return (Element)transformer_.transform(style_doc, page);   
     83    if (request_type.equals("d")) {// just a display request
     84        return page_response;
    15585    }
    15686   
    15787    // add in the format info to the stylesheet if there is any
    158     Element format_elem = getAndTransformFormat(format_response);
     88    Element format_elem = (Element)GSXML.getChildByTagName(format_response, GSXML.FORMAT_ELEM);
    15989    if (format_elem != null) {
    160         GSXSLT.mergeStylesheets(style_doc, format_elem);
     90        System.out.println("QueryAction: found a format element, adding it to the page response");
     91        // for now just add to the response
     92        page_response.appendChild(doc_.importNode(format_elem, true));
    16193    }
    16294
     
    16496    // do the query
    16597    Element mr_query_message = doc_.createElement(GSXML.MESSAGE_ELEM);
    166     Element mr_query_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_PROCESS, to, page.getAttribute(GSXML.LANG_ATT));
     98    Element mr_query_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_PROCESS, to, lang);
    16799    mr_query_message.appendChild(mr_query_request);
    168100   
     
    197129    // documentList not present if no docs found
    198130    if (document_list == null) {
    199         GSXSLT.absoluteIncludePaths(style_doc, config_);
    200         return (Element)transformer_.transform(style_doc, page);   
    201        
     131        return page_response;
    202132    }
    203133   
    204    
    205     // we have a doc list, so get the metadata - look through the stylesheet to determine what metadata to ask for
    206 
    207     Vector document_metadata = GSXSLT.extractWantedMetadata(style_doc, GSXML.DOC_NODE_ELEM);
    208     if (document_metadata.isEmpty()) {
    209         System.err.println("no document metadata specified!!");
    210         // we dont need to do the metadata request, just append the original doc list and return the page
    211         page_response.appendChild(doc_.importNode(document_list, true));
    212         GSXSLT.absoluteIncludePaths(style_doc, config_);
    213         return (Element)transformer_.transform(style_doc, page);
    214 
    215     }
    216     // we have to do the metadata request
    217 
     134    // do the metadata request
    218135    Element mr_metadata_message = doc_.createElement(GSXML.MESSAGE_ELEM);
    219136    Element mr_metadata_request = doc_.createElement(GSXML.REQUEST_ELEM);
     
    221138   
    222139    mr_metadata_request.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
    223     mr_metadata_request.setAttribute(GSXML.LANG_ATT, page.getAttribute(GSXML.LANG_ATT));
     140    mr_metadata_request.setAttribute(GSXML.LANG_ATT, lang);
    224141    to = GSPath.appendLink(collection, "DocumentMetadataRetrieve"); // Hard-wired?
    225142    mr_metadata_request.setAttribute(GSXML.TO_ATT, to);
    226143
    227     Element dm_param_list = GSXML.createMetadataParamList(doc_, document_metadata);
     144    // just get all for now - the receptionist should perhaps pass in some
     145    // metadata that it wants, and QueryAction should look through the format stuff to see if there is any other?
     146    Element dm_param_list  = doc_.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     147    Element param = doc_.createElement(GSXML.PARAM_ELEM);
     148    dm_param_list.appendChild(param);
     149    param.setAttribute(GSXML.NAME_ATT, "metadata");
     150    param.setAttribute(GSXML.VALUE_ATT, "all");
    228151    mr_metadata_request.appendChild(dm_param_list);
    229152   
     
    232155    mr_metadata_request.appendChild(doc_.importNode(document_list, true));
    233156    Element mr_metadata_response = (Element) mr_.process(mr_metadata_message); 
    234 
     157   
    235158    path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
    236159    Element query_result_document_list = (Element) GSXML.getNodeByPath(mr_metadata_response, path);
     
    240163    }
    241164
    242     // System.out.println("Query page:\n" + converter_.getPrettyString(page));
    243 
    244     // output the page
    245     // process using the stylesheet
    246     GSXSLT.absoluteIncludePaths(style_doc, config_);
    247     return (Element)transformer_.transform(style_doc, page);
     165    // System.out.println("Query page:\n" + converter_.getPrettyString(page_response));
     166    return page_response;
    248167    }
    249168}
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/SystemAction.java

    r4144 r4257  
    2727    HashMap params = GSXML.extractParams(cgi_param_list, false);
    2828
    29     Element page = doc_.createElement(GSXML.PAGE_ELEM);
    30     page.setAttribute(GSXML.LANG_ATT, lang);
    31 
    32     // add the page extra stuff from message
    33     page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.PAGE_EXTRA_ELEM), true));
    34 
     29    Element result = doc_.createElement(GSXML.MESSAGE_ELEM);
     30   
    3531    String coll = (String)params.get(GSCGI.COLLECTION_ARG);
    3632
     
    6965        // for now just have an error
    7066        System.err.println("SystemAction error: bad subaction type");
    71         return null;
     67        Element page_response = doc_.createElement(GSXML.RESPONSE_ELEM);
     68        result.appendChild(page_response);
     69   
     70        return result;
    7271        }
    7372    }
     
    7574    Element response_message = mr_.process(mr_request_message);
    7675   
    77     page.appendChild(GSXML.duplicateWithNewName(doc_, (Element)GSXML.getChildByTagName(response_message, GSXML.RESPONSE_ELEM), GSXML.PAGE_RESPONSE_ELEM, true));
    78    
    79     // check that the stylesheet is present - cant output the page without one.
    80     String stylesheet = GSFile.stylesheetFile(config_, "system.xsl");
    81     if (stylesheet==null) {
    82         System.err.println("SystemAction Error: system stylesheet not found!");
    83         return page;
    84     }
    85     Document style_doc = converter_.getDOM(new File(stylesheet));
    86     GSXSLT.absoluteIncludePaths(style_doc, config_);
    87     return (Element)transformer_.transform(style_doc, page);
    88 
     76    result.appendChild(GSXML.duplicateWithNewName(doc_, (Element)GSXML.getChildByTagName(response_message, GSXML.RESPONSE_ELEM), GSXML.RESPONSE_ELEM, true));
     77    return result;
    8978   
    9079    }
Note: See TracChangeset for help on using the changeset viewer.