Changeset 3896
- Timestamp:
- 2003-03-18T15:02:23+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/action/DocumentAction.java
r3868 r3896 38 38 public class DocumentAction extends Action { 39 39 40 // this is used to specify that the sibling nodes of a selected one should be obtained 41 public static final String SIBLING_ARG = "sib"; 42 43 /* add the action specific args to the cgi param list 44 */ 45 public void addCGIParams() { 46 cgi_.addStaticParam(SIBLING_ARG); 47 } 48 49 40 50 public Element process (Element message) 41 51 { … … 54 64 return null; 55 65 } 56 57 66 //whether to retrieve siblings or not 67 boolean get_siblings = false; 68 String sibs = (String) params.get(SIBLING_ARG); 69 if (sibs != null && sibs.equals("1")) { 70 get_siblings = true; 71 } 72 58 73 // Build a request to obtain the document structure 59 74 Element ds_message = doc_.createElement(GSXML.MESSAGE_ELEM); … … 76 91 ds_param.setAttribute(GSXML.NAME_ATT, "structure"); 77 92 ds_param.setAttribute(GSXML.VALUE_ATT, "children"); 78 93 if (get_siblings) { 94 ds_param = doc_.createElement(GSXML.PARAM_ELEM); 95 ds_param_list.appendChild(ds_param); 96 ds_param.setAttribute(GSXML.NAME_ATT, "structure"); 97 ds_param.setAttribute(GSXML.VALUE_ATT, "siblings"); 98 } 79 99 // create a doc_node_list and put in the doc_node that we are interested in 80 100 Element ds_doc_list = doc_.createElement(GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER); … … 102 122 the_document.appendChild(doc_.importNode(structs.item(i), true)); 103 123 } 104 //Element ds_response = (Element) GSXML.getChildByTagName(ds_response_message, GSXML.RESPONSE_ELEM);105 //Element ds_response_doc_list = (Element) GSXML.getChildByTagName(ds_response, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);106 //Element ds_response_document = (Element) GSXML.getChildByTagName(ds_response_doc_list, GSXML.DOC_NODE_ELEM);107 108 // Detach the document from the list, remove the list, and add the document back109 // ds_response is the re110 //ds_response.removeChild(ds_response_doc_list);111 //ds_response.appendChild(ds_response_document);112 113 124 114 125 // Build a request to obtain some document metadata … … 155 166 Element dm_response_doc_list = (Element) GSXML.getNodeByPath(dm_response_message, path); 156 167 157 //Element dm_response_content = (Element) GSXML.getNodeByPath(dm_response, "response/content");158 //Element dm_response_doc_list = (Element) GSXML.getNodeByPath(dm_response_content, "documentList");159 160 168 // Merge the metadata with the structure information 161 169 NodeList dm_response_docs = dm_response_doc_list.getChildNodes(); … … 180 188 // the doc list for the content request is the same as the one for the structure request 181 189 dc_request.appendChild(ds_doc_list); 182 // Element dc_doc_list = doc_.createElement(GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);183 // dc_request.appendChild(dc_doc_list);184 // Element dc_doc = doc_.createElement(GSXML.DOC_NODE_ELEM);185 // dc_doc_list.appendChild(dc_doc);186 // dc_doc.setAttribute(GSXML.DOC_NODE_ID, document_name);187 190 188 191 // System.out.println("(DocumentAction) Content request:\n" + converter_.getString(dc_request)); … … 191 194 192 195 path = GSPath.appendLink(path, GSXML.DOC_NODE_ELEM); 193 path = GSPath.appendLink(path, GSXML.DOC_NODE_CONTENT_ELEM); 194 Element dc_response_doc_content = (Element) GSXML.getNodeByPath(dc_response_message, path); 195 196 Element dc_response_doc = (Element) GSXML.getNodeByPath(dc_response_message, path); 197 //path = GSPath.appendLink(path, GSXML.DOC_NODE_CONTENT_ELEM); 198 Element dc_response_doc_content = (Element) GSXML.getChildByTagName(dc_response_doc, GSXML.DOC_NODE_CONTENT_ELEM); 199 // use the returned id rather than the sent one cos there may have 200 // been modifiers such as .pr that are removed. 201 String modified_doc_id = dc_response_doc.getAttribute(GSXML.NODE_ID_ATT); 196 202 // Merge the document content with the metadata and structure information 197 203 for (int i = 0; i < doc_nodes.getLength(); i++) { … … 199 205 Node doc_node_id = doc_node.getAttributes().getNamedItem(GSXML.DOC_NODE_ID_ATT); 200 206 String dc_doc_id = doc_node_id.getNodeValue(); 201 if (dc_doc_id == document_name) {207 if (dc_doc_id.equals(modified_doc_id)) { 202 208 doc_node.appendChild(doc_.importNode(dc_response_doc_content, true)); 203 209 break; … … 219 225 response.appendChild(the_document); 220 226 221 // System.out.println("Finished page: " + converter_.getString(page));227 System.out.println("doc action: Finished page: " + converter_.getString(page)); 222 228 223 229
Note:
See TracChangeset
for help on using the changeset viewer.