Changeset 3502
- Timestamp:
- 2002-10-29T15:31:12+13:00 (22 years ago)
- Location:
- trunk/gsdl3/src/java/org/greenstone/gsdl3
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/collection/ServiceCluster.java
r3498 r3502 215 215 Element e = doc.getDocumentElement(); 216 216 217 Noderes = process(e);217 Element res = process(e); 218 218 return converter_.getString(res); 219 219 … … 223 223 * 224 224 */ 225 public Node process(Node xml_in) { 226 227 // xml_in should always be an Element - should check this 228 Element xml = (Element)xml_in; 229 String to = xml.getAttribute("to"); 225 public Element process(Element message) { 226 227 String to = message.getAttribute("to"); 230 228 231 229 // the cluster name should be first, check, then remove … … 233 231 if (clustername.equals(cluster_name_)){ 234 232 to = GSPath.removeFirstLink(to); 235 xml.setAttribute("to", to);233 message.setAttribute("to", to); 236 234 } else { 237 235 System.out.println("ServiceCluster error: cluster name wrong! was "+clustername+" should have been "+cluster_name_); … … 240 238 241 239 if (to.equals("")) { // this command is for me 242 String type = xml.getAttribute("type");240 String type = message.getAttribute("type"); 243 241 if (type.equals("describe")) { 244 242 // create a response with the description inside it … … 250 248 } else { 251 249 System.out.println("ServiceCluster: error, cant handle request:"); 252 System.out.println(converter_.getString( xml));250 System.out.println(converter_.getString(message)); 253 251 return null; 254 252 } … … 258 256 259 257 if (service_map_.containsKey(service)) { 260 return ((ModuleInterface)service_map_.get(service)).process( xml);258 return ((ModuleInterface)service_map_.get(service)).process(message); 261 259 } else { 262 System.err.println("ServiceCluster: non-existant service, "+service+", specified, in:\n"+converter_.getString( xml));260 System.err.println("ServiceCluster: non-existant service, "+service+", specified, in:\n"+converter_.getString(message)); 263 261 return null; 264 262 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/comms/Communicator.java
r3235 r3502 23 23 24 24 //XML packages 25 import org.w3c.dom. Node;25 import org.w3c.dom.Element; 26 26 27 27 /** Communicator - base class for Modules that talk via some protocol to other modules … … 67 67 abstract public String process(String xml_in); 68 68 69 abstract public Node process(Nodexml_in);69 abstract public Element process(Element xml_in); 70 70 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/comms/SOAPCommunicator.java
r3462 r3502 73 73 74 74 // put this into Communicator?? 75 public Node process(Nodexml_in) {75 public Element process(Element xml_in) { 76 76 // needs to catch SOAPException, MalformedURLException 77 77 try { … … 149 149 150 150 public String process(String xml_in) { 151 Node n = converter_.getDOM(xml_in).getDocumentElement(); 152 Node result = process(n); 153 if (result == null) { 154 return ""; 155 } 151 Element e = converter_.getDOM(xml_in).getDocumentElement(); 152 Node result = process(e); 156 153 return converter_.getString(result); 157 154 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/core/MessageRouter.java
r3485 r3502 173 173 Document doc = converter_.getDOM(xml_in); 174 174 175 Node result = process(doc);175 Element result = process(doc.getDocumentElement()); 176 176 return converter_.getString(result); 177 177 } 178 178 179 179 /** 180 * Process an XML request - as a DOM model node 181 * the Node may be an Element or a Document 180 * Process an XML request - as a DOM Element 182 181 * 183 182 * @param xml_in the message to process - should be <message> 184 183 * @return the response - contains any error messages 185 * @see Node186 * @see Document187 184 * @see Element 188 185 */ 189 public Node process(Node xml_in) { 190 191 // check if Element or Document - we want to deal with Elements 192 Element message=null; 193 short node_type = xml_in.getNodeType(); 194 if (node_type == Node.DOCUMENT_NODE) { 195 message = ((Document)xml_in).getDocumentElement(); 196 } else if (node_type == Node.ELEMENT_NODE) { 197 message = (Element)xml_in; 198 } else { 199 System.err.println("MessageRouter:process: invalid Node type"); 200 } 201 186 public Element process(Element message) { 187 202 188 // check that its a correct message tag 203 189 if (!message.getTagName().equals(GSDL_MESSAGE_NAME)) { -
trunk/gsdl3/src/java/org/greenstone/gsdl3/core/ModuleInterface.java
r3235 r3502 19 19 package org.greenstone.gsdl3.core; 20 20 21 import org.w3c.dom. Node;21 import org.w3c.dom.Element; 22 22 23 23 /** 24 * Module interface for all components/modules in greenstone.24 * interface for all modules in greenstone. 25 25 * 26 26 * all components talk via a process method - in its simplest form, 27 27 * it takes a String of XML, and returns a String of XML 28 28 * 29 * Java modules also implement a convenience process method -30 * uses DOM Nodes instead of Strings -avoids parsing the XML at each module29 * the more efficient process method uses DOM Element Nodes instead 30 * of Strings - this avoids parsing the XML at each module 31 31 * 32 32 * @author <a href="mailto:[email protected]">Katherine Don</a> … … 45 45 46 46 /** 47 * Process an XML request - as a DOM model node 48 * the Node may be an Element or a Document 47 * Process an XML request - as a DOM model Element 49 48 * 50 * @param in the request to process49 * @param xml_in the request to process 51 50 * @return the response - contains any error messages 52 * @see org.w3c.dom.Node53 * @see org.w3c.dom.Document54 51 * @see org.w3c.dom.Element 55 52 */ 56 abstract public Node process(Node xml_in); 57 //abstract public XMLConverter process(XMLConverter out); 53 abstract public Element process(Element xml_in); 58 54 } 59 55 -
trunk/gsdl3/src/java/org/greenstone/gsdl3/core/Receptionist.java
r3486 r3502 157 157 } 158 158 159 public Node process(Nodexml_in) {159 public Element process(Element xml_in) { 160 160 return xml_in; // for now 161 161 -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/ModuleWrapper.java
r3251 r3502 28 28 import org.apache.xindice.xml.TextWriter; 29 29 import org.w3c.dom.Document; 30 import org.w3c.dom.Element; 30 31 import org.w3c.dom.Node; 31 32 import org.w3c.dom.Node; … … 212 213 213 214 /** 214 * Process an XML request - as a DOM model node 215 * the Node may be an Element or a Document 215 * Process an XML request - as a DOM Element 216 216 * 217 217 * @param in the request to process 218 218 * @return the response - contains any error messages 219 * @see org.w3c.dom.Node220 * @see org.w3c.dom.Document221 219 * @see org.w3c.dom.Element 222 220 */ 223 public Node process(NodexmlIn) {221 public Element process(Element xmlIn) { 224 222 throw new Error("Not implmented yet. Should be faked by stringizing the node."); 225 223 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/ServicesImpl.java
r3492 r3502 124 124 Document doc = converter_.getDOM(xml_in); 125 125 126 Node res = process(doc);126 Element res = process(doc.getDocumentElement()); 127 127 return converter_.getString(res); 128 128 … … 137 137 * @see Element 138 138 */ 139 public Node process(Node xml_in) { 140 141 // check if request is Element or Document - we want to work 142 // with an Element 143 Element request=null; 144 145 short node_type = xml_in.getNodeType(); 146 if (node_type == Node.DOCUMENT_NODE) { 147 request = ((Document)xml_in).getDocumentElement(); 148 } else if (node_type == Node.ELEMENT_NODE) { 149 request = (Element)xml_in; 150 } else { 151 System.err.println("ServicesImpl:process error: input should be an Element or Document!"); 152 } 139 public Element process(Element request) { 153 140 154 141 String req = request.getNodeName();
Note:
See TracChangeset
for help on using the changeset viewer.