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 | /** core class for web interface generation. Receives requests consisting
|
---|
17 | * of an xml representation of cgi args, and returns the page of data - in
|
---|
18 | * html by default. The requests are processed by the appropriate action class
|
---|
19 | *
|
---|
20 | * @see Action
|
---|
21 | */
|
---|
22 | public class WebReceptionist extends TransformingReceptionist {
|
---|
23 |
|
---|
24 | /** the set up variables */
|
---|
25 |
|
---|
26 | /** the cgi args converter */
|
---|
27 | protected GSCGI cgi = null;
|
---|
28 |
|
---|
29 | public void setCGI(GSCGI cgi) {
|
---|
30 | this.cgi=cgi;
|
---|
31 | }
|
---|
32 |
|
---|
33 | protected void preProcessRequest(Element request) {
|
---|
34 | // convert cgi short names to long names in the param list
|
---|
35 | Element param_list = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
|
---|
36 | if (param_list!=null) {
|
---|
37 | if (!this.cgi.paramListToLongNames(param_list)) {
|
---|
38 | System.err.println("Receptionist Error: couldn't convert short names to long names in the param list!");
|
---|
39 |
|
---|
40 | }
|
---|
41 | }
|
---|
42 | }
|
---|
43 |
|
---|
44 | // need to modify some param lists
|
---|
45 | protected Element transformPage(Element page) {
|
---|
46 |
|
---|
47 | Element page_response = (Element)GSXML.getChildByTagName(page, GSXML.PAGE_RESPONSE_ELEM);
|
---|
48 | // look for a service description
|
---|
49 | Element service = (Element)GSXML.getChildByTagName(page_response, GSXML.SERVICE_ELEM);
|
---|
50 | if (service != null) {
|
---|
51 | // look for a param-list
|
---|
52 | Element param_list = (Element)GSXML.getChildByTagName(service, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
|
---|
53 | if (param_list != null) {
|
---|
54 |
|
---|
55 | // add in cgi short names
|
---|
56 | this.cgi.paramListAddShortNames(param_list);
|
---|
57 | }
|
---|
58 | }
|
---|
59 | return super.transformPage(page);
|
---|
60 | }
|
---|
61 |
|
---|
62 | }
|
---|