Changeset 8828
- Timestamp:
- 2004-12-16T15:27:06+13:00 (19 years ago)
- Location:
- trunk/gsdl3/src/java/org/greenstone/gsdl3/service
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGRetrieve.java
r8674 r8828 122 122 for (int i = 0; i < doc_ids.length; i++) { 123 123 String doc_id = doc_ids[i]; 124 // Create the document node 125 Element doc = this.doc.createElement(GSXML.DOC_NODE_ELEM); 126 doc.setAttribute(GSXML.NODE_ID_ATT, doc_id); 127 doc_list.appendChild(doc); 128 124 129 System.err.println("doc id= "+doc_id); 125 130 if (extlink) { … … 131 136 } else { 132 137 doc_id = this.gdbm_src.extlink2OID(doc_id); 133 134 138 } 139 if (doc_id == null) { 140 System.err.println("extlink "+doc_id +" couldn't be converted to proper id"); 141 continue; 142 } 143 doc.setAttribute(GSXML.NODE_ID_ATT, doc_id); // reset the att cos it may have changed 144 135 145 } 136 146 else if (OID.needsTranslating(doc_id)) { 137 147 doc_id = this.gdbm_src.translateOID(doc_id); 148 doc.setAttribute(GSXML.NODE_ID_ATT, doc_id); // reset the att cos it may have changed 138 149 } 139 System.err.println("remaining dco id = "+doc_id); 150 151 System.err.println("remaining doc id = "+doc_id); 140 152 long doc_num = this.gdbm_src.OID2Docnum(doc_id); 141 153 if (doc_num == -1) { 154 System.err.println("OID "+doc_id +" couldn't be converted to mg num"); 155 continue; 156 } 142 157 String doc_content = this.mg_src.getDocument(basedir, textdir, doc_num); 143 // Create the text node144 Element doc = this.doc.createElement(GSXML.DOC_NODE_ELEM);145 doc.setAttribute(GSXML.NODE_ID_ATT, doc_id);146 doc_list.appendChild(doc);147 158 148 159 if (doc_content!=null) { … … 151 162 //System.err.println("doc content "+doc_content); 152 163 doc_content = doc_content.replaceAll("\u0002|\u0003", ""); 164 System.err.println("replaced ctrl b"); 153 165 // replace _httpimg_ with the correct address 154 166 doc_content = resolveTextMacros(doc_content, doc_id, lang); 167 System.err.println("resolved text macros"); 155 168 GSXML.addDocText(this.doc, doc, doc_content); 169 System.err.println("added text"); 156 170 } else { 157 171 System.err.println("the doc content was null, not getting that section\n"); -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2Retrieve.java
r8823 r8828 379 379 * child is true is it definitely is a child of something - just for efficiency purposes */ 380 380 protected Element createDocNode(String node_id, boolean parent, boolean child) { 381 381 382 // create this here or pass it in? 382 383 DBInfo info = this.gdbm_src.getInfo(node_id); … … 410 411 } 411 412 413 if (info==null) { 414 node = this.doc.createElement(GSXML.DOC_NODE_ELEM); 415 node.setAttribute(GSXML.NODE_ID_ATT, node_id); 416 return node; 417 } 412 418 String top_id = OID.getTop(node_id); 413 419 boolean is_top = (top_id.equals(node_id) ? true : false); … … 436 442 info = this.gdbm_src.getInfo(top_id); 437 443 } 438 439 String childtype = info.getInfo("childtype"); 440 if (childtype.equals("Paged")) { 441 node.setAttribute(GSXML.DOC_TYPE_ATT, "paged"); 442 } else { 443 node.setAttribute(GSXML.DOC_TYPE_ATT, "hierarchy"); 444 if (info != null) { 445 String childtype = info.getInfo("childtype"); 446 if (childtype.equals("Paged")) { 447 node.setAttribute(GSXML.DOC_TYPE_ATT, "paged"); 448 } else { 449 node.setAttribute(GSXML.DOC_TYPE_ATT, "hierarchy"); 450 } 444 451 } 445 452 } … … 481 488 { 482 489 DBInfo info = this.gdbm_src.getInfo(doc_id); 490 if (info == null) { 491 return; 492 } 483 493 String contains = info.getInfo("contains"); 484 494 … … 525 535 { 526 536 DBInfo info = this.gdbm_src.getInfo(oid); 537 if (info == null) { 538 return true; // or should it be false? 539 } 527 540 String children = info.getInfo("contains"); 528 541 return (children.equals("")); … … 639 652 GSXML.NODE_ID_ATT); 640 653 for (int i = 0; i < doc_ids.length; i++) { 641 String doc_id = doc_ids[i];642 643 if (OID.needsTranslating(doc_id)) {644 doc_id = this.gdbm_src.translateOID(doc_id);645 }646 647 654 // Add the document to the list 648 655 Element doc = this.doc.createElement(node_name); 649 656 doc_list.appendChild(doc); 657 658 String doc_id = doc_ids[i]; 650 659 doc.setAttribute(GSXML.NODE_ID_ATT, doc_id); 651 660 661 if (OID.needsTranslating(doc_id)) { 662 doc_id = this.gdbm_src.translateOID(doc_id); 663 if (doc_id == null) { 664 continue; 665 } 666 doc.setAttribute(GSXML.NODE_ID_ATT, doc_id); 667 } 652 668 653 669 if (want_info) { … … 798 814 Element request_node = (Element) request_nodes.item(i); 799 815 String node_id = request_node.getAttribute(GSXML.NODE_ID_ATT); 816 817 // Add the document to the results list 818 Element new_node = (Element)this.doc.importNode(request_node, false); 819 node_list.appendChild(new_node); 800 820 801 821 if (extlink) { … … 812 832 node_id = this.gdbm_src.translateOID(node_id); 813 833 } 814 815 // Add the document to the list 816 Element new_node = (Element)this.doc.importNode(request_node, false); 817 node_list.appendChild(new_node); 834 if (node_id == null) { 835 continue; 836 } 818 837 819 838 // Add the requested metadata information … … 968 987 protected String resolveTextMacros(String doc_content, String doc_id, String lang) 969 988 { 970 String top_doc_id = OID.getTop(doc_id); 971 DBInfo info = this.gdbm_src.getInfo(top_doc_id); 972 String archivedir = info.getInfo("archivedir"); 973 String image_dir = this.site_http_address + "/collect/"+this.cluster_name+"/index/assoc/"+archivedir; 974 975 // Resolve all "_httpdocimg_"s 976 doc_content = doc_content.replaceAll("_httpdocimg_", image_dir); 989 DBInfo info = null; 990 if (doc_content.indexOf("_httpdocimg_")!=-1) { 991 String top_doc_id = OID.getTop(doc_id); 992 info = this.gdbm_src.getInfo(top_doc_id); 993 if (info == null) { 994 // perhaps we had per.iods in the ids - just try the current id 995 top_doc_id = doc_id; 996 info = this.gdbm_src.getInfo(top_doc_id); 997 } 998 if (info != null) { 999 String archivedir = info.getInfo("archivedir"); 1000 String image_dir = this.site_http_address + "/collect/"+this.cluster_name+"/index/assoc/"+archivedir; 1001 1002 // Resolve all "_httpdocimg_"s 1003 doc_content = doc_content.replaceAll("_httpdocimg_", image_dir); 1004 } 1005 } 977 1006 // resolve any collection specific macros 978 doc_content = macro_resolver.resolve(doc_content, lang, GS2MacroResolver.SCOPE_TEXT, top_doc_id, info);1007 doc_content = macro_resolver.resolve(doc_content, lang, GS2MacroResolver.SCOPE_TEXT, doc_id, info); 979 1008 return doc_content; 980 1009 } … … 998 1027 } else { 999 1028 DBInfo info = this.gdbm_src.getInfo(parent_id); 1000 String contains = info.getInfo("contains"); 1001 contains = contains.replaceAll("\"", parent_id); 1002 String [] children = contains.split(";"); 1003 for (int i=0;i<children.length;i++) { 1004 String child_id = children[i]; 1005 if (child_id.equals(doc_id)) { 1006 value = String.valueOf(i+1); // make it from 1 to length 1007 break; 1029 if (info==null) { 1030 value ="-1"; 1031 } else { 1032 String contains = info.getInfo("contains"); 1033 contains = contains.replaceAll("\"", parent_id); 1034 String [] children = contains.split(";"); 1035 for (int i=0;i<children.length;i++) { 1036 String child_id = children[i]; 1037 if (child_id.equals(doc_id)) { 1038 value = String.valueOf(i+1); // make it from 1 to length 1039 break; 1040 } 1008 1041 } 1009 1042 } … … 1020 1053 protected int getNumChildren(String doc_id) { 1021 1054 DBInfo info = this.gdbm_src.getInfo(doc_id); 1055 if (info == null) { 1056 return 0; 1057 } 1022 1058 String contains = info.getInfo("contains"); 1023 1059 if (contains.equals("")) {
Note:
See TracChangeset
for help on using the changeset viewer.