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

Last change on this file since 4287 was 4257, 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

  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 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.NodeList;
8import org.w3c.dom.Element;
9import org.w3c.dom.Document;
10
11// other java stuff
12import java.io.File;
13import java.util.Vector;
14/** base class for Actions */
15abstract public class Action {
16
17 /** the interface setup variables */
18 protected ConfigVars config_=null;
19 /** container Document to create XML Nodes */
20 protected Document doc_=null;
21 /** a converter class to parse XML and create Docs */
22 protected XMLConverter converter_=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 doc_ = converter_.newDOM();
31 }
32 /** gsdl_home_ must be set before configure called */
33 public void setConfigVars(ConfigVars config) {
34 config_ = config;
35 }
36 /** sets the message router */
37 public void setMessageRouter(ModuleInterface m) {
38 mr_ = m;
39 }
40 public void configure() {
41 // does nothing yet
42 }
43
44 /** process takes an xml representation of cgi args
45 * and returns the page of results - may be in html/xml/other
46 * depending on the output att of the request */
47 public String process(String xml_in) {
48
49 Element message = converter_.getDOM(xml_in).getDocumentElement();
50
51 Element result = process(message);
52 return converter_.getString(result);
53 }
54
55 /** the main process method - must be implemented in subclass */
56 abstract public Element process(Element xml_in);
57
58// protected Vector getMetadata(Element format) {
59// NodeList nodes = format.getElementsByTagName("gsf:metadata");
60// Vector meta_names = new Vector();
61// for (int i=0; i<nodes.getLength(); i++) {
62// meta_names.add(((Element)nodes.item(i)).getAttribute("name"));
63// }
64// return meta_names;
65// }
66}
67
68
69
70
Note: See TracBrowser for help on using the repository browser.