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/AppletAction.java

    r3512 r3568  
    1212import java.io.File;
    1313
     14/** action class for handling applets */
    1415public class AppletAction extends Action {
    1516   
    1617
    17     public String process (Element message) {
    18 
     18    public Element process (Element message) {
     19   
    1920
    2021    // find the stylesheet
     
    2223
    2324    if (stylesheet==null) {
    24         return GSHTML.errorPage("applet stylesheet not found!");
     25        System.err.println("AppletAction Error: applet stylesheet not found!");
     26        return null;
    2527    }
    26 
    27     Element request = (Element)message.getElementsByTagName(GSXML.REQUEST_ELEM).item(0);
    28 
    29     // subaction is display/request
    30     String request_type = request.getAttribute(GSXML.SUBACTION_ATT); // should be 'd' or 'r'
     28   
     29    Element request = (Element)GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
     30   
     31    // subaction is display (d) or request (r)
     32    String request_type = request.getAttribute(GSXML.SUBACTION_ATT);
    3133    if (!request_type.equals("d")&&!request_type.equals("r")) {
    32         return GSHTML.errorPage("the sa arg to a=a should be d or r!!");
     34        System.err.println("AppletAction Error: the sa arg should be either d or r, instead it was "+request_type+"!");
     35        return null;
    3336    }
    3437   
    3538    // get the collection and service param
    36     Element cgi_paramList = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    37     cgi_.toLong(cgi_paramList);
    38     HashMap params = GSXML.extractParams(cgi_paramList);
     39    Element cgi_param_list = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     40    HashMap params = GSXML.extractParams(cgi_param_list);
    3941
    4042    String collection = (String)params.get("collection");
     
    4951    }
    5052
    51     System.out.println("to="+to);
    52 
    53 
    5453    if (request_type.equals("d")) {
    5554        // we are just displaying the applet - get the description from
     
    6261        mr_message.appendChild(mr_request);
    6362        mr_request.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_DESCRIBE);
     63        mr_request.setAttribute(GSXML.LANG_ATT, request.getAttribute(GSXML.LANG_ATT));
    6464        mr_request.setAttribute(GSXML.TO_ATT, to);
    65         //mr_request.setAttribute(GSXML."info", "appletInfo");
    6665       
    6766        Element mr_response = (Element)mr_.process(mr_message);
    6867       
    69         System.out.println("applet mr response =");
    70         System.out.println(converter_.getString(mr_response));
    7168        // create the return page tree
    7269        Element page = doc_.createElement(GSXML.PAGE_ELEM);
    73         page.setAttribute(GSXML.LANG_ATT, message.getAttribute(GSXML.LANG_ATT));
     70        page.setAttribute(GSXML.LANG_ATT, request.getAttribute(GSXML.LANG_ATT));
    7471        // add the lang stuff from message
    75         page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.TRANSLATION_ELEM), true));
     72        page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.DISPLAY_ELEM), true));
    7673        // add the config stuff from message
    7774        page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.CONFIGURATION_ELEM), true));
     
    9289        Document style_doc = converter_.getDOM(new File(stylesheet));
    9390        GSXSLT.absoluteIncludePaths(style_doc, config_);
    94         return transformer_.transform(style_doc, page);   
     91        return (Element)transformer_.transform(style_doc, page);   
    9592
    9693    }
     
    103100        mr_request.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_QUERY);
    104101        mr_request.setAttribute(GSXML.TO_ATT, to);
    105        
     102        mr_request.setAttribute(GSXML.LANG_ATT, request.getAttribute(GSXML.LANG_ATT));
     103
    106104        // just append the params for now
    107         mr_request.appendChild(doc_.importNode(cgi_paramList, true));
     105        mr_request.appendChild(doc_.importNode(cgi_param_list, true));
    108106       
    109107        Element mr_response = (Element)mr_.process(mr_message);
    110         System.out.println("applet query response:");
    111         // dont need to create a page, just extract the info out.
    112         System.out.println(converter_.getString(mr_response));
    113108        // add in the applet data
    114109        String path = GSXML.RESPONSE_ELEM;
    115110        path = GSPath.appendLink(path, GSXML.APPLET_DATA_ELEM);
    116111        Element applet_info = (Element)GSXML.getNodeByPath(mr_response, path).getFirstChild();
    117         System.out.println("applet action: applet data =");
    118         System.out.println(converter_.getString(applet_info));
    119         return converter_.getString(applet_info);
     112        return applet_info;
    120113
    121114    }
    122     else {
    123         // should never get here
    124         return GSHTML.errorPage("applet action, wrong subaction type");
    125     }
     115    // should never get here
     116    return null;
    126117    }
    127118
Note: See TracChangeset for help on using the changeset viewer.