source: trunk/gsdl3/src/java/org/greenstone/gsdl3/core/DefaultReceptionist.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/** The default greenstone receptionist - needs some extra info for each page
17 * @see WebReceptionist
18 */
19public class DefaultReceptionist extends WebReceptionist {
20
21 protected void addExtraInfo(Element page) {
22 // we want to add in the collection description for each page - cos
23 // our default xslt needs this.
24 super.addExtraInfo(page);
25
26 Element page_request = (Element)GSXML.getChildByTagName(page, GSXML.PAGE_REQUEST_ELEM);
27 System.out.println("add extra info, page request="+this.converter.getString(page_request));
28 // is a collection defined?
29 Element param_list = (Element)GSXML.getChildByTagName(page_request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
30 if (param_list==null) { // must be the original home page
31 return;
32 }
33 Element coll_param = GSXML.getNamedElement(param_list, GSXML.PARAM_ELEM, GSXML.NAME_ATT, this.cgi.COLLECTION_ARG);
34 if (coll_param == null) {
35 return;
36 }
37 String action = page_request.getAttribute(GSXML.ACTION_ATT);
38 if (action.equals("p")) {
39 return;
40 }
41 // we have a collection, and we are not page action. get the coll description
42
43 String collection = coll_param.getAttribute(GSXML.VALUE_ATT);
44 String lang = page_request.getAttribute(GSXML.LANG_ATT);
45 Element coll_about_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
46 Element coll_about_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, collection, lang);
47 coll_about_message.appendChild(coll_about_request);
48
49 Element coll_about_response_message = this.mr.process(coll_about_message);
50 Element coll_about_response = (Element)GSXML.getChildByTagName(coll_about_response_message, GSXML.RESPONSE_ELEM);
51 Element coll_description = (Element)GSXML.getChildByTagName(coll_about_response, GSXML.COLLECTION_ELEM);
52 if (coll_description==null) { // may be a cluster
53 coll_description = (Element)GSXML.getChildByTagName(coll_about_response, GSXML.CLUSTER_ELEM);
54 }
55 if (coll_description != null) {
56 Element page_response = (Element)GSXML.getChildByTagName(page, GSXML.PAGE_RESPONSE_ELEM);
57 page_response.appendChild(this.doc.importNode(coll_description, true));
58 }
59 }
60}
61
Note: See TracBrowser for help on using the repository browser.