source: trunk/gsdl3/src/java/org/greenstone/gsdl3/action/Action.java@ 3913

Last change on this file since 3913 was 3911, checked in by kjdon, 21 years ago

removed createDescribeRequest method - its now in GSXML

  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1package org.greenstone.gsdl3.action;
2
3import org.greenstone.gsdl3.core.ModuleInterface;
4import org.greenstone.gsdl3.util.*;
5// XML classes
6import org.w3c.dom.Node;
7import org.w3c.dom.Element;
8import org.w3c.dom.Document;
9
10/** base class for Actions */
11abstract public class Action {
12
13 /** the interface setup variables */
14 protected ConfigVars config_=null;
15 /** container Document to create XML Nodes */
16 protected Document doc_=null;
17 /** a converter class to parse XML and create Docs */
18 protected XMLConverter converter_=null;
19 /** cgi args converter */
20 protected GSCGI cgi_ = null;
21 /** a transformer class to transform xml using xslt */
22 protected XMLTransformer transformer_=null;
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 public Action() {
29 converter_ = new XMLConverter();
30 transformer_ = new XMLTransformer();
31 doc_ = converter_.newDOM();
32 }
33 /** gsdl_home_ must be set before configure called */
34 public void setConfigVars(ConfigVars config) {
35 config_ = config;
36 }
37 /** sets the message router */
38 public void setMessageRouter(ModuleInterface m) {
39 mr_ = m;
40 }
41 /** sets the GSCGI object - used to convert between short and long names
42 * of params */
43 public void setCGI(GSCGI cgi) {
44 cgi_ = cgi;
45 // add in any action specific params
46 addCGIParams();
47 }
48 public void configure() {
49 // does nothing yet
50 }
51 /** any action specific cgi params should be added to the GSCGI object-
52 * overwrite this if a new action has its own params
53 * using cgi_.addStaticParam(param-name) */
54 protected void addCGIParams() {
55
56 }
57 /** process takes an xml representation of cgi args
58 * and returns the page of results - may be in html/xml/other
59 * depending on the output att of the request */
60 public String process(String xml_in) {
61
62 Element message = converter_.getDOM(xml_in).getDocumentElement();
63
64 Element result = process(message);
65 return converter_.getString(result);
66 }
67
68 /** the main process method - must be implemented in subclass */
69 abstract public Element process(Element xml_in);
70
71
72}
73
Note: See TracBrowser for help on using the repository browser.