Changeset 16688

Show
Ignore:
Timestamp:
08.08.2008 13:23:59 (11 years ago)
Author:
davidb
Message:

Changed 'Element process(Element)' in ModuleInterface? to 'Node process(Node)'. After some deliberation is was decided this is a more useful (generic) layer of the DOM to pass information around in. Helps with the DocType? problem when producing XSL Transformed pages, for example. When this was an Element, it would loose track of its DocType?. Supporting method provided in XMLConverter 'Element nodeToElement(Node)' which checks a nodes docType and casts to Element if appropriate, or if a Document, typecasts to that and then extracts the top-level Element. With this fundamental change in ModuleInterface?, around 20 files needed to be updated (Actions, Services, etc) that build on top of 'process()' to reflect this change, and use nodeToElement where necessary.

Location:
greenstone3/trunk/src/java/org/greenstone/gsdl3
Files:
29 modified

Legend:

Unmodified
Added
Removed
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/Library2.java

    r10296 r16688  
    2424import org.w3c.dom.Document; 
    2525import org.w3c.dom.Element; 
     26import org.w3c.dom.Node; 
    2627 
    2728import java.io.BufferedReader; 
     
    112113    System.out.println("*********************"); 
    113114    System.out.println(converter.getPrettyString(xml_message)); 
    114     Element xml_result = recept.process(xml_message); 
     115    Node xml_result = recept.process(xml_message); 
    115116    return this.converter.getPrettyString(xml_result); 
    116117    } 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/LibraryServlet.java

    r16515 r16688  
    498498    //GSXML.printXMLNode(xml_message); 
    499499     
    500     Node xml_result = this.recept.processToPage (xml_message); 
     500    Node xml_result = this.recept.process(xml_message); 
    501501    encodeURLs (xml_result, response); 
    502502    out.println (this.converter.getPrettyString (xml_result)); 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/OAIServer.java

    r14227 r16688  
    285285    xml_message.appendChild(xml_request); 
    286286          
    287     Element xml_result = this.recept.process (xml_message); 
     287    Node xml_result = this.recept.process (xml_message); 
    288288    if (xml_result == null) { 
    289289      logger.info("xml_result is null"); 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/SOAPServerlocalsite.java

    r10322 r16688  
    2424import org.greenstone.gsdl3.util.GSFile; 
    2525import org.greenstone.gsdl3.util.GSXML; 
     26import org.greenstone.gsdl3.util.XMLConverter; 
    2627import org.w3c.dom.Element; 
     28import org.w3c.dom.Node; 
    2729import java.io.File; 
    2830 
     
    4244    protected String site_name = "localsite"; 
    4345   
     46    protected XMLConverter converter = null; 
     47 
    4448    /** The no-args constructor */ 
    4549    public SOAPServerlocalsite() { 
     50 
     51    converter = new XMLConverter(); 
     52 
    4653    String gsdl3_home = GlobalProperties.getGSDL3Home(); 
    4754    if (gsdl3_home == null || gsdl3_home.equals("")) { 
     
    7481        } 
    7582        Element new_req = GSXML.duplicateWithNewName(req.getOwnerDocument(), req, tag_name, true); 
    76         Element r = mr.process(new_req); 
     83        Node n = mr.process(new_req); 
     84        Element r = converter.nodeToElement(n); 
    7785        // add the namespace back on 
    7886        //Element new_res = r; 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/action/Action.java

    r13270 r16688  
    6262        return null; 
    6363    } 
    64     Element result = process(message_doc.getDocumentElement()); 
     64    Node result = process(message_doc); 
    6565    return this.converter.getString(result); 
    6666    } 
    6767     
    6868    /** the main process method - must be implemented in subclass */ 
    69     abstract public Element process(Element xml_in); 
     69    abstract public Node process(Node xml_in); 
    7070 
    7171    /** tell the param class what its arguments are  
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/action/AppletAction.java

    r14226 r16688  
    1919      static Logger logger = Logger.getLogger(org.greenstone.gsdl3.action.AppletAction.class.getName());    
    2020 
    21     public Element process (Element message) { 
     21    public Node process (Node message_node) { 
    2222     
     23    Element message = this.converter.nodeToElement(message_node); 
     24 
    2325    Element request = (Element)GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM); 
    2426    Element result = this.doc.createElement(GSXML.MESSAGE_ELEM); 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/action/BrowseAction.java

    r13270 r16688  
    2626 
    2727    /** process the request */ 
    28     public Element process (Element message) { 
     28    public Node process (Node message_node) { 
     29 
     30    Element message = this.converter.nodeToElement(message_node); 
    2931 
    3032    // get the request - assume only one 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/action/DocumentAction.java

    r14525 r16688  
    6767    return true; 
    6868    } 
    69     public Element process (Element message) 
     69    public Node process (Node message_node) 
    7070    { 
    7171    // for now, no subaction eventually we may want to have subactions such as text assoc or something ? 
    7272     
     73    Element message = this.converter.nodeToElement(message_node); 
     74 
    7375    // the response 
    7476    Element result = this.doc.createElement(GSXML.MESSAGE_ELEM); 
     
    441443        e_doc_list.appendChild(this.doc.importNode(dc_response_doc, true)); 
    442444         
    443         Element enrich_response = this.mr.process(enrich_message); 
     445        Node enrich_response = this.mr.process(enrich_message); 
    444446         
    445447        String [] links = {GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER, GSXML.DOC_NODE_ELEM, GSXML.NODE_CONTENT_ELEM}; 
     
    554556        } 
    555557        if (service_found) { 
    556         Element enrich_response = this.mr.process(enrich_message); 
    557  
     558        Element enrich_response = (Element)this.mr.process(enrich_message); 
     559         
    558560        NodeList e_responses = enrich_response.getElementsByTagName(GSXML.RESPONSE_ELEM); 
    559561        Element service_list = this.doc.createElement(GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER); 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/action/GS2BrowseAction.java

    r13568 r16688  
    2424 
    2525    /** process the request */ 
    26     public Element process (Element message) { 
     26    public Node process (Node message_node) { 
     27 
     28    Element message = this.converter.nodeToElement(message_node); 
    2729 
    2830    // get the request - assume only one 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/action/GeneralAction.java

    r14421 r16688  
    1111     
    1212    /** process a request */ 
    13     public Element process (Element message) { 
     13    public Node process (Node message_node) { 
     14 
     15    Element message = this.converter.nodeToElement(message_node); 
    1416 
    1517    // the result 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/action/NoCollQueryAction.java

    r14226 r16688  
    2626    /** process - processes a request. 
    2727     */  
    28     public Element process (Element message) { 
     28    public Node process (Node message_node) { 
     29 
     30    Element message = this.converter.nodeToElement(message_node); 
    2931 
    3032    // get the request - assume there is only one 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/action/PageAction.java

    r14642 r16688  
    2323    public static final String GLI4GS3_PAGE="gli4gs3"; 
    2424 
    25     public Element process (Element message) { 
    26  
    27         Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM); 
    28         // the page name is the subaction 
    29         String page_name = request.getAttribute(GSXML.SUBACTION_ATT); 
    30         if (page_name.equals("")) { // if no page specified, assume home page 
    31             page_name = HOME_PAGE; 
    32         } 
    33         Element result = this.doc.createElement(GSXML.MESSAGE_ELEM); 
    34         Element response; 
    35         if (page_name.equals(HOME_PAGE)) { 
    36             response = homePage(request); 
     25    public Node process (Node message_node) { 
     26 
     27        Element message = this.converter.nodeToElement(message_node); 
     28 
     29        Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM); 
     30        // the page name is the subaction 
     31        String page_name = request.getAttribute(GSXML.SUBACTION_ATT); 
     32        if (page_name.equals("")) { // if no page specified, assume home page 
     33        page_name = HOME_PAGE; 
     34        } 
     35        Element result = this.doc.createElement(GSXML.MESSAGE_ELEM); 
     36        Element response; 
     37        if (page_name.equals(HOME_PAGE)) { 
     38        response = homePage(request); 
    3739        //} else if (page_name.equals(ABOUT_PAGE)) { 
    38         } else if (page_name.equals(ABOUT_PAGE) || page_name.equals(PREFS_PAGE)) { 
    39             response = aboutPage(request); 
     40        } else if (page_name.equals(ABOUT_PAGE) || page_name.equals(PREFS_PAGE)) { 
     41        response = aboutPage(request); 
    4042        //}else if (page_name.equals(PREFS_PAGE)) { 
    41             //response = prefsPage(request); 
    42         } else if (page_name.equals(GLI4GS3_PAGE)){ 
    43             response = gli4gs3Page(request); 
    44         }else { // unknown page 
    45  
    46             logger.error("unknown page specified!"); 
    47             response =  unknownPage(request); 
    48         } 
    49  
    50         result.appendChild(this.doc.importNode(response, true)); 
    51         logger.debug("page action result: "+this.converter.getPrettyString(result)); 
    52         return result; 
    53     } 
    54  
     43        //response = prefsPage(request); 
     44        } else if (page_name.equals(GLI4GS3_PAGE)){ 
     45        response = gli4gs3Page(request); 
     46        }else { // unknown page 
     47         
     48        logger.error("unknown page specified!"); 
     49        response =  unknownPage(request); 
     50        } 
     51         
     52        result.appendChild(this.doc.importNode(response, true)); 
     53        logger.debug("page action result: "+this.converter.getPrettyString(result)); 
     54        return result; 
     55    } 
     56     
    5557 
    5658    protected Element homePage(Element request) { 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/action/ProcessAction.java

    r8801 r16688  
    1717     
    1818    /** process a request */ 
    19     public Element process (Element message) { 
     19    public Node process (Node message_node) { 
     20 
     21    Element message = this.converter.nodeToElement(message_node); 
    2022 
    2123    // the result 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/action/QueryAction.java

    r14947 r16688  
    2727    /** process - processes a request. 
    2828     */  
    29     public Element process (Element message) { 
     29    public Node process (Node message_node) { 
     30 
     31    Element message = this.converter.nodeToElement(message_node); 
    3032 
    3133    // get the request - assume there is only one 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/action/SystemAction.java

    r13270 r16688  
    2020 
    2121    /** process a request */ 
    22     public Element process (Element message) { 
     22    public Node process (Node message_node) { 
    2323     
     24    Element message = this.converter.nodeToElement(message_node); 
     25 
    2426    // assume only one request 
    2527    Element request = (Element)GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM); 
     
    7779    } 
    7880 
    79     Element response_message = this.mr.process(mr_request_message); 
     81    Node response_message = this.mr.process(mr_request_message); 
    8082     
    8183    result.appendChild(GSXML.duplicateWithNewName(this.doc, (Element)GSXML.getChildByTagName(response_message, GSXML.RESPONSE_ELEM), GSXML.RESPONSE_ELEM, true)); 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/action/XMLDocumentAction.java

    r6300 r16688  
    2424    /** process - processes a request. 
    2525     */  
    26     public Element process (Element message) { 
     26    public Node process (Node message_node) { 
    2727     
     28    Element message = this.converter.nodeToElement(message_node); 
     29 
    2830    // get the request - assume there is only one 
    2931    Element request = (Element)GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM); 
     
    8688    mr_message.appendChild(meta_request); 
    8789     
    88     Element ret_response = this.mr.process(mr_message); 
     90    Element ret_response = (Element)this.mr.process(mr_message); 
    8991    String [] links = {GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER, GSXML.DOC_NODE_ELEM}; 
    9092    String path = GSPath.createPath(links); 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/collection/ServiceCluster.java

    r15945 r16688  
    372372 
    373373    Document doc = this.converter.getDOM(in); 
    374     Element e = doc.getDocumentElement(); 
    375      
    376     Element res = process(e); 
     374     
     375    Node res = process(doc); 
    377376    return this.converter.getString(res); 
    378377     
     
    382381     * 
    383382     */ 
    384     public Element process(Element message) { 
     383    public Node process(Node message_node) { 
     384 
     385    Element message = this.converter.nodeToElement(message_node); 
    385386 
    386387    NodeList requests = message.getElementsByTagName(GSXML.REQUEST_ELEM); 
     
    428429        Element single_message = mess_doc.createElement(GSXML.MESSAGE_ELEM); 
    429430        single_message.appendChild(request); 
    430         Element response_message = ((ModuleInterface)this.service_map.get(service)).process(single_message); 
     431        Node response_message = ((ModuleInterface)this.service_map.get(service)).process(single_message); 
    431432        if (response_message != null) { 
    432433            Element response = (Element) GSXML.getChildByTagName(response_message, GSXML.RESPONSE_ELEM); 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/comms/Communicator.java

    r9874 r16688  
    6161 
    6262    public String process(String xml_in) { 
    63     Element e = converter_.getDOM(xml_in).getDocumentElement(); 
    64     Node result = process(e); 
     63    Node n = converter_.getDOM(xml_in); 
     64    Node result = process(n); 
    6565    return converter_.getString(result);     
    6666    } 
    6767 
    68     abstract public Element process(Element xml_in); 
     68    abstract public Node process(Node xml_in_node); 
    6969} 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/comms/SOAPCommunicator.java

    r13270 r16688  
    5656    private Call call_ = null; 
    5757 
    58   /** The no-args constructor */ 
    59     public SOAPCommunicator() { 
    60      
     58    protected XMLConverter converter_ = null; 
     59 
     60    /** The no-args constructor */ 
     61    public SOAPCommunicator() {  
     62    converter_ = new XMLConverter(); 
    6163    } 
    6264         
     
    9496    } 
    9597 
    96     public Element process(Element message) { 
     98    public Node process(Node message_node) { 
    9799     
     100    Element message = converter_.nodeToElement(message_node); 
     101 
    98102    NodeList requests = message.getElementsByTagName(GSXML.REQUEST_ELEM); 
    99103    if (requests.getLength()==0) { 
     
    159163    message = "<message><request type=\"describe\" to=\"\" lang=\"en\"/></message>"; 
    160164    Element request_elem = converter.getDOM(message).getDocumentElement(); 
    161     Element response = comm.process(request_elem); 
     165    Node response = comm.process(request_elem); 
    162166     
    163167    logger.error("response was "+converter.getPrettyString(response)); 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/core/DefaultReceptionist.java

    r13959 r16688  
    6868        coll_about_message.appendChild(coll_about_request); 
    6969         
    70         Element coll_about_response_message = this.mr.process(coll_about_message); 
     70        Node coll_about_response_message = this.mr.process(coll_about_message); 
    7171        Element coll_about_response = (Element)GSXML.getChildByTagName(coll_about_response_message, GSXML.RESPONSE_ELEM); 
    7272        if (coll_about_response == null) { 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/core/MessageRouter.java

    r15944 r16688  
    205205    Document doc = this.converter.getDOM(xml_in); 
    206206     
    207     Element result = process(doc.getDocumentElement()); 
     207    Node result = process(doc); 
    208208    return this.converter.getString(result); 
    209209  } 
     
    216216   * @see Element 
    217217   */ 
    218   public Element process(Element message) { 
    219      
     218  public Node process(Node message_node) { 
     219     
     220      Element message = this.converter.nodeToElement(message_node); 
     221 
    220222    // check that its a correct message tag 
    221223    if (!message.getTagName().equals(GSXML.MESSAGE_ELEM)) { 
     
    737739     
    738740    // process the message 
    739     Element info_response = comm.process(info_request); 
     741    Node info_response_node = comm.process(info_request); 
     742    Element info_response = converter.nodeToElement(info_response_node); 
     743 
    740744    if (info_response == null) { 
    741745      return false; 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/core/ModuleInterface.java

    r9874 r16688  
    1919package org.greenstone.gsdl3.core; 
    2020    
    21 import org.w3c.dom.Element;                                                 
     21import org.w3c.dom.Node; 
    2222 
    2323/** 
     
    2727 * it takes a String of XML, and returns a String of XML 
    2828 * 
    29  * the more efficient process method uses DOM Element Nodes instead  
     29 * the more efficient process method uses DOM Nodes instead  
    3030 * of Strings - this avoids parsing the XML at each module 
    3131 * 
     
    4545 
    4646  /** 
    47    * Process an XML request - as a DOM model Element 
     47   * Process an XML request - as a DOM model Node 
    4848   * 
    4949   * @param xml_in the request to process 
    5050   * @return the response - contains any error messages 
    51    * @see org.w3c.dom.Element 
     51   * @see org.w3c.dom.Node 
    5252   */ 
    53     abstract public Element process(Element xml_in); 
     53    abstract public Node process(Node xml_in); 
    5454 
    5555    /**  
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/core/OAIReceptionist.java

    r14211 r16688  
    8383  public String process(String xml_in) { 
    8484     
    85     Element message = this.converter.getDOM(xml_in).getDocumentElement(); 
    86     Element page = process(message); 
     85    Node message_node = this.converter.getDOM(xml_in); 
     86    Node page = process(message_node); 
    8787    return this.converter.getString(page); 
    8888  } 
     89 
    8990  //Compose a message element used to send back to the OAIServer servlet.  
    9091  //This method is only used within OAIReceptionist 
     
    9798   * if something goes wrong, it returns null - 
    9899   */ 
    99   public Element process(Element message) { 
     100  public Node process(Node message_node) { 
    100101    logger.error("OAIReceptionist received request"); 
     102 
     103    Element message = this.converter.nodeToElement(message_node); 
    101104    logger.error(this.converter.getString(message)); 
     105 
    102106    // check that its a correct message tag 
    103107    if (!message.getTagName().equals(GSXML.MESSAGE_ELEM)) { 
     
    145149    request.setAttribute(OAIXML.TYPE, OAIXML.OAI_SET_LIST); 
    146150    request.setAttribute(OAIXML.TO, ""); 
    147     Element msg_elem = mr.process(message); 
    148      
    149     if (msg_elem == null) { 
    150       logger.error("returned msg_elem from mr is null"); 
     151    Node msg_node = mr.process(message); 
     152     
     153    if (msg_node == null) { 
     154      logger.error("returned msg_node from mr is null"); 
    151155      return null; 
    152156    } 
    153     Element resp = (Element)GSXML.getChildByTagName(msg_elem, OAIXML.RESPONSE); 
     157    Element resp = (Element)GSXML.getChildByTagName(msg_node, OAIXML.RESPONSE); 
    154158    Element coll_list = (Element)GSXML.getChildByTagName(resp, OAIXML.COLLECTION_LIST); 
    155159    if (coll_list == null) { 
     
    411415        coll_name = full_name.substring(full_name.indexOf(":") + 1); 
    412416        req.setAttribute(OAIXML.TO, coll_name + "/" + verb); 
    413         Element e = mr.process(msg); 
     417        Node n = mr.process(msg); 
     418    Element e = converter.nodeToElement(n); 
    414419        result = collectAll(result, e, verb, OAIXML.HEADER); 
    415420         
     
    420425    } else { 
    421426      req.setAttribute(OAIXML.TO, coll_name + "/" + verb); 
    422       result = mr.process(msg); 
     427      Node result_node = mr.process(msg); 
     428      result = converter.nodeToElement(result_node); 
    423429    } 
    424430     
     
    606612        req.setAttribute(OAIXML.TO, coll_name + "/" + verb); 
    607613        //logger.info(GSXML.xmlNodeToString(req)); 
    608         Element e = mr.process(msg); 
     614        Node n = mr.process(msg); 
     615    Element e = converter.nodeToElement(n); 
    609616        result = collectAll(result, e, verb, OAIXML.RECORD); 
    610617         
     
    615622    } else { 
    616623      req.setAttribute(OAIXML.TO, coll_name + "/" + verb); 
    617       result = mr.process(msg); 
     624 
     625      Node result_node = mr.process(msg); 
     626      result = converter.nodeToElement(result_node); 
    618627    } 
    619628     
     
    791800 
    792801        //Now send the request to the message router to process 
    793         return mr.process(msg); 
     802    Node result_node = mr.process(msg); 
     803    return converter.nodeToElement(result_node); 
    794804      } 
    795805    } 
     
    955965 
    956966    //Now send the request to the message router to process 
    957     return mr.process(msg); 
     967    Node result_node = mr.process(msg); 
     968    return converter.nodeToElement(result_node); 
    958969  } 
    959970} 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/core/Receptionist.java

    r16648 r16688  
    130130    } 
    131131 
     132 
     133 
    132134    public String process(String xml_in) { 
    133135 
    134     Element message = this.converter.getDOM(xml_in).getDocumentElement(); 
    135     Node page = process(message); 
    136     return this.converter.getString(page); 
    137     } 
    138  
    139     public Element process(Element message) { 
    140     Node node = processToPage(message); 
    141  
    142     short nodeType = node.getNodeType(); 
    143  
    144     if (nodeType == Node.DOCUMENT_NODE) { 
    145         Document docNode = (Document)node; 
    146         return docNode.getDocumentElement() ; 
    147     } 
    148     else if (nodeType == Node.ELEMENT_NODE) { 
    149         return (Element)node; 
    150     } 
    151     else { 
    152         System.err.println("Receptionist.process was not returned a document node"); 
    153         return null; 
    154     } 
    155     } 
    156  
    157  
    158  
    159  
    160     /** process using strings - just calls process using Elements */ 
    161     public String processToPage(String xml_in) { 
    162  
    163     Element message = this.converter.getDOM(xml_in).getDocumentElement(); 
    164     Node page = processToPage(message); 
     136    Node message_node = this.converter.getDOM(xml_in); 
     137    Node page = process(message_node); 
    165138    return this.converter.getString(page); 
    166139    } 
     
    170143     * if something goes wrong, it returns null -  
    171144     * TODO:  return a suitable message to the user */ 
    172     public Node processToPage(Element message) { 
     145    public Node process(Node message_node) { 
     146 
     147    Element message = this.converter.nodeToElement(message_node); 
    173148 
    174149    // get the request out of the message - assume that there is only one 
     
    225200    //logger.info(a+" mesa=" + this.converter.getPrettyString(message)); 
    226201    // get the page data from the action 
    227     Element action_response = a.process(message); 
     202    Node action_response = a.process(message); 
    228203 
    229204    boolean response_only=false; 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/service/CrossCollectionSearch.java

    r13978 r16688  
    2323 
    2424import org.w3c.dom.Element; 
     25import org.w3c.dom.Node; 
    2526import org.w3c.dom.NodeList; 
    2627 
     
    176177    query_request.appendChild(new_param_list); 
    177178    new_param_list.appendChild(this.doc.importNode(GSXML.getNamedElement(param_list, GSXML.PARAM_ELEM, GSXML.NAME_ATT, QUERY_PARAM), true)); 
    178     Element query_result = this.router.process(query_message); 
     179    Element query_result = (Element)this.router.process(query_message); 
    179180     
    180181    // gather up the data from each response 
     
    353354    } 
    354355 
    355     Element meta_result = this.router.process(meta_request_message); 
     356    Node meta_result_node = this.router.process(meta_request_message); 
     357    Element meta_result = this.converter.nodeToElement(meta_result_node); 
    356358     
    357359    // now need to put the doc nodes back in the right order 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/service/GS2Construct.java

    r13270 r16688  
    308308    } 
    309309    request.appendChild(command); 
    310     Element response = this.router.process(message); // at the moment, get no info in response so ignore it 
     310    Node response = this.router.process(message); // at the moment, get no info in response so ignore it 
    311311    Text t; 
    312312    String[] args={coll_name}; 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/service/ModuleWrapper.java

    r13270 r16688  
    226226   * @see org.w3c.dom.Element 
    227227   */ 
    228   public Element process(Element xmlIn) { 
     228  public Node process(Node xmlIn) { 
    229229    throw new Error("Not implmented yet. Should be faked by stringizing the node."); 
    230230  } 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/service/ServiceRack.java

    r14528 r16688  
    171171        return null; 
    172172    } 
    173     Element res = process(doc.getDocumentElement()); 
     173    Node res = process(doc); 
    174174    return this.converter.getString(res); 
    175175     
     
    178178    /** process an XML request in DOM form 
    179179     * 
    180      * @param xml_in the Element node containing the request 
     180     * @param message the Node node containing the request 
    181181     * should be <message>  
    182      * @return an Element with the result XML 
    183      * @see Element 
     182     * @return an Node with the result XML 
     183     * @see Node/Element 
    184184     */ 
    185     public Element process(Element message) { 
     185    public Node process(Node message_node) { 
     186 
     187    Element message = this.converter.nodeToElement(message_node); 
    186188 
    187189    NodeList requests = message.getElementsByTagName(GSXML.REQUEST_ELEM); 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/util/XMLConverter.java

    r16374 r16688  
    2222import org.w3c.dom.Document;  
    2323import org.w3c.dom.DocumentType;  
     24import org.w3c.dom.Element;  
    2425import org.w3c.dom.Node;  
    2526import org.w3c.dom.NodeList; 
     
    8182    this.parser.setEntityResolver(er); 
    8283    } 
    83      
     84 
     85 
     86    public Element nodeToElement(Node node) 
     87    { 
     88    short nodeType = node.getNodeType(); 
     89 
     90    if (nodeType == Node.DOCUMENT_NODE) { 
     91        Document docNode = (Document)node; 
     92        return docNode.getDocumentElement() ; 
     93    } 
     94    else if (nodeType == Node.ELEMENT_NODE) { 
     95        return (Element)node; 
     96    } 
     97    else { 
     98        System.err.println("Expecting Document or Element node type but got " + node.getNodeName()); 
     99        System.err.println("Returning null"); 
     100        return null; 
     101    } 
     102    } 
     103 
    84104    /** returns a DOM Document */ 
    85105    public Document getDOM(String in) {