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

Last change on this file since 4717 was 4695, checked in by kjdon, 21 years ago

no longer use ConfigVars, use a HashMap instead

  • 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;
14import java.util.HashMap;
15
16/** base class for Actions */
17abstract public class Action {
18
19 /** the system set up variables */
20 protected HashMap config_params = null;
21 /** container Document to create XML Nodes */
22 protected Document doc_=null;
23 /** a converter class to parse XML and create Docs */
24 protected XMLConverter converter_=null;
25 /** a reference to the message router that it must talk to to
26 * get info. it may be a communicator acting as a proxy, but it
27 doesn't care about that */
28 protected ModuleInterface mr_=null;
29
30 public Action() {
31 converter_ = new XMLConverter();
32 doc_ = converter_.newDOM();
33 }
34 /** the config variables must be set before configure is called */
35 public void setConfigParams(HashMap params) {
36 this.config_params = params;
37 }
38 /** sets the message router */
39 public void setMessageRouter(ModuleInterface m) {
40 mr_ = m;
41 }
42 public void configure() {
43 // does nothing yet
44 }
45
46 /** process takes an xml representation of cgi args
47 * and returns the page of results - may be in html/xml/other
48 * depending on the output att of the request */
49 public String process(String xml_in) {
50
51 Element message = converter_.getDOM(xml_in).getDocumentElement();
52
53 Element result = process(message);
54 return converter_.getString(result);
55 }
56
57 /** the main process method - must be implemented in subclass */
58 abstract public Element process(Element xml_in);
59
60// protected Vector getMetadata(Element format) {
61// NodeList nodes = format.getElementsByTagName("gsf:metadata");
62// Vector meta_names = new Vector();
63// for (int i=0; i<nodes.getLength(); i++) {
64// meta_names.add(((Element)nodes.item(i)).getAttribute("name"));
65// }
66// return meta_names;
67// }
68}
69
70
71
72
Note: See TracBrowser for help on using the repository browser.