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 | /** The default greenstone receptionist - needs some extra info for each page
|
---|
17 | * @see WebReceptionist
|
---|
18 | */
|
---|
19 | public 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 |
|
---|