- 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/BrowseAction.java
r3512 r3568 10 10 import java.util.HashMap; 11 11 import java.io.File; 12 13 /** action for classifier browsing */ 12 14 public class BrowseAction extends Action { 13 15 16 public Element process (Element message) { 14 17 15 public String process (Element message) { 16 18 // get the request - assume only one 19 Element request = (Element)GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM); 20 17 21 // create the return page tree 18 22 Element page = doc_.createElement(GSXML.PAGE_ELEM); 19 page.setAttribute(GSXML.LANG_ATT, message.getAttribute(GSXML.LANG_ATT));23 page.setAttribute(GSXML.LANG_ATT, request.getAttribute(GSXML.LANG_ATT)); 20 24 // add the lang stuff from message 21 page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML. TRANSLATION_ELEM), true));25 page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.DISPLAY_ELEM), true)); 22 26 // add the system stuff from message 23 27 page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.CONFIGURATION_ELEM), true)); 24 28 25 Element request = (Element)message.getElementsByTagName(GSXML.REQUEST_ELEM).item(0);26 29 27 30 // the browse type is the subaction … … 37 40 38 41 39 protected StringclassifierBrowse(Element page, Element request) {42 protected Element classifierBrowse(Element page, Element request) { 40 43 41 44 // 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 42 45 String stylesheet = GSFile.stylesheetFile(config_, "classifier.xsl"); 43 46 if (stylesheet==null) { 44 return GSHTML.errorPage("classifier stylesheet not found!"); 47 System.err.println("BrowseAction Error: classifier stylesheet not found!"); 48 return null; 45 49 } 46 50 Document style_doc = converter_.getDOM(new File(stylesheet)); … … 54 58 String collection = (String)params.get("collection"); 55 59 if (collection == null || collection.equals("")) { 56 return GSHTML.errorPage("classifierbrowse, need to specify a collection!"); 60 System.err.println("BrowseAction Error:classifierbrowse, need to specify a collection!"); 61 return null; 62 57 63 } 58 64 59 // the first part of the data for the page is the cgi-params60 Element cgi_request = (Element)doc_.importNode(request, true);61 page.appendChild(cgi_request);62 65 63 // get the service info from the MR - this will probably need to be cached somehow later on. and add as a description node to the cgi-request - this doesn't work. change to add the specified value as a current attribute to the param - need to do somthing different for query66 // get the service info from the MR - this will probably need to be cached somehow later on. 64 67 65 68 Element mr_info_message = doc_.createElement(GSXML.MESSAGE_ELEM); … … 67 70 mr_info_message.appendChild(mr_info_request); 68 71 mr_info_request.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_DESCRIBE); 72 mr_info_request.setAttribute(GSXML.LANG_ATT, request.getAttribute(GSXML.LANG_ATT)); 69 73 70 74 String to = collection; … … 73 77 74 78 Element mr_info_response = (Element) mr_.process(mr_info_message); 75 Element description = doc_.createElement(GSXML.DESCRIPTION_ELEM);76 79 77 80 String path = GSXML.RESPONSE_ELEM; 78 81 path = GSPath.appendLink(path, GSXML.SERVICE_ELEM); 79 path = GSPath.appendLink(path, GSXML.CLASSIFIER_ELEM+GSXML.LIST_MODIFIER);80 Node cl = GSXML.getNodeByPath(mr_info_response, path);81 82 82 Element imported_classList = (Element)doc_.importNode(cl, true); 83 Element description = (Element)doc_.importNode(GSXML.getNodeByPath(mr_info_response, path), true); 84 85 // the first part of the data for the page is the cgi-params 86 Element cgi_request = (Element)doc_.importNode(request, true); 87 page.appendChild(cgi_request); 83 88 84 description.appendChild(imported_classList); 85 cgi_request.appendChild(description); 86 87 89 page.appendChild(description); 90 88 91 // if there is a cl field in the cgi params, get the classifier info 89 92 String node = (String)params.get("classifier"); 93 94 if (node!=null && !node.equals("")) { 90 95 91 if (node==null|| node.equals("")) { 92 System.out.println("no cl node selected"); 93 // if there is no cl set, just output the list 94 GSXSLT.absoluteIncludePaths(style_doc, config_); 95 return transformer_.transform(style_doc, page); 96 // get the info for the selected node 97 Element mr_query_message = doc_.createElement(GSXML.MESSAGE_ELEM); 98 Element mr_query_request = doc_.createElement(GSXML.REQUEST_ELEM); 99 mr_query_message.appendChild(mr_query_request); 100 101 mr_query_request.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_QUERY); 102 mr_query_request.setAttribute(GSXML.TO_ATT, to); 103 mr_query_request.setAttribute(GSXML.LANG_ATT, request.getAttribute(GSXML.LANG_ATT)); 104 105 106 // paramList - empty for now 107 Element paramList = doc_.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 108 mr_query_request.appendChild(paramList); 109 110 111 // content - contains the classifier node, may be more than one 112 // call this resource list for now 113 Element query_content = doc_.createElement(GSXML.CONTENT_ELEM); 114 mr_query_request.appendChild(query_content); 115 116 Element resource_list = doc_.createElement(GSXML.RESOURCE_ELEM+GSXML.LIST_MODIFIER); 117 Element resource = doc_.createElement(GSXML.RESOURCE_ELEM); 118 resource.setAttribute(GSXML.NAME_ATT, node); 119 resource_list.appendChild(resource); 120 query_content.appendChild(resource_list); 121 122 Element mr_query_response = (Element)mr_.process(mr_query_message); 123 124 Element response = (Element)GSXML.getChildByTagName(mr_query_response, GSXML.RESPONSE_ELEM); 125 Node new_style = GSXML.getChildByTagName(response, "stylesheet"); 126 if (new_style !=null) { 127 GSXSLT.mergeStylesheets(style_doc, (Element)new_style); 128 response.removeChild(new_style); 129 } 130 // add the response to the page data 131 page.appendChild(doc_.importNode(response, true)); 132 96 133 } 97 134 98 // get the info for the selected node99 Element mr_query_message = doc_.createElement(GSXML.MESSAGE_ELEM);100 Element mr_query_request = doc_.createElement(GSXML.REQUEST_ELEM);101 mr_query_message.appendChild(mr_query_request);102 103 mr_query_request.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_QUERY);104 mr_query_request.setAttribute(GSXML.TO_ATT, to);105 106 // paramList - empty for now107 Element paramList = doc_.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);108 mr_query_request.appendChild(paramList);109 110 111 // content - contains the classifier node, may be more than one112 // call this resource list for now113 Element query_content = doc_.createElement(GSXML.CONTENT_ELEM);114 mr_query_request.appendChild(query_content);115 116 Element resource_list = doc_.createElement(GSXML.RESOURCE_ELEM+GSXML.LIST_MODIFIER);117 Element resource = doc_.createElement(GSXML.RESOURCE_ELEM);118 resource.setAttribute(GSXML.NAME_ATT, node);119 resource_list.appendChild(resource);120 query_content.appendChild(resource_list);121 122 Element mr_query_response = (Element)mr_.process(mr_query_message);123 124 Element response = (Element)GSXML.getChildByTagName(mr_query_response, GSXML.RESPONSE_ELEM);125 Node new_style = GSXML.getChildByTagName(response, "stylesheet");126 if (new_style !=null) {127 GSXSLT.mergeStylesheets(style_doc, (Element)new_style);128 response.removeChild(new_style);129 }130 // add the response to the page data131 page.appendChild(doc_.importNode(response, true));132 133 135 GSXSLT.absoluteIncludePaths(style_doc, config_); 134 return transformer_.transform(style_doc, page);136 return (Element)transformer_.transform(style_doc, page); 135 137 } 136 138 137 protected StringunknownBrowse(Element page, Element request, String browse_type) {138 139 return GSHTML.errorPage("unknown browse subtype: "+browse_type);139 protected Element unknownBrowse(Element page, Element request, String browse_type) { 140 System.err.println("BrowseAction Error: unknown browse subtype: "+browse_type); 141 return null; 140 142 } 141 143 }
Note:
See TracChangeset
for help on using the changeset viewer.