1 | package org.greenstone.gsdl3.core;
|
---|
2 |
|
---|
3 | import org.greenstone.gsdl3.util.*;
|
---|
4 | import org.greenstone.gsdl3.action.*;
|
---|
5 | // XML classes
|
---|
6 | import org.w3c.dom.Node;
|
---|
7 | import org.w3c.dom.NodeList;
|
---|
8 | import org.w3c.dom.Document;
|
---|
9 | import org.w3c.dom.Element;
|
---|
10 |
|
---|
11 | // other java classes
|
---|
12 | import java.io.File;
|
---|
13 | import java.util.HashMap;
|
---|
14 | import java.util.Enumeration;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * This is a new version of the Receptionist for the NZDL interface
|
---|
18 | * the interface requires a lot more info for each page
|
---|
19 | * @see DefaultReceptionist
|
---|
20 | */
|
---|
21 | public class NZDLReceptionist extends DefaultReceptionist {
|
---|
22 |
|
---|
23 | protected void addExtraInfo(Element page) {
|
---|
24 | ///ystem.out.println("the page before adding extra info is");
|
---|
25 | ///ystem.out.println(this.converter.getPrettyString(page));
|
---|
26 |
|
---|
27 | super.addExtraInfo(page);
|
---|
28 |
|
---|
29 | // this gets the collection info
|
---|
30 | Element page_response = (Element)GSXML.getChildByTagName(page, GSXML.PAGE_RESPONSE_ELEM);
|
---|
31 | Element collection_info = (Element)GSXML.getChildByTagName(page_response, GSXML.COLLECTION_ELEM);
|
---|
32 | if (collection_info== null) {
|
---|
33 | return;
|
---|
34 | }
|
---|
35 |
|
---|
36 | String collection = collection_info.getAttribute("name"); // should we take this from the request instead??
|
---|
37 | // look through services and see if classifier one is present - need to
|
---|
38 | // get the list of classifiers
|
---|
39 | Element service_list = (Element)GSXML.getChildByTagName(collection_info, GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER);
|
---|
40 | if (service_list == null) {
|
---|
41 | // something weird has gone wrong
|
---|
42 | return;
|
---|
43 | }
|
---|
44 |
|
---|
45 | Element classifier_service = GSXML.getNamedElement(service_list, GSXML.SERVICE_ELEM, GSXML.NAME_ATT, "ClassifierBrowse");
|
---|
46 | if (classifier_service == null) {
|
---|
47 | return; // no browsing stuff
|
---|
48 | }
|
---|
49 |
|
---|
50 | String lang = page.getAttribute(GSXML.LANG_ATT);
|
---|
51 | // find the list of classifiers
|
---|
52 | Element info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
|
---|
53 | String to = GSPath.appendLink(collection, "ClassifierBrowse");
|
---|
54 | Element info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, lang);
|
---|
55 | info_message.appendChild(info_request);
|
---|
56 |
|
---|
57 | Element info_response = (Element) this.mr.process(info_message);
|
---|
58 | String path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.SERVICE_ELEM);
|
---|
59 | Element classifier_service_info = (Element)GSXML.getNodeByPath(info_response, path);
|
---|
60 |
|
---|
61 | service_list.replaceChild(this.doc.importNode(classifier_service_info, true), classifier_service);
|
---|
62 | ///ystem.out.println("the final page before transforming is");
|
---|
63 | ///ystem.out.println(this.converter.getPrettyString(page));
|
---|
64 | return;
|
---|
65 | }
|
---|
66 |
|
---|
67 | }
|
---|
68 |
|
---|