1 | package org.greenstone.gsdl3.action;
|
---|
2 |
|
---|
3 | import org.greenstone.gsdl3.core.ModuleInterface;
|
---|
4 | import org.greenstone.gsdl3.util.*;
|
---|
5 | // XML classes
|
---|
6 | import org.w3c.dom.Node;
|
---|
7 | import org.w3c.dom.Element;
|
---|
8 | import org.w3c.dom.Document;
|
---|
9 |
|
---|
10 | abstract public class Action {
|
---|
11 |
|
---|
12 | protected ConfigVars config_=null;
|
---|
13 |
|
---|
14 | /** container Document to create XML Nodes */
|
---|
15 | protected Document doc_=null;
|
---|
16 | /** a converter class to parse XML and create Docs */
|
---|
17 | protected XMLConverter converter_=null;
|
---|
18 | /** cgi args conveter */
|
---|
19 | protected CGIArgConverter cgi_=null;
|
---|
20 | /** a transformer class to transform xml using xslt */
|
---|
21 | protected XMLTransformer transformer_=null;
|
---|
22 |
|
---|
23 | /** a reference to the message router that it must talk to to
|
---|
24 | * get info. it may be a communicator acting as a proxy, but it
|
---|
25 | doesn't care about that */
|
---|
26 | protected ModuleInterface mr_=null;
|
---|
27 |
|
---|
28 |
|
---|
29 | public Action() {
|
---|
30 | converter_ = new XMLConverter();
|
---|
31 | transformer_ = new XMLTransformer();
|
---|
32 | doc_ = converter_.newDOM();
|
---|
33 | }
|
---|
34 | /** gsdl_home_ must be set before configure called */
|
---|
35 | public void setConfigVars(ConfigVars config) {
|
---|
36 | config_ = config;
|
---|
37 | }
|
---|
38 | /** sets the message router */
|
---|
39 | public void setMessageRouter(ModuleInterface m) {
|
---|
40 | mr_ = m;
|
---|
41 | }
|
---|
42 |
|
---|
43 | public void setCGIConverter(CGIArgConverter cgi) {
|
---|
44 | cgi_ = cgi;
|
---|
45 | }
|
---|
46 | public void configure() {
|
---|
47 | // does nothing yet
|
---|
48 | }
|
---|
49 |
|
---|
50 | /** process takes an xml representation of cgi args
|
---|
51 | * and returns the page of results - may be in html/xml/other
|
---|
52 | * depending on the output att of the request */
|
---|
53 | public String process(String xml_in) {
|
---|
54 |
|
---|
55 | Element message = converter_.getDOM(xml_in).getDocumentElement();
|
---|
56 |
|
---|
57 | return process(message);
|
---|
58 | }
|
---|
59 |
|
---|
60 | abstract public String process(Element xml_in);
|
---|
61 |
|
---|
62 |
|
---|
63 | }
|
---|
64 |
|
---|