- Timestamp:
- 2002-11-26T13:55:24+13:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/action/AppletAction.java
r3512 r3568 12 12 import java.io.File; 13 13 14 /** action class for handling applets */ 14 15 public class AppletAction extends Action { 15 16 16 17 17 public Stringprocess (Element message) {18 18 public Element process (Element message) { 19 19 20 20 21 // find the stylesheet … … 22 23 23 24 if (stylesheet==null) { 24 return GSHTML.errorPage("applet stylesheet not found!"); 25 System.err.println("AppletAction Error: applet stylesheet not found!"); 26 return null; 25 27 } 26 27 Element request = (Element) message.getElementsByTagName(GSXML.REQUEST_ELEM).item(0);28 29 // subaction is display /request30 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); 31 33 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; 33 36 } 34 37 35 38 // 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); 39 41 40 42 String collection = (String)params.get("collection"); … … 49 51 } 50 52 51 System.out.println("to="+to);52 53 54 53 if (request_type.equals("d")) { 55 54 // we are just displaying the applet - get the description from … … 62 61 mr_message.appendChild(mr_request); 63 62 mr_request.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_DESCRIBE); 63 mr_request.setAttribute(GSXML.LANG_ATT, request.getAttribute(GSXML.LANG_ATT)); 64 64 mr_request.setAttribute(GSXML.TO_ATT, to); 65 //mr_request.setAttribute(GSXML."info", "appletInfo");66 65 67 66 Element mr_response = (Element)mr_.process(mr_message); 68 67 69 System.out.println("applet mr response =");70 System.out.println(converter_.getString(mr_response));71 68 // create the return page tree 72 69 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)); 74 71 // 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)); 76 73 // add the config stuff from message 77 74 page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.CONFIGURATION_ELEM), true)); … … 92 89 Document style_doc = converter_.getDOM(new File(stylesheet)); 93 90 GSXSLT.absoluteIncludePaths(style_doc, config_); 94 return transformer_.transform(style_doc, page);91 return (Element)transformer_.transform(style_doc, page); 95 92 96 93 } … … 103 100 mr_request.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_QUERY); 104 101 mr_request.setAttribute(GSXML.TO_ATT, to); 105 102 mr_request.setAttribute(GSXML.LANG_ATT, request.getAttribute(GSXML.LANG_ATT)); 103 106 104 // just append the params for now 107 mr_request.appendChild(doc_.importNode(cgi_param List, true));105 mr_request.appendChild(doc_.importNode(cgi_param_list, true)); 108 106 109 107 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));113 108 // add in the applet data 114 109 String path = GSXML.RESPONSE_ELEM; 115 110 path = GSPath.appendLink(path, GSXML.APPLET_DATA_ELEM); 116 111 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; 120 113 121 114 } 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; 126 117 } 127 118
Note:
See TracChangeset
for help on using the changeset viewer.