source: trunk/gsdl3/src/java/org/greenstone/gsdl3/core/NZDLReceptionist.java@ 4859

Last change on this file since 4859 was 4258, checked in by kjdon, 21 years ago

simplified actions, the receptionist does a lot more of teh work now. actions have no knowledge of transformations, whether they are in a cgi context, and only get the info that they need - eg the collection info which is needed by the xslt is now gathered by the receptionist. there are several types of receptionists now: Receptionist is a very basic one, which just puts the request and response into a page and returns that. TransformingReceptionist keeps a list of xslt needed for each action, and transforms the result before sending it back. WebReceptionist has cgi args info, and adds shortnames to params, and turns shortnames back to long names when the requests come in. it also adds config and display info to teh page before transforming it. DefaultReceptionist is the greenstone default - its a web receptionist that adds in some extra info to teh page - collection description. NZDLReceptionist is the one for NZDL. it inherits from DefaultREceptionist and adds some more info to the page - needed for the navigation bar.

  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1package org.greenstone.gsdl3.core;
2
3import org.greenstone.gsdl3.util.*;
4import org.greenstone.gsdl3.action.*;
5// XML classes
6import org.w3c.dom.Node;
7import org.w3c.dom.NodeList;
8import org.w3c.dom.Document;
9import org.w3c.dom.Element;
10
11// other java classes
12import java.io.File;
13import java.util.HashMap;
14import 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 */
21public class NZDLReceptionist extends DefaultReceptionist {
22
23 protected void addExtraInfo(Element page) {
24 System.out.println("the page before adding extra info is");
25 System.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 String lang = page.getAttribute(GSXML.LANG_ATT);
50 // find the list of classifiers
51 Element info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
52 String to = GSPath.appendLink(collection, "ClassifierBrowse");
53 Element info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, lang);
54 info_message.appendChild(info_request);
55
56 Element info_response = (Element) this.mr.process(info_message);
57 String path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.SERVICE_ELEM);
58 Element classifier_service_info = (Element)GSXML.getNodeByPath(info_response, path);
59 // add all the children into the classifier service element
60 GSXML.copyAllChildren(classifier_service, classifier_service_info);
61 System.out.println("the final page before transforming is");
62 System.out.println(this.converter.getPrettyString(page));
63 return;
64 }
65
66}
67
Note: See TracBrowser for help on using the repository browser.