Changeset 4257
- Timestamp:
- 2003-05-08T16:11:22+12:00 (21 years ago)
- 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 5 5 // XML classes 6 6 import org.w3c.dom.Node; 7 import org.w3c.dom.NodeList; 7 8 import org.w3c.dom.Element; 8 9 import org.w3c.dom.Document; … … 10 11 // other java stuff 11 12 import java.io.File; 12 13 import java.util.Vector; 13 14 /** base class for Actions */ 14 15 abstract public class Action { … … 20 21 /** a converter class to parse XML and create Docs */ 21 22 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;26 23 /** a reference to the message router that it must talk to to 27 24 * get info. it may be a communicator acting as a proxy, but it … … 31 28 public Action() { 32 29 converter_ = new XMLConverter(); 33 transformer_ = new XMLTransformer();34 30 doc_ = converter_.newDOM(); 35 31 } … … 42 38 mr_ = m; 43 39 } 44 /** sets the GSCGI object - used to convert between short and long names45 * of params */46 public void setCGI(GSCGI cgi) {47 cgi_ = cgi;48 // add in any action specific params49 addCGIParams();50 }51 40 public void configure() { 52 41 // does nothing yet 53 42 } 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 60 44 /** process takes an xml representation of cgi args 61 45 * and returns the page of results - may be in html/xml/other … … 68 52 return converter_.getString(result); 69 53 } 70 54 71 55 /** the main process method - must be implemented in subclass */ 72 56 abstract public Element process(Element xml_in); 73 57 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 // } 91 66 } 92 67 -
trunk/gsdl3/src/java/org/greenstone/gsdl3/action/AppletAction.java
r4144 r4257 19 19 20 20 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 22 25 // get the collection and service params 23 26 Element cgi_param_list = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); … … 28 31 if (!request_type.equals("d")&&!request_type.equals("r")) { 29 32 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; 31 34 } 32 35 … … 61 64 } 62 65 63 // else request type = 'd'64 // find the stylesheet65 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 from73 // the service, and process using xslt74 75 76 // create the return page tree77 Element page = doc_.createElement(GSXML.PAGE_ELEM);78 page.setAttribute(GSXML.LANG_ATT, lang);79 // add the page extra stuff from message80 page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.PAGE_EXTRA_ELEM), true));81 82 // add in the page Request83 Element page_request = GSXML.duplicateWithNewName(doc_, request, "pageRequest", true);84 page.appendChild(page_request);85 66 86 67 // get the applet description, and the collection info if a collection is specified 87 68 88 69 Element mr_message = doc_.createElement(GSXML.MESSAGE_ELEM); 89 70 Element applet_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_DESCRIBE, to, lang); 90 71 mr_message.appendChild(applet_request); 91 72 92 if (coll_specified) {93 Element coll_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_DESCRIBE, collection, lang);94 mr_message.appendChild(coll_request);95 }96 73 97 74 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 101 76 // add in the applet info 102 77 String path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.SERVICE_ELEM); … … 105 80 // must handle any params that have values that are not 106 81 // necessarily known by the service 82 // should this be done here or by web receptionist?? 83 // cant really have an applet without web? 107 84 editLocalParams(app_desc, config_.library_name_, collection); 108 85 page_response.appendChild(app_desc); 109 86 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; 120 88 121 89 } … … 124 92 * 'library' or 'collection'. If found, the params are set to 125 93 * the appropriate values 94 * should this be done here or in the receptionist? 126 95 */ 127 96 protected void editLocalParams(Element description, String library_name, -
trunk/gsdl3/src/java/org/greenstone/gsdl3/action/BrowseAction.java
r4189 r4257 18 18 public static final String CLASSIFIER_ARG = "cl"; 19 19 public static final String SIBLING_ARG = "sib"; 20 /* add the action specific args to the cgi param list21 */22 public void addCGIParams() {23 cgi_.addStaticParam(CLASSIFIER_ARG);24 }25 20 26 21 /** process the request */ … … 29 24 // get the request - assume only one 30 25 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; 40 32 } 41 33 42 34 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 57 39 // extract the params from the cgi-request, and check that we have a coll specified 58 40 Element cgi_paramList = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); … … 62 44 String collection = (String)params.get(GSCGI.COLLECTION_ARG); 63 45 if (collection == null || collection.equals("")) { 64 System.err.println("BrowseAction Error:classifier browse, need to specify a collection!");65 return null;46 System.err.println("BrowseAction Error:classifierBrowse, need to specify a collection!"); 47 return page_response; 66 48 67 49 } … … 74 56 } 75 57 76 // the main response for the page is in a pageResponse element77 Element page_response = doc_.createElement(GSXML.PAGE_RESPONSE_ELEM);78 page.appendChild(page_response);79 80 58 String lang = request.getAttribute(GSXML.LANG_ATT); 81 59 String to = GSPath.appendLink(collection, service_name); 82 60 83 // the second part of the page is the service description61 // the first part of the response is the service description 84 62 // for now get this again from the service. 85 // this will probably need tobe cached somehow later on.63 // this should be cached somehow later on. 86 64 87 65 Element info_message = doc_.createElement(GSXML.MESSAGE_ELEM); … … 89 67 info_message.appendChild(info_request); 90 68 91 // also get the collection description (should be just metadata?) for the http address stuff92 Element coll_info_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_DESCRIBE, collection, lang);93 info_message.appendChild(coll_info_request);94 69 // also get the format stuff now if there is some 95 70 Element format_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_FORMAT, to, lang); … … 99 74 Element info_response = (Element) mr_.process(info_message); 100 75 101 // the t hreeresponses76 // the two responses 102 77 NodeList responses = info_response.getElementsByTagName(GSXML.RESPONSE_ELEM); 103 78 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); 106 80 107 81 Element service_description = (Element)GSXML.getChildByTagName(service_response, GSXML.SERVICE_ELEM); 108 82 page_response.appendChild(doc_.importNode(service_description, true)); 109 83 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 114 91 // get the node that the user has clicked on 115 92 String classifier_node = (String)params.get(CLASSIFIER_ARG); … … 117 94 // if the node is not defined, return the page that we have so far 118 95 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; 121 97 } 122 98 … … 124 100 String top_id = OID.getTop(classifier_node); 125 101 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); 130 104 if (format_elem != null) { 105 // find the one for the classifier we are in 131 106 Element this_format = GSXML.getNamedElement(format_elem, GSXML.CLASSIFIER_ELEM, GSXML.NAME_ATT, top_id); 132 107 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 137 113 // get the browse structure for the selected node 138 114 Element classify_message = doc_.createElement(GSXML.MESSAGE_ELEM); … … 183 159 if (cl_structure ==null) { 184 160 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; 189 162 } 190 163 … … 226 199 } 227 200 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 239 211 } 240 212 … … 261 233 } 262 234 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); 274 242 275 243 } … … 305 273 306 274 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; 312 277 } 313 278 -
trunk/gsdl3/src/java/org/greenstone/gsdl3/action/DocumentAction.java
r4144 r4257 43 43 /** if this is set to true, when a document is displayed, any annotation 44 44 * 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; 53 46 54 47 public Element process (Element message) … … 56 49 // for now, no subaction eventually we may want to have subactions such as text assoc or something ? 57 50 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); 64 55 65 56 // get the request - assume only one … … 73 64 if (document_name == null || document_name.equals("")) { 74 65 System.err.println("DocumentAction Error: no document specified!"); 75 return null;66 return result; 76 67 } 77 68 … … 83 74 } 84 75 85 // Create the return page tree86 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 message90 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 data94 Element page_response = doc_.createElement(GSXML.PAGE_RESPONSE_ELEM);95 page.appendChild(page_response);96 97 76 // get the additional data needed for the page 98 77 getBackgroundData(page_response, collection, lang); 99 78 100 79 // the_document is where all the doc info - structure and metadata etc 101 // -is added into, to be returned in the page80 // is added into, to be returned in the page 102 81 Element the_document = doc_.createElement(GSXML.DOCUMENT_ELEM); 103 82 page_response.appendChild(the_document); … … 127 106 ds_param.setAttribute(GSXML.VALUE_ATT, "siblings"); 128 107 } 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 129 125 // create a doc_node_list and put in the doc_node that we are interested in 130 126 Element ds_doc_list = doc_.createElement(GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER); … … 135 131 136 132 // Process the document structure retrieve message 137 // System.out.println("(DocumentAction) Structure request:\n" + converter_.getString(ds_message));138 133 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); 141 140 // 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); 143 143 path = GSPath.appendLink(path, GSXML.DOC_NODE_ELEM); 144 144 path = GSPath.appendLink(path, GSXML.NODE_STRUCTURE_ELEM); … … 202 202 doc_node.setAttribute(GSXML.NODE_ID_ATT, document_name+".rt"); 203 203 doc_list.appendChild(doc_node); 204 // System.out.println("(DocumentAction) Metadata request:\n" + converter_.getString(dm_request));205 204 Element dm_response_message = (Element) mr_.process(dm_message); 206 // System.out.println("(DocumentAction) Metadata response:\n" + converter_.getString(dm_response));207 205 208 206 path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER); … … 273 271 } 274 272 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; 279 275 } 280 276 … … 307 303 Element info_message = doc_.createElement(GSXML.MESSAGE_ELEM); 308 304 309 // the collection request310 Element coll_about_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_DESCRIBE, collection, lang);311 info_message.appendChild(coll_about_request);312 313 305 // the format request - ignore for now, where does this request go to?? 314 306 //Element format_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_FORMAT, ???, lang); … … 327 319 // the collection is the first response 328 320 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 332 321 //Element format_resp = (Element) responses.item(1); 333 322 //page_reponse.appendChild(doc_.importNode(GSXML.getChildByTagName(format_resp, GSXML.FORMAT_ELEM), true)); … … 335 324 336 325 if (provide_annotations) { 337 Element services_resp = (Element)responses.item( 1); // change when format request added in326 Element services_resp = (Element)responses.item(0); // change when format request added in 338 327 339 328 // a new message for the mr … … 358 347 Element e_service = (Element)doc_.importNode(GSXML.getChildByTagName(e_resp, GSXML.SERVICE_ELEM), true); 359 348 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 list363 cgi_.paramListAddShortNames(pl);364 }365 349 service_list.appendChild(e_service); 366 350 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/action/PageAction.java
r4155 r4257 14 14 public class PageAction extends Action { 15 15 16 public static final String SHORT_ACTION_NAME = "p";17 16 public static final String HOME_PAGE = "home"; 18 17 public static final String ABOUT_PAGE = "about"; … … 26 25 page_name = HOME_PAGE; 27 26 } 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 28 34 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 } 37 38 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; 47 41 } 48 42 49 43 50 protected Element homePage(Element page, Element orig_message) {44 protected Element homePage(Element request) { 51 45 52 String lang = page.getAttribute(GSXML.LANG_ATT); 46 String lang = request.getAttribute(GSXML.LANG_ATT); 47 53 48 // first, get the message router info 54 49 Element coll_list_message = doc_.createElement(GSXML.MESSAGE_ELEM); … … 87 82 if (c1.getAttribute(GSXML.NAME_ATT).equals(c2.getAttribute(GSXML.FROM_ATT))) { 88 83 // add the metadata to the original response 89 GSXML.mergeMetadataLists(c1, GSXML.getChildByTagName(c2, GSXML.COLLECTION_ELEM)); // add the metadata to the original response84 GSXML.mergeMetadataLists(c1, GSXML.getChildByTagName(c2, GSXML.COLLECTION_ELEM)); 90 85 } else { 91 86 System.err.println("PageAction Error: response does not correspond to request!"); … … 95 90 } 96 91 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 100 94 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; 108 96 109 97 } // homePage 110 98 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); 112 132 113 133 // extract the params from the cgi-request, … … 117 137 String coll_name = (String)params.get(GSCGI.COLLECTION_ARG); 118 138 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); 121 141 } 122 142 123 // get the collection or cluster description124 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 page132 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 stylesheet137 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 instead153 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 stylesheet163 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 }171 143 // else get the coll description - actually this is the same as for the about page - should we merge these two methods?? 172 144 … … 175 147 Element coll_about_message = doc_.createElement(GSXML.MESSAGE_ELEM); 176 148 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); 178 150 coll_about_message.appendChild(coll_about_request); 179 151 180 152 Element coll_about_response = (Element)mr_.process(coll_about_message); 181 153 182 // add the response to the page 154 // add the response to the page get teh response element and return it 183 155 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; 191 157 192 158 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/action/ProcessAction.java
r4154 r4257 19 19 public Element process (Element message) { 20 20 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 21 26 // assume only one request 22 27 Element request = (Element)GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM); 23 28 24 // we ignore the subaction for now - all types are processed by the same method25 //String subaction = request.getAttribute(GSXML.SUBACTION_ATT);26 29 // get the param list 27 30 Element cgi_param_list = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); … … 35 38 } 36 39 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); 44 41 // what is carried out depends on the request_type 45 42 // if rt=d, then a describe request is done, … … 51 48 // without any page processing 52 49 53 //the stylesheet54 String stylesheet = GSFile.stylesheetFile(config_, "process.xsl");55 56 if (!request_only) {57 // check that the stylesheet is present58 if (stylesheet==null) {59 System.err.println("ProcessAction Error: process stylesheet not found!");60 return null;61 }62 }63 50 64 51 // where to send requests … … 70 57 71 58 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; 78 60 Element param_list; 79 61 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; 82 63 param_list = doc_.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 83 64 Element param = doc_.createElement(GSXML.PARAM_ELEM); … … 86 67 param_list.appendChild(param); 87 68 } else { 88 mr_query_request.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);69 request_type_att = GSXML.REQUEST_TYPE_PROCESS; 89 70 // add in the params - except the ones only used by the action 90 71 param_list = getServiceParamList(cgi_param_list); 91 72 92 73 } 74 Element mr_query_request = GSXML.createBasicRequest(doc_, request_type_att, to, lang); 93 75 mr_query_request.appendChild(param_list); 94 76 mr_query_message.appendChild(mr_query_request); 95 77 96 78 Element mr_query_response = (Element)mr_.process(mr_query_message); … … 107 89 } 108 90 109 // add the page extra stuff from message110 page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.PAGE_EXTRA_ELEM), true));111 91 112 92 // another part of the page is the service description … … 114 94 // request the service info for the selected service - should be cached 115 95 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); 117 97 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 123 98 Element mr_info_response = (Element) mr_.process(mr_info_message); 124 99 … … 127 102 Element description = (Element)doc_.importNode(GSXML.getNodeByPath(mr_info_response, path), true); 128 103 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 list133 cgi_.paramListAddShortNames(pl);134 135 // for each param in the description, overwrite the default value with the currently set value if present136 Element param = (Element)pl.getFirstChild();137 while (param !=null) {138 if (param.getNodeName().equals(GSXML.PARAM_ELEM)) { // just in case139 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 }148 104 page_response.appendChild(description); 149 105 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; 160 107 } 161 108 … … 171 118 continue; 172 119 } 173 // e sle add it in to the list120 // else add it in to the list 174 121 new_param_list.appendChild(doc_.importNode(p, true)); 175 122 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/action/QueryAction.java
r4144 r4257 26 26 Element request = (Element)GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM); 27 27 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; 45 34 } 46 35 … … 49 38 * params to the service, then gets the titles for any results 50 39 */ 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 62 45 // extract the params from the cgi-request, and check that we have a coll specified 63 46 Element cgi_param_list = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); … … 67 50 String service_name = (String)params.get(GSCGI.SERVICE_ARG); 68 51 String collection = (String)params.get(GSCGI.COLLECTION_ARG); 52 69 53 if (collection == null || collection.equals("")) { 70 54 System.err.println("QueryAction Error: no collection was specified!"); 71 return null;55 return page_response; // an empty response 72 56 } 73 57 74 58 String lang = request.getAttribute(GSXML.LANG_ATT); 75 59 String to = GSPath.appendLink(collection, service_name); 76 77 //create the pageResponse78 Element page_response = doc_.createElement(GSXML.PAGE_RESPONSE_ELEM);79 page.appendChild(page_response);80 60 81 // the second part of the page is the service description61 // part of the response is the service description 82 62 // for now get this again from the service. 83 63 // this will probably need to be cached somehow later on. … … 90 70 mr_info_message.appendChild(format_request); 91 71 92 // also get the coll description93 Element coll_about_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_DESCRIBE, collection, lang);94 mr_info_message.appendChild(coll_about_request);95 96 72 // process the messages 97 73 Element mr_info_response = (Element) mr_.process(mr_info_message); 98 74 99 // the t hreeresponses75 // the two responses 100 76 NodeList responses = mr_info_response.getElementsByTagName(GSXML.RESPONSE_ELEM); 101 77 Element service_response = (Element)responses.item(0); 102 78 Element format_response = (Element)responses.item(1); 103 Element coll_response = (Element)responses.item(2);104 79 105 80 Element service_description = (Element)doc_.importNode(GSXML.getChildByTagName(service_response, GSXML.SERVICE_ELEM), true); 106 81 page_response.appendChild(service_description); 107 82 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; 155 85 } 156 86 157 87 // 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); 159 89 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)); 161 93 } 162 94 … … 164 96 // do the query 165 97 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); 167 99 mr_query_message.appendChild(mr_query_request); 168 100 … … 197 129 // documentList not present if no docs found 198 130 if (document_list == null) { 199 GSXSLT.absoluteIncludePaths(style_doc, config_); 200 return (Element)transformer_.transform(style_doc, page); 201 131 return page_response; 202 132 } 203 133 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 218 135 Element mr_metadata_message = doc_.createElement(GSXML.MESSAGE_ELEM); 219 136 Element mr_metadata_request = doc_.createElement(GSXML.REQUEST_ELEM); … … 221 138 222 139 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); 224 141 to = GSPath.appendLink(collection, "DocumentMetadataRetrieve"); // Hard-wired? 225 142 mr_metadata_request.setAttribute(GSXML.TO_ATT, to); 226 143 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"); 228 151 mr_metadata_request.appendChild(dm_param_list); 229 152 … … 232 155 mr_metadata_request.appendChild(doc_.importNode(document_list, true)); 233 156 Element mr_metadata_response = (Element) mr_.process(mr_metadata_message); 234 157 235 158 path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER); 236 159 Element query_result_document_list = (Element) GSXML.getNodeByPath(mr_metadata_response, path); … … 240 163 } 241 164 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; 248 167 } 249 168 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/action/SystemAction.java
r4144 r4257 27 27 HashMap params = GSXML.extractParams(cgi_param_list, false); 28 28 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 35 31 String coll = (String)params.get(GSCGI.COLLECTION_ARG); 36 32 … … 69 65 // for now just have an error 70 66 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; 72 71 } 73 72 } … … 75 74 Element response_message = mr_.process(mr_request_message); 76 75 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; 89 78 90 79 }
Note:
See TracChangeset
for help on using the changeset viewer.