Changeset 36978
- Timestamp:
- 2022-12-07T12:14:03+13:00 (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/DocumentAction.java
r35363 r36978 21 21 // Greenstone classes 22 22 import org.greenstone.gsdl3.core.ModuleInterface; 23 import org.greenstone.gsdl3.service.AbstractDocumentRetrieve; 24 import org.greenstone.gsdl3.service.DocXMLUtil; 23 25 import org.greenstone.gsdl3.util.*; 24 26 import org.greenstone.util.GlobalProperties; … … 125 127 return result; 126 128 } 129 130 String doc_id_modifier = ""; 131 String sibling_num = (String) params.get(GOTO_PAGE_ARG); 132 if (sibling_num != null && !sibling_num.equals("")) 133 { 134 // we have to modify the doc name 135 doc_id_modifier = "." + sibling_num + ".ss"; 136 } 137 127 138 128 139 UserContext userContext = new UserContext(request); … … 134 145 // get the additional data needed for the page 135 146 getBackgroundData(page_response, collection, userContext); 147 148 // create a basic doc list containing the current node 149 // we will use this to query whether the id is valid, and to get document type 150 Element basic_doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 151 Element current_doc = doc.createElement(GSXML.DOC_NODE_ELEM); 152 basic_doc_list.appendChild(current_doc); 153 if (document_id != null) 154 { 155 current_doc.setAttribute(GSXML.NODE_ID_ATT, document_id + doc_id_modifier); 156 } 157 else 158 { 159 current_doc.setAttribute(GSXML.HREF_ID_ATT, href); 160 // do we need this?? 161 current_doc.setAttribute(GSXML.ID_MOD_ATT, doc_id_modifier); 162 } 163 164 // lets do a quick check here for valid doc id. 165 if (document_id != null) { 166 boolean is_valid = checkValidOID(basic_doc_list, collection, userContext, page_response ); 167 if (!is_valid) { 168 GSXML.addError(page_response, "Invalid doc id ("+document_id+")", GSXML.ERROR_TYPE_INVALID_ID); 169 return result; 170 } 171 } 136 172 Element format_elem = (Element) GSXML.getChildByTagName(page_response, GSXML.FORMAT_ELEM); 137 173 … … 180 216 } 181 217 182 String doc_id_modifier = "";183 String sibling_num = (String) params.get(GOTO_PAGE_ARG);184 if (sibling_num != null && !sibling_num.equals(""))185 {186 // we have to modify the doc name187 doc_id_modifier = "." + sibling_num + ".ss";188 }189 190 218 boolean expand_document = false; 191 219 String ed_arg = (String) params.get(EXPAND_DOCUMENT_ARG); … … 226 254 page_response.appendChild(the_document); 227 255 228 // create a basic doc list containing the current node 229 Element basic_doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 230 Element current_doc = doc.createElement(GSXML.DOC_NODE_ELEM); 231 basic_doc_list.appendChild(current_doc); 232 if (document_id != null) 233 { 234 current_doc.setAttribute(GSXML.NODE_ID_ATT, document_id + doc_id_modifier); 235 } 236 else 237 { 238 current_doc.setAttribute(GSXML.HREF_ID_ATT, href); 239 // do we need this?? 240 current_doc.setAttribute(GSXML.ID_MOD_ATT, doc_id_modifier); 241 } 242 256 // used to create basic_doc_list here 243 257 if (document_type == null) 244 258 { … … 342 356 // Build a request to obtain the document structure 343 357 Element ds_message = doc.createElement(GSXML.MESSAGE_ELEM); 344 String to = GSPath.appendLink(collection, "DocumentStructureRetrieve");// Hard-wired?358 String to = GSPath.appendLink(collection, AbstractDocumentRetrieve.DOCUMENT_STRUCTURE_RETRIEVE_SERVICE); 345 359 Element ds_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext); 346 360 ds_message.appendChild(ds_request); … … 421 435 // Build a request to obtain some document metadata 422 436 Element dm_message = doc.createElement(GSXML.MESSAGE_ELEM); 423 String to = GSPath.appendLink(collection, "DocumentMetadataRetrieve"); // Hard-wired?437 String to = GSPath.appendLink(collection, AbstractDocumentRetrieve.DOCUMENT_METADATA_RETRIEVE_SERVICE); 424 438 Element dm_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext); 425 439 dm_message.appendChild(dm_request); … … 575 589 // Build a request to obtain some document content 576 590 Element dc_message = doc.createElement(GSXML.MESSAGE_ELEM); 577 to = GSPath.appendLink(collection, "DocumentContentRetrieve"); // Hard-wired?591 to = GSPath.appendLink(collection, AbstractDocumentRetrieve.DOCUMENT_CONTENT_RETRIEVE_SERVICE); 578 592 Element dc_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext); 579 593 dc_message.appendChild(dc_request); … … 783 797 } 784 798 799 protected boolean checkValidOID(Element basic_doc_list, String collection, UserContext userContext, Element page_response) { 800 Document doc = basic_doc_list.getOwnerDocument(); 801 802 Element v_message = doc.createElement(GSXML.MESSAGE_ELEM); 803 String to = GSPath.appendLink(collection, AbstractDocumentRetrieve.VALIDATE_DOCUMENT_ID_SERVICE); 804 Element v_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext); 805 v_message.appendChild(v_request); 806 807 // add the node list 808 v_request.appendChild(basic_doc_list); 809 Element v_response_message = (Element) this.mr.process(v_message); 810 if (processErrorElements(v_response_message, page_response)) 811 { 812 return false; 813 } 814 String[] links = { GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER, GSXML.DOC_NODE_ELEM }; 815 String path = GSPath.createPath(links); 816 Element info_elem = (Element) GSXML.getNodeByPath(v_response_message, path); 817 if (info_elem == null) { 818 return false; 819 } 820 if (info_elem.getAttribute("valid").equals("true")) { 821 return true; 822 } 823 return false; 824 825 } 826 785 827 protected Element getFormattedArchiveDoc(Document doc, String collection, String document_id, String document_type, Element result, Element page_response, UserContext userContext ) { 786 828 // call get archive doc 787 829 Element dx_message = doc.createElement(GSXML.MESSAGE_ELEM); 788 String to = "DocXMLGetSection";830 String to = DocXMLUtil.DOC_XML_GET_SECTION_SERVICE; 789 831 Element dx_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext); 790 832 dx_message.appendChild(dx_request); … … 881 923 // these could all be cached 882 924 Element info_message = doc.createElement(GSXML.MESSAGE_ELEM); 883 String path = GSPath.appendLink(collection, "DocumentContentRetrieve");925 String path = GSPath.appendLink(collection, AbstractDocumentRetrieve.DOCUMENT_CONTENT_RETRIEVE_SERVICE); 884 926 // the format request - ignore for now, where does this request go to?? 885 927 Element format_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_FORMAT, path, userContext); … … 957 999 958 1000 Element ds_message = doc.createElement(GSXML.MESSAGE_ELEM); 959 String to = GSPath.appendLink(collection, "DocumentStructureRetrieve");// Hard-wired?1001 String to = GSPath.appendLink(collection, AbstractDocumentRetrieve.DOCUMENT_STRUCTURE_RETRIEVE_SERVICE); 960 1002 Element ds_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext); 961 1003 ds_message.appendChild(ds_request); … … 1332 1374 1333 1375 Element hl_message = doc.createElement(GSXML.MESSAGE_ELEM); 1334 to = GSPath.appendLink(collection, "DocumentContentRetrieve");1376 to = GSPath.appendLink(collection, AbstractDocumentRetrieve.DOCUMENT_CONTENT_RETRIEVE_SERVICE); 1335 1377 Element dc_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext); 1336 1378 hl_message.appendChild(dc_request);
Note:
See TracChangeset
for help on using the changeset viewer.