source: trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2Retrieve.java@ 3939

Last change on this file since 3939 was 3938, checked in by kjdon, 21 years ago

configure takes two args - the xml for teh service plus some optional stuff - eg teh collection configuration file - its up to teh service now to extract what it needs. the query services need the index specific display elements and a general format element, the classifier services need classifier specific display and format stuff.

  • Property svn:keywords set to Author Date Id Revision
File size: 22.8 KB
Line 
1/*
2 * GS2Retrieve.java
3 * Copyright (C) 2002 New Zealand Digital Library, http://www.nzdl.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19package org.greenstone.gsdl3.service;
20
21
22// Greenstone classes
23import org.greenstone.gdbm.*;
24import org.greenstone.gsdl3.util.*;
25
26// XML classes
27import org.w3c.dom.Document;
28import org.w3c.dom.Element;
29import org.w3c.dom.NodeList;
30
31// General Java classes
32import java.util.StringTokenizer;
33import java.util.Vector;
34
35
36/** Implements the generic retrieval and classifier services for GS2
37 * collections.
38 *
39 * @author <a href="mailto:[email protected]">Katherine Don</a>
40 * @author <a href="mailto:[email protected]">Michael Dewsnip</a>
41 * @version $Revision: 3938 $
42 */
43
44public abstract class GS2Retrieve
45 extends ServiceRack {
46
47 // the services on offer
48 // these strings must match what is found in the properties file
49 protected static final String DOCUMENT_STRUCTURE_RETRIEVE_SERVICE = "DocumentStructureRetrieve";
50 protected static final String DOCUMENT_METADATA_RETRIEVE_SERVICE = "DocumentMetadataRetrieve";
51 protected static final String DOCUMENT_CONTENT_RETRIEVE_SERVICE = "DocumentContentRetrieve";
52
53
54 // the browsing services - now in here, these will only be advertised if classifiers have been specified in the config file
55 private static final String CLASSIFIER_SERVICE = "ClassifierBrowse";
56 private static final String CLASSIFIER_METADATA_SERVICE = "ClassifierBrowseMetadataRetrieve";
57
58 protected static final int DOCUMENT=1;
59 protected static final int CLASSIFIER=2;
60
61 protected GDBMWrapper gdbm_src_ = null;
62
63 protected Element config_info_ = null; // the xml from the config file
64
65 /** constructor */
66 protected GS2Retrieve()
67 {
68 gdbm_src_ = new GDBMWrapper();
69 }
70
71
72 /** configure this service */
73 public boolean configure(Element info, Element extra_info)
74 {
75 System.out.println("Configuring GS2Retrieve...");
76 config_info_ = info;
77
78 // set up short_service_info_ - for now just has name and type
79 Element dsr_service = doc_.createElement(GSXML.SERVICE_ELEM);
80 dsr_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE);
81 dsr_service.setAttribute(GSXML.NAME_ATT, DOCUMENT_STRUCTURE_RETRIEVE_SERVICE);
82 short_service_info_.appendChild(dsr_service);
83
84 Element dmr_service = doc_.createElement(GSXML.SERVICE_ELEM);
85 dmr_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE);
86 dmr_service.setAttribute(GSXML.NAME_ATT, DOCUMENT_METADATA_RETRIEVE_SERVICE);
87 short_service_info_.appendChild(dmr_service);
88
89 Element dcr_service = doc_.createElement(GSXML.SERVICE_ELEM);
90 dcr_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE);
91 dcr_service.setAttribute(GSXML.NAME_ATT, DOCUMENT_CONTENT_RETRIEVE_SERVICE);
92 short_service_info_.appendChild(dcr_service);
93
94 // set up service_info_map_ - for now, just has the same elements as above
95 // should have full details about each service incl params lists etc.
96 service_info_map_.put(DOCUMENT_STRUCTURE_RETRIEVE_SERVICE, dsr_service);
97 service_info_map_.put(DOCUMENT_METADATA_RETRIEVE_SERVICE, dmr_service);
98 service_info_map_.put(DOCUMENT_CONTENT_RETRIEVE_SERVICE, dcr_service);
99
100 // Open GDBM database for querying
101 String gdbm_db_file = GSFile.GDBMDatabaseFile(site_home_, cluster_name_);
102 if (!gdbm_src_.openDatabase(gdbm_db_file, GDBMWrapper.READER)) {
103 System.err.println("Error: Could not open GDBM database!");
104 return false;
105 }
106
107 // now do the classifier browse service
108
109 // check that there are classifiers specified
110 Element class_list = (Element)GSXML.getChildByTagName(info, GSXML.CLASSIFIER_ELEM+GSXML.LIST_MODIFIER);
111 if (class_list == null) {
112 // no classifiers specified
113 return true;
114 }
115
116 // get the display and format elements from the coll config file for
117 // the classifiers
118 extractExtraClassifierInfo(info, extra_info);
119 config_info_ = info;
120
121 // short_service_info_ - the browse one
122 Element cb_service = doc_.createElement(GSXML.SERVICE_ELEM);
123 cb_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_BROWSE);
124 cb_service.setAttribute(GSXML.NAME_ATT, CLASSIFIER_SERVICE);
125 short_service_info_.appendChild(cb_service);
126
127 // metadata retrieval for the browsing
128 Element cbmr_service = doc_.createElement(GSXML.SERVICE_ELEM);
129 cbmr_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE);
130 cbmr_service.setAttribute(GSXML.NAME_ATT, CLASSIFIER_METADATA_SERVICE);
131 short_service_info_.appendChild(cbmr_service);
132
133 // service_info_map_
134
135 // the metadata one has the same info for now - should this advertise what metadata is available??
136 Element cbmr_service_info = (Element) cbmr_service.cloneNode(true);
137 service_info_map_.put(CLASSIFIER_METADATA_SERVICE, cbmr_service_info);
138
139 //the browse one
140 Element cb_service_info = (Element)cb_service.cloneNode(true);
141 Element cl_list = doc_.createElement(GSXML.CLASSIFIER_ELEM+GSXML.LIST_MODIFIER);
142 cb_service_info.appendChild(cl_list);
143
144 // the format info
145 Element cb_format_info = doc_.createElement(GSXML.FORMAT_ELEM);
146 boolean format_found = false;
147 // add in to the description a simplified list of classifiers
148 NodeList classifiers = class_list.getElementsByTagName(GSXML.CLASSIFIER_ELEM);
149 for(int i=0; i<classifiers.getLength(); i++) {
150 Element cl = (Element)classifiers.item(i);
151 Element new_cl = (Element)doc_.importNode(cl, false); // just import this node, not the children
152
153 cl_list.appendChild(new_cl);
154
155 // get the format info out, and put inside a classifier element
156 Element format_cl = (Element)new_cl.cloneNode(false);
157 Element format = (Element)GSXML.getChildByTagName(cl, GSXML.FORMAT_ELEM);
158 if (format != null) {
159
160 //copy all the children
161 NodeList elems = format.getChildNodes();
162 for (int j=0; j<elems.getLength();j++) {
163 format_cl.appendChild(doc_.importNode(elems.item(j), true));
164 }
165 cb_format_info.appendChild(format_cl);
166 format_found = true;
167 }
168
169
170 }
171
172
173 service_info_map_.put(CLASSIFIER_SERVICE, cb_service_info);
174 if (format_found) {
175 format_info_map_.put(CLASSIFIER_SERVICE, cb_format_info);
176 }
177 return true;
178 }
179
180 /** this looks for any classifier specific display or format info from extra_info and adds it in to the correct place in info */
181 protected boolean extractExtraClassifierInfo(Element info, Element extra_info) {
182
183 if (extra_info == null) {
184 return false;
185 }
186
187 Document owner = info.getOwnerDocument();
188 // so far we have display and format elements that we need for classifiers
189 NodeList classifiers = info.getElementsByTagName(GSXML.CLASSIFIER_ELEM);
190 Element config_browse = (Element)GSXML.getChildByTagName(extra_info, GSXML.BROWSE_ELEM);
191
192 for (int i=0; i<classifiers.getLength();i++) {
193 Element cl = (Element)classifiers.item(i);
194 String name = cl.getAttribute(GSXML.NAME_ATT);
195 Element node_extra = GSXML.getNamedElement(config_browse,
196 GSXML.CLASSIFIER_ELEM,
197 GSXML.NAME_ATT,
198 name);
199 if (node_extra == null) {
200 System.out.println("haven't found extra info for classifier named "+name);
201 continue;
202 }
203
204 // get the display elements if any - displayName
205 NodeList display_names = node_extra.getElementsByTagName(GSXML.DISPLAYNAME_ELEM);
206 if (display_names !=null) {
207 Element display = owner.createElement(GSXML.DISPLAY_ELEM);
208 for (int j=0; j<display_names.getLength(); j++) {
209 Element e = (Element)display_names.item(j);
210
211 Element display_name = GSXML.createTextElement(owner, GSXML.DISPLAY_NAME_ELEM, GSXML.getNodeText(e));
212 display_name.setAttribute(GSXML.LANG_ATT, e.getAttribute(GSXML.LANG_ATT));
213 display.appendChild(display_name);
214 }
215 cl.appendChild(display);
216 }
217
218 // get the format element if any
219 Element format = (Element)GSXML.getChildByTagName(node_extra, GSXML.FORMAT_ELEM);
220 if (format==null) { // try a generic one that applies to all classifiers
221 format = (Element)GSXML.getChildByTagName(extra_info,
222 GSXML.FORMAT_ELEM);
223 }
224 if (format!=null) { // append to index info
225 cl.appendChild(owner.importNode(format, true));
226 }
227 } // for each classifier
228 return true;
229 }
230
231
232 /** creates a display element containing all the text strings needed to display the service page, in the language specified
233 * the retrieval services dont get displayed to the users - they are only used internally by the actions. so this returns an empty display element
234 * for those services. CLASSIFIER_BROWSE service returns some info */
235 protected Element createServiceDisplay(String service, String lang)
236 {
237 Element display = doc_.createElement(GSXML.DISPLAY_ELEM);
238 if (!service.equals(CLASSIFIER_SERVICE)) {
239 return display;
240 }
241
242 // CLASSIFIER_SERVICE
243 display.appendChild(GSXML.createTextElement(doc_, GSXML.DISPLAY_NAME_ELEM, getTextString(service+".name", lang)));
244 //display.appendChild(GSXML.createTextElement(doc_, GSXML.DISPLAY_SUBMIT_ELEM, getTextString(service+".submit", lang)));
245
246 // need to add in the classifier name info
247 // add <classifier name="CL1">text name</classifier> to the
248 // display node
249 NodeList classifiers = config_info_.getElementsByTagName(GSXML.CLASSIFIER_ELEM);
250 for (int i=0; i<classifiers.getLength(); i++) {
251 Element cl = (Element)classifiers.item(i);
252 Element disp = (Element)GSXML.getChildByTagName(cl, GSXML.DISPLAY_ELEM);
253 String text = null;
254 if (disp !=null) {
255 text = GSXML.getDisplayText(disp,
256 GSXML.DISPLAY_NAME_ELEM,
257 lang, "en");
258 }
259 if (text == null || text.equals("")) {
260 // no display element was specified, use the metadata name
261 // for now this looks in the class properties file
262 // this needs to use a general metadata thing instead
263 text = getTextString(cl.getAttribute(GSXML.CLASSIFIER_CONTENT_ATT), lang);
264 }
265
266 Element cl_elem = doc_.createElement(GSXML.CLASSIFIER_ELEM);
267 cl_elem.setAttribute(GSXML.NAME_ATT, cl.getAttribute(GSXML.NAME_ATT));
268 Element cl_name = GSXML.createTextElement(doc_, GSXML.DISPLAY_NAME_ELEM, text);
269 cl_elem.appendChild(cl_name);
270
271 display.appendChild(cl_elem);
272
273 }
274
275 return display;
276
277 }
278
279 /** parent is true if this node is definitely the parent of something,
280 * child is true is it definitely is a child of something - just for efficiency purposes */
281 protected Element createDocNode(String doc_id, boolean parent, boolean child) {
282
283 // create this here or pass it in?
284 DBInfo db_info = gdbm_src_.getInfo(doc_id);
285 Element node;
286 if (isClassifier(doc_id)) {
287 node = doc_.createElement(GSXML.CLASS_NODE_ELEM);
288 String childtype = db_info.getInfo("childtype");
289 String orientation="";
290 if (childtype.equals("HList")) {
291 orientation = "horizontal";
292 } else { // assume vertical
293 orientation = "vertical";
294 }
295 node.setAttribute(GSXML.CLASS_NODE_ORIENTATION_ATT, orientation);
296 } else {
297 node = doc_.createElement(GSXML.DOC_NODE_ELEM);
298 if (!child && OID.isTop(doc_id)) {
299 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_ROOT);
300 } else if (!parent && isLeafNode(doc_id)) {
301 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF);
302 } else {
303 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_INTERIOR);
304 }
305 }
306 node.setAttribute(GSXML.NODE_ID_ATT, doc_id);
307 return node;
308
309 }
310 /** Returns the parent of a specified documentID, or null if none exists */
311 protected Element getParent(String doc_id)
312 {
313 String parent_id = OID.getParent(doc_id);
314 if (parent_id.equals(doc_id))
315 return null;
316
317 return createDocNode(parent_id, true, false);
318 }
319
320
321 /** adds all the children of doc_id the the doc element,
322 * and if recursive=true, adds all their children as well*/
323 protected void addDescendants(Element doc, String doc_id,
324 boolean recursive)
325 {
326 DBInfo info = gdbm_src_.getInfo(doc_id);
327 String contains = info.getInfo("contains");
328
329 StringTokenizer st = new StringTokenizer(contains, ";");
330 while (st.hasMoreTokens()) {
331 String child_id = st.nextToken().replaceAll("\"", doc_id);
332 Element child = createDocNode(child_id, false, true);
333 doc.appendChild(child);
334
335 // Apply recursively, if desired
336 if (recursive) {
337 addDescendants(child, child_id, recursive);
338 }
339
340 }
341 }
342
343 /** adds all the siblings of current_id to the parent element. */
344 protected Element addSiblings(Element parent, String parent_id, String current_id) {
345 Element current_node = (Element)parent.getFirstChild();
346 if (current_node ==null) {
347 // create a sensible error message
348 System.err.println("Error: there should be a first child.");
349 return null;
350 }
351 // remove the current child,- will add it in later in its correct place
352 parent.removeChild(current_node);
353
354 // add in all the siblings,
355 addDescendants(parent, parent_id, false);
356
357 // find the node that is now the current node
358 // this assumes that the new node that was created is the same as
359 // the old one that was removed - we may want to replace the new one
360 // with the old one.
361 Element new_current = GSXML.getNamedElement(parent, current_node.getNodeName(), GSXML.NODE_ID_ATT, current_id);
362 return new_current;
363
364 }
365 /** Returns true if the OID specifies a leaf node, false otherwise
366 Note: this makes a request to the GDBM database so it may not be
367 a particularly cheap operation */
368 protected boolean isLeafNode(String oid)
369 {
370 DBInfo info = gdbm_src_.getInfo(oid);
371 String children = info.getInfo("contains");
372 return (children == "");
373 }
374
375 // for now just use CL for classifiers - should have a type? in teh gdbm
376 // database.
377 protected boolean isClassifier(String oid) {
378 if (oid.startsWith("CL")) {
379 return true;
380 }
381 return false;
382 }
383
384 protected Element processDocumentStructureRetrieve(Element request) {
385 return genericStructureRetrieve(request, DOCUMENT);
386 }
387
388 protected Element processClassifierBrowse(Element request) {
389 return genericStructureRetrieve(request, CLASSIFIER);
390 }
391
392 /** Retrieve the structure of a document */
393 protected Element genericStructureRetrieve(Element request, int type)
394 {
395 // Create a new (empty) result message
396 Element result = doc_.createElement(GSXML.RESPONSE_ELEM);
397
398 String node_name;
399 String from;
400 if (type==DOCUMENT) {
401 from = GSPath.appendLink(cluster_name_, DOCUMENT_STRUCTURE_RETRIEVE_SERVICE);
402 node_name = GSXML.DOC_NODE_ELEM;
403 } else {
404 from = GSPath.appendLink(cluster_name_, CLASSIFIER_SERVICE);
405 node_name = GSXML.CLASS_NODE_ELEM;
406 }
407
408 result.setAttribute(GSXML.FROM_ATT, from);
409 result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
410
411 // Get the parameters of the request
412 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
413 if (param_list == null) {
414 System.err.println("Error: DocumentStructureRetrieve request had no paramList.");
415 return result; // Return the empty result
416 }
417
418 // The document structure information desired
419 boolean wantAncestors = false;
420 boolean wantParent = false;
421 boolean wantSiblings = false;
422 boolean wantChildren = false;
423 boolean wantDescendants = false;
424
425 // Process the request parameters
426 Element param = (Element) param_list.getFirstChild();
427 while (param != null) {
428 if (!param.getNodeName().equals(GSXML.PARAM_ELEM)) {
429 System.err.println("Warning: Non-param in paramList (ignored).");
430 }
431 else {
432 // Identify the structure information desired
433 if (param.getAttribute(GSXML.NAME_ATT) == "structure") {
434 String structure = GSXML.getValue(param);
435 // System.out.println("Structure desired: " + structure);
436
437 // This is NOT locale sensitive
438 if (structure.compareToIgnoreCase("ancestors") == 0)
439 wantAncestors = true;
440 else if (structure.compareToIgnoreCase("parent") == 0)
441 wantParent = true;
442 else if (structure.compareToIgnoreCase("siblings") == 0)
443 wantSiblings = true;
444 else if (structure.compareToIgnoreCase("children") == 0)
445 wantChildren = true;
446 else if (structure.compareToIgnoreCase("descendants") == 0)
447 wantDescendants = true;
448 else
449 System.err.println("Warning: Unknown value \"" + structure + "\".");
450 }
451 }
452
453 param = (Element) param.getNextSibling();
454 }
455
456 // Make sure there is no repeated information
457 if (wantAncestors)
458 wantParent = false;
459 if (wantDescendants)
460 wantChildren = false;
461
462
463 Element query_doc_list = (Element) GSXML.getChildByTagName(request, node_name+GSXML.LIST_MODIFIER);
464 if (query_doc_list == null) {
465 System.err.println("Error: DocumentStructureRetrieve request specified no doc nodes.\n");
466 return result;
467 }
468
469 Element doc_list = doc_.createElement(node_name+GSXML.LIST_MODIFIER);
470 result.appendChild(doc_list);
471
472 // Get the documents
473 String[] doc_ids = GSXML.getAttributeValuesFromList(query_doc_list,
474 GSXML.NODE_ID_ATT);
475 for (int i = 0; i < doc_ids.length; i++) {
476 String doc_id = doc_ids[i];
477
478
479 if (OID.needsTranslating(doc_id)) {
480 doc_id = gdbm_src_.translateOID(doc_id);
481 }
482
483 // Add the document to the list
484 Element doc = doc_.createElement(node_name);
485 doc_list.appendChild(doc);
486 doc.setAttribute(GSXML.NODE_ID_ATT, doc_id);
487 // all structure info goes into a docNodestructure elem
488 // classifier elem should be something else???
489 Element structure_elem = doc_.createElement(GSXML.DOC_NODE_STRUCTURE_ELEM);
490 doc.appendChild(structure_elem);
491
492 // Add the requested structure information
493 Element current = createDocNode(doc_id, false, false);
494
495 //Ancestors: continually add parent nodes until the root is reached
496 Element top_node = current; // the top node so far
497 if (wantAncestors) {
498 String current_id = doc_id;
499 while (true) {
500 Element parent = getParent(current_id);
501 if (parent == null)
502 break;
503
504 parent.appendChild(top_node);
505 current_id = parent.getAttribute(GSXML.NODE_ID_ATT);
506 top_node = parent;
507 }
508 }
509 // Parent: get the parent of the selected node
510 if (wantParent) {
511 Element parent = getParent(doc_id);
512 if (parent != null) {
513 parent.appendChild(current);
514 top_node = parent;
515 }
516 }
517
518 // now the top node is the root of the structure
519 structure_elem.appendChild(top_node);
520
521 //Siblings: get the other descendants of the selected node's parent
522 if (wantSiblings) {
523 Element parent = (Element)current.getParentNode(); // this may be the structure element if there has been no request for parents or ancestors
524 String parent_id = OID.getParent(doc_id);
525
526 // add siblings, - returns a pointer to the new current node
527 current = addSiblings(parent, parent_id, doc_id);
528 }
529
530 // Children: get the descendants, but only one level deep
531 if (wantChildren)
532 addDescendants(current, doc_id, false);
533 // Descendants: recursively get every descendant of the selected node
534 if (wantDescendants)
535 addDescendants(current, doc_id, true);
536 }
537 //System.out.println("the result of structure retrieve is");
538 //System.out.println(converter_.getString(result));
539 return result;
540 }
541
542
543 protected Element processDocumentMetadataRetrieve(Element request) {
544 return genericMetadataRetrieve(request, DOCUMENT);
545 }
546
547 protected Element processClassifierBrowseMetadataRetrieve(Element request) {
548 return genericMetadataRetrieve(request, CLASSIFIER);
549 }
550
551
552 /** Retrieve metadata associated with a document or classifier node*/
553 protected Element genericMetadataRetrieve(Element request, int type)
554 {
555 // Create a new (empty) result message
556 Element result = doc_.createElement(GSXML.RESPONSE_ELEM);
557
558 String node_name;
559
560 String from;
561 if (type==DOCUMENT) {
562 from = GSPath.appendLink(cluster_name_, DOCUMENT_METADATA_RETRIEVE_SERVICE);
563 node_name = GSXML.DOC_NODE_ELEM;
564 } else {
565 from = GSPath.appendLink(cluster_name_, CLASSIFIER_METADATA_SERVICE);
566 node_name = GSXML.CLASS_NODE_ELEM;
567 }
568 result.setAttribute(GSXML.FROM_ATT, from);
569 result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
570
571 // Get the parameters of the request
572 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
573 if (param_list == null) {
574 System.err.println("GS2Retrieve, DocumentMetadataRetrieve Error: missing paramList.\n");
575 return result; // Return the empty result
576 }
577
578 // The metadata information required
579 Vector metadata_list = new Vector();
580
581 // Process the request parameters
582 Element param = (Element) param_list.getFirstChild();
583 while (param != null) {
584 // Identify the metadata information desired
585 if (param.getAttribute(GSXML.NAME_ATT) == "metadata") {
586 String metadata = GSXML.getValue(param);
587 System.out.println("Metadata desired: " + metadata);
588 metadata_list.add(metadata);
589 }
590 param = (Element) param.getNextSibling();
591 }
592
593 Element node_list = doc_.createElement(node_name+GSXML.LIST_MODIFIER);
594 result.appendChild(node_list);
595
596 // Get the documents
597 Element request_node_list = (Element) GSXML.getChildByTagName(request, node_name+GSXML.LIST_MODIFIER);
598 if (request_node_list == null) {
599 System.err.println("Error: DocumentMetadataRetrieve request had no "+node_name+"List.\n");
600 return result;
601 }
602
603 NodeList request_nodes = request_node_list.getChildNodes();
604 for (int i = 0; i < request_nodes.getLength(); i++) {
605 Element request_node = (Element) request_nodes.item(i);
606 String node_id = request_node.getAttribute(GSXML.NODE_ID_ATT);
607 System.out.println("Retrieving metadata for " + node_id + "...");
608
609
610 if (OID.needsTranslating(node_id)) {
611 node_id = gdbm_src_.translateOID(node_id);
612 }
613
614 // Add the document to the list
615 Element new_node = (Element)doc_.importNode(request_node, false);
616 node_list.appendChild(new_node);
617
618 // Add the requested metadata information
619 Element node_meta_list = doc_.createElement(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
620 new_node.appendChild(node_meta_list);
621 DBInfo info = gdbm_src_.getInfo(node_id);
622 for (int m = 0; m < metadata_list.size(); m++) {
623 String metadata = (String) metadata_list.get(m);
624 String value = info.getInfo(metadata);
625 GSXML.addMetadata(doc_, node_meta_list, metadata, value);
626 }
627 }
628
629 return result;
630 }
631
632
633 /** Retrieve the content of a document - implemented by concrete subclasses */
634 protected abstract Element processDocumentContentRetrieve(Element request);
635}
Note: See TracBrowser for help on using the repository browser.