Changeset 3901
- Timestamp:
- 2003-03-18T15:07:27+12:00 (21 years ago)
- Location:
- trunk/gsdl3/src/java/org/greenstone/gsdl3/service
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGPPRetrieve.java
r3862 r3901 77 77 } 78 78 79 80 /** Retrieve the structure of a document - this function needed as its called specifically on the class name*/ 81 protected Element processDocumentStructureRetrieve(Element request) 82 { 83 return super.processDocumentStructureRetrieve(request); 84 } 85 86 87 /** Retrieve metadata associated with a document - this function needed as its called specifically on the class name*/ 88 protected Element processDocumentMetadataRetrieve(Element request) 89 { 90 return super.processDocumentMetadataRetrieve(request); 91 } 92 93 79 94 80 /** Retrieve the content of a document */ 95 81 protected Element processDocumentContentRetrieve(Element request) … … 100 86 result.setAttribute(GSXML.FROM_ATT, from); 101 87 result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 102 //Element result_content = doc_.createElement(GSXML.CONTENT_ELEM);103 //result.appendChild(result_content);104 88 105 89 // Get the parameters of the request - not used at the moment … … 121 105 122 106 // Get the documents 123 //String[] doc_ids = GSXML.getDocumentNameList(content);124 107 String[] doc_ids = GSXML.getAttributeValuesFromList(query_doc_list, 125 108 GSXML.DOC_NODE_ID_ATT); 126 109 for (int i = 0; i < doc_ids.length; i++) { 127 110 String doc_id = doc_ids[i]; 111 112 if (OID.needsTranslating(doc_id)) { 113 doc_id = gdbm_src_.translateOID(doc_id); 114 } 115 128 116 long doc_num = gdbm_src_.oid2Docnum(doc_id); 129 117 String doc_content = mgpp_src_.getDocument(basedir, textdir, default_level_, doc_num); … … 141 129 } 142 130 } 131 -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGRetrieve.java
r3862 r3901 80 80 81 81 82 /** Retrieve the structure of a document */83 protected Element processDocumentStructureRetrieve(Element request)84 {85 return super.processDocumentStructureRetrieve(request);86 }87 88 89 /** Retrieve metadata associated with a document */90 protected Element processDocumentMetadataRetrieve(Element request)91 {92 return super.processDocumentMetadataRetrieve(request);93 }94 95 96 82 /** Retrieve the content of a document */ 97 83 protected Element processDocumentContentRetrieve(Element request) … … 102 88 result.setAttribute(GSXML.FROM_ATT, from); 103 89 result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 104 //Element result_content = doc_.createElement(GSXML.CONTENT_ELEM);105 //result.appendChild(result_content);106 90 107 91 // Get the parameters of the request - no parameters at this stage 108 92 //Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 109 93 110 // Get the request content 94 // Get the request content 111 95 112 96 Element query_doc_list = (Element) GSXML.getChildByTagName(request, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER); … … 128 112 129 113 // Get the documents 130 //String[] doc_ids = GSXML.getDocumentNameList(query_doc_list);131 114 String[] doc_ids = GSXML.getAttributeValuesFromList(query_doc_list, 132 GSXML.DOC_NODE_ID_ATT);115 GSXML.DOC_NODE_ID_ATT); 133 116 for (int i = 0; i < doc_ids.length; i++) { 134 117 String doc_id = doc_ids[i]; 118 if (OID.needsTranslating(doc_id)) { 119 doc_id = gdbm_src_.translateOID(doc_id); 120 } 135 121 long doc_num = gdbm_src_.oid2Docnum(doc_id); 136 122 String doc_content = mg_src_.getDocument(basedir, textdir, doc_num); -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2Retrieve.java
r3866 r3901 33 33 34 34 35 /** 35 /** Implements the generic retrieval and classifier services for GS2 36 * collections. 36 37 * 37 38 * @author <a href="mailto:[email protected]">Katherine Don</a> 39 * @author <a href="mailto:[email protected]">Michael Dewsnip</a> 38 40 * @version $Revision$ 39 41 */ … … 48 50 protected static final String DOCUMENT_CONTENT_RETRIEVE_SERVICE = "DocumentContentRetrieve"; 49 51 52 53 // the browsing services - now in here, these will only be advertised if classifiers have been specified in the config file 54 private static final String CLASSIFIER_SERVICE = "ClassifierBrowse"; 55 private static final String CLASSIFIER_METADATA_SERVICE = "ClassifierBrowseMetadataRetrieve"; 56 57 protected static final int DOCUMENT=1; 58 protected static final int CLASSIFIER=2; 59 50 60 protected GDBMWrapper gdbm_src_ = null; 51 61 62 protected Element config_info_ = null; // the xml from the config file 52 63 53 64 /** constructor */ … … 62 73 { 63 74 System.out.println("Configuring GS2Retrieve..."); 75 config_info_ = info; 64 76 65 77 // set up short_service_info_ - for now just has name and type … … 92 104 } 93 105 106 // now do the classifier browse service 107 108 // check that there are classifiers specified 109 Element class_list = (Element)GSXML.getChildByTagName(info, GSXML.CLASSIFIER_ELEM+GSXML.LIST_MODIFIER); 110 if (class_list == null) { 111 // no classifiers specified 112 return true; 113 } 114 115 // short_service_info_ - the browse one 116 Element cb_service = doc_.createElement(GSXML.SERVICE_ELEM); 117 cb_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_BROWSE); 118 cb_service.setAttribute(GSXML.NAME_ATT, CLASSIFIER_SERVICE); 119 short_service_info_.appendChild(cb_service); 120 121 // metadata retrieval for the browsing 122 Element cbmr_service = doc_.createElement(GSXML.SERVICE_ELEM); 123 cbmr_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 124 cbmr_service.setAttribute(GSXML.NAME_ATT, CLASSIFIER_METADATA_SERVICE); 125 short_service_info_.appendChild(cbmr_service); 126 127 // service_info_map_ 128 129 // the metadata one has the same info for now - should this advertise what metadata is available?? 130 Element cbmr_service_info = (Element) cbmr_service.cloneNode(true); 131 service_info_map_.put(CLASSIFIER_METADATA_SERVICE, cbmr_service_info); 132 133 //the browse one 134 Element cb_service_info = (Element)cb_service.cloneNode(true); 135 Element cl_list = doc_.createElement(GSXML.CLASSIFIER_ELEM+GSXML.LIST_MODIFIER); 136 cb_service_info.appendChild(cl_list); 137 138 // add in to the description a simplified list of classifiers 139 NodeList classifiers = class_list.getElementsByTagName(GSXML.CLASSIFIER_ELEM); 140 for(int i=0; i<classifiers.getLength(); i++) { 141 Element cl = (Element)classifiers.item(i); 142 Element new_cl = (Element)doc_.importNode(cl, false); // just import this node, not the children 143 144 cl_list.appendChild(new_cl); 145 146 } 147 148 service_info_map_.put(CLASSIFIER_SERVICE, cb_service_info); 149 94 150 return true; 95 151 } 96 152 97 153 98 154 /** creates a display element containing all the text strings needed to display the service page, in the language specified 99 * these retrieval services dont get displayed to the users - they are only used internally by the actions. so this returns an empty display element*/ 155 * the retrieval services dont get displayed to the users - they are only used internally by the actions. so this returns an empty display element 156 * for those services. CLASSIFIER_BROWSE service returns some info */ 100 157 protected Element createServiceDisplay(String service, String lang) 101 158 { 102 return doc_.createElement(GSXML.DISPLAY_ELEM); 103 } 104 105 159 Element display = doc_.createElement(GSXML.DISPLAY_ELEM); 160 if (!service.equals(CLASSIFIER_SERVICE)) { 161 return display; 162 } 163 164 // CLASSIFIER_SERVICE 165 display.appendChild(GSXML.createTextElement(doc_, GSXML.DISPLAY_NAME_ELEM, getTextString(service+".name", lang))); 166 //display.appendChild(GSXML.createTextElement(doc_, GSXML.DISPLAY_SUBMIT_ELEM, getTextString(service+".submit", lang))); 167 168 // need to add in the classifier name info 169 // add <classifier name="CL1">text name</classifier> to the 170 // display node 171 NodeList classifiers = config_info_.getElementsByTagName(GSXML.CLASSIFIER_ELEM); 172 for (int i=0; i<classifiers.getLength(); i++) { 173 Element cl = (Element)classifiers.item(i); 174 Element disp = (Element)GSXML.getChildByTagName(cl, GSXML.DISPLAY_ELEM); 175 String text = null; 176 if (disp !=null) { 177 text = GSXML.getDisplayText(disp, 178 GSXML.DISPLAY_NAME_ELEM, 179 lang, "en"); 180 } 181 if (text == null || text.equals("")) { 182 // no display element was specified, use the metadata name 183 // for now this looks in the class properties file 184 // this needs to use a general metadata thing instead 185 text = getTextString(cl.getAttribute(GSXML.CLASSIFIER_CONTENT_ATT), lang); 186 } 187 188 Element cl_elem = doc_.createElement(GSXML.CLASSIFIER_ELEM); 189 cl_elem.setAttribute(GSXML.NAME_ATT, cl.getAttribute(GSXML.NAME_ATT)); 190 Element cl_name = GSXML.createTextElement(doc_, GSXML.DISPLAY_NAME_ELEM, text); 191 cl_elem.appendChild(cl_name); 192 193 display.appendChild(cl_elem); 194 195 } 196 197 return display; 198 199 } 200 201 /** parent is true if this node is definitely the parent of something, 202 * child is true is it definitely is a child of something - just for efficiency purposes */ 203 protected Element createDocNode(String doc_id, boolean parent, boolean child) { 204 205 // create this here or pass it in? 206 DBInfo db_info = gdbm_src_.getInfo(doc_id); 207 Element node; 208 if (isClassifier(doc_id)) { 209 node = doc_.createElement(GSXML.CLASS_NODE_ELEM); 210 String childtype = db_info.getInfo("childtype"); 211 String orientation=""; 212 if (childtype.equals("HList")) { 213 orientation = "horizontal"; 214 } else { // assume vertical 215 orientation = "vertical"; 216 } 217 node.setAttribute(GSXML.CLASS_NODE_ORIENTATION_ATT, orientation); 218 } else { 219 node = doc_.createElement(GSXML.DOC_NODE_ELEM); 220 if (!child && OID.isTop(doc_id)) { 221 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_ROOT); 222 } else if (!parent && isLeafNode(doc_id)) { 223 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF); 224 } else { 225 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_INTERIOR); 226 } 227 } 228 node.setAttribute(GSXML.NODE_ID_ATT, doc_id); 229 return node; 230 231 } 106 232 /** Returns the parent of a specified documentID, or null if none exists */ 107 233 protected Element getParent(String doc_id) 108 234 { 109 235 String parent_id = OID.getParent(doc_id); 110 if (parent_id == "")236 if (parent_id.equals(doc_id)) 111 237 return null; 112 113 Element parent = doc_.createElement(GSXML.DOC_NODE_ELEM); 114 parent.setAttribute(GSXML.DOC_NODE_ID_ATT, parent_id); 115 if (OID.isTop(parent_id)) 116 parent.setAttribute(GSXML.DOC_NODE_TYPE_ATT, GSXML.NODE_TYPE_ROOT); 117 else 118 parent.setAttribute(GSXML.DOC_NODE_TYPE_ATT, GSXML.NODE_TYPE_INTERIOR); 119 120 return parent; 121 } 122 123 124 /** */ 125 protected void addDescendants(Element doc, String doc_id, boolean recursive) 238 239 return createDocNode(parent_id, true, false); 240 } 241 242 243 /** adds all the children of doc_id the the doc element, 244 * and if recursive=true, adds all their children as well*/ 245 protected void addDescendants(Element doc, String doc_id, 246 boolean recursive) 126 247 { 127 248 DBInfo info = gdbm_src_.getInfo(doc_id); … … 131 252 while (st.hasMoreTokens()) { 132 253 String child_id = st.nextToken().replaceAll("\"", doc_id); 133 Element child = doc_.createElement(GSXML.DOC_NODE_ELEM);254 Element child = createDocNode(child_id, false, true); 134 255 doc.appendChild(child); 135 child.setAttribute(GSXML.DOC_NODE_ID_ATT, child_id);136 256 137 257 // Apply recursively, if desired … … 139 259 addDescendants(child, child_id, recursive); 140 260 } 141 142 // Record if the node is a leaf node or an internal node 143 if (isLeafNode(child_id)) 144 child.setAttribute(GSXML.DOC_NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF); 145 else 146 child.setAttribute(GSXML.DOC_NODE_TYPE_ATT, GSXML.NODE_TYPE_INTERIOR); 147 } 148 } 149 150 261 262 } 263 } 264 265 /** adds all the siblings of current_id to the parent element. */ 266 protected Element addSiblings(Element parent, String parent_id, String current_id) { 267 Element current_node = (Element)parent.getFirstChild(); 268 if (current_node ==null) { 269 // create a sensible error message 270 System.err.println("Error: there should be a first child."); 271 return null; 272 } 273 // remove the current child,- will add it in later in its correct place 274 parent.removeChild(current_node); 275 276 // add in all the siblings, 277 addDescendants(parent, parent_id, false); 278 279 // find the node that is now the current node 280 // this assumes that the new node that was created is the same as 281 // the old one that was removed - we may want to replace the new one 282 // with the old one. 283 Element new_current = GSXML.getNamedElement(parent, current_node.getNodeName(), GSXML.NODE_ID_ATT, current_id); 284 return new_current; 285 286 } 151 287 /** Returns true if the OID specifies a leaf node, false otherwise 152 288 Note: this makes a request to the GDBM database so it may not be … … 159 295 } 160 296 297 // for now just use CL for classifiers - should have a type? in teh gdbm 298 // database. 299 protected boolean isClassifier(String oid) { 300 if (oid.startsWith("CL")) { 301 return true; 302 } 303 return false; 304 } 305 306 protected Element processDocumentStructureRetrieve(Element request) { 307 return genericStructureRetrieve(request, DOCUMENT); 308 } 309 310 protected Element processClassifierBrowse(Element request) { 311 return genericStructureRetrieve(request, CLASSIFIER); 312 } 161 313 162 314 /** Retrieve the structure of a document */ 163 protected Element processDocumentStructureRetrieve(Element request)315 protected Element genericStructureRetrieve(Element request, int type) 164 316 { 165 317 // Create a new (empty) result message 166 318 Element result = doc_.createElement(GSXML.RESPONSE_ELEM); 167 String from = GSPath.appendLink(cluster_name_, DOCUMENT_STRUCTURE_RETRIEVE_SERVICE); 319 320 String node_name; 321 String from; 322 if (type==DOCUMENT) { 323 from = GSPath.appendLink(cluster_name_, DOCUMENT_STRUCTURE_RETRIEVE_SERVICE); 324 node_name = GSXML.DOC_NODE_ELEM; 325 } else { 326 from = GSPath.appendLink(cluster_name_, CLASSIFIER_SERVICE); 327 node_name = GSXML.CLASS_NODE_ELEM; 328 } 329 168 330 result.setAttribute(GSXML.FROM_ATT, from); 169 331 result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 170 //Element result_content = doc_.createElement(GSXML.CONTENT_ELEM);171 //result.appendChild(result_content);172 332 173 333 // Get the parameters of the request … … 221 381 if (wantDescendants) 222 382 wantChildren = false; 223 224 // // Get the request content 225 // Element content = (Element) GSXML.getChildByTagName(request, GSXML.CONTENT_ELEM); 226 // if (content == null) { 227 // System.err.println("Error: DocumentStructureRetrieve request had no content."); 228 // return result; 229 // } 230 231 Element query_doc_list = (Element) GSXML.getChildByTagName(request, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER); 383 384 385 Element query_doc_list = (Element) GSXML.getChildByTagName(request, node_name+GSXML.LIST_MODIFIER); 232 386 if (query_doc_list == null) { 233 387 System.err.println("Error: DocumentStructureRetrieve request specified no doc nodes.\n"); 234 388 return result; 235 389 } 236 237 Element doc_list = doc_.createElement( GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);390 391 Element doc_list = doc_.createElement(node_name+GSXML.LIST_MODIFIER); 238 392 result.appendChild(doc_list); 239 393 240 394 // Get the documents 241 395 String[] doc_ids = GSXML.getAttributeValuesFromList(query_doc_list, 242 GSXML. DOC_NODE_ID_ATT);396 GSXML.NODE_ID_ATT); 243 397 for (int i = 0; i < doc_ids.length; i++) { 244 398 String doc_id = doc_ids[i]; 245 399 400 401 if (OID.needsTranslating(doc_id)) { 402 doc_id = gdbm_src_.translateOID(doc_id); 403 } 404 246 405 // Add the document to the list 247 Element doc = doc_.createElement( GSXML.DOC_NODE_ELEM);406 Element doc = doc_.createElement(node_name); 248 407 doc_list.appendChild(doc); 249 doc.setAttribute(GSXML. DOC_NODE_ID_ATT, doc_id);408 doc.setAttribute(GSXML.NODE_ID_ATT, doc_id); 250 409 // all structure info goes into a docNodestructure elem 410 // classifier elem should be something else??? 251 411 Element structure_elem = doc_.createElement(GSXML.DOC_NODE_STRUCTURE_ELEM); 252 412 doc.appendChild(structure_elem); 413 253 414 // Add the requested structure information 254 Element current = doc_.createElement(GSXML.DOC_NODE_ELEM); 255 current.setAttribute(GSXML.DOC_NODE_ID_ATT, doc_id); 256 if (OID.isTop(doc_id)) 257 current.setAttribute(GSXML.DOC_NODE_TYPE_ATT, GSXML.NODE_TYPE_ROOT); 258 else if (isLeafNode(doc_id)) 259 current.setAttribute(GSXML.DOC_NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF); 260 else 261 current.setAttribute(GSXML.DOC_NODE_TYPE_ATT, GSXML.NODE_TYPE_INTERIOR); 262 263 // Ancestors: continually add parent nodes until the root is reached 415 Element current = createDocNode(doc_id, false, false); 416 417 //Ancestors: continually add parent nodes until the root is reached 418 Element top_node = current; // the top node so far 264 419 if (wantAncestors) { 265 420 String current_id = doc_id; 266 Element current_node = current;267 421 while (true) { 268 422 Element parent = getParent(current_id); … … 270 424 break; 271 425 272 parent.appendChild( current_node);273 current_ node = parent;274 current_id = OID.getParent(current_id);426 parent.appendChild(top_node); 427 current_id = parent.getAttribute(GSXML.NODE_ID_ATT); 428 top_node = parent; 275 429 } 276 430 } … … 280 434 if (parent != null) { 281 435 parent.appendChild(current); 436 top_node = parent; 282 437 } 283 438 } 284 439 285 // Siblings: get the other descendants of the selected node's parent 440 // now the top node is the root of the structure 441 structure_elem.appendChild(top_node); 442 443 //Siblings: get the other descendants of the selected node's parent 286 444 if (wantSiblings) { 287 // !! TO DO !! 288 } 445 Element parent = (Element)current.getParentNode(); // this may be the structure element if there has been no request for parents or ancestors 446 String parent_id = OID.getParent(doc_id); 447 448 // add siblings, - returns a pointer to the new current node 449 current = addSiblings(parent, parent_id, doc_id); 450 } 289 451 290 452 // Children: get the descendants, but only one level deep … … 294 456 if (wantDescendants) 295 457 addDescendants(current, doc_id, true); 296 297 // Add the root of the structure information to the document 298 Element root = current; 299 while (true) { 300 if (root.getParentNode() == null) 301 break; 302 303 root = (Element) root.getParentNode(); 304 } 305 structure_elem.appendChild(root); 306 } 307 458 } 459 //System.out.println("the result of structure retrieve is"); 460 //System.out.println(converter_.getString(result)); 308 461 return result; 309 462 } 310 463 311 464 312 /** Retrieve metadata associated with a document */ 313 protected Element processDocumentMetadataRetrieve(Element request) 465 protected Element processDocumentMetadataRetrieve(Element request) { 466 return genericMetadataRetrieve(request, DOCUMENT); 467 } 468 469 protected Element processClassifierBrowseMetadataRetrieve(Element request) { 470 return genericMetadataRetrieve(request, CLASSIFIER); 471 } 472 473 474 /** Retrieve metadata associated with a document or classifier node*/ 475 protected Element genericMetadataRetrieve(Element request, int type) 314 476 { 315 477 // Create a new (empty) result message 316 478 Element result = doc_.createElement(GSXML.RESPONSE_ELEM); 317 String from = GSPath.appendLink(cluster_name_, DOCUMENT_METADATA_RETRIEVE_SERVICE); 479 480 String node_name; 481 482 String from; 483 if (type==DOCUMENT) { 484 from = GSPath.appendLink(cluster_name_, DOCUMENT_METADATA_RETRIEVE_SERVICE); 485 node_name = GSXML.DOC_NODE_ELEM; 486 } else { 487 from = GSPath.appendLink(cluster_name_, CLASSIFIER_METADATA_SERVICE); 488 node_name = GSXML.CLASS_NODE_ELEM; 489 } 318 490 result.setAttribute(GSXML.FROM_ATT, from); 319 491 result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 320 //Element result_content = doc_.createElement(GSXML.CONTENT_ELEM);321 //result.appendChild(result_content);322 492 323 493 // Get the parameters of the request … … 330 500 // The metadata information required 331 501 Vector metadata_list = new Vector(); 332 502 333 503 // Process the request parameters 334 504 Element param = (Element) param_list.getFirstChild(); 335 505 while (param != null) { 336 if (!param.getNodeName().equals(GSXML.PARAM_ELEM)) { 337 System.err.println("Warning: Non-param in paramList (ignored)."); 338 } 339 else { 340 // Identify the metadata information desired 341 if (param.getAttribute(GSXML.NAME_ATT) == "metadata") { 342 String metadata = GSXML.getValue(param); 343 System.out.println("Metadata desired: " + metadata); 344 metadata_list.add(metadata); 345 } 346 } 347 506 // Identify the metadata information desired 507 if (param.getAttribute(GSXML.NAME_ATT) == "metadata") { 508 String metadata = GSXML.getValue(param); 509 System.out.println("Metadata desired: " + metadata); 510 metadata_list.add(metadata); 511 break; // metadata is the only one we are after 512 } 348 513 param = (Element) param.getNextSibling(); 349 514 } 350 351 // Get the request content 352 // Element content = (Element) GSXML.getChildByTagName(request, GSXML.CONTENT_ELEM); 353 // if (content == null) { 354 // System.err.println("Error: DocumentMetadataRetrieve request had no content.\n"); 355 // return result; 356 // } 357 358 Element doc_list = doc_.createElement(GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER); 359 //result_content.appendChild(doc_list); 360 result.appendChild(doc_list); 515 516 Element node_list = doc_.createElement(node_name+GSXML.LIST_MODIFIER); 517 result.appendChild(node_list); 361 518 362 519 // Get the documents 363 //Element request_doc_list = (Element) GSXML.getChildByTagName(content, GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER); 364 Element request_doc_list = (Element) GSXML.getChildByTagName(request, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER); 365 if (request_doc_list == null) { 366 System.err.println("Error: DocumentMetadataRetrieve request had no documentList.\n"); 520 Element request_node_list = (Element) GSXML.getChildByTagName(request, node_name+GSXML.LIST_MODIFIER); 521 if (request_node_list == null) { 522 System.err.println("Error: DocumentMetadataRetrieve request had no "+node_name+"List.\n"); 367 523 return result; 368 524 } 369 NodeList request_docs = request_doc_list.getChildNodes(); 370 for (int i = 0; i < request_docs.getLength(); i++) { 371 Element request_doc = (Element) request_docs.item(i); 372 String doc_id = request_doc.getAttribute(GSXML.DOC_NODE_ID_ATT); 373 System.out.println("Retrieving metadata for " + doc_id + "..."); 525 526 NodeList request_nodes = request_node_list.getChildNodes(); 527 for (int i = 0; i < request_nodes.getLength(); i++) { 528 Element request_node = (Element) request_nodes.item(i); 529 String node_id = request_node.getAttribute(GSXML.NODE_ID_ATT); 530 System.out.println("Retrieving metadata for " + node_id + "..."); 531 532 533 if (OID.needsTranslating(node_id)) { 534 node_id = gdbm_src_.translateOID(node_id); 535 } 374 536 375 537 // Add the document to the list 376 Element doc_node = doc_.createElement(GSXML.DOC_NODE_ELEM); 377 doc_list.appendChild(doc_node); 378 doc_node.setAttribute(GSXML.DOC_NODE_ID_ATT, doc_id); 379 doc_node.setAttribute(GSXML.DOC_NODE_TYPE_ATT, 380 request_doc.getAttribute(GSXML.DOC_NODE_TYPE_ATT)); 538 Element new_node = (Element)doc_.importNode(request_node, false); 539 node_list.appendChild(new_node); 381 540 382 541 // Add the requested metadata information 383 Element doc_meta_list = doc_.createElement(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);384 doc_node.appendChild(doc_meta_list);385 DBInfo info = gdbm_src_.getInfo( doc_id);542 Element node_meta_list = doc_.createElement(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER); 543 new_node.appendChild(node_meta_list); 544 DBInfo info = gdbm_src_.getInfo(node_id); 386 545 for (int m = 0; m < metadata_list.size(); m++) { 387 546 String metadata = (String) metadata_list.get(m); 388 547 String value = info.getInfo(metadata); 389 GSXML.addMetadata(doc_, doc_meta_list, metadata, value);390 } 391 } 392 548 GSXML.addMetadata(doc_, node_meta_list, metadata, value); 549 } 550 } 551 393 552 return result; 394 553 }
Note:
See TracChangeset
for help on using the changeset viewer.