Changeset 28860


Ignore:
Timestamp:
2014-02-27T14:25:44+13:00 (7 years ago)
Author:
kjdon
Message:

removed all use of this.doc. I have left the variable in though so I don't have to update all service classes at this stage. Eventually want to remove this.doc altogether, as DOM is not thread safe.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/ServiceRack.java

    r27087 r28860  
    7878
    7979    /** XML element for describe requests - the container doc */
    80     protected Document doc = null;
     80       protected Document doc = null;
    8181
    8282    /**
     
    223223
    224224        NodeList requests = message.getElementsByTagName(GSXML.REQUEST_ELEM);
    225         Element mainResult = this.doc.createElement(GSXML.MESSAGE_ELEM);
     225        Document doc = this.converter.newDOM();
     226        Element mainResult = doc.createElement(GSXML.MESSAGE_ELEM);
    226227        if (requests.getLength() == 0)
    227228        {
     
    240241                if (response != null)
    241242                {
    242                     mainResult.appendChild(this.doc.importNode(response, true));
     243                    mainResult.appendChild(doc.importNode(response, true));
    243244                }
    244245
     
    247248            {
    248249                Element response = processFormat(request);
    249                 mainResult.appendChild(this.doc.importNode(response, true));
     250                mainResult.appendChild(doc.importNode(response, true));
    250251            }
    251252            else
     
    311312                if (response != null)
    312313                {
    313                     mainResult.appendChild(this.doc.importNode(response, true));
     314                    mainResult.appendChild(doc.importNode(response, true));
    314315                }
    315316                else
     
    317318                    // add in a dummy response
    318319                    logger.error("adding in an error element\n");
    319                     response = this.doc.createElement(GSXML.RESPONSE_ELEM);
    320                     GSXML.addError(this.doc, response, error_string.toString());
     320                    response = doc.createElement(GSXML.RESPONSE_ELEM);
     321                    GSXML.addError(doc, response, error_string.toString());
    321322                    mainResult.appendChild(response);
    322323
     
    335336    protected Element processDescribe(Element request)
    336337    {
    337 
    338         Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
     338      Document doc = this.converter.newDOM();
     339        Element response = doc.createElement(GSXML.RESPONSE_ELEM);
    339340        response.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_DESCRIBE);
    340341
     
    343344        if (to.equals(""))
    344345        { // return the service list
    345             response.appendChild(getServiceList(lang));
     346          response.appendChild(doc.importNode(getServiceList(lang), true));
    346347            return response;
    347348        }
     
    378379        if (description != null)
    379380        { // may be null if non-existant service
    380             response.appendChild(description);
     381          response.appendChild(doc.importNode(description, true));
    381382        }
    382383        return response;
     
    389390    protected Element processFormat(Element request)
    390391    {
    391         Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
     392      Document doc = this.converter.newDOM();
     393        Element response = doc.createElement(GSXML.RESPONSE_ELEM);
    392394        response.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_FORMAT);
    393395
     
    402404        if (this.format_info_map.containsKey(to))
    403405        {
    404             response.appendChild(response.getOwnerDocument().importNode(getServiceFormat(to), true));
     406            response.appendChild(doc.importNode(getServiceFormat(to), true));
    405407            if (_globalFormat != null)
    406408            {
    407                 response.appendChild(response.getOwnerDocument().importNode(GSXML.duplicateWithNewName(response.getOwnerDocument(), _globalFormat, GSXML.GLOBAL_FORMAT_ELEM, false), true));
     409                response.appendChild(GSXML.duplicateWithNewName(doc, _globalFormat, GSXML.GLOBAL_FORMAT_ELEM, false));
    408410            }
    409411            response.setAttribute(GSXML.FROM_ATT, to);
Note: See TracChangeset for help on using the changeset viewer.