Ignore:
Timestamp:
2002-11-26T13:55:24+13:00 (21 years ago)
Author:
kjdon
Message:

tidied up a bit, uses new page structure and new display elements

File:
1 edited

Legend:

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

    r3512 r3568  
    1111import java.io.File;
    1212
     13/** Action class for retrieving Documents or Resources via the message router
     14 */
    1315public class ResourceAction extends Action {
    14 
    15 
    16     // could pass in action name, and have it dynamically decide the name
    17    
    18     public String process (Element message) {
    19 
     16 
     17    public Element process (Element message) {
     18   
    2019    // find the stylesheet
    2120    String stylesheet = GSFile.stylesheetFile(config_, "resource.xsl");
    2221
    2322    if (stylesheet==null) {
    24         return GSHTML.errorPage("resource stylesheet not found!");
     23        System.err.println("ResourceAction Error: resource stylesheet not found!");
     24        return null;
    2525    }
    26 
     26   
    2727    // for now, no subaction eventually we may want to have subactions such as text assoc or something ?
    2828   
    29     Element request = (Element)message.getElementsByTagName(GSXML.REQUEST_ELEM).item(0);
    30 
     29    // get the request - assume only one
     30    Element request = (Element)GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
    3131    Element cgi_paramList = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    32     cgi_.toLong(cgi_paramList);
    3332    HashMap params = GSXML.extractParams(cgi_paramList);
    3433
    3534    String resource_name = (String)params.get("resource");
    3635    if (resource_name == null || resource_name.equals("")) {
    37         // no doc to show
    38         return GSHTML.errorPage("no resource specified");
     36        System.err.println("ResourceAction Error: no resource specified!");
     37        return null;
    3938    }
    40    
    41    
     39       
    4240    // create the return page tree
    4341    Element page = doc_.createElement(GSXML.PAGE_ELEM);
    44     page.setAttribute(GSXML.LANG_ATT, message.getAttribute(GSXML.LANG_ATT));
     42    page.setAttribute(GSXML.LANG_ATT, request.getAttribute(GSXML.LANG_ATT));
    4543    // add the lang stuff from message
    46     page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.TRANSLATION_ELEM), true));
     44    page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.DISPLAY_ELEM), true));
    4745    // add the config stuff from message
    4846    page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.CONFIGURATION_ELEM), true));
    49 
    50 
    5147
    5248    // build up the mr request
     
    5551    mr_message.appendChild(mr_request);
    5652    mr_request.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_QUERY);
     53    mr_request.setAttribute(GSXML.LANG_ATT, page.getAttribute(GSXML.LANG_ATT));
    5754    mr_request.setAttribute("resourceType", "core");
    5855    String to = (String)params.get("collection"); // collection name
     
    8279    Document style_doc = converter_.getDOM(new File(stylesheet));
    8380    GSXSLT.absoluteIncludePaths(style_doc, config_);
    84     return transformer_.transform(style_doc, page);   
     81    return (Element)transformer_.transform(style_doc, page);   
    8582
    8683    }
Note: See TracChangeset for help on using the changeset viewer.