Changeset 14529
- Timestamp:
- 2007-09-17T15:37:16+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
greenstone3/trunk/src/java/org/greenstone/gsdl3/service/AbstractDocumentRetrieve.java
r14225 r14529 28 28 import org.greenstone.gsdl3.util.MacroResolver; 29 29 import org.greenstone.gsdl3.util.OID; 30 import org.greenstone.gsdl3.util.GlobalProperties; 31 import org.greenstone.gsdl3.util.GSConstants; 30 32 31 33 // XML classes … … 138 140 } 139 141 } 140 142 141 143 if (macro_resolver != null) { 142 macro_resolver.setSiteDetails(this.site_http_address, this.cluster_name );144 macro_resolver.setSiteDetails(this.site_http_address, this.cluster_name, this.getLibraryName()); 143 145 // set up the macro resolver 144 146 Element replacement_elem = (Element)GSXML.getChildByTagName(extra_info, "replaceList"); … … 183 185 return result; 184 186 } 185 186 187 // Get the parameters of the request 187 188 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); … … 238 239 239 240 // Whew, now we have checked (almost) all the syntax of the request, now we can process it. 240 241 241 for (int i = 0; i < request_nodes.getLength(); i++) { 242 242 Element request_node = (Element) request_nodes.item(i); 243 243 String node_id = request_node.getAttribute(GSXML.NODE_ID_ATT); 244 245 if (external_id) { 246 // can we have .pr etc extensions with external ids? 247 node_id = translateExternalId(node_id); 248 } else if (idNeedsTranslating(node_id)) { 249 node_id = translateId(node_id); 250 } 244 245 boolean is_external_link = false; 246 if (!node_id.startsWith("HASH")){ 247 if (node_id.endsWith(".rt")){ 248 node_id = getHrefOID(node_id.substring(0,node_id.length()-3)); 249 if (node_id!=null){ 250 node_id += ".rt"; 251 }else{ 252 is_external_link = true; 253 } 254 }else{ 255 node_id = getHrefOID(node_id); 256 if (node_id==null){ 257 is_external_link = true; 258 } 259 } 260 } 261 if (!is_external_link){ 262 if (external_id) { 263 // can we have .pr etc extensions with external ids? 264 node_id = translateExternalId(node_id); 265 } else if (idNeedsTranslating(node_id)) { 266 node_id = translateId(node_id); 267 } 268 } 269 251 270 if (node_id == null) { 252 271 continue; 253 272 } 254 try { 255 Element metadata_list = getMetadataList(node_id, all_metadata, metadata_names_list); 256 request_node.appendChild(metadata_list); 257 } catch (GSException e) { 258 GSXML.addError(this.doc, result, e.getMessage(), e.getType()); 259 if (e.getType().equals(GSXML.ERROR_TYPE_SYSTEM)) { 260 // there is no point trying any others 261 return result; 262 } 263 } 273 if (!is_external_link){ 274 try { 275 Element metadata_list = getMetadataList(node_id, all_metadata, metadata_names_list); 276 request_node.appendChild(metadata_list); 277 } catch (GSException e) { 278 GSXML.addError(this.doc, result, e.getMessage(), e.getType()); 279 if (e.getType().equals(GSXML.ERROR_TYPE_SYSTEM)) { 280 // there is no point trying any others 281 return result; 282 } 283 } 284 }else{ 285 request_node.setAttribute("external_link",request_node.getAttribute(GSXML.NODE_ID_ATT)); 286 } 264 287 } 265 288 … … 366 389 Element doc = (Element) node_list.item(i); 367 390 String doc_id = doc.getAttribute(GSXML.NODE_ID_ATT); 368 if (external_id) { 369 doc_id = translateExternalId(doc_id); 370 doc.setAttribute(GSXML.NODE_ID_ATT, doc_id); 371 } else if (idNeedsTranslating(doc_id)) { 372 doc_id = translateId(doc_id); 373 doc.setAttribute(GSXML.NODE_ID_ATT, doc_id); 374 } 391 String is_external=doc.getAttribute("externalURL"); 392 393 boolean is_external_link = false; 394 if (is_external.equals("0")) {is_external_link = true;} 395 if (!doc_id.startsWith("HASH") && !is_external_link){ 396 if (doc_id.endsWith(".rt")){ 397 doc_id = getHrefOID(doc_id.substring(0,doc_id.length()-3)); 398 if (doc_id!=null){ 399 doc_id += ".rt"; 400 // }else{ 401 // is_external_link = true; 402 // } 403 }else{ 404 doc_id = getHrefOID(doc_id); 405 // if (doc_id==null){ 406 // is_external_link = true; 407 } 408 } 409 } 410 411 if (!is_external_link){ 412 if (external_id) { 413 doc_id = translateExternalId(doc_id); 414 doc.setAttribute(GSXML.NODE_ID_ATT, doc_id); 415 } else if (idNeedsTranslating(doc_id)) { 416 doc_id = translateId(doc_id); 417 doc.setAttribute(GSXML.NODE_ID_ATT, doc_id); 418 } 419 375 420 if (doc_id == null) { 376 421 continue; … … 461 506 } 462 507 } // if want structure 508 509 }else{ 510 Element external_link_elem = this.doc.createElement("external"); 511 external_link_elem.setAttribute("external_link",doc.getAttribute(GSXML.NODE_ID_ATT)); 512 doc.appendChild(external_link_elem); 513 }// if is_external_link 463 514 } // for each doc 464 515 return result; … … 501 552 String[] doc_ids = GSXML.getAttributeValuesFromList(query_doc_list, 502 553 GSXML.NODE_ID_ATT); 554 String[] is_externals=GSXML.getAttributeValuesFromList(query_doc_list,"externalURL"); 555 503 556 for (int i = 0; i < doc_ids.length; i++) { 504 557 String doc_id = doc_ids[i]; 558 String is_external=is_externals[i]; 559 boolean is_external_link=false; 560 if (is_external.equals("0")){is_external_link = true;} 561 if (!doc_id.startsWith("HASH") && !is_external_link){ 562 if (doc_id.endsWith(".rt")){ 563 String find_doc_id = getHrefOID(doc_id.substring(0,doc_id.length()-3)); 564 if (find_doc_id!=null){ 565 doc_id = doc_id + ".rt"; 566 //}else{ 567 //is_external_link=true; 568 } 569 }else { 570 String find_doc_id = getHrefOID(doc_id); 571 if (find_doc_id!=null){ 572 doc_id = find_doc_id; 573 //}else{ 574 //is_external_link=true; 575 } 576 } 577 } 578 579 if (!is_external_link){ 505 580 // Create the document node 506 581 Element doc = this.doc.createElement(GSXML.DOC_NODE_ELEM); … … 525 600 return result; 526 601 602 } 603 }else{ 604 Element doc = this.doc.createElement(GSXML.DOC_NODE_ELEM); 605 doc.setAttribute(GSXML.NODE_ID_ATT, doc_id); 606 //doc.setAttribute("external_link", doc_id); 607 Element external_link_elem = this.doc.createElement("external"); 608 external_link_elem.setAttribute("external_link",doc_id); 609 doc.appendChild(external_link_elem); 610 611 doc_list.appendChild(doc); 527 612 } 528 613 } … … 701 786 */ 702 787 abstract protected String getStructureInfo(String doc_id, String info_type); 788 789 protected String getHrefOID(String href_url){ 790 return null; 791 } 703 792 704 793 }
Note:
See TracChangeset
for help on using the changeset viewer.