- Timestamp:
- 2012-03-27T15:18:44+13:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/DocumentAction.java
r25128 r25305 48 48 public static final String GOTO_PAGE_ARG = "gp"; 49 49 public static final String ENRICH_DOC_ARG = "end"; 50 public static final String EXPAND_DOCUMENT_ARG = "ed"; 51 public static final String EXPAND_CONTENTS_ARG = "ec"; 52 public static final String REALISTIC_BOOK_ARG = "book"; 50 53 51 54 /** … … 92 95 HashMap service_params = (HashMap) params.get("s0"); 93 96 94 String has_rl = null;95 String has_href = null;96 has_href = (String) params.get("href");//for an external link : get the href URL if it is existing in the params list97 has_rl = (String) params.get("rl");//for an external link : get the rl value if it is existing in the params list98 97 String collection = (String) params.get(GSParams.COLLECTION); 99 UserContext userContext = new UserContext(request); 100 String document_name = (String) params.get(GSParams.DOCUMENT); 101 if ((document_name == null || document_name.equals("")) && (has_href == null || has_href.equals(""))) 98 String document_id = (String) params.get(GSParams.DOCUMENT); 99 if (document_id != null && document_id.equals("")) { 100 document_id = null; 101 } 102 String href = (String) params.get(GSParams.HREF);//for an external link : get the href URL if it is existing in the params list 103 if (href != null && href.equals("")) { 104 href = null; 105 } 106 String rl = (String) params.get(GSParams.RELATIVE_LINK);//for an external link : get the rl value if it is existing in the params list 107 if (document_id == null && href == null) 102 108 { 103 109 logger.error("no document specified!"); 104 110 return result; 105 111 } 112 if (rl != null && rl.equals("0")) { 113 // this is a true external link, we should have been directed to a different page or action 114 logger.error("rl value was 0, shouldn't get here"); 115 return result; 116 } 106 117 String document_type = (String) params.get(GSParams.DOCUMENT_TYPE); 107 if (document_type == null )118 if (document_type == null || document_type.equals("")) 108 119 { 109 120 document_type = "simple"; … … 117 128 } 118 129 130 String doc_id_modifier = ""; 119 131 String sibling_num = (String) params.get(GOTO_PAGE_ARG); 120 132 if (sibling_num != null && !sibling_num.equals("")) 121 133 { 122 134 // we have to modify the doc name 123 doc ument_name = document_name +"." + sibling_num + ".ss";135 doc_id_modifier = "." + sibling_num + ".ss"; 124 136 } 125 137 126 138 boolean expand_document = false; 127 String ed_arg = (String) params.get( GSParams.EXPAND_DOCUMENT);139 String ed_arg = (String) params.get(EXPAND_DOCUMENT_ARG); 128 140 if (ed_arg != null && ed_arg.equals("1")) 129 141 { … … 138 150 else 139 151 { 140 String ec_arg = (String) params.get( GSParams.EXPAND_CONTENTS);152 String ec_arg = (String) params.get(EXPAND_CONTENTS_ARG); 141 153 if (ec_arg != null && ec_arg.equals("1")) 142 154 { … … 144 156 } 145 157 } 158 159 UserContext userContext = new UserContext(request); 146 160 147 161 //append site metadata … … 165 179 Element current_doc = this.doc.createElement(GSXML.DOC_NODE_ELEM); 166 180 basic_doc_list.appendChild(current_doc); 167 if (document_name.length() != 0) 168 { 169 current_doc.setAttribute(GSXML.NODE_ID_ATT, document_name); 170 } 171 else if (has_href.length() != 0) 172 { 173 current_doc.setAttribute(GSXML.NODE_ID_ATT, has_href); 174 current_doc.setAttribute("externalURL", has_rl); 181 if (document_id != null) 182 { 183 current_doc.setAttribute(GSXML.NODE_ID_ATT, document_id+doc_id_modifier); 184 } 185 else 186 { 187 current_doc.setAttribute(GSXML.HREF_ID_ATT, href); 188 // do we need this?? 189 current_doc.setAttribute(GSXML.ID_MOD_ATT, doc_id_modifier); 175 190 } 176 191 … … 198 213 } 199 214 200 // get t ehinfo needed for paged naviagtion215 // get the info needed for paged naviagtion 201 216 ds_param = this.doc.createElement(GSXML.PARAM_ELEM); 202 217 ds_param_list.appendChild(ds_param); … … 305 320 // no structure nodes, so put in a dummy doc node 306 321 Element doc_node = this.doc.createElement(GSXML.DOC_NODE_ELEM); 307 if (document_ name.length() != 0)308 { 309 doc_node.setAttribute(GSXML.NODE_ID_ATT, document_ name);310 } 311 else if (has_href.length() != 0)312 { 313 doc_node.setAttribute(GSXML. NODE_ID_ATT, has_href);314 doc_node.setAttribute("externalURL", has_rl);322 if (document_id != null) 323 { 324 doc_node.setAttribute(GSXML.NODE_ID_ATT, document_id); 325 } 326 else 327 { 328 doc_node.setAttribute(GSXML.HREF_ID_ATT, href); 329 315 330 } 316 331 the_document.appendChild(doc_node); … … 323 338 // no structure request, so just put in a dummy doc node 324 339 Element doc_node = this.doc.createElement(GSXML.DOC_NODE_ELEM); 325 if (document_name.length() != 0) 326 { 327 doc_node.setAttribute(GSXML.NODE_ID_ATT, document_name); 328 } 329 else if (has_href.length() != 0) 330 { 331 doc_node.setAttribute(GSXML.NODE_ID_ATT, has_href); 332 doc_node.setAttribute("externalURL", has_rl); 340 if (document_id != null) 341 { 342 doc_node.setAttribute(GSXML.NODE_ID_ATT, document_id); 343 } 344 else 345 { 346 doc_node.setAttribute(GSXML.HREF_ID_ATT, href); 333 347 } 334 348 the_document.appendChild(doc_node); … … 398 412 Element doc_node = this.doc.createElement(GSXML.DOC_NODE_ELEM); 399 413 // the node we want is the root document node 400 if (document_name.length() != 0) 401 { 402 doc_node.setAttribute(GSXML.NODE_ID_ATT, document_name + ".rt"); 403 } 404 else if (has_href.length() != 0) 405 { 406 doc_node.setAttribute(GSXML.NODE_ID_ATT, has_href + ".rt"); 407 doc_node.setAttribute("externalURL", has_rl); 414 if (document_id != null) 415 { 416 doc_node.setAttribute(GSXML.NODE_ID_ATT, document_id + ".rt"); 417 } 418 else 419 { 420 doc_node.setAttribute(GSXML.HREF_ID_ATT, href);// + ".rt"); 421 // can we assume that href is always a top level doc?? 422 //doc_node.setAttribute(GSXML.ID_MOD_ATT, ".rt"); 423 //doc_node.setAttribute("externalURL", has_rl); 408 424 } 409 425 doc_list.appendChild(doc_node); … … 486 502 Element dc_response_doc = (Element) GSXML.getChildByTagName(dc_response_doc_list, GSXML.DOC_NODE_ELEM); 487 503 Element dc_response_doc_content = (Element) GSXML.getChildByTagName(dc_response_doc, GSXML.NODE_CONTENT_ELEM); 488 Element dc_response_doc_external = (Element) GSXML.getChildByTagName(dc_response_doc, "external");504 //Element dc_response_doc_external = (Element) GSXML.getChildByTagName(dc_response_doc, "external"); 489 505 490 506 if (dc_response_doc_content == null) 491 507 { 492 508 // no content to add 493 if (dc_response_doc_external != null) 494 { 495 String modified_doc_id = dc_response_doc.getAttribute(GSXML.NODE_ID_ATT); 496 497 the_document.setAttribute("selectedNode", modified_doc_id); 498 the_document.setAttribute("external", dc_response_doc_external.getAttribute("external_link")); 499 } 500 return result; 509 if (dc_response_doc.getAttribute("external").equals("true")) { 510 511 //if (dc_response_doc_external != null) 512 //{ 513 String href_id = dc_response_doc.getAttribute(GSXML.HREF_ID_ATT); 514 515 the_document.setAttribute("selectedNode", href_id); 516 the_document.setAttribute("external", href_id); 517 } 518 return result; 501 519 } 502 520 if (highlight_query_terms) … … 598 616 * important for args that should not be saved 599 617 */ 600 public boolean getActionParameters(GSParams params)618 public boolean addActionParameters(GSParams params) 601 619 { 602 620 params.addParameter(GOTO_PAGE_ARG, false); 603 621 params.addParameter(ENRICH_DOC_ARG, false); 622 params.addParameter(EXPAND_DOCUMENT_ARG, false); 623 params.addParameter(EXPAND_CONTENTS_ARG, false); 624 params.addParameter(REALISTIC_BOOK_ARG, false); 625 604 626 return true; 605 627 }
Note:
See TracChangeset
for help on using the changeset viewer.