Ignore:
Timestamp:
2014-04-10T14:39:33+12:00 (10 years ago)
Author:
kjdon
Message:

Lots of changes. Mainly to do with removing this.doc from everywhere. Document is not thread safe. Now we tend to create a new Document everytime we are starting a new page/message etc. in service this.desc_doc is available as teh document to create service info stuff. But it should only be used for this and not for other messages. newDOM is now static for XMLConverter. method param changes for some GSXML methods.

File:
1 edited

Legend:

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

    r25635 r28966  
    88import org.apache.log4j.Logger;
    99import org.greenstone.gsdl3.util.GSXML;
     10import org.greenstone.gsdl3.util.XMLConverter;
     11
     12import org.w3c.dom.Document;
    1013import org.w3c.dom.Element;
    1114
     
    3437        for (int i = 0; i < services.length; i++)
    3538        {
    36             Element service = this.doc.createElement(GSXML.SERVICE_ELEM);
     39            Element service = this.desc_doc.createElement(GSXML.SERVICE_ELEM);
    3740            service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE);
    3841            service.setAttribute(GSXML.NAME_ATT, services[i]);
     
    4346    }
    4447
    45     protected Element getServiceDescription(String service_id, String lang, String subset)
     48    protected Element getServiceDescription(Document doc, String service_id, String lang, String subset)
    4649    {
    4750        for (int i = 0; i < services.length; i++)
     
    4952            if (service_id.equals(services[i]))
    5053            {
    51                 Element service_elem = this.doc.createElement(GSXML.SERVICE_ELEM);
     54                Element service_elem = doc.createElement(GSXML.SERVICE_ELEM);
    5255                service_elem.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE);
    5356                service_elem.setAttribute(GSXML.NAME_ATT, services[i]);
     
    6164    protected Element processGetAllImagesInCollection(Element request)
    6265    {
    63         Element result = GSXML.createBasicResponse(this.doc, GET_ALL_IMAGES_IN_COLLECTION);
     66      Document result_doc = XMLConverter.newDOM();
     67        Element result = GSXML.createBasicResponse(result_doc, GET_ALL_IMAGES_IN_COLLECTION);
    6468
    6569        if (request == null)
    6670        {
    67             GSXML.addError(this.doc, result, GET_ALL_IMAGES_IN_COLLECTION + ": Request is null", GSXML.ERROR_TYPE_SYNTAX);
     71            GSXML.addError(result, GET_ALL_IMAGES_IN_COLLECTION + ": Request is null", GSXML.ERROR_TYPE_SYNTAX);
    6872            return result;
    6973        }
     
    7680
    7781        if (param_list == null) {
    78             GSXML.addError(this.doc, result, GET_ALL_IMAGES_IN_COLLECTION + ": No param list specified", GSXML.ERROR_TYPE_SYNTAX);
     82            GSXML.addError(result, GET_ALL_IMAGES_IN_COLLECTION + ": No param list specified", GSXML.ERROR_TYPE_SYNTAX);
    7983            return result;  // Return the empty result
    8084        }
     
    8589        if(regex == null)
    8690        {
    87             GSXML.addError(this.doc, result, GET_ALL_IMAGES_IN_COLLECTION + ": No file name extensions specified", GSXML.ERROR_TYPE_SYNTAX);
     91            GSXML.addError(result, GET_ALL_IMAGES_IN_COLLECTION + ": No file name extensions specified", GSXML.ERROR_TYPE_SYNTAX);
    8892            return result;
    8993        }
     
    9397        if(collection == null)
    9498        {
    95             GSXML.addError(this.doc, result, GET_ALL_IMAGES_IN_COLLECTION + ": No collection specified", GSXML.ERROR_TYPE_SYNTAX);
     99            GSXML.addError(result, GET_ALL_IMAGES_IN_COLLECTION + ": No collection specified", GSXML.ERROR_TYPE_SYNTAX);
    96100            return result;
    97101        }
     
    101105        getImagesRecursive(indexDir, regex, images);
    102106       
    103         Element imageListElem = this.doc.createElement("imageList");
     107        Element imageListElem = result_doc.createElement("imageList");
    104108        result.appendChild(imageListElem);
    105109        for(String i : images)
    106110        {
    107             Element imageElem = this.doc.createElement("image");
    108             imageElem.appendChild(this.doc.createTextNode(i));
     111            Element imageElem = result_doc.createElement("image");
     112            imageElem.appendChild(result_doc.createTextNode(i));
    109113            imageListElem.appendChild(imageElem);
    110114        }
Note: See TracChangeset for help on using the changeset viewer.