- 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/ResourceAction.java
r3512 r3568 11 11 import java.io.File; 12 12 13 /** Action class for retrieving Documents or Resources via the message router 14 */ 13 15 public 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 20 19 // find the stylesheet 21 20 String stylesheet = GSFile.stylesheetFile(config_, "resource.xsl"); 22 21 23 22 if (stylesheet==null) { 24 return GSHTML.errorPage("resource stylesheet not found!"); 23 System.err.println("ResourceAction Error: resource stylesheet not found!"); 24 return null; 25 25 } 26 26 27 27 // for now, no subaction eventually we may want to have subactions such as text assoc or something ? 28 28 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); 31 31 Element cgi_paramList = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 32 cgi_.toLong(cgi_paramList);33 32 HashMap params = GSXML.extractParams(cgi_paramList); 34 33 35 34 String resource_name = (String)params.get("resource"); 36 35 if (resource_name == null || resource_name.equals("")) { 37 // no doc to show38 return GSHTML.errorPage("no resource specified");36 System.err.println("ResourceAction Error: no resource specified!"); 37 return null; 39 38 } 40 41 39 42 40 // create the return page tree 43 41 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)); 45 43 // 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)); 47 45 // add the config stuff from message 48 46 page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.CONFIGURATION_ELEM), true)); 49 50 51 47 52 48 // build up the mr request … … 55 51 mr_message.appendChild(mr_request); 56 52 mr_request.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_QUERY); 53 mr_request.setAttribute(GSXML.LANG_ATT, page.getAttribute(GSXML.LANG_ATT)); 57 54 mr_request.setAttribute("resourceType", "core"); 58 55 String to = (String)params.get("collection"); // collection name … … 82 79 Document style_doc = converter_.getDOM(new File(stylesheet)); 83 80 GSXSLT.absoluteIncludePaths(style_doc, config_); 84 return transformer_.transform(style_doc, page);81 return (Element)transformer_.transform(style_doc, page); 85 82 86 83 }
Note:
See TracChangeset
for help on using the changeset viewer.